aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-07-30 13:06:42 +0100
committerSébastien Determe <sebastien.determe@intl.att.com>2020-09-07 10:06:59 +0000
commit26cba80ddf5e97e1df856ed013ea69c45c5c0976 (patch)
treea88c4b3c6f45254d0fec97b0d148414beb7130fd /catalog-model/src/main/java
parentde805023e2d1c8565efc9a707a82c9fc3903ab38 (diff)
Add 'data_types' during import VFCs
Change-Id: Ib9974bbc1eb88633e7e6834cc7ef8ae95deda539 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3191
Diffstat (limited to 'catalog-model/src/main/java')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java44
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/ToscaElement.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java102
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java45
5 files changed, 117 insertions, 77 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java
index a54e3264e2..7cdf932ce9 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java
@@ -20,13 +20,19 @@
package org.openecomp.sdc.be.model;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.dao.utils.CollectionUtils;
import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import java.util.List;
-import java.util.stream.Collectors;
+@Getter
+@Setter
+@NoArgsConstructor
+@ToString
public class DataTypeDefinition extends DataTypeDataDefinition {
private DataTypeDefinition derivedFrom;
@@ -35,10 +41,6 @@ public class DataTypeDefinition extends DataTypeDataDefinition {
private List<PropertyDefinition> properties;
- public DataTypeDefinition() {
- super();
- }
-
public DataTypeDefinition(DataTypeDataDefinition p) {
super(p);
}
@@ -52,38 +54,8 @@ public class DataTypeDefinition extends DataTypeDataDefinition {
this.setDescription(pd.getDescription());
}
- public List<PropertyConstraint> getConstraints() {
- return constraints;
- }
-
public List<PropertyConstraint> safeGetConstraints() {
return CollectionUtils.safeGetList(constraints);
}
- public void setConstraints(List<PropertyConstraint> constraints) {
- this.constraints = constraints;
- }
-
- public DataTypeDefinition getDerivedFrom() {
- return derivedFrom;
- }
-
- public void setDerivedFrom(DataTypeDefinition derivedFrom) {
- this.derivedFrom = derivedFrom;
- }
-
- public List<PropertyDefinition> getProperties() {
- return properties;
- }
-
- public void setProperties(List<PropertyDefinition> properties) {
- this.properties = properties;
- }
-
- @Override
- public String toString() {
- return super.toString() + " DataTypeDefinition [derivedFrom=" + derivedFrom + ", constraints=" + constraints
- + ", properties=" + properties + "]";
- }
-
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
index 7b9fd6fa05..1bf35fbd9f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
@@ -79,7 +79,6 @@ public class TopologyTemplate extends ToscaElement {
private Map<String, InterfaceDataDefinition> interfaces;
private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces;
private Map<String, MapInterfaceDataDefinition> componentInstInterfaces;
- private Map<String, DataTypeDataDefinition> dataTypes;
private Map<String, CINodeFilterDataDefinition> nodeFilterComponents;
private Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap;
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 d6d3347000..ce9e5e0c43 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
@@ -28,6 +28,7 @@ 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.DataTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
@@ -56,6 +57,7 @@ public abstract class ToscaElement {
private Map<String, ListCapabilityDataDefinition> capabilities;
private Map<String, MapPropertiesDataDefinition> capabilitiesProperties;
private Map<String, ListRequirementDataDefinition> requirements;
+ private Map<String, DataTypeDataDefinition> dataTypes;
// User
private String creatorUserId;
private String creatorFullName;
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 ba488fe2af..6798af42db 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
@@ -20,11 +20,13 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
+import static org.openecomp.sdc.be.utils.TypeUtils.setField;
+
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.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -43,6 +45,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
@@ -51,6 +54,7 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -62,6 +66,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;
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;
@@ -167,7 +172,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
if (createNextVersionRes.isRight()) {
status = createNextVersionRes.right().value();
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to create tosca element vertex {} with version {} on graph. Status is {}. ", previousToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME),
- previousToscaElement.getMetadataProperty(GraphPropertyEnum.VERSION), status);
+ previousToscaElement.getMetadataProperty(GraphPropertyEnum.VERSION), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
if (result == null) {
@@ -178,7 +183,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
.createEdge(user.getVertex(), createdToscaElementVertex.getVertex(), EdgeLabelEnum.STATE, properties);
if (status != JanusGraphOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_CREATE_EDGE_WITH_LABEL_FROM_USER_VERTEX_TO_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS, EdgeLabelEnum.STATE, user.getUniqueId(),
- previousToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
+ previousToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
}
@@ -187,26 +192,26 @@ public abstract class ToscaElementOperation extends BaseOperation {
.createEdge(user.getVertex(), createdToscaElementVertex.getVertex(), EdgeLabelEnum.LAST_MODIFIER, new HashMap<>());
if (status != JanusGraphOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_CREATE_EDGE_WITH_LABEL_FROM_USER_VERTEX_TO_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS, EdgeLabelEnum.LAST_MODIFIER, user.getUniqueId(),
- nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
+ nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
}
if (result == null) {
Either<GraphVertex, JanusGraphOperationStatus> creatorVertexRes = janusGraphDao.getParentVertex(previousToscaElement,
- EdgeLabelEnum.CREATOR, JsonParseFlagEnum.NoParse);
+ EdgeLabelEnum.CREATOR, JsonParseFlagEnum.NoParse);
if (creatorVertexRes.isRight()) {
status = creatorVertexRes.right().value();
CommonUtility.addRecordToLog(log,
- LogLevelEnum.DEBUG, FAILED_TO_GET_CREATOR_VERTEX_OF_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS,
- EdgeLabelEnum.CREATOR,
- nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
+ LogLevelEnum.DEBUG, FAILED_TO_GET_CREATOR_VERTEX_OF_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS,
+ EdgeLabelEnum.CREATOR,
+ nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
status = janusGraphDao.createEdge(creatorVertexRes.left().value().getVertex(), createdToscaElementVertex.getVertex(),
- EdgeLabelEnum.CREATOR, new HashMap<>());
+ EdgeLabelEnum.CREATOR, new HashMap<>());
if (status != JanusGraphOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_CREATE_EDGE_WITH_LABEL_FROM_USER_VERTEX_TO_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS, EdgeLabelEnum.CREATOR, user.getUniqueId(),
- nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
+ nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
}
@@ -219,7 +224,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
.createEdge(createdToscaElementVertex.getVertex(), currVertex, EdgeLabelEnum.getEdgeLabelEnum(currEdge.label()), currEdge);
if (status != JanusGraphOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to create edge with label {} from tosca element vertex {} to vertex with label {} on graph. Status is {}. ", currEdge.label(), createdToscaElementVertex.getUniqueId(),
- currVertex.property(GraphPropertyEnum.LABEL.getProperty()), status);
+ currVertex.property(GraphPropertyEnum.LABEL.getProperty()), status);
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
break;
}
@@ -327,6 +332,10 @@ public abstract class ToscaElementOperation extends BaseOperation {
if (toscaVersion != null) {
nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.TOSCA_DEFINITIONS_VERSION, toscaVersion);
}
+ final Map<String, DataTypeDataDefinition> dataTypes = toscaElement.getDataTypes();
+ if (MapUtils.isNotEmpty(dataTypes)) {
+ nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.DATA_TYPES, dataTypes);
+ }
}
protected StorageOperationStatus assosiateToUsers(GraphVertex nodeTypeVertex, ToscaElement toscaElement) {
@@ -738,12 +747,12 @@ public abstract class ToscaElementOperation extends BaseOperation {
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());
- return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(childrenVertecies.right().value()));
+ return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(childrenVertecies.right().value()));
}
// get all resource with current state
if (childrenVertecies.isLeft()) {
- componentsPerUser = fetchComponents(userId, lifecycleStates, childrenVertecies.left().value(), neededType, EdgeLabelEnum.STATE);
+ componentsPerUser = fetchComponents(userId, lifecycleStates, childrenVertecies.left().value(), neededType, EdgeLabelEnum.STATE);
if (componentsPerUser != null) {
for (T comp : componentsPerUser) {
@@ -932,11 +941,60 @@ public abstract class ToscaElementOperation extends BaseOperation {
if (toscaVersion != null) {
toscaElement.setToscaVersion((String) toscaVersion);
}
+ final Object dataTypes = jsonMetada.get(ToscaTagNamesEnum.DATA_TYPES.getElementName());
+ if (dataTypes != null) {
+ final Map<String, DataTypeDataDefinition> dataTypeDefinitionMap = new HashMap<>();
+
+ final Map<String, Object> toscaAttributes = (Map<String, Object>) dataTypes;
+
+ for (final Entry<String, Object> attributeNameValue : toscaAttributes.entrySet()) {
+ final Object value = attributeNameValue.getValue();
+ final String key = attributeNameValue.getKey();
+ if (value instanceof Map) {
+ final DataTypeDefinition dataTypeDefinition =
+ createDataTypeDefinitionWithName(attributeNameValue);
+ dataTypeDefinitionMap.put(dataTypeDefinition.getName(), dataTypeDefinition);
+ } else {
+ dataTypeDefinitionMap.put(key, createDataType(String.valueOf(value)));
+ }
+ }
+ toscaElement.setDataTypes(dataTypeDefinitionMap);
+ }
}
}
return (T) toscaElement;
}
+ public static DataTypeDefinition createDataType(final String dataTypeName) {
+ final DataTypeDefinition dataType = new DataTypeDefinition();
+ dataType.setName(dataTypeName);
+ return dataType;
+ }
+
+ public static DataTypeDefinition createDataTypeDefinitionWithName(final Entry<String, Object> attributeNameValue) {
+ final Map<String, Object> attributeMap = (Map<String, Object>) attributeNameValue.getValue();
+ final DataTypeDefinition dataType = createDataType(attributeNameValue.getKey());
+ setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, dataType::setDescription);
+ setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DERIVED_FROM_NAME, dataType::setDerivedFromName);
+ // TODO - find the way to set the properties
+// CommonImportManager.setProperties(attributeMap, dataType::setProperties);
+ final Object derivedFrom = attributeMap.get(JsonPresentationFields.DERIVED_FROM.getPresentation());
+ if (derivedFrom instanceof Map) {
+ final Map<String, Object> derivedFromMap = (Map<String, Object>) derivedFrom;
+ final DataTypeDefinition parentDataTypeDataDefinition = new DataTypeDefinition();
+ parentDataTypeDataDefinition
+ .setName((String) derivedFromMap.get(JsonPresentationFields.NAME.getPresentation()));
+ parentDataTypeDataDefinition
+ .setUniqueId((String) derivedFromMap.get(JsonPresentationFields.UNIQUE_ID.getPresentation()));
+ parentDataTypeDataDefinition
+ .setCreationTime((Long) derivedFromMap.get(JsonPresentationFields.CREATION_TIME.getPresentation()));
+ parentDataTypeDataDefinition.setModificationTime(
+ (Long) derivedFromMap.get(JsonPresentationFields.MODIFICATION_TIME.getPresentation()));
+ dataType.setDerivedFrom(parentDataTypeDataDefinition);
+ }
+ return dataType;
+ }
+
private Map<String, AttributeDataDefinition> getAttributesFromComponentV(final GraphVertex componentV) {
final Map<String, Object> jsonMetada = componentV.getMetadataJson();
final Map<String, AttributeDataDefinition> attributeDataDefinitionMap = new HashMap<>();
@@ -1185,7 +1243,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
private void generateNewToscaFileName(String componentType, String componentName, ArtifactDataDefinition artifactInfo) {
Map<String, Object> getConfig = (Map<String, Object>) ConfigurationManager.getConfigurationManager().getConfiguration().getToscaArtifacts().entrySet().stream().filter(p -> p.getKey().equalsIgnoreCase(artifactInfo.getArtifactLabel()))
- .findAny().get().getValue();
+ .findAny().get().getValue();
artifactInfo.setArtifactName(componentType + "-" + componentName + getConfig.get("artifactName"));
}
@@ -1355,7 +1413,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
public Either<List<GraphVertex>, JanusGraphOperationStatus> getListOfHighestComponents(ComponentTypeEnum
- componentType, List<ResourceTypeEnum> excludeTypes, JsonParseFlagEnum parseFlag) {
+ componentType, List<ResourceTypeEnum> excludeTypes, JsonParseFlagEnum parseFlag) {
Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
Map<GraphPropertyEnum, Object> propertiesHasNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
@@ -1413,7 +1471,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
protected Either<List<GraphVertex>, StorageOperationStatus> getAllComponentsMarkedForDeletion(ComponentTypeEnum
- componentType) {
+ componentType) {
// get all components marked for delete
Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
@@ -1437,7 +1495,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
protected JanusGraphOperationStatus setAdditionalInformationFromGraph(GraphVertex componentV, ToscaElement
- toscaElement) {
+ toscaElement) {
Either<Map<String, AdditionalInfoParameterDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ADDITIONAL_INFORMATION);
if (result.isLeft()) {
toscaElement.setAdditionalInformation(result.left().value());
@@ -1451,16 +1509,16 @@ public abstract class ToscaElementOperation extends BaseOperation {
// --------------------------------------------
public abstract <T extends
- ToscaElement> Either<T, StorageOperationStatus> getToscaElement(String uniqueId, ComponentParametersView componentParametersView);
+ ToscaElement> Either<T, StorageOperationStatus> getToscaElement(String uniqueId, ComponentParametersView componentParametersView);
public abstract <T extends
- ToscaElement> Either<T, StorageOperationStatus> getToscaElement(GraphVertex toscaElementVertex, ComponentParametersView componentParametersView);
+ ToscaElement> Either<T, StorageOperationStatus> getToscaElement(GraphVertex toscaElementVertex, ComponentParametersView componentParametersView);
public abstract <T extends
- ToscaElement> Either<T, StorageOperationStatus> deleteToscaElement(GraphVertex toscaElementVertex);
+ ToscaElement> Either<T, StorageOperationStatus> deleteToscaElement(GraphVertex toscaElementVertex);
public abstract <T extends
- ToscaElement> Either<T, StorageOperationStatus> createToscaElement(ToscaElement toscaElement);
+ ToscaElement> Either<T, StorageOperationStatus> createToscaElement(ToscaElement toscaElement);
protected abstract <T extends ToscaElement> JanusGraphOperationStatus
setCategoriesFromGraph(GraphVertex vertexComponent, T toscaElement);
@@ -1478,6 +1536,6 @@ public abstract class ToscaElementOperation extends BaseOperation {
updateDerived(T toscaElementToUpdate, GraphVertex updateElementV);
public abstract <T extends ToscaElement> void fillToscaElementVertexData(GraphVertex elementV, T
- toscaElementToUpdate, JsonParseFlagEnum flag);
+ toscaElementToUpdate, JsonParseFlagEnum flag);
}
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 5ceb7f194c..839ae27a19 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
@@ -260,6 +260,7 @@ public class ModelConverter {
convertCapabilities(nodeType, resource);
convertRequirements(nodeType, resource);
convertInterfaces(nodeType, resource);
+ convertDataTypes(nodeType, resource);
} else {
TopologyTemplate topologyTemplate = (TopologyTemplate) toscaElement;
@@ -813,6 +814,11 @@ public class ModelConverter {
if (toscaVersion != null) {
nodeType.setToscaVersion(toscaVersion);
}
+ final List<DataTypeDefinition> dataTypes = resource.getDataTypes();
+ if (CollectionUtils.isNotEmpty(dataTypes)) {
+ nodeType.setDataTypes(dataTypes.stream()
+ .collect(Collectors.toMap(DataTypeDefinition::getName, dataTypeDefinition -> dataTypeDefinition)));
+ }
convertCommonToscaData(component, nodeType);
convertAdditionalInformation(component, nodeType);
convertArtifacts(resource, nodeType);
@@ -1259,23 +1265,24 @@ public class ModelConverter {
}
}
- private static void convertDataTypes(TopologyTemplate topologyTemplate, Component component) {
- Map<String, DataTypeDataDefinition> dataTypeDataMap = topologyTemplate.getDataTypes();
+ private static void convertDataTypes(final ToscaElement toscaElement, final Component component) {
+ final Map<String, DataTypeDataDefinition> dataTypeDataMap = toscaElement.getDataTypes();
if (MapUtils.isNotEmpty(dataTypeDataMap)) {
- List<DataTypeDefinition> dataTypeMap = dataTypeDataMap.values().stream().map(e -> {
- DataTypeDefinition dataType = new DataTypeDefinition(e);
-
- if(CollectionUtils.isNotEmpty(e.getPropertiesData())) {
- log.debug("#convertDataTypes - propertiesData is not null. {}",
- ReflectionToStringBuilder.toString(e.getPropertiesData()));
- dataType.setProperties(e.getPropertiesData().stream()
+ final List<DataTypeDefinition> dataTypeDefinitionList =
+ dataTypeDataMap.values().stream().map(dataTypeDataDefinition -> {
+ final DataTypeDefinition dataTypeDefinition = new DataTypeDefinition(dataTypeDataDefinition);
+
+ if (CollectionUtils.isNotEmpty(dataTypeDataDefinition.getPropertiesData())) {
+ log.debug("#convertDataTypes - propertiesData is not null. {}",
+ ReflectionToStringBuilder.toString(dataTypeDataDefinition.getPropertiesData()));
+ dataTypeDefinition.setProperties(dataTypeDataDefinition.getPropertiesData().stream()
.map(PropertyDefinition::new).collect(Collectors.toList()));
- } else {
- log.debug("#convertDataTypes - propertiesData is null. ignore.");
- }
- return dataType;
- }).collect(Collectors.toList());
- component.setDataTypes(dataTypeMap);
+ } else {
+ log.debug("#convertDataTypes - propertiesData is null. ignore.");
+ }
+ return dataTypeDefinition;
+ }).collect(Collectors.toList());
+ component.setDataTypes(dataTypeDefinitionList);
}
}
@@ -1342,11 +1349,13 @@ public class ModelConverter {
toscaElement.setMetadataValue(JsonPresentationFields.TAGS, component.getTags());
toscaElement.setMetadataValue(JsonPresentationFields.INVARIANT_UUID, component.getInvariantUUID());
toscaElement.setMetadataValue(JsonPresentationFields.CONTACT_ID, component.getContactId());
+ final List<DataTypeDefinition> dataTypes = component.getDataTypes();
+ if (CollectionUtils.isNotEmpty(dataTypes)) {
+ toscaElement.setDataTypes(dataTypes.stream()
+ .collect(Collectors.toMap(DataTypeDefinition::getName, dataTypeDefinition -> dataTypeDefinition)));
+ }
}
-
-
-
private static void setComponentInstancesToComponent(TopologyTemplate topologyTemplate, Component component) {
List<ComponentInstance> componentInstances = new ArrayList<>();