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(); }
static MgmtDistributionSetType toResponse(final DistributionSetType type) { final MgmtDistributionSetType result = new MgmtDistributionSetType(); MgmtRestModelMapper.mapNamedToNamed(result, type); result.setKey(type.getKey()); result.setModuleId(type.getId()); result.setDeleted(type.isDeleted()); result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId())) .withSelfRel()); return result; }
/** * Checks if the given {@link SoftwareModuleType} is in this * {@link DistributionSetType}. * * @param softwareModuleType * search for * @return <code>true</code> if found */ default boolean containsModuleType(final SoftwareModuleType softwareModuleType) { return containsMandatoryModuleType(softwareModuleType) || containsOptionalModuleType(softwareModuleType); }
private void populateValuesOfDistribution(final Long editDistId) { final Optional<DistributionSet> distSet = distributionSetManagement.getWithDetails(editDistId); if (!distSet.isPresent()) { return; } distNameTextField.setValue(distSet.get().getName()); distVersionTextField.setValue(distSet.get().getVersion()); if (distSet.get().getType().isDeleted()) { distsetTypeNameComboBox.addItem(distSet.get().getType().getId()); } distsetTypeNameComboBox.setValue(distSet.get().getType().getId()); distsetTypeNameComboBox.setEnabled(false); reqMigStepCheckbox.setValue(distSet.get().isRequiredMigrationStep()); descTextArea.setValue(distSet.get().getDescription()); }
@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(); }
currentDefaultDisSetType = currentDistributionSetType.getId(); combobox.setNullSelectionAllowed(false); for (final DistributionSetType distributionSetType : distributionSetTypeCollection) { combobox.addItem(distributionSetType.getId()); combobox.setItemCaption(distributionSetType.getId(), distributionSetType.getKey() + " (" + distributionSetType.getName() + ")"); if (distributionSetType.getId().equals(currentDistributionSetType.getId())) { combobox.select(distributionSetType.getId());
/** * Populate DistributionSet Type name combo. */ private void populateDistSetTypeNameCombo() { distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer()); distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId()); }
@Override protected String getDuplicateKeyErrorMessage(final DistributionSetType existingType) { return getI18n().getMessage("message.type.key.duplicate.check", existingType.getKey()); }
/** * 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()); } }
@SuppressWarnings("unchecked") private void updateDistributionSetType(final DistributionSetType existingType) { final List<Long> itemIds = (List<Long>) getTwinTables().getSelectedTable().getItemIds(); final DistributionSetTypeUpdate update = getEntityFactory().distributionSetType().update(existingType.getId()) .description(getTagDesc().getValue()) .colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview())); if (distributionSetManagement.countByTypeId(existingType.getId()) <= 0 && !CollectionUtils.isEmpty(itemIds)) { update.mandatory(itemIds.stream() .filter(itemId -> DistributionSetTypeSoftwareModuleSelectLayout .isMandatoryModuleType(getTwinTables().getSelectedTable().getItem(itemId))) .collect(Collectors.toList())) .optional(itemIds.stream() .filter(itemId -> DistributionSetTypeSoftwareModuleSelectLayout .isOptionalModuleType(getTwinTables().getSelectedTable().getItem(itemId))) .collect(Collectors.toList())); } final DistributionSetType updateDistSetType = getDistributionSetTypeManagement().update(update); getUiNotification().displaySuccess(getI18n().getMessage("message.update.success", updateDistSetType.getName())); getEventBus().publish(this, new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType)); }
private boolean isDefaultDsType(final String dsTypeName) { return getCurrentDistributionSetType() != null && getCurrentDistributionSetType().getName().equals(dsTypeName); }
/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getOptionalModuleTypes()}. * * @param softwareModuleTypeId * search by {@link SoftwareModuleType#getId()} * @return <code>true</code> if found */ default boolean containsOptionalModuleType(final Long softwareModuleTypeId) { return getOptionalModuleTypes().stream().anyMatch(element -> element.getId().equals(softwareModuleTypeId)); }
/** * 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)); }
private void checkTypeCompatability(final SoftwareModule softwareModule) { // we cannot allow that modules are added without a type defined if (type == null) { throw new DistributionSetTypeUndefinedException(); } // check if it is allowed to such a module to this DS type if (!type.containsModuleType(softwareModule.getType())) { throw new UnsupportedSoftwareModuleForThisDistributionSetException(); } }
/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getOptionalModuleTypes()}. * * @param softwareModuleType * search for * @return <code>true</code> if found */ default boolean containsOptionalModuleType(final SoftwareModuleType softwareModuleType) { return containsOptionalModuleType(softwareModuleType.getId()); }
/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getMandatoryModuleTypes()}. * * @param softwareModuleType * search for * @return <code>true</code> if found */ default boolean containsMandatoryModuleType(final SoftwareModuleType softwareModuleType) { return containsMandatoryModuleType(softwareModuleType.getId()); }
@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(); }
currentDefaultDisSetType = currentDistributionSetType.getId(); combobox.setNullSelectionAllowed(false); for (final DistributionSetType distributionSetType : distributionSetTypeCollection) { combobox.addItem(distributionSetType.getId()); combobox.setItemCaption(distributionSetType.getId(), distributionSetType.getKey() + " (" + distributionSetType.getName() + ")"); if (distributionSetType.getId().equals(currentDistributionSetType.getId())) { combobox.select(distributionSetType.getId());
/** * Populate DistributionSet Type name combo. */ private void populateDistSetTypeNameCombo() { distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer()); distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId()); }
@Override protected String getDuplicateKeyErrorMessage(final DistributionSetType existingType) { return getI18n().getMessage("message.type.key.duplicate.check", existingType.getKey()); }