/** * Constructor. * * @param distributionSet * the distributionSet */ public DistributionSetIdName(final DistributionSet distributionSet) { this(distributionSet.getId(), distributionSet.getName(), distributionSet.getVersion()); }
/** * Constructor. * * @param distributionSet * the distributionSet */ public DistributionSetIdName(final DistributionSet distributionSet) { this(distributionSet.getId(), distributionSet.getName(), distributionSet.getVersion()); }
private boolean isDuplicate(final Long editDistId) { final String name = distNameTextField.getValue(); final String version = distVersionTextField.getValue(); final Optional<DistributionSet> existingDs = distributionSetManagement.getByNameAndVersion(name, version); /* * Distribution should not exists with the same name & version. Display * error message, when the "existingDs" is not null and it is add window * (or) when the "existingDs" is not null and it is edit window and the * distribution Id of the edit window is different then the "existingDs" */ if (existingDs.isPresent() && !existingDs.get().getId().equals(editDistId)) { distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT); distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT); notificationMessage.displayValidationError(i18n.getMessage("message.duplicate.dist", existingDs.get().getName(), existingDs.get().getVersion())); return true; } return false; }
private boolean isDuplicate(final Long editDistId) { final String name = distNameTextField.getValue(); final String version = distVersionTextField.getValue(); final Optional<DistributionSet> existingDs = distributionSetManagement.getByNameAndVersion(name, version); /* * Distribution should not exists with the same name & version. Display * error message, when the "existingDs" is not null and it is add window * (or) when the "existingDs" is not null and it is edit window and the * distribution Id of the edit window is different then the "existingDs" */ if (existingDs.isPresent() && !existingDs.get().getId().equals(editDistId)) { distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT); distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT); notificationMessage.displayValidationError(i18n.getMessage("message.duplicate.dist", new Object[] { existingDs.get().getName(), existingDs.get().getVersion() })); return true; } return false; }
public static String distributionSetUpdateValidFieldsOnly(final DistributionSet set) throws JSONException { 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("version", set.getVersion()).put("requiredMigrationStep", set.isRequiredMigrationStep()) .toString(); }
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()); }
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)); }
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()); }
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)); }
private List<ProxyDistribution> createProxyDistributions(final Page<DistributionSet> distBeans) { final List<ProxyDistribution> proxyDistributions = new ArrayList<>(); for (final DistributionSet distributionSet : distBeans) { final ProxyDistribution proxyDistribution = new ProxyDistribution(); proxyDistribution.setName( HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setDistId(distributionSet.getId()); proxyDistribution.setId(distributionSet.getId()); proxyDistribution.setVersion(distributionSet.getVersion()); proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet)); proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet)); proxyDistribution.setIsComplete(distributionSet.isComplete()); proxyDistributions.add(proxyDistribution); } return proxyDistributions; }
private void populateDistributionDtls(final VerticalLayout layout, final DistributionSet distributionSet) { layout.removeAllComponents(); layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.name"), distributionSet == null ? "" : distributionSet.getName())); layout.addComponent( SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.version"), distributionSet == null ? "" : distributionSet.getVersion())); if (distributionSet == null) { return; } distributionSet.getModules() .forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module))); }
private void populateDistributionDtls(final VerticalLayout layout, final DistributionSet distributionSet) { layout.removeAllComponents(); layout.addComponent(SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.name"), distributionSet == null ? "" : distributionSet.getName())); layout.addComponent( SPUIComponentProvider.createNameValueLabel(getI18n().getMessage("label.dist.details.version"), distributionSet == null ? "" : distributionSet.getVersion())); if (distributionSet == null) { return; } distributionSet.getModules() .forEach(module -> layout.addComponent(getSWModlabel(module.getType().getName(), module))); }
@Override public void saveOrUpdate() { final String name = distNameTextField.getValue(); final String version = distVersionTextField.getValue(); final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue(); final String desc = descTextArea.getValue(); final boolean isMigStepReq = reqMigStepCheckbox.getValue(); final DistributionSetType distributionSetType = distributionSetTypeManagement.get(distSetTypeId) .orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distSetTypeId)); final DistributionSet newDist = distributionSetManagement .create(entityFactory.distributionSet().create().name(name).version(version).description(desc) .type(distributionSetType).requiredMigrationStep(isMigStepReq)); eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.ADD_ENTITY, newDist)); notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", new Object[] { newDist.getName(), newDist.getVersion() })); distributionSetTable.setValue(Sets.newHashSet(newDist.getId())); }
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 saveOrUpdate() { final String name = distNameTextField.getValue(); final String version = distVersionTextField.getValue(); final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue(); final String desc = descTextArea.getValue(); final boolean isMigStepReq = reqMigStepCheckbox.getValue(); final DistributionSetType distributionSetType = distributionSetTypeManagement.get(distSetTypeId) .orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distSetTypeId)); final DistributionSet newDist = distributionSetManagement .create(entityFactory.distributionSet().create().name(name).version(version).description(desc) .type(distributionSetType).requiredMigrationStep(isMigStepReq)); eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.ADD_ENTITY, newDist)); notificationMessage.displaySuccess( i18n.getMessage("message.new.dist.save.success", newDist.getName(), newDist.getVersion())); distributionSetTable.setValue(Sets.newHashSet(newDist.getId())); }
@Override public void saveOrUpdate() { if (isDuplicate(editDistId)) { return; } final boolean isMigStepReq = reqMigStepCheckbox.getValue(); final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue(); distributionSetTypeManagement.get(distSetTypeId).ifPresent(type -> { final DistributionSet currentDS = distributionSetManagement.update(entityFactory.distributionSet() .update(editDistId).name(distNameTextField.getValue()).description(descTextArea.getValue()) .version(distVersionTextField.getValue()).requiredMigrationStep(isMigStepReq)); notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", new Object[] { currentDS.getName(), currentDS.getVersion() })); // update table row+details layout eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.UPDATED_ENTITY, currentDS)); }); }
/** * Creates a new proxy distribution set by using the values from a * distribution set * * @param distributionSet * the source distribution set */ public ProxyDistribution(final DistributionSet distributionSet) { setName(distributionSet.getName()); setDescription(distributionSet.getDescription()); setDistId(distributionSet.getId()); setId(distributionSet.getId()); setVersion(distributionSet.getVersion()); setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet)); setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet)); setNameVersion( HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); setIsComplete(distributionSet.isComplete()); }
@Override public void saveOrUpdate() { if (isDuplicate(editDistId)) { return; } final boolean isMigStepReq = reqMigStepCheckbox.getValue(); final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue(); distributionSetTypeManagement.get(distSetTypeId).ifPresent(type -> { final DistributionSet currentDS = distributionSetManagement.update(entityFactory.distributionSet() .update(editDistId).name(distNameTextField.getValue()).description(descTextArea.getValue()) .version(distVersionTextField.getValue()).requiredMigrationStep(isMigStepReq)); notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", new Object[] { currentDS.getName(), currentDS.getVersion() })); // update table row+details layout eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.UPDATED_ENTITY, currentDS)); }); }
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) { final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules); if (distributionSetManagement.isInUse(distributionSet.getId())) { uiNotification.displayValidationError(i18n.getMessage("message.error.notification.ds.target.assigned", distributionSet.getName(), distributionSet.getVersion())); } else { final DistributionSet newDistributionSet = distributionSetManagement .unassignSoftwareModule(distributionSet.getId(), unAssignedSw.getId()); manageDistUIState.setLastSelectedEntityId(newDistributionSet.getId()); eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet)); eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION); uiNotification.displaySuccess(i18n.getMessage("message.sw.unassigned", unAssignedSw.getName())); } }
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) { final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules); if (distributionSetManagement.isInUse(distributionSet.getId())) { uiNotification.displayValidationError(i18n.getMessage("message.error.notification.ds.target.assigned", distributionSet.getName(), distributionSet.getVersion())); } else { final DistributionSet newDistributionSet = distributionSetManagement .unassignSoftwareModule(distributionSet.getId(), unAssignedSw.getId()); manageDistUIState.setLastSelectedEntityId(newDistributionSet.getId()); eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.SELECTED_ENTITY, newDistributionSet)); eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION); uiNotification.displaySuccess(i18n.getMessage("message.sw.unassigned", unAssignedSw.getName())); } }