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()); }
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()); }
/** * Populate DistributionSet Type name combo. */ private void populateDistSetTypeNameCombo() { distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer()); distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId()); }
/** * Populate DistributionSet Type name combo. */ private void populateDistSetTypeNameCombo() { distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer()); distsetTypeNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId()); }
@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)); }
@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)); }
@Override protected void deleteEntity(final String entityToDelete) { final Optional<DistributionSetType> distTypeToDelete = distributionSetTypeManagement.getByName(entityToDelete); distTypeToDelete.ifPresent(tag -> { if (tag.equals(manageDistUIState.getManageDistFilters().getClickedDistSetType())) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.delete", entityToDelete)); removeUpdateAndDeleteColumn(); } else if (isDefaultDsType(entityToDelete)) { uiNotification.displayValidationError(getI18n().getMessage("message.cannot.delete.default.dstype")); removeUpdateAndDeleteColumn(); } else { distributionSetTypeManagement.delete(distTypeToDelete.get().getId()); getEventBus().publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES); uiNotification.displaySuccess(getI18n().getMessage("message.delete.success", entityToDelete)); } }); }
@Override protected void deleteEntity(final String entityToDelete) { final Optional<DistributionSetType> distTypeToDelete = distributionSetTypeManagement.getByName(entityToDelete); distTypeToDelete.ifPresent(tag -> { if (tag.equals(manageDistUIState.getManageDistFilters().getClickedDistSetType())) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.delete", entityToDelete)); removeUpdateAndDeleteColumn(); } else if (isDefaultDsType(entityToDelete)) { uiNotification.displayValidationError(getI18n().getMessage("message.cannot.delete.default.dstype")); removeUpdateAndDeleteColumn(); } else { distributionSetTypeManagement.delete(distTypeToDelete.get().getId()); getEventBus().publish(this, SaveActionWindowEvent.SAVED_DELETE_DIST_SET_TYPES); uiNotification.displaySuccess(getI18n().getMessage("message.delete.success", entityToDelete)); } }); }
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 void addLinks(final DistributionSet distributionSet, final MgmtDistributionSet response) { response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getAssignedSoftwareModules(response.getDsId(), MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null)) .withRel(MgmtRestConstants.DISTRIBUTIONSET_V1_MODULE)); response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class) .getDistributionSetType(distributionSet.getType().getId())).withRel("type")); response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getMetadata(response.getDsId(), MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata")); }
@Test @Description("Handles the GET request of retrieving a single distribution set type within SP. Required Permission: READ_REPOSITORY") public void deleteDistributionSetType() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.update(entityFactory.distributionSetType() .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); mockMvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", testType.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
public void putDistributionSetType() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.update(entityFactory.distributionSetType() .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); final String body = new JSONObject().put("description", "an updated desription").toString(); testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(
@Test @Description("Handles the GET request of retrieving all distribution set types within SP with a defined page size and offset, sortet by name in descending order and filtered down to all targets which name starts with 'a'. Required Permission: READ_REPOSITORY.") public void getDistributionSetTypesWithParameters() throws Exception { distributionSetTypeManagement.update(entityFactory.distributionSetType() .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON) .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==a*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(this.document.document(getFilterRequestParamter())); }
@Test @Description("Handles the POST request for adding a mandatory software module type to a distribution set type." + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) public void postMandatoryModule() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create( entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1")); mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes", testType.getId()) .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") .description(ApiModelPropertiesGeneric.ITEM_ID)), requestFields(requestFieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
@Test @Description("Handles the POST request for adding an optional software module type to a distribution set type." + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) public void postOptionalModule() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create( entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1")); mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes", testType.getId()) .content("{\"id\":" + appType.getId() + "}").contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") .description(ApiModelPropertiesGeneric.ITEM_ID)), requestFields(requestFieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
@Test @Description("Handles DELETE request for removing an optional module from the distribution set type." + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) public void deleteOptionalModule() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test1").name("TestName1").description("Desc1").mandatory(osType).optional(runtimeType)); mockMvc.perform(delete( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId}", testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
@Test @Description("Handles the GET request of retrieving the list of software module types in that distribution set. " + "Note that a DS type cannot be changed after it has been used by a DS. Required permissions: " + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) public void deleteMandatoryModule() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test1").name("TestName1").description("Desc1").mandatory(osType).optional(runtimeType)); mockMvc.perform(delete( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId}", testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }
@Test @Description("Handles the GET request of retrieving the list of optional software module types in that distribution set type. Required Permission: " + SpPermission.READ_REPOSITORY) public void getOptionalModules() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test1").name("TestName1").description("Desc1").mandatory(osType).optional(runtimeType)); mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes", testType.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") .description(ApiModelPropertiesGeneric.ITEM_ID)), responseFields(fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), fieldWithPath("[]key").description(MgmtApiModelProperties.SM_TYPE_KEY), fieldWithPath("[]maxAssignments") .description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), fieldWithPath("[]lastModifiedAt") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT), fieldWithPath("[]lastModifiedBy") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY), fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), fieldWithPath("[]_links.self").ignored()))); }
@Test @Description("Handles the GET request of retrieving the single mandatory software module type in that distribution set type. Required Permission: " + SpPermission.READ_REPOSITORY) public void getMandatoryModule() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test1").name("TestName1").description("Desc1").mandatory(osType).optional(runtimeType)); mockMvc.perform(get( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId}", testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("softwareModuleTypeId").description(ApiModelPropertiesGeneric.ITEM_ID)), responseFields(fieldWithPath("createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), fieldWithPath("createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), fieldWithPath("description").description(ApiModelPropertiesGeneric.DESCRPTION), fieldWithPath("key").description(MgmtApiModelProperties.SM_TYPE_KEY), fieldWithPath("maxAssignments").description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), fieldWithPath("id").description(ApiModelPropertiesGeneric.ITEM_ID), fieldWithPath("lastModifiedAt").description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT) .type("Number"), fieldWithPath("lastModifiedBy").description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY) .type("String"), fieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), fieldWithPath("deleted").description(ApiModelPropertiesGeneric.DELETED), fieldWithPath("_links.self").ignored()))); }
@Test @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Handles the GET request of retrieving the list of mandatory software module types in that distribution set type. Required Permission: READ_REPOSITORY.") public void getMandatoryModules() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test1").name("TestName1").description("Desc1").mandatory(osType).optional(runtimeType)); mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes", testType.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") .description(ApiModelPropertiesGeneric.ITEM_ID)), responseFields(fieldWithPath("[]createdBy").description(ApiModelPropertiesGeneric.CREATED_BY), fieldWithPath("[]createdAt").description(ApiModelPropertiesGeneric.CREATED_AT), fieldWithPath("[]description").description(ApiModelPropertiesGeneric.DESCRPTION), fieldWithPath("[]key").description(MgmtApiModelProperties.SM_TYPE_KEY), fieldWithPath("[]maxAssignments") .description(MgmtApiModelProperties.SMT_MAX_ASSIGNMENTS), fieldWithPath("[]id").description(ApiModelPropertiesGeneric.ITEM_ID), fieldWithPath("[]lastModifiedAt") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_AT).type("Number"), fieldWithPath("[]lastModifiedBy") .description(ApiModelPropertiesGeneric.LAST_MODIFIED_BY).type("String"), fieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), fieldWithPath("[]deleted").description(ApiModelPropertiesGeneric.DELETED), fieldWithPath("[]_links.self").ignored()))); }