aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-01-25 19:53:06 +0000
committerAndr� Schmid <andre.schmid@est.tech>2022-01-28 14:49:49 +0000
commiteb7d16f50c59ca2979ec2a79fe57edafafc97e96 (patch)
tree27b4aaf3cf2080dd7015b0e7663fd60032f20099
parentfa5b6ac34fc3f8ebe9e91d8363a0dbb6841d3c03 (diff)
Fix issue in artifact type update
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3860 Change-Id: Idad3cde460f8ce8c88914a2ddde63c1950f9536b
-rw-r--r--catalog-be/src/main/resources/import/tosca/artifact-types/artifactTypes.yml37
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ArtifactTypeOperation.java18
2 files changed, 29 insertions, 26 deletions
diff --git a/catalog-be/src/main/resources/import/tosca/artifact-types/artifactTypes.yml b/catalog-be/src/main/resources/import/tosca/artifact-types/artifactTypes.yml
index 97d00e5b51..0453fb7f16 100644
--- a/catalog-be/src/main/resources/import/tosca/artifact-types/artifactTypes.yml
+++ b/catalog-be/src/main/resources/import/tosca/artifact-types/artifactTypes.yml
@@ -1,40 +1,41 @@
tosca.artifacts.Root:
description: This is the default (root) TOSCA Artifact Type definition that all other TOSCA base Artifact Types derive from.
+tosca.artifacts.Deployment:
+ derived_from: tosca.artifacts.Root
+ description: This artifact type represents the parent type for all deployment artifacts in TOSCA. This class of artifacts typically represents a binary packaging of an application or service that is used to install/create or deploy it as part of a node's lifecycle.
+
tosca.artifacts.Deployment.Image:
derived_from: tosca.artifacts.Deployment
description: This artifact type represents a parent type for any "image" which is an opaque packaging of a TOSCA Node's deployment (whether real or virtual) whose contents are typically already installed and pre-configured (i.e., "stateful") and prepared to be run on a known target container.
-tosca.artifacts.Implementation.Bash:
- derived_from: tosca.artifacts.Implementation
- description: This artifact type represents a Bash script type that contains Bash commands that can be executed on the Unix Bash shell.
-
tosca.artifacts.Deployment.Image.VM:
derived_from: tosca.artifacts.Deployment
description: This artifact represents the parent type for all Virtual Machine (VM) image and container formatted deployment artifacts. These images contain a stateful capture of a machine (e.g., server) including operating system and installed software along with any configurations and can be run on another machine using a hypervisor which virtualizes typical server (i.e., hardware) resources.
-tosca.artifacts.Implementation.Python:
- derived_from: tosca.artifacts.Implementation
- description: This artifact type represents a Python file that contains Python language constructs that can be executed within a Python interpreter.
-
-tosca.artifacts.Deployment:
- derived_from: tosca.artifacts.Root
- description: This artifact type represents the parent type for all deployment artifacts in TOSCA. This class of artifacts typically represents a binary packaging of an application or service that is used to install/create or deploy it as part of a node's lifecycle.
-
-tosca.artifacts.File:
- derived_from: tosca.artifacts.Root
- description: This artifact type is used when an artifact definition needs to have its associated file simply treated as a file and no special handling/handlers are invoked (i.e., it is not treated as either an implementation or deployment artifact type).
+tosca.artifacts.nfv.SwImage:
+ derived_from: tosca.artifacts.Deployment.Image
+ description: describes the software image which is directly loaded on the virtualisation container realizing of the VDU or is to be loaded on a virtual
tosca.artifacts.Implementation:
derived_from: tosca.artifacts.Root
description: This artifact type represents the parent type for all implementation artifacts in TOSCA. These artifacts are used to implement operations of TOSCA interfaces either directly (e.g., scripts) or indirectly (e.g., config. files).
+
+tosca.artifacts.Implementation.Bash:
+ derived_from: tosca.artifacts.Implementation
+ description: This artifact type represents a Bash script type that contains Bash commands that can be executed on the Unix Bash shell.
-tosca.artifacts.nfv.SwImage:
- derived_from: tosca.artifacts.Deployment.Image
- description: describes the software image which is directly loaded on the virtualisation container realizing of the VDU or is to be loaded on a virtual
+tosca.artifacts.Implementation.Python:
+ derived_from: tosca.artifacts.Implementation
+ description: This artifact type represents a Python file that contains Python language constructs that can be executed within a Python interpreter.
tosca.artifacts.Implementation.nfv.Mistral:
derived_from: tosca.artifacts.Implementation
description: artifacts for Mistral workflows
mime_type: application/x-yaml
file_ext: [ yaml ]
+
+tosca.artifacts.File:
+ derived_from: tosca.artifacts.Root
+ description: This artifact type is used when an artifact definition needs to have its associated file simply treated as a file and no special handling/handlers are invoked (i.e., it is not treated as either an implementation or deployment artifact type).
+
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);
}