@Override protected String getDuplicateKeyErrorMessage(final DistributionSetType existingType) { return getI18n().getMessage("message.type.key.duplicate.check", existingType.getKey()); }
@Override protected String getDuplicateKeyErrorMessage(final DistributionSetType existingType) { return getI18n().getMessage("message.type.key.duplicate.check", existingType.getKey()); }
private JpaDistributionSet getAndValidateDsById(final Long dsID) { final JpaDistributionSet distributionSet = distributionSetRepository.findById(dsID) .orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, dsID)); if (!distributionSet.isComplete()) { throw new IncompleteDistributionSetException("Distribution set of type " + distributionSet.getType().getKey() + " is incomplete: " + distributionSet.getId()); } return distributionSet; }
public static JSONObject distributionSet(final DistributionSet set) throws JSONException { final List<JSONObject> modules = set.getModules().stream().map(module -> { try { return new JSONObject().put("id", module.getId()); } catch (final JSONException e) { e.printStackTrace(); return null; } }).collect(Collectors.toList()); return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) .put("type", set.getType() == null ? null : set.getType().getKey()).put("id", Long.MAX_VALUE) .put("version", set.getVersion()).put("createdAt", "0").put("updatedAt", "0") .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh") .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", new JSONArray(modules)); }
public static JSONObject distributionSetCreateValidFieldsOnly(final DistributionSet set) throws JSONException { final List<JSONObject> modules = set.getModules().stream().map(module -> { try { return new JSONObject().put("id", module.getId()); } catch (final JSONException e) { e.printStackTrace(); return null; } }).collect(Collectors.toList()); return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) .put("type", set.getType() == null ? null : set.getType().getKey()).put("version", set.getVersion()) .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", new JSONArray(modules)); }
"Distribution set of type " + set.getType().getKey() + " is incomplete: " + set.getId());
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public DistributionSet create(final DistributionSetCreate c) { final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c; if (create.getType() == null) { create.type(systemManagement.getTenantMetadata().getDefaultDsType().getKey()); } return distributionSetRepository.save(create.build()); }
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(); }
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public DistributionSet create(final DistributionSetCreate c) { final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c; if (create.getType() == null) { create.type(systemManagement.getTenantMetadata().getDefaultDsType().getKey()); } return distributionSetRepository.save(create.build()); }
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(); }
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; }
static MgmtDistributionSet toResponse(final DistributionSet distributionSet) { if (distributionSet == null) { return null; } final MgmtDistributionSet response = new MgmtDistributionSet(); MgmtRestModelMapper.mapNamedToNamed(response, distributionSet); response.setDsId(distributionSet.getId()); response.setVersion(distributionSet.getVersion()); response.setComplete(distributionSet.isComplete()); response.setType(distributionSet.getType().getKey()); response.setDeleted(distributionSet.isDeleted()); distributionSet.getModules() .forEach(module -> response.getModules().add(MgmtSoftwareModuleMapper.toResponse(module))); response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId())) .withSelfRel()); return response; }
@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(); }
combobox.addItem(distributionSetType.getId()); combobox.setItemCaption(distributionSetType.getId(), distributionSetType.getKey() + " (" + distributionSetType.getName() + ")");
combobox.addItem(distributionSetType.getId()); combobox.setItemCaption(distributionSetType.getId(), distributionSetType.getKey() + " (" + distributionSetType.getName() + ")");