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(); }
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(); }