Fix update VSP missing VSP version id 35/124335/2
authorandre.schmid <andre.schmid@est.tech>
Fri, 17 Sep 2021 17:57:23 +0000 (18:57 +0100)
committerMichael Morris <michael.morris@est.tech>
Mon, 20 Sep 2021 07:28:42 +0000 (07:28 +0000)
Fills the gaps of persisting and loading the VSP version id

Change-Id: I4d6c63bd2309777fdfb337cf98c1a0f9daaa434b
Issue-ID: SDC-3731
Signed-off-by: andre.schmid <andre.schmid@est.tech>
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java
catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionaryExtractor.java
catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceMetadataData.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceMetadata.java
catalog-ui/src/app/models/component-metadata.ts
common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java

index 018deca..9ba20f4 100644 (file)
@@ -3599,6 +3599,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
             if (oldResource.getCsarUUID() != null) {
                 newResource.setCsarUUID(oldResource.getCsarUUID());
             }
+            if (oldResource.getCsarVersionId() != null) {
+                newResource.setCsarVersionId(oldResource.getCsarVersionId());
+            }
             if (oldResource.getImportedToscaChecksum() != null) {
                 newResource.setImportedToscaChecksum(oldResource.getImportedToscaChecksum());
             }
index 6bb7fda..0c5acca 100644 (file)
@@ -2419,6 +2419,9 @@ public class ServiceImportBusinessLogic {
         if (oldResource.getCsarUUID() != null) {
             newResource.setCsarUUID(oldResource.getCsarUUID());
         }
+        if (oldResource.getCsarVersionId() != null) {
+            newResource.setCsarVersionId(oldResource.getCsarVersionId());
+        }
         if (oldResource.getImportedToscaChecksum() != null) {
             newResource.setImportedToscaChecksum(oldResource.getImportedToscaChecksum());
         }
index 03016f7..145bcbd 100644 (file)
@@ -65,6 +65,7 @@ public enum GraphPropertiesDictionary {
     ENTRY_SCHEMA               ("entry_schema",                        String.class,                           false,          false),
     CSAR_UUID                  ("csarUuid",                            String.class,                           false,          true),
     CSAR_VERSION               ("csarVersion",                         String.class,                           false,          true),
+    CSAR_VERSION_ID                    ("csarUuid",                            String.class,                           false,          true),
     IMPORTED_TOSCA_CHECKSUM    ("importedToscaChecksum",                               String.class,                           false,          true),
     GENERATED                  ("generated",                           Boolean.class,                          false,          false),
     // User
index ed1dc29..3b11743 100644 (file)
@@ -120,6 +120,10 @@ public class GraphPropertiesDictionaryExtractor {
         return (String) properties.get(GraphPropertiesDictionary.CSAR_VERSION.getProperty());
     }
 
+    public String getCsarVersionId() {
+        return (String) properties.get(GraphPropertiesDictionary.CSAR_VERSION_ID.getProperty());
+    }
+
     public String getImportedToscaChecksum() {
         return (String) properties.get(GraphPropertiesDictionary.IMPORTED_TOSCA_CHECKSUM.getProperty());
     }
index 5163b00..1b5f948 100644 (file)
@@ -36,29 +36,31 @@ public class ResourceMetadataData extends ComponentMetadataData {
         super(NodeTypeEnum.Resource, metadataDataDefinition);
     }
 
-    public ResourceMetadataData(GraphPropertiesDictionaryExtractor extractor) {
+    public ResourceMetadataData(final GraphPropertiesDictionaryExtractor extractor) {
         super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition(), extractor);
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setVendorName(extractor.getVendorName());
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setVendorRelease(extractor.getVendorRelease());
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setResourceType(extractor.getResourceType());
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setAbstract(extractor.isAbstract());
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setCost(extractor.getCost());
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setLicenseType(extractor.getLicenseType());
-        ((ResourceMetadataDataDefinition) metadataDataDefinition).setToscaResourceName(extractor.getToscaResourceName());
+        final var resourceMetadataDataDefinition = (ResourceMetadataDataDefinition) metadataDataDefinition;
+        resourceMetadataDataDefinition.setVendorName(extractor.getVendorName());
+        resourceMetadataDataDefinition.setVendorRelease(extractor.getVendorRelease());
+        resourceMetadataDataDefinition.setResourceType(extractor.getResourceType());
+        resourceMetadataDataDefinition.setAbstract(extractor.isAbstract());
+        resourceMetadataDataDefinition.setCost(extractor.getCost());
+        resourceMetadataDataDefinition.setLicenseType(extractor.getLicenseType());
+        resourceMetadataDataDefinition.setToscaResourceName(extractor.getToscaResourceName());
+        resourceMetadataDataDefinition.setCsarVersionId(extractor.getCsarVersionId());
     }
 
     @Override
     public Map<String, Object> toGraphMap() {
-        Map<String, Object> graphMap = super.toGraphMap();
-        addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_NAME, ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorName());
-        addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_RELEASE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorRelease());
-        addIfExists(graphMap, GraphPropertiesDictionary.RESOURCE_TYPE,
-            ((ResourceMetadataDataDefinition) metadataDataDefinition).getResourceType().name());
-        addIfExists(graphMap, GraphPropertiesDictionary.IS_ABSTRACT, ((ResourceMetadataDataDefinition) metadataDataDefinition).isAbstract());
-        addIfExists(graphMap, GraphPropertiesDictionary.COST, ((ResourceMetadataDataDefinition) metadataDataDefinition).getCost());
-        addIfExists(graphMap, GraphPropertiesDictionary.LICENSE_TYPE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getLicenseType());
-        addIfExists(graphMap, GraphPropertiesDictionary.TOSCA_RESOURCE_NAME,
-            ((ResourceMetadataDataDefinition) metadataDataDefinition).getToscaResourceName());
+        final Map<String, Object> graphMap = super.toGraphMap();
+        final ResourceMetadataDataDefinition resourceMetadataDataDefinition = (ResourceMetadataDataDefinition) metadataDataDefinition;
+        addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_NAME, resourceMetadataDataDefinition.getVendorName());
+        addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_RELEASE, resourceMetadataDataDefinition.getVendorRelease());
+        addIfExists(graphMap, GraphPropertiesDictionary.RESOURCE_TYPE, resourceMetadataDataDefinition.getResourceType().name());
+        addIfExists(graphMap, GraphPropertiesDictionary.IS_ABSTRACT, resourceMetadataDataDefinition.isAbstract());
+        addIfExists(graphMap, GraphPropertiesDictionary.COST, resourceMetadataDataDefinition.getCost());
+        addIfExists(graphMap, GraphPropertiesDictionary.LICENSE_TYPE, resourceMetadataDataDefinition.getLicenseType());
+        addIfExists(graphMap, GraphPropertiesDictionary.TOSCA_RESOURCE_NAME, resourceMetadataDataDefinition.getToscaResourceName());
+        addIfExists(graphMap, GraphPropertiesDictionary.CSAR_VERSION_ID, resourceMetadataDataDefinition.getCsarVersionId());
         return graphMap;
     }
 }
index 78aa4c7..61b11b3 100644 (file)
@@ -590,6 +590,8 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
             nodeTypeVertex.setJson(topologyTemplate.getCompositions());
         }
         nodeTypeVertex.addMetadataProperty(GraphPropertyEnum.CSAR_UUID, topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_UUID));
+        nodeTypeVertex.addMetadataProperty(GraphPropertyEnum.CSAR_VERSION_UUID,
+            topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_VERSION_ID));
         nodeTypeVertex.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS,
             topologyTemplate.getMetadataValue(JsonPresentationFields.DISTRIBUTION_STATUS));
         return nodeTypeVertex;
index b2ccb6d..1c753a5 100644 (file)
@@ -2432,10 +2432,10 @@ public class ToscaOperationFacade {
                     log.debug("getLatestResourceByCsarOrName - getByCriteria(by system name) returned 2 latest CERTIFIED versions");
                     return Either.right(StorageOperationStatus.GENERAL_ERROR);
                 }
-                if (resourceMetadataData.getJsonMetadataField(JsonPresentationFields.CSAR_UUID) != null && !((String) resourceMetadataData
-                    .getJsonMetadataField(JsonPresentationFields.CSAR_UUID)).equals(csarUUID)) {
+                final Object csarUuid = resourceMetadataData.getJsonMetadataField(JsonPresentationFields.CSAR_UUID);
+                if (csarUuid != null && !csarUuid.equals(csarUUID)) {
                     log.debug("getLatestResourceByCsarOrName - same system name {} but different csarUUID. exist {} and new {} ", systemName,
-                        resourceMetadataData.getJsonMetadataField(JsonPresentationFields.CSAR_UUID), csarUUID);
+                        csarUuid, csarUUID);
                     // correct error will be returned from create flow. with all
 
                     // correct audit records!!!!!
index 079f5a4..9efef3b 100644 (file)
@@ -253,6 +253,7 @@ public class ModelConverter {
             TopologyTemplate topologyTemplate = (TopologyTemplate) toscaElement;
             if (resource.getResourceType() == ResourceTypeEnum.VF || resource.getResourceType() == ResourceTypeEnum.PNF) {
                 resource.setCsarUUID((String) topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_UUID));
+                resource.setCsarVersionId((String) topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_VERSION_ID));
                 resource.setCsarVersion((String) topologyTemplate.getMetadataValue(JsonPresentationFields.CSAR_VERSION));
                 resource.setImportedToscaChecksum((String) topologyTemplate.getMetadataValue(JsonPresentationFields.IMPORTED_TOSCA_CHECKSUM));
                 convertInterfaces(topologyTemplate, resource);
@@ -1112,6 +1113,7 @@ public class ModelConverter {
             topologyTemplate.setResourceType(resource.getResourceType());
             topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_UUID, resource.getCsarUUID());
             topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_VERSION, resource.getCsarVersion());
+            topologyTemplate.setMetadataValue(JsonPresentationFields.CSAR_VERSION_ID, resource.getCsarVersionId());
             topologyTemplate.setMetadataValue(JsonPresentationFields.IMPORTED_TOSCA_CHECKSUM, resource.getImportedToscaChecksum());
             convertTopologyTemplateInterfaces(resource, topologyTemplate);
         }
index b8fcc40..9cc5294 100644 (file)
@@ -43,6 +43,7 @@ public class UiResourceMetadata extends UiComponentMetadata {
     private String toscaResourceName;
     private List<String> derivedFrom;
     private Map<String, String> categorySpecificMetadata;
+    private String csarVersionId;
 
     public UiResourceMetadata(List<CategoryDefinition> categories, List<String> derivedFrom, ResourceMetadataDataDefinition metadata) {
         super(categories, metadata);
@@ -55,5 +56,6 @@ public class UiResourceMetadata extends UiComponentMetadata {
         this.toscaResourceName = metadata.getToscaResourceName();
         this.derivedFrom = derivedFrom;
         this.categorySpecificMetadata = metadata.getCategorySpecificMetadata();
+        this.csarVersionId = metadata.getCsarVersionId();
     }
 }
index 351ae4a..2aae977 100644 (file)
@@ -60,6 +60,7 @@ export interface IComponentMetadata {
     resourceType: string;
     csarUUID: string;
     csarVersion: string;
+    csarVersionId: string;
     derivedList: string[];
     vendorName: string;
     vendorRelease: string;
@@ -187,6 +188,7 @@ export class ComponentMetadata implements IComponentMetadata {
         this.resourceType = response.resourceType;
         this.csarUUID = response.csarUUID;
         this.csarVersion = response.csarVersion;
+        this.csarVersionId = response.csarVersionId;
         this.state = response.state;
         this.ecompGeneratedNaming = response.ecompGeneratedNaming;
         this.namingPolicy = response.namingPolicy;
index 1d65d1d..ab3a05e 100644 (file)
@@ -44,6 +44,7 @@ public enum GraphPropertyEnum {
     IS_ABSTRACT("abstract", Boolean.class, false, true),
     INVARIANT_UUID("invariantUuid", String.class, false, true),
     CSAR_UUID("csarUuid", String.class, false, true),
+    CSAR_VERSION_UUID("csarVersionUuid", String.class, false, true),
     //used for user (old format, no json for users)
     USERID("userId", String.class, true, true),
     ROLE("role", String.class, false, false),