private JpaDistributionSetType setModuleType(final SoftwareModuleType smType, final boolean mandatory) { if (elements == null) { elements = new HashSet<>(); elements.add(new DistributionSetTypeElement(this, (JpaSoftwareModuleType) smType, mandatory)); return this; } // check if this was in the list before before final Optional<DistributionSetTypeElement> existing = elements.stream() .filter(element -> element.getSmType().getKey().equals(smType.getKey())).findAny(); if (existing.isPresent()) { existing.get().setMandatory(mandatory); } else { elements.add(new DistributionSetTypeElement(this, (JpaSoftwareModuleType) smType, mandatory)); } return this; }
private JpaDistributionSetType setModuleType(final SoftwareModuleType smType, final boolean mandatory) { if (elements == null) { elements = new HashSet<>(); elements.add(new DistributionSetTypeElement(this, (JpaSoftwareModuleType) smType, mandatory)); return this; } // check if this was in the list before before final Optional<DistributionSetTypeElement> existing = elements.stream() .filter(element -> element.getSmType().getKey().equals(smType.getKey())).findAny(); if (existing.isPresent()) { existing.get().setMandatory(mandatory); } else { elements.add(new DistributionSetTypeElement(this, (JpaSoftwareModuleType) smType, mandatory)); } return this; }
@Override protected String getDuplicateKeyErrorMessage(final SoftwareModuleType existingType) { return getI18n().getMessage("message.type.key.swmodule.duplicate.check", existingType.getKey()); }
@Override protected String getDuplicateKeyErrorMessage(final SoftwareModuleType existingType) { return getI18n().getMessage("message.type.key.swmodule.duplicate.check", existingType.getKey()); }
public boolean addModule(final SoftwareModule softwareModule) { if (modules == null) { modules = new HashSet<>(); } checkTypeCompatability(softwareModule); final Optional<SoftwareModule> found = modules.stream() .filter(module -> module.getId().equals(softwareModule.getId())).findAny(); if (found.isPresent()) { return false; } final long allready = modules.stream() .filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count(); if (allready >= softwareModule.getType().getMaxAssignments()) { modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())) .findAny().ifPresent(modules::remove); } if (modules.add(softwareModule)) { complete = type.checkComplete(this); return true; } return false; }
public boolean addModule(final SoftwareModule softwareModule) { if (modules == null) { modules = new HashSet<>(); } checkTypeCompatability(softwareModule); final Optional<SoftwareModule> found = modules.stream() .filter(module -> module.getId().equals(softwareModule.getId())).findAny(); if (found.isPresent()) { return false; } final long allready = modules.stream() .filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())).count(); if (allready >= softwareModule.getType().getMaxAssignments()) { modules.stream().filter(module -> module.getType().getKey().equals(softwareModule.getType().getKey())) .findAny().ifPresent(modules::remove); } if (modules.add(softwareModule)) { complete = type.checkComplete(this); return true; } return false; }
private DmfSoftwareModule convertToAmqpSoftwareModule(final Target target, final Entry<SoftwareModule, List<SoftwareModuleMetadata>> entry) { final DmfSoftwareModule amqpSoftwareModule = new DmfSoftwareModule(); amqpSoftwareModule.setModuleId(entry.getKey().getId()); amqpSoftwareModule.setModuleType(entry.getKey().getType().getKey()); amqpSoftwareModule.setModuleVersion(entry.getKey().getVersion()); amqpSoftwareModule.setArtifacts(convertArtifacts(target, entry.getKey().getArtifacts())); if (!CollectionUtils.isEmpty(entry.getValue())) { amqpSoftwareModule.setMetadata(convertMetadata(entry.getValue())); } return amqpSoftwareModule; }
static List<DdiChunk> createChunks(final Target target, final Action uAction, final ArtifactUrlHandler artifactUrlHandler, final SystemManagement systemManagement, final HttpRequest request, final ControllerManagement controllerManagement) { final Map<Long, List<SoftwareModuleMetadata>> metadata = controllerManagement .findTargetVisibleMetaDataBySoftwareModuleId(uAction.getDistributionSet().getModules().stream() .map(SoftwareModule::getId).collect(Collectors.toList())); return uAction.getDistributionSet().getModules().stream() .map(module -> new DdiChunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(), module.getName(), createArtifacts(target, module, artifactUrlHandler, systemManagement, request), mapMetadata(metadata.get(module.getId())))) .collect(Collectors.toList()); }
static List<DdiChunk> createChunks(final Target target, final Action uAction, final ArtifactUrlHandler artifactUrlHandler, final SystemManagement systemManagement, final HttpRequest request, final ControllerManagement controllerManagement) { final Map<Long, List<SoftwareModuleMetadata>> metadata = controllerManagement .findTargetVisibleMetaDataBySoftwareModuleId(uAction.getDistributionSet().getModules().stream() .map(SoftwareModule::getId).collect(Collectors.toList())); return new ResponseList<>(uAction.getDistributionSet().getModules().stream() .map(module -> new DdiChunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(), module.getName(), createArtifacts(target, module, artifactUrlHandler, systemManagement, request), mapMetadata(metadata.get(module.getId())))) .collect(Collectors.toList())); }
public static String softwareModuleTypes(final List<SoftwareModuleType> types) throws JSONException { final StringBuilder builder = new StringBuilder(); builder.append("["); int i = 0; for (final SoftwareModuleType module : types) { builder.append(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("id", Long.MAX_VALUE).put("key", module.getKey()) .put("maxAssignments", module.getMaxAssignments()).put("createdAt", "0").put("updatedAt", "0") .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString()); if (++i < types.size()) { builder.append(","); } } builder.append("]"); return builder.toString(); }
public static String softwareModuleTypesCreatableFieldsOnly(final List<SoftwareModuleType> types) throws JSONException { final StringBuilder builder = new StringBuilder(); builder.append("["); int i = 0; for (final SoftwareModuleType module : types) { builder.append(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("key", module.getKey()).put("maxAssignments", module.getMaxAssignments()).toString()); if (++i < types.size()) { builder.append(","); } } builder.append("]"); return builder.toString(); }
public static String softwareModules(final List<SoftwareModule> modules) throws JSONException { final StringBuilder builder = new StringBuilder(); builder.append("["); int i = 0; for (final SoftwareModule module : modules) { builder.append(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("type", module.getType().getKey()).put("id", Long.MAX_VALUE).put("vendor", module.getVendor()) .put("version", module.getVersion()).put("createdAt", "0").put("updatedAt", "0") .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString()); if (++i < modules.size()) { builder.append(","); } } builder.append("]"); return builder.toString(); }
public static String softwareModulesCreatableFieldsOnly(final List<SoftwareModule> modules) throws JSONException { final StringBuilder builder = new StringBuilder(); builder.append("["); int i = 0; for (final SoftwareModule module : modules) { builder.append(new JSONObject().put("name", module.getName()).put("description", module.getDescription()) .put("type", module.getType().getKey()).put("vendor", module.getVendor()) .put("version", module.getVersion()).toString()); if (++i < modules.size()) { builder.append(","); } } builder.append("]"); return builder.toString(); }
private VerticalLayout createSoftModuleLayout(final SoftwareModuleType swModType, final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) { final VerticalLayout verticalLayout = new VerticalLayout(); for (final SoftwareModule sw : alreadyAssignedSwModules) { if (swModType.getKey().equals(sw.getType().getKey())) { final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(""); final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorder.class); reassignSoftModule .addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules)); final String softwareModNameVersion = HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()); softwareModule.setValue(softwareModNameVersion); softwareModule.setDescription(softwareModNameVersion); softwareModule.setId(sw.getName() + "-label"); horizontalLayout.addComponent(softwareModule); horizontalLayout.setExpandRatio(softwareModule, 1F); if (isUnassignSoftModAllowed && permissionChecker.hasUpdateRepositoryPermission() && !isTargetAssigned && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) { horizontalLayout.addComponent(reassignSoftModule); } verticalLayout.addComponent(horizontalLayout); } } return verticalLayout; }
private VerticalLayout createSoftModuleLayout(final SoftwareModuleType swModType, final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) { final VerticalLayout verticalLayout = new VerticalLayout(); for (final SoftwareModule sw : alreadyAssignedSwModules) { if (swModType.getKey().equals(sw.getType().getKey())) { final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(""); final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorder.class); reassignSoftModule .addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules)); final String softwareModNameVersion = HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()); softwareModule.setValue(softwareModNameVersion); softwareModule.setDescription(softwareModNameVersion); softwareModule.setId(sw.getName() + "-label"); horizontalLayout.addComponent(softwareModule); horizontalLayout.setExpandRatio(softwareModule, 1F); if (isUnassignSoftModAllowed && permissionChecker.hasUpdateRepositoryPermission() && !isTargetAssigned && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) { horizontalLayout.addComponent(reassignSoftModule); } verticalLayout.addComponent(horizontalLayout); } } return verticalLayout; }
@Override public void setTagDetails(final String selectedEntity) { getSoftwareModuleTypeManagement().getByName(selectedEntity).ifPresent(selectedTypeTag -> { getTagName().setValue(selectedTypeTag.getName()); getTagDesc().setValue(selectedTypeTag.getDescription()); getTypeKey().setValue(selectedTypeTag.getKey()); if (selectedTypeTag.getMaxAssignments() == 1) { getAssignOptiongroup().setValue(getSingleAssignStr()); } else { getAssignOptiongroup().setValue(getMultiAssignStr()); } setColorPickerComponentsColor(selectedTypeTag.getColour()); }); disableFields(); }
@Override public void setTagDetails(final String selectedEntity) { getSoftwareModuleTypeManagement().getByName(selectedEntity).ifPresent(selectedTypeTag -> { getTagName().setValue(selectedTypeTag.getName()); getTagDesc().setValue(selectedTypeTag.getDescription()); getTypeKey().setValue(selectedTypeTag.getKey()); if (selectedTypeTag.getMaxAssignments() == 1) { getAssignOptiongroup().setValue(getSingleAssignStr()); } else { getAssignOptiongroup().setValue(getMultiAssignStr()); } setColorPickerComponentsColor(selectedTypeTag.getColour()); }); disableFields(); }
static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType(); MgmtRestModelMapper.mapNamedToNamed(result, type); result.setKey(type.getKey()); result.setMaxAssignments(type.getMaxAssignments()); result.setModuleId(type.getId()); result.setDeleted(type.isDeleted()); result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) .withSelfRel()); return result; }
static MgmtSoftwareModule toResponse(final SoftwareModule softwareModule) { if (softwareModule == null) { return null; } final MgmtSoftwareModule response = new MgmtSoftwareModule(); MgmtRestModelMapper.mapNamedToNamed(response, softwareModule); response.setModuleId(softwareModule.getId()); response.setVersion(softwareModule.getVersion()); response.setType(softwareModule.getType().getKey()); response.setVendor(softwareModule.getVendor()); response.setDeleted(softwareModule.isDeleted()); response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getModuleId())) .withSelfRel()); return response; }