From eb7d16f50c59ca2979ec2a79fe57edafafc97e96 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Tue, 25 Jan 2022 19:53:06 +0000 Subject: Fix issue in artifact type update Signed-off-by: MichaelMorris Issue-ID: SDC-3860 Change-Id: Idad3cde460f8ce8c88914a2ddde63c1950f9536b --- .../model/operations/impl/ArtifactTypeOperation.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'catalog-model/src/main') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactTypeOperation.java index d16a7353cb..8dfea30340 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactTypeOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactTypeOperation.java @@ -105,7 +105,7 @@ public class ArtifactTypeOperation extends AbstractOperation implements IArtifac createNodeResult = janusGraphGenericDao.updateNode(artifactTypeData, ArtifactTypeData.class).right() .map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus).left() .bind(updatedNode -> updateArtifactProperties(artifactType.getUniqueId(), artifactType.getProperties())).left() - .bind(updatedProperties -> updateArtifactDerivedFrom(artifactType, artifactType.getDerivedFrom())).left() + .bind(updatedProperties -> updateArtifactDerivedFrom(artifactType)).left() .map(updatedDerivedFrom -> artifactType); } if (createNodeResult.isRight()) { @@ -165,15 +165,18 @@ public class ArtifactTypeOperation extends AbstractOperation implements IArtifac .bind(deleteProps -> addPropertiesToArtifact(artifactId, properties)); } - private Either updateArtifactDerivedFrom(ArtifactTypeDefinition updatedArtifactType, - String currDerivedFromArtifactType) { + private Either updateArtifactDerivedFrom(ArtifactTypeDefinition updatedArtifactType) { String artifactTypeId = updatedArtifactType.getUniqueId(); + + Either currentDerivedFrom = derivedFromOperation.getDerivedFromChild(updatedArtifactType.getUniqueId(), NodeTypeEnum.ArtifactType, ArtifactTypeData.class); LOGGER.debug( "#updateArtifactDerivedFrom - updating artifact derived from relation for artifact type with id {}. old derived type {}. new derived type {}", - artifactTypeId, currDerivedFromArtifactType, updatedArtifactType.getDerivedFrom()); - StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromArtifactType(artifactTypeId, currDerivedFromArtifactType, updatedArtifactType.getModel()); - if (deleteDerivedRelationStatus != StorageOperationStatus.OK) { - return Either.right(deleteDerivedRelationStatus); + artifactTypeId, currentDerivedFrom.isLeft() ? currentDerivedFrom: "", updatedArtifactType.getDerivedFrom()); + if (currentDerivedFrom.isLeft()) { + StorageOperationStatus deleteDerivedRelationStatus = deleteDerivedFromArtifactType(artifactTypeId, currentDerivedFrom.left().value().getArtifactTypeDataDefinition().getType(), updatedArtifactType.getModel()); + if (deleteDerivedRelationStatus != StorageOperationStatus.OK) { + return Either.right(deleteDerivedRelationStatus); + } } return addDerivedFromRelation(updatedArtifactType, artifactTypeId); } @@ -240,7 +243,6 @@ public class ArtifactTypeOperation extends AbstractOperation implements IArtifac private Either getProjectionLatestArtifactTypeByType(String type, String model) { Map mapCriteria = new HashMap<>(); mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type); - mapCriteria.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true); return getArtifactTypeByCriteria(type, mapCriteria, model); } -- cgit 1.2.3-korg