private void addSoftwareModulesToConsolidatedDsAssignmentMap(final DistributionSet distributionSet, final Set<SoftwareModule> softwareModules) { final Map<Long, Set<SoftwareModuleIdName>> assignmentMap = getConsolidatedAssignmentMap(distributionSet); for (final SoftwareModule softwareModule : softwareModules) { final SoftwareModuleIdName softwareModuleIdName = new SoftwareModuleIdName(softwareModule); final Long smTypeID = softwareModule.getType().getId(); assignmentMap.computeIfAbsent(smTypeID, key -> new HashSet<SoftwareModuleIdName>()); if (softwareModule.getType().getMaxAssignments() > 1) { // add application assignmentMap.get(smTypeID).add(softwareModuleIdName); } else if (softwareModule.getType().getMaxAssignments() == 1) { // replace firmware assignmentMap.get(smTypeID).clear(); assignmentMap.get(smTypeID).add(softwareModuleIdName); } publishAssignEvent(distributionSet.getId(), softwareModule); } }
private void addSoftwareModulesToConsolidatedDsAssignmentMap(final DistributionSet distributionSet, final Set<SoftwareModule> softwareModules) { final Map<Long, Set<SoftwareModuleIdName>> assignmentMap = getConsolidatedAssignmentMap(distributionSet); for (final SoftwareModule softwareModule : softwareModules) { final SoftwareModuleIdName softwareModuleIdName = new SoftwareModuleIdName(softwareModule); final Long smTypeID = softwareModule.getType().getId(); assignmentMap.computeIfAbsent(smTypeID, key -> new HashSet<SoftwareModuleIdName>()); if (softwareModule.getType().getMaxAssignments() > 1) { // add application assignmentMap.get(smTypeID).add(softwareModuleIdName); } else if (softwareModule.getType().getMaxAssignments() == 1) { // replace firmware assignmentMap.get(smTypeID).clear(); assignmentMap.get(smTypeID).add(softwareModuleIdName); } publishAssignEvent(distributionSet.getId(), softwareModule); } }
public boolean addModule(final SoftwareModule softwareModule) { if (modules == null) { modules = new HashSet<>(); } checkTypeCompatability(softwareModule); final Optional<SoftwareModule> found = modules.stream() .filter(module -> module.getId().equals(softwareModule.getId())).findAny(); if (found.isPresent()) { return false; } final long allready = modules.stream() .filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count(); if (allready >= softwareModule.getType().getMaxAssignments()) { modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())) .findAny().ifPresent(modules::remove); } if (modules.add(softwareModule)) { complete = type.checkComplete(this); return true; } return false; }
public boolean addModule(final SoftwareModule softwareModule) { if (modules == null) { modules = new HashSet<>(); } checkTypeCompatability(softwareModule); final Optional<SoftwareModule> found = modules.stream() .filter(module -> module.getId().equals(softwareModule.getId())).findAny(); if (found.isPresent()) { return false; } final long allready = modules.stream() .filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count(); if (allready >= softwareModule.getType().getMaxAssignments()) { modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())) .findAny().ifPresent(modules::remove); } if (modules.add(softwareModule)) { complete = type.checkComplete(this); return true; } return false; }
public static String softwareModuleTypes(final List<SoftwareModuleType> types) throws JSONException { final StringBuilder builder = new StringBuilder(); builder.append("["); int i = 0; for (final SoftwareModuleType module : types) { builder.append(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("id", Long.MAX_VALUE).put("key", module.getKey()) .put("maxAssignments", module.getMaxAssignments()).put("createdAt", "0").put("updatedAt", "0") .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString()); if (++i < types.size()) { builder.append(","); } } builder.append("]"); return builder.toString(); }
public static String softwareModuleTypesCreatableFieldsOnly(final List<SoftwareModuleType> types) throws JSONException { final StringBuilder builder = new StringBuilder(); builder.append("["); int i = 0; for (final SoftwareModuleType module : types) { builder.append(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("key", module.getKey()).put("maxAssignments", module.getMaxAssignments()).toString()); if (++i < types.size()) { builder.append(","); } } builder.append("]"); return builder.toString(); }
if (module.getType().getMaxAssignments() > 1) { assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>") .append(getUnsavedAssignedSwModule(module.getName(), module.getVersion())).append("</I>"); if (module.getType().getMaxAssignments() == 1) { assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>") .append(getUnsavedAssignedSwModule(module.getName(), module.getVersion())).append("</I>"));
if (module.getType().getMaxAssignments() > 1) { assignedSWModule.get(module.getType().getName()).append("</br>").append("<I>") .append(getUnsavedAssignedSwModule(module.getName(), module.getVersion())).append("</I>"); if (module.getType().getMaxAssignments() == 1) { assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>") .append(getUnsavedAssignedSwModule(module.getName(), module.getVersion())).append("</I>"));
private void populateDetails() { if (getSelectedBaseEntity() != null) { String maxAssign; if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) { maxAssign = getI18n().getMessage("label.singleAssign.type"); } else { maxAssign = getI18n().getMessage("label.multiAssign.type"); } updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(), getSelectedBaseEntity().getVendor(), maxAssign); } else { updateSoftwareModuleDetailsLayout("", "", ""); } }
@Override public void setTagDetails(final String selectedEntity) { getSoftwareModuleTypeManagement().getByName(selectedEntity).ifPresent(selectedTypeTag -> { getTagName().setValue(selectedTypeTag.getName()); getTagDesc().setValue(selectedTypeTag.getDescription()); getTypeKey().setValue(selectedTypeTag.getKey()); if (selectedTypeTag.getMaxAssignments() == 1) { getAssignOptiongroup().setValue(getSingleAssignStr()); } else { getAssignOptiongroup().setValue(getMultiAssignStr()); } setColorPickerComponentsColor(selectedTypeTag.getColour()); }); disableFields(); }
private void populateDetails() { if (getSelectedBaseEntity() != null) { String maxAssign; if (getSelectedBaseEntity().getType().getMaxAssignments() == 1) { maxAssign = getI18n().getMessage("label.singleAssign.type"); } else { maxAssign = getI18n().getMessage("label.multiAssign.type"); } updateSoftwareModuleDetailsLayout(getSelectedBaseEntity().getType().getName(), getSelectedBaseEntity().getVendor(), maxAssign); } else { updateSoftwareModuleDetailsLayout("", "", ""); } }
@Override public void setTagDetails(final String selectedEntity) { getSoftwareModuleTypeManagement().getByName(selectedEntity).ifPresent(selectedTypeTag -> { getTagName().setValue(selectedTypeTag.getName()); getTagDesc().setValue(selectedTypeTag.getDescription()); getTypeKey().setValue(selectedTypeTag.getKey()); if (selectedTypeTag.getMaxAssignments() == 1) { getAssignOptiongroup().setValue(getSingleAssignStr()); } else { getAssignOptiongroup().setValue(getMultiAssignStr()); } setColorPickerComponentsColor(selectedTypeTag.getColour()); }); disableFields(); }
static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType(); MgmtRestModelMapper.mapNamedToNamed(result, type); result.setKey(type.getKey()); result.setMaxAssignments(type.getMaxAssignments()); result.setModuleId(type.getId()); result.setDeleted(type.isDeleted()); result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) .withSelfRel()); return result; }
return false; if (sm.getType().getMaxAssignments() < 1) { return false;
return false; if (sm.getType().getMaxAssignments() < 1) { return false;