From 1a64c83fc436e17f93e468f7d46ff9f5fcb081ce Mon Sep 17 00:00:00 2001 From: vasraz Date: Fri, 7 Feb 2020 10:14:06 +0000 Subject: Add support for simple yaml profile 1.2 Change-Id: I735d25c6b6c3344c4b742f09b3aeaf4d03c2d17c Signed-off-by: Vasyl Razinkov Issue-ID: SDC-2738 --- .../java/org/openecomp/sdc/be/model/Resource.java | 45 +++---- .../jsonjanusgraph/datamodel/ToscaElement.java | 147 +++------------------ .../operations/ToscaElementOperation.java | 19 ++- .../model/jsonjanusgraph/utils/ModelConverter.java | 8 ++ 4 files changed, 55 insertions(+), 164 deletions(-) (limited to 'catalog-model/src/main/java/org') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java index a38095a3ce..e9756b6c4e 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java @@ -57,9 +57,7 @@ public class Resource extends Component { private List attributes; - private Map instInterfaces; - - private List defaultCapabilities; + private String toscaVersion; public Resource() { super(new ResourceMetadataDefinition()); @@ -75,16 +73,6 @@ public class Resource extends Component { this.getComponentMetadataDefinition().getMetadataDataDefinition().setComponentType(ComponentTypeEnum.RESOURCE); } - @Override - public List getProperties() { - return properties; - } - - @Override - public void setProperties(List properties) { - this.properties = properties; - } - public Boolean isAbstract() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition() .getMetadataDataDefinition()) @@ -115,7 +103,6 @@ public class Resource extends Component { .setLicenseType(licenseType); } - public String getToscaResourceName() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) .getToscaResourceName(); @@ -136,36 +123,36 @@ public class Resource extends Component { .setResourceType(resourceType); } - public void setVendorName(String vendorName) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setVendorName(vendorName); - } - - public void setVendorRelease(String vendorRelease) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) - .setVendorRelease(vendorRelease); - } - - public void setResourceVendorModelNumber(String resourceVendorModelNumber) { - ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()). - setResourceVendorModelNumber(resourceVendorModelNumber); - } - public String getVendorName() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) .getVendorName(); } + public void setVendorName(String vendorName) { + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) + .setVendorName(vendorName); + } + public String getVendorRelease() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) .getVendorRelease(); } + public void setVendorRelease(String vendorRelease) { + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) + .setVendorRelease(vendorRelease); + } + public String getResourceVendorModelNumber() { return ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()) .getResourceVendorModelNumber(); } + public void setResourceVendorModelNumber(String resourceVendorModelNumber) { + ((ResourceMetadataDataDefinition) getComponentMetadataDefinition().getMetadataDataDefinition()). + setResourceVendorModelNumber(resourceVendorModelNumber); + } + @Override public String fetchGenericTypeToscaNameFromConfig() { String result = super.fetchGenericTypeToscaNameFromConfig(); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java index 28efb308b6..d6d3347000 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java @@ -20,6 +20,12 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; @@ -35,25 +41,21 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeTypeOperation; import org.openecomp.sdc.common.log.api.ILogConfiguration; import org.slf4j.MDC; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - +@Getter +@Setter public abstract class ToscaElement { protected Map metadata; protected List categories; protected Map toscaArtifacts; + protected ToscaElementTypeEnum toscaType; private Map artifacts; private Map deploymentArtifacts; private Map additionalInformation; private Map properties; private Map capabilities; - private Map capabiltiesProperties; + private Map capabilitiesProperties; private Map requirements; - - protected ToscaElementTypeEnum toscaType; // User private String creatorUserId; private String creatorFullName; @@ -61,101 +63,12 @@ public abstract class ToscaElement { private String lastUpdaterFullName; private Map allVersions; + private String toscaVersion; public ToscaElement(ToscaElementTypeEnum toscaType){ this.toscaType = toscaType; } - public Map getMetadata() { - return metadata; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; - } - public Map getToscaArtifacts() { - return toscaArtifacts; - } - - public void setToscaArtifacts(Map toscaArtifacts) { - this.toscaArtifacts = toscaArtifacts; - } - - public ToscaElementTypeEnum getToscaType() { - return toscaType; - } - - public void setToscaType(ToscaElementTypeEnum toscaType) { - this.toscaType = toscaType; - } - public Map getArtifacts() { - return artifacts; - } - - public void setArtifacts(Map artifacts) { - this.artifacts = artifacts; - } - - public Map getDeploymentArtifacts() { - return deploymentArtifacts; - } - - public void setDeploymentArtifacts(Map deploymentArtifacts) { - this.deploymentArtifacts = deploymentArtifacts; - } - public Map getAdditionalInformation() { - return additionalInformation; - } - public void setAdditionalInformation(Map additionalInformation) { - this.additionalInformation = additionalInformation; - } - public Map getProperties() { - return properties; - } - public void setProperties(Map properties) { - this.properties = properties; - } - - public Map getAllVersions() { - return allVersions; - } - - public void setAllVersions(Map allVersions) { - this.allVersions = allVersions; - } - - public Map getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map capabilities) { - this.capabilities = capabilities; - } - - public Map getRequirements() { - return requirements; - } - - public void setRequirements(Map requirements) { - this.requirements = requirements; - } - - public Map getCapabilitiesProperties() { - return capabiltiesProperties; - } - - public void setCapabilitiesProperties(Map capabiltiesProperties) { - this.capabiltiesProperties = capabiltiesProperties; - } - // metadata properties // ---------------------------- public Object getMetadataValue(JsonPresentationFields name) { @@ -294,42 +207,16 @@ public abstract class ToscaElement { return (Long)archiveTime; } - public void setArchiveTime(Long archiveTime) { setMetadataValue(JsonPresentationFields.ARCHIVE_TIME, archiveTime); } - - public Boolean isVspArchived() { return (Boolean) getMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED); } - - public void setVspArchived(Boolean vspArchived) { setMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED, vspArchived); } - - public String getCreatorUserId() { - return creatorUserId; - } - - public void setCreatorUserId(String creatorUserId) { - this.creatorUserId = creatorUserId; - } - - public String getCreatorFullName() { - return creatorFullName; - } - - public void setCreatorFullName(String creatorFullName) { - this.creatorFullName = creatorFullName; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; + public void setArchiveTime(Long archiveTime) { + setMetadataValue(JsonPresentationFields.ARCHIVE_TIME, archiveTime); } - public String getLastUpdaterFullName() { - return lastUpdaterFullName; + public Boolean isVspArchived() { + return (Boolean) getMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED); } - public void setLastUpdaterFullName(String lastUpdaterFullName) { - this.lastUpdaterFullName = lastUpdaterFullName; + public void setVspArchived(Boolean vspArchived) { + setMetadataValue(JsonPresentationFields.IS_VSP_ARCHIVED, vspArchived); } public void generateUUID() { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index e973400963..ec1185a706 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -24,7 +24,6 @@ import java.lang.reflect.Type; import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; - import org.apache.commons.collections.CollectionUtils; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Edge; @@ -60,6 +59,7 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; +import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum; import org.openecomp.sdc.common.jsongraph.util.CommonUtility; import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum; import org.openecomp.sdc.common.log.wrappers.Logger; @@ -170,7 +170,7 @@ public abstract class ToscaElementOperation extends BaseOperation { } if (result == null) { createdToscaElementVertex = createNextVersionRes.left().value(); - Map properties = new HashMap<>(); + final Map properties = new EnumMap<>(EdgePropertyEnum.class); properties.put(EdgePropertyEnum.STATE, createdToscaElementVertex.getMetadataProperty(GraphPropertyEnum.STATE)); status = janusGraphDao .createEdge(user.getVertex(), createdToscaElementVertex.getVertex(), EdgeLabelEnum.STATE, properties); @@ -321,7 +321,10 @@ public abstract class ToscaElementOperation extends BaseOperation { nodeTypeVertex.setUniqueId(toscaElement.getUniqueId()); nodeTypeVertex.setType(toscaElement.getComponentType()); - + final String toscaVersion = toscaElement.getToscaVersion(); + if (toscaVersion != null) { + nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.TOSCA_DEFINITIONS_VERSION, toscaVersion); + } } protected StorageOperationStatus assosiateToUsers(GraphVertex nodeTypeVertex, ToscaElement toscaElement) { @@ -729,7 +732,7 @@ public abstract class ToscaElementOperation extends BaseOperation { List components = new ArrayList<>(); List componentsPerUser; - HashSet ids = new HashSet(); + final Set ids = new HashSet<>(); Either, JanusGraphOperationStatus> childrenVertecies = janusGraphDao.getChildrenVertices(userV, EdgeLabelEnum.STATE, JsonParseFlagEnum.NoParse); if (childrenVertecies.isRight() && childrenVertecies.right().value() != JanusGraphOperationStatus.NOT_FOUND) { log.debug("Failed to fetch children vertices for user {} by edge {} error {}", userV.getMetadataProperty(GraphPropertyEnum.USERID), EdgeLabelEnum.STATE, childrenVertecies.right().value()); @@ -918,9 +921,15 @@ public abstract class ToscaElementOperation extends BaseOperation { break; } - Map jsonMetada = componentV.getMetadataJson(); if (toscaElement != null) { + final Map jsonMetada = componentV.getMetadataJson(); toscaElement.setMetadata(jsonMetada); + if (jsonMetada != null) { + final Object toscaVersion = jsonMetada.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName()); + if (toscaVersion != null) { + toscaElement.setToscaVersion((String) toscaVersion); + } + } } return (T) toscaElement; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java index c16c8a98e5..ae854254c2 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java @@ -246,6 +246,10 @@ public class ModelConverter { resource.setDerivedList(nodeType.getDerivedList()); resource.setDerivedFromMapOfIdToName(nodeType.getDerivedFromMapOfIdToName()); resource.setAbstract((Boolean) nodeType.getMetadataValue(JsonPresentationFields.IS_ABSTRACT)); + final String toscaVersion = nodeType.getToscaVersion(); + if (toscaVersion != null) { + resource.setToscaVersion(toscaVersion); + } convertAttributes(nodeType, resource); convertCapabilities(nodeType, resource); convertRequirements(nodeType, resource); @@ -798,6 +802,10 @@ public class ModelConverter { nodeType.setDerivedFrom(resource.getDerivedFrom()); nodeType.setDerivedList(resource.getDerivedList()); nodeType.setResourceType(resource.getResourceType()); + final String toscaVersion = resource.getToscaVersion(); + if (toscaVersion != null) { + nodeType.setToscaVersion(toscaVersion); + } convertCommonToscaData(component, nodeType); convertAdditionalInformation(component, nodeType); convertArtifacts(resource, nodeType); -- cgit 1.2.3-korg