/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getMandatoryModuleTypes()}. * * @param softwareModuleTypeId * search for by {@link SoftwareModuleType#getId()} * @return <code>true</code> if found */ default boolean containsMandatoryModuleType(final Long softwareModuleTypeId) { return getMandatoryModuleTypes().stream().anyMatch(element -> element.getId().equals(softwareModuleTypeId)); }
@Override public ResponseEntity<List<MgmtSoftwareModuleType>> getMandatoryModules( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getMandatoryModuleTypes())); }
public static String distributionSetTypes(final List<DistributionSetType> types) throws JSONException { final JSONArray result = new JSONArray(); for (final DistributionSetType type : types) { final JSONArray osmTypes = new JSONArray(); type.getOptionalModuleTypes().forEach(smt -> { try { osmTypes.put(new JSONObject().put("id", smt.getId())); } catch (final JSONException e1) { e1.printStackTrace(); } }); final JSONArray msmTypes = new JSONArray(); type.getMandatoryModuleTypes().forEach(smt -> { try { msmTypes.put(new JSONObject().put("id", smt.getId())); } catch (final JSONException e) { e.printStackTrace(); } }); result.put(new JSONObject().put("name", type.getName()).put("description", type.getDescription()) .put("id", Long.MAX_VALUE).put("key", type.getKey()).put("createdAt", "0").put("updatedAt", "0") .put("createdBy", "fghdfkjghdfkjh").put("optionalmodules", osmTypes) .put("mandatorymodules", msmTypes).put("updatedBy", "fghdfkjghdfkjh")); } return result.toString(); }
/** * Populate software module table. * * @param distributionSet */ public void populateModule(final DistributionSet distributionSet) { removeAllItems(); if (distributionSet != null) { if (isUnassignSoftModAllowed && permissionChecker.hasUpdateRepositoryPermission()) { try { isTargetAssigned = false; } catch (final EntityReadOnlyException exception) { isTargetAssigned = true; LOG.info("Target already assigned for the distribution set: " + distributionSet.getName(), exception); } } final Set<SoftwareModuleType> swModuleMandatoryTypes = distributionSet.getType().getMandatoryModuleTypes(); final Set<SoftwareModuleType> swModuleOptionalTypes = distributionSet.getType().getOptionalModuleTypes(); if (!CollectionUtils.isEmpty(swModuleMandatoryTypes)) { swModuleMandatoryTypes.forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet)); } if (!CollectionUtils.isEmpty(swModuleOptionalTypes)) { swModuleOptionalTypes.forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet)); } setAmountOfTableRows(getContainerDataSource().size()); } }
/** * Populate software module table. * * @param distributionSet */ public void populateModule(final DistributionSet distributionSet) { removeAllItems(); if (distributionSet != null) { if (isUnassignSoftModAllowed && permissionChecker.hasUpdateRepositoryPermission()) { try { isTargetAssigned = false; } catch (final EntityReadOnlyException exception) { isTargetAssigned = true; LOG.info("Target already assigned for the distribution set: " + distributionSet.getName(), exception); } } final Set<SoftwareModuleType> swModuleMandatoryTypes = distributionSet.getType().getMandatoryModuleTypes(); final Set<SoftwareModuleType> swModuleOptionalTypes = distributionSet.getType().getOptionalModuleTypes(); if (!CollectionUtils.isEmpty(swModuleMandatoryTypes)) { swModuleMandatoryTypes.forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet)); } if (!CollectionUtils.isEmpty(swModuleOptionalTypes)) { swModuleOptionalTypes.forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet)); } setAmountOfTableRows(getContainerDataSource().size()); } }
public static String distributionSetTypesCreateValidFieldsOnly(final List<DistributionSetType> types) { final JSONArray result = new JSONArray(); for (final DistributionSetType module : types) { try { final JSONArray osmTypes = new JSONArray(); module.getOptionalModuleTypes().forEach(smt -> { try { osmTypes.put(new JSONObject().put("id", smt.getId())); } catch (final JSONException e) { e.printStackTrace(); } }); final JSONArray msmTypes = new JSONArray(); module.getMandatoryModuleTypes().forEach(smt -> { try { msmTypes.put(new JSONObject().put("id", smt.getId())); } catch (final JSONException e) { e.printStackTrace(); } }); result.put(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("key", module.getKey()).put("optionalmodules", osmTypes) .put("mandatorymodules", msmTypes)); } catch (final JSONException e) { e.printStackTrace(); } } return result.toString(); }
@Override public void setTagDetails(final String selectedEntity) { getTwinTables().createSourceTableData(); getTwinTables().getSelectedTable().getContainerDataSource().removeAllItems(); final Optional<DistributionSetType> selectedDistSetType = getDistributionSetTypeManagement() .getByName(selectedEntity); selectedDistSetType.ifPresent(selectedType -> { getTagName().setValue(selectedType.getName()); getTagDesc().setValue(selectedType.getDescription()); getTypeKey().setValue(selectedType.getKey()); if (distributionSetManagement.countByTypeId(selectedType.getId()) <= 0) { getTwinTables().getDistTypeSelectLayout().setEnabled(true); getTwinTables().getSelectedTable().setEnabled(true); } else { getUiNotification().displayValidationError( selectedType.getName() + " " + getI18n().getMessage("message.error.dist.set.type.update")); getTwinTables().getDistTypeSelectLayout().setEnabled(false); getTwinTables().getSelectedTable().setEnabled(false); } createOriginalSelectedTableContainer(); selectedType.getOptionalModuleTypes().forEach(swModuleType -> addTargetTableForUpdate(swModuleType, false)); selectedType.getMandatoryModuleTypes().forEach(swModuleType -> addTargetTableForUpdate(swModuleType, true)); setColorPickerComponentsColor(selectedType.getColour()); }); disableFields(); getWindow().setOrginaleValues(); }
@Override public void setTagDetails(final String selectedEntity) { getTwinTables().createSourceTableData(); getTwinTables().getSelectedTable().getContainerDataSource().removeAllItems(); final Optional<DistributionSetType> selectedDistSetType = getDistributionSetTypeManagement() .getByName(selectedEntity); selectedDistSetType.ifPresent(selectedType -> { getTagName().setValue(selectedType.getName()); getTagDesc().setValue(selectedType.getDescription()); getTypeKey().setValue(selectedType.getKey()); if (distributionSetManagement.countByTypeId(selectedType.getId()) <= 0) { getTwinTables().getDistTypeSelectLayout().setEnabled(true); getTwinTables().getSelectedTable().setEnabled(true); } else { getUiNotification().displayValidationError( selectedType.getName() + " " + getI18n().getMessage("message.error.dist.set.type.update")); getTwinTables().getDistTypeSelectLayout().setEnabled(false); getTwinTables().getSelectedTable().setEnabled(false); } createOriginalSelectedTableContainer(); selectedType.getOptionalModuleTypes().forEach(swModuleType -> addTargetTableForUpdate(swModuleType, false)); selectedType.getMandatoryModuleTypes().forEach(swModuleType -> addTargetTableForUpdate(swModuleType, true)); setColorPickerComponentsColor(selectedType.getColour()); }); disableFields(); getWindow().setOrginaleValues(); }