summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-02-07 10:14:06 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-22 12:47:42 +0000
commit1a64c83fc436e17f93e468f7d46ff9f5fcb081ce (patch)
tree835abbeb362b01216df6549233d48745b9c19bb4 /catalog-model/src/main
parent6329f959f27920179604e1a015003a0f6614bd97 (diff)
Add support for simple yaml profile 1.2
Change-Id: I735d25c6b6c3344c4b742f09b3aeaf4d03c2d17c Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-2738
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java147
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java19
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java8
4 files changed, 55 insertions, 164 deletions
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<PropertyDefinition> attributes;
- private Map<String, InterfaceInstanceDataDefinition> instInterfaces;
-
- private List<String> 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<PropertyDefinition> getProperties() {
- return properties;
- }
-
- @Override
- public void setProperties(List<PropertyDefinition> 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<String, Object> metadata;
protected List<CategoryDefinition> categories;
protected Map<String, ArtifactDataDefinition> toscaArtifacts;
+ protected ToscaElementTypeEnum toscaType;
private Map<String, ArtifactDataDefinition> artifacts;
private Map<String, ArtifactDataDefinition> deploymentArtifacts;
private Map<String, AdditionalInfoParameterDataDefinition> additionalInformation;
private Map<String, PropertyDataDefinition> properties;
private Map<String, ListCapabilityDataDefinition> capabilities;
- private Map<String, MapPropertiesDataDefinition> capabiltiesProperties;
+ private Map<String, MapPropertiesDataDefinition> capabilitiesProperties;
private Map<String, ListRequirementDataDefinition> requirements;
-
- protected ToscaElementTypeEnum toscaType;
// User
private String creatorUserId;
private String creatorFullName;
@@ -61,101 +63,12 @@ public abstract class ToscaElement {
private String lastUpdaterFullName;
private Map<String, String> allVersions;
+ private String toscaVersion;
public ToscaElement(ToscaElementTypeEnum toscaType){
this.toscaType = toscaType;
}
- public Map<String, Object> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, Object> metadata) {
- this.metadata = metadata;
- }
-
- public List<CategoryDefinition> getCategories() {
- return categories;
- }
-
- public void setCategories(List<CategoryDefinition> categories) {
- this.categories = categories;
- }
- public Map<String, ArtifactDataDefinition> getToscaArtifacts() {
- return toscaArtifacts;
- }
-
- public void setToscaArtifacts(Map<String, ArtifactDataDefinition> toscaArtifacts) {
- this.toscaArtifacts = toscaArtifacts;
- }
-
- public ToscaElementTypeEnum getToscaType() {
- return toscaType;
- }
-
- public void setToscaType(ToscaElementTypeEnum toscaType) {
- this.toscaType = toscaType;
- }
- public Map<String, ArtifactDataDefinition> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(Map<String, ArtifactDataDefinition> artifacts) {
- this.artifacts = artifacts;
- }
-
- public Map<String, ArtifactDataDefinition> getDeploymentArtifacts() {
- return deploymentArtifacts;
- }
-
- public void setDeploymentArtifacts(Map<String, ArtifactDataDefinition> deploymentArtifacts) {
- this.deploymentArtifacts = deploymentArtifacts;
- }
- public Map<String, AdditionalInfoParameterDataDefinition> getAdditionalInformation() {
- return additionalInformation;
- }
- public void setAdditionalInformation(Map<String, AdditionalInfoParameterDataDefinition> additionalInformation) {
- this.additionalInformation = additionalInformation;
- }
- public Map<String, PropertyDataDefinition> getProperties() {
- return properties;
- }
- public void setProperties(Map<String, PropertyDataDefinition> properties) {
- this.properties = properties;
- }
-
- public Map<String, String> getAllVersions() {
- return allVersions;
- }
-
- public void setAllVersions(Map<String, String> allVersions) {
- this.allVersions = allVersions;
- }
-
- public Map<String, ListCapabilityDataDefinition> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, ListCapabilityDataDefinition> capabilities) {
- this.capabilities = capabilities;
- }
-
- public Map<String, ListRequirementDataDefinition> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(Map<String, ListRequirementDataDefinition> requirements) {
- this.requirements = requirements;
- }
-
- public Map<String, MapPropertiesDataDefinition> getCapabilitiesProperties() {
- return capabiltiesProperties;
- }
-
- public void setCapabilitiesProperties(Map<String, MapPropertiesDataDefinition> 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<EdgePropertyEnum, Object> properties = new HashMap<>();
+ final Map<EdgePropertyEnum, Object> 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<T> components = new ArrayList<>();
List<T> componentsPerUser;
- HashSet<String> ids = new HashSet<String>();
+ final Set<String> ids = new HashSet<>();
Either<List<GraphVertex>, 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<String, Object> jsonMetada = componentV.getMetadataJson();
if (toscaElement != null) {
+ final Map<String, Object> 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);