diff options
author | MichaelMorris <michael.morris@est.tech> | 2022-01-25 19:53:06 +0000 |
---|---|---|
committer | Andr� Schmid <andre.schmid@est.tech> | 2022-01-28 14:49:49 +0000 |
commit | eb7d16f50c59ca2979ec2a79fe57edafafc97e96 (patch) | |
tree | 27b4aaf3cf2080dd7015b0e7663fd60032f20099 /catalog-model | |
parent | fa5b6ac34fc3f8ebe9e91d8363a0dbb6841d3c03 (diff) |
Fix issue in artifact type update
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3860
Change-Id: Idad3cde460f8ce8c88914a2ddde63c1950f9536b
Diffstat (limited to 'catalog-model')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactTypeOperation.java | 18 |
1 files changed, 10 insertions, 8 deletions
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<GraphRelation, StorageOperationStatus> updateArtifactDerivedFrom(ArtifactTypeDefinition updatedArtifactType, - String currDerivedFromArtifactType) { + private Either<GraphRelation, StorageOperationStatus> updateArtifactDerivedFrom(ArtifactTypeDefinition updatedArtifactType) { String artifactTypeId = updatedArtifactType.getUniqueId(); + + Either<ArtifactTypeData, StorageOperationStatus> 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<ArtifactTypeDefinition, StorageOperationStatus> getProjectionLatestArtifactTypeByType(String type, String model) { Map<String, Object> mapCriteria = new HashMap<>(); mapCriteria.put(GraphPropertiesDictionary.TYPE.getProperty(), type); - mapCriteria.put(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty(), true); return getArtifactTypeByCriteria(type, mapCriteria, model); } |