@Override public ResponseEntity<MgmtDistributionSet> updateDistributionSet( @PathVariable("distributionSetId") final Long distributionSetId, @RequestBody final MgmtDistributionSetRequestBodyPut toUpdate) { final DistributionSet updated = distributionSetManagement.update(entityFactory.distributionSet() .update(distributionSetId).name(toUpdate.getName()).description(toUpdate.getDescription()) .version(toUpdate.getVersion()).requiredMigrationStep(toUpdate.isRequiredMigrationStep())); final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(updated); MgmtDistributionSetMapper.addLinks(updated, response); return ResponseEntity.ok(response); }
/** * Creates {@link DistributionSet}s in repository including three * {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} * , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an * iterative number and {@link DistributionSet#isRequiredMigrationStep()} * <code>false</code>. * * In addition it updates the created {@link DistributionSet}s and * {@link SoftwareModule}s to ensure that * {@link BaseEntity#getLastModifiedAt()} and * {@link BaseEntity#getLastModifiedBy()} is filled. * * @return persisted {@link DistributionSet}. */ public DistributionSet createUpdatedDistributionSet() { DistributionSet set = createDistributionSet(""); set = distributionSetManagement.update( entityFactory.distributionSet().update(set.getId()).description("Updated " + DEFAULT_DESCRIPTION)); set.getModules().forEach(module -> softwareModuleManagement.update( entityFactory.softwareModule().update(module.getId()).description("Updated " + DEFAULT_DESCRIPTION))); // load also lazy stuff return distributionSetManagement.getWithDetails(set.getId()).get(); }
/** * Creates {@link DistributionSet}s in repository including three * {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} * , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an * iterative number and {@link DistributionSet#isRequiredMigrationStep()} * <code>false</code>. * * In addition it updates the created {@link DistributionSet}s and * {@link SoftwareModule}s to ensure that * {@link BaseEntity#getLastModifiedAt()} and * {@link BaseEntity#getLastModifiedBy()} is filled. * * @return persisted {@link DistributionSet}. */ public DistributionSet createUpdatedDistributionSet() { DistributionSet set = createDistributionSet(""); set = distributionSetManagement.update( entityFactory.distributionSet().update(set.getId()).description("Updated " + DEFAULT_DESCRIPTION)); set.getModules().forEach(module -> softwareModuleManagement.update( entityFactory.softwareModule().update(module.getId()).description("Updated " + DEFAULT_DESCRIPTION))); // load also lazy stuff return distributionSetManagement.getWithDetails(set.getId()).get(); }
protected DistributionSet createDistributionSet() { DistributionSet distributionSet = testdataFactory.createDistributionSet(""); distributionSet = distributionSetManagement.update(entityFactory.distributionSet() .update(distributionSet.getId()).description("The descption of the distribution set.")); distributionSet.getModules().forEach(module -> { final byte[] random = RandomStringUtils.random(5).getBytes(); artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), module.getId(), "file1", false, 0)); softwareModuleManagement.update(entityFactory.softwareModule().update(module.getId()) .description("Description of the software module")); }); return distributionSet; }
@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)); }); }
@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)); }); }
@Test @Description("Get paged list of Distribution Sets with given page size and offset including sorting by name descending and filter down to all sets which name starts with 'testDs'. Required Permission: " + SpPermission.READ_REPOSITORY) public void getDistributionSetsWithParameters() throws Exception { final List<DistributionSet> sets = testdataFactory.createDistributionSets("testDS", 3); sets.forEach(set -> distributionSetManagement .update(entityFactory.distributionSet().update(set.getId()).description("updated description"))); mockMvc.perform( get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).param("offset", "1").param("limit", "2") .param("sort", "version:DESC").param("q", "name==testDS*").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andDo(this.document.document(getFilterRequestParamter())); }