/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getOptionalModuleTypes()}. * * @param softwareModuleType * search for * @return <code>true</code> if found */ default boolean containsOptionalModuleType(final SoftwareModuleType softwareModuleType) { return containsOptionalModuleType(softwareModuleType.getId()); }
public JpaDistributionSetType removeModuleType(final Long smTypeId) { if (elements == null) { return this; } // we search by id (standard equals compares also revison) elements.stream().filter(element -> element.getSmType().getId().equals(smTypeId)).findAny() .ifPresent(elements::remove); return this; }
/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getMandatoryModuleTypes()}. * * @param softwareModuleType * search for * @return <code>true</code> if found */ default boolean containsMandatoryModuleType(final SoftwareModuleType softwareModuleType) { return containsMandatoryModuleType(softwareModuleType.getId()); }
/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getMandatoryModuleTypes()}. * * @param softwareModuleTypeId * search for by {@link SoftwareModuleType#getId()} * @return <code>true</code> if found */ default boolean containsMandatoryModuleType(final Long softwareModuleTypeId) { return getMandatoryModuleTypes().stream().anyMatch(element -> element.getId().equals(softwareModuleTypeId)); }
/** * Checks if the given {@link SoftwareModuleType} is in * {@link #getOptionalModuleTypes()}. * * @param softwareModuleTypeId * search by {@link SoftwareModuleType#getId()} * @return <code>true</code> if found */ default boolean containsOptionalModuleType(final Long softwareModuleTypeId) { return getOptionalModuleTypes().stream().anyMatch(element -> element.getId().equals(softwareModuleTypeId)); }
public JpaDistributionSetType removeModuleType(final Long smTypeId) { if (elements == null) { return this; } // we search by id (standard equals compares also revison) elements.stream().filter(element -> element.getSmType().getId().equals(smTypeId)).findAny() .ifPresent(elements::remove); return this; }
@Override protected void deleteEntity(final String entityToDelete) { final Optional<SoftwareModuleType> swmTypeToDelete = softwareModuleTypeManagement.getByName(entityToDelete); swmTypeToDelete.ifPresent(tag -> { if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().equals(swmTypeToDelete)) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.delete", entityToDelete)); removeUpdateAndDeleteColumn(); } else { softwareModuleTypeManagement.delete(swmTypeToDelete.get().getId()); getEventBus().publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFTWARE_TYPE); uiNotification.displaySuccess(getI18n().getMessage("message.delete.success", entityToDelete)); } }); }
@Override protected void deleteEntity(final String entityToDelete) { final Optional<SoftwareModuleType> swmTypeToDelete = softwareModuleTypeManagement.getByName(entityToDelete); swmTypeToDelete.ifPresent(tag -> { if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().equals(swmTypeToDelete)) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.delete", entityToDelete)); removeUpdateAndDeleteColumn(); } else { softwareModuleTypeManagement.delete(swmTypeToDelete.get().getId()); getEventBus().publish(this, UploadArtifactUIEvent.DELETED_ALL_SOFTWARE_TYPE); uiNotification.displaySuccess(getI18n().getMessage("message.delete.success", entityToDelete)); } }); }
@Override protected void deleteEntity(final String entityToDelete) { final Optional<SoftwareModuleType> swmTypeToDelete = softwareModuleTypeManagement.getByName(entityToDelete); swmTypeToDelete.ifPresent(tag -> { if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().equals(swmTypeToDelete)) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.delete", entityToDelete)); removeUpdateAndDeleteColumn(); } else { softwareModuleTypeManagement.delete(swmTypeToDelete.get().getId()); getEventBus().publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES); uiNotification.displaySuccess(getI18n().getMessage("message.delete.success", entityToDelete)); } }); } }
@Override protected void deleteEntity(final String entityToDelete) { final Optional<SoftwareModuleType> swmTypeToDelete = softwareModuleTypeManagement.getByName(entityToDelete); swmTypeToDelete.ifPresent(tag -> { if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().equals(swmTypeToDelete)) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.delete", entityToDelete)); removeUpdateAndDeleteColumn(); } else { softwareModuleTypeManagement.delete(swmTypeToDelete.get().getId()); getEventBus().publish(this, SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES); uiNotification.displaySuccess(getI18n().getMessage("message.delete.success", entityToDelete)); } }); } }
@SuppressWarnings("unchecked") protected void createSourceTableData() { sourceTableContainer.removeAllItems(); final Iterable<SoftwareModuleType> moduleTypeBeans = softwareModuleTypeManagement .findAll(PageRequest.of(0, 1000)); Item saveTblitem; for (final SoftwareModuleType swTypeTag : moduleTypeBeans) { saveTblitem = sourceTableContainer.addItem(swTypeTag.getId()); saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue(swTypeTag.getName()); saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue(swTypeTag.getDescription()); } }
@SuppressWarnings("unchecked") protected void createSourceTableData() { sourceTableContainer.removeAllItems(); final Iterable<SoftwareModuleType> moduleTypeBeans = softwareModuleTypeManagement .findAll(new PageRequest(0, 1000)); Item saveTblitem; for (final SoftwareModuleType swTypeTag : moduleTypeBeans) { saveTblitem = sourceTableContainer.addItem(swTypeTag.getId()); saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue(swTypeTag.getName()); saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue(swTypeTag.getDescription()); } }
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 void addLinks(final SoftwareModule softwareModule, final MgmtSoftwareModule response) { response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getModuleId())) .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT)); response.add(linkTo( methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(softwareModule.getType().getId())) .withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE)); response.add(linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getModuleId(), MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata") .expand()); }
@Test @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Handles the DELETE request for a single software module Type within SP. Required Permission: DELETE_REPOSITORY.") public void deleteSoftwareModuleType() throws Exception { final SoftwareModuleType testType = softwareModuleTypeManagement.create( entityFactory.softwareModuleType().create().key("test1").name("TestName1").description("Desc1")); assertThat(softwareModuleTypeManagement.count()).isEqualTo(4); this.mockMvc .perform(delete(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeID}", testType.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("softwareModuleTypeID").description(ApiModelPropertiesGeneric.ITEM_ID)))); assertThat(softwareModuleTypeManagement.count()).isEqualTo(3); }
private void updateSWModuleType(final SoftwareModuleType existingType) { getSoftwareModuleTypeManagement().update(getEntityFactory().softwareModuleType().update(existingType.getId()) .description(getTagDesc().getValue()) .colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()))); getUiNotification().displaySuccess(getI18n().getMessage("message.update.success", existingType.getName())); getEventBus().publish(this, new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE, existingType)); }
private void updateSWModuleType(final SoftwareModuleType existingType) { getSoftwareModuleTypeManagement().update(getEntityFactory().softwareModuleType().update(existingType.getId()) .description(getTagDesc().getValue()) .colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()))); getUiNotification().displaySuccess(getI18n().getMessage("message.update.success", existingType.getName())); getEventBus().publish(this, new SoftwareModuleTypeEvent(SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE, existingType)); }
@Test @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Handles the GET request of retrieving all software module types within SP with parametsrs. In this case the first 10 result in ascending order by name wher the name starts with 'a'. Required Permission: READ_REPOSITORY.") public void getSoftwareModuleTypesWithParameters() throws Exception { final SoftwareModuleType testType = testdataFactory.findOrCreateSoftwareModuleType("test123"); softwareModuleTypeManagement .update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234")); mockMvc.perform(get( MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a") .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(getFilterRequestParamter())); }
@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 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)))); }