protected boolean compareSoftwareModulesById(final SoftwareModule softwareModule, final Long selectedBaseSwModuleId) { if (softwareModule == null) { return false; } return softwareModule.getId().equals(selectedBaseSwModuleId); }
protected boolean compareSoftwareModulesById(final SoftwareModule softwareModule, final Long selectedBaseSwModuleId) { if (softwareModule == null) { return false; } return softwareModule.getId().equals(selectedBaseSwModuleId); }
public boolean removeModule(final SoftwareModule softwareModule) { if (modules == null) { return false; } final Optional<SoftwareModule> found = modules.stream() .filter(module -> module.getId().equals(softwareModule.getId())).findAny(); if (found.isPresent()) { modules.remove(found.get()); complete = type.checkComplete(this); return true; } return false; }
@Override protected void deleteMetadata(final SoftwareModule entity, final String key) { softwareModuleManagement.deleteMetaData(entity.getId(), key); }
@Override public ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); softwareModuleManagement.delete(module.getId()); return ResponseEntity.ok().build(); }
/** * Constructor. * * @param softwareModule * the softwareModule */ public SoftwareModuleIdName(final SoftwareModule softwareModule) { this(softwareModule.getId(), softwareModule.getName(), softwareModule.getVersion()); }
@Override protected List<SoftwareModuleMetadata> getMetadataList() { return Collections.unmodifiableList(softwareModuleManagement .findMetaDataBySoftwareModuleId(new PageRequest(0, MAX_METADATA_QUERY), getSelectedEntity().getId()) .getContent()); }
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; }
private void addTestModuleMetadata(final SoftwareModule module) { softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId()) .key(VISIBLE_SM_MD_KEY).value(VISIBLE_SM_MD_VALUE).targetVisible(true)); softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId()) .key(INVISIBLE_SM_MD_KEY).value(INVISIBLE_SM_MD_VALUE).targetVisible(false)); }
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final long id) { final JpaArtifact existing = (JpaArtifact) get(id) .orElseThrow(() -> new EntityNotFoundException(Artifact.class, id)); clearArtifactBinary(existing.getSha1Hash(), existing.getSoftwareModule().getId()); ((JpaSoftwareModule) existing.getSoftwareModule()).removeArtifact(existing); softwareModuleRepository.save((JpaSoftwareModule) existing.getSoftwareModule()); localArtifactRepository.delete(id); }
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final long id) { final JpaArtifact existing = (JpaArtifact) get(id) .orElseThrow(() -> new EntityNotFoundException(Artifact.class, id)); clearArtifactBinary(existing.getSha1Hash(), existing.getSoftwareModule().getId()); ((JpaSoftwareModule) existing.getSoftwareModule()).removeArtifact(existing); softwareModuleRepository.save((JpaSoftwareModule) existing.getSoftwareModule()); localArtifactRepository.deleteById(id); }
@Override protected SoftwareModuleMetadata updateMetadata(final SoftwareModule entity, final String key, final String value) { final SoftwareModuleMetadata swMetadata = softwareModuleManagement .updateMetaData(entityFactory.softwareModuleMetadata().update(entity.getId(), key).value(value) .targetVisible(targetVisibleField.getValue())); setSelectedEntity(swMetadata.getSoftwareModule()); return swMetadata; }
@Override protected SoftwareModuleMetadata updateMetadata(final SoftwareModule entity, final String key, final String value) { final SoftwareModuleMetadata swMetadata = softwareModuleManagement .updateMetaData(entityFactory.softwareModuleMetadata().update(entity.getId(), key).value(value) .targetVisible(targetVisibleField.getValue())); setSelectedEntity(swMetadata.getSoftwareModule()); return swMetadata; }
@Override protected SoftwareModuleMetadata createMetadata(final SoftwareModule entity, final String key, final String value) { final SoftwareModuleMetadata swMetadata = softwareModuleManagement .createMetaData(entityFactory.softwareModuleMetadata().create(entity.getId()).key(key).value(value) .targetVisible(targetVisibleField.getValue())); setSelectedEntity(swMetadata.getSoftwareModule()); return swMetadata; }
@SuppressWarnings("unchecked") @Override protected void updateEntity(final SoftwareModule baseEntity, final Item item) { final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(), baseEntity.getVersion()); item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion); item.getItemProperty("swId").setValue(baseEntity.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor()); super.updateEntity(baseEntity, item); }
@SuppressWarnings("unchecked") @Override protected void updateEntity(final SoftwareModule baseEntity, final Item item) { final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(), baseEntity.getVersion()); item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion); item.getItemProperty("swId").setValue(baseEntity.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor()); super.updateEntity(baseEntity, item); }
@Override @SuppressWarnings("unchecked") protected void updateEntity(final SoftwareModule baseEntity, final Item item) { final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(), baseEntity.getVersion()); item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion); item.getItemProperty(SPUILabelDefinitions.VAR_SWM_ID).setValue(baseEntity.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor()); item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(baseEntity.getType().getColour()); super.updateEntity(baseEntity, item); }
@Override @SuppressWarnings("unchecked") protected void updateEntity(final SoftwareModule baseEntity, final Item item) { final String swNameVersion = HawkbitCommonUtil.concatStrings(":", baseEntity.getName(), baseEntity.getVersion()); item.getItemProperty(SPUILabelDefinitions.NAME_VERSION).setValue(swNameVersion); item.getItemProperty(SPUILabelDefinitions.VAR_SWM_ID).setValue(baseEntity.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(baseEntity.getVendor()); item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(baseEntity.getType().getColour()); super.updateEntity(baseEntity, item); }
static MgmtArtifact toResponse(final Artifact artifact) { final MgmtArtifact artifactRest = new MgmtArtifact(); artifactRest.setArtifactId(artifact.getId()); artifactRest.setSize(artifact.getSize()); artifactRest.setHashes(new MgmtArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash())); artifactRest.setProvidedFilename(artifact.getFilename()); MgmtRestModelMapper.mapBaseToBase(artifactRest, artifact); artifactRest.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class) .getArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withSelfRel()); return artifactRest; }
@Test @Description("Handles the DELETE request for a single softwaremodule within SP. Required Permission: " + SpPermission.DELETE_REPOSITORY) public void deleteSoftwareModule() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); this.mockMvc .perform( delete(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId())) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)))); }