aboutsummaryrefslogtreecommitdiffstats
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
parentde805023e2d1c8565efc9a707a82c9fc3903ab38 (diff)
Add 'data_types' during import VFCs
Change-Id: Ib9974bbc1eb88633e7e6834cc7ef8ae95deda539 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3191
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java240
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java73
-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
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java168
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java74
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java19
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java4
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java2
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java16
14 files changed, 486 insertions, 317 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index 01698fa662..4db44d3a76 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,11 +26,13 @@ import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.tinkerpop.gremlin.structure.T;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
@@ -40,6 +42,7 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -83,12 +86,14 @@ import java.util.function.Function;
import static org.apache.commons.collections.CollectionUtils.isEmpty;
import static org.openecomp.sdc.be.components.impl.ResourceImportManager.PROPERTY_NAME_PATTERN_IGNORE_LENGTH;
import static org.openecomp.sdc.be.datatypes.elements.Annotation.setAnnotationsName;
+import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataType;
+import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataTypeDefinitionWithName;
@Component
public final class ImportUtils {
private static final CustomResolver customResolver = new CustomResolver();
- private static final Yaml strictYamlLoader = new YamlLoader().getStrictYamlLoader();
+ private static final Yaml strictYamlLoader = new YamlLoader().getStrictYamlLoader();
private static ComponentsUtils componentsUtils;
@@ -103,6 +108,7 @@ public final class ImportUtils {
}
private static class CustomResolver extends Resolver {
+
@Override
protected void addImplicitResolvers() {
// avoid implicit resolvers for strings that can be interpreted as boolean values
@@ -124,41 +130,43 @@ public final class ImportUtils {
Map<String, Object> result = new LinkedHashMap<>();
buildMap(result, (Map) value);
output.put(key, result);
- }
- else if (value instanceof Collection) {
+ } else if (value instanceof Collection) {
Map<String, Object> result = new LinkedHashMap<>();
int i = 0;
- for(Object item : (Collection<Object>) value) {
+ for (Object item : (Collection<Object>) value) {
buildMap(result, Collections.singletonMap("[" + (i++) + "]", item));
}
output.put(key, new ArrayList<>(result.values()));
- }
- else {
+ } else {
output.put(key, value);
}
}
}
- public static Map<String, Object> loadYamlAsStrictMap(String content){
+ public static Map<String, Object> loadYamlAsStrictMap(String content) {
Map<String, Object> result = new LinkedHashMap<>();
Object map = strictYamlLoader.load(content);
- buildMap(result, (Map<String, Object>)map);
+ buildMap(result, (Map<String, Object>) map);
return result;
}
private static class YamlLoader extends YamlProcessor {
+
public Yaml getStrictYamlLoader() {
return createYaml();
}
}
@SuppressWarnings("unchecked")
- public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParamsWithoutImplicitTypes(String heatDecodedPayload, String artifactType) {
- Map<String, Object> heatData = (Map<String, Object>) new Yaml(new Constructor(), new Representer(), new DumperOptions(), customResolver).load(heatDecodedPayload);
+ public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParamsWithoutImplicitTypes(
+ String heatDecodedPayload, String artifactType) {
+ Map<String, Object> heatData = (Map<String, Object>) new Yaml(new Constructor(), new Representer(),
+ new DumperOptions(), customResolver).load(heatDecodedPayload);
return getHeatParameters(heatData, artifactType);
}
public static class Constants {
+
public static final String FIRST_NON_CERTIFIED_VERSION = "0.1";
public static final String VENDOR_NAME = "ONAP (Tosca)";
public static final String VENDOR_RELEASE = "1.0.0.wd03";
@@ -175,7 +183,8 @@ public final class ImportUtils {
public static final String ESCAPED_DOUBLE_QUOTE = "\"";
public static final String QUOTE = "'";
- private Constants() {}
+ private Constants() {
+ }
}
public enum ResultStatusEnum {
@@ -187,7 +196,8 @@ public final class ImportUtils {
}
@SuppressWarnings("unchecked")
- private static void handleElementNameNotFound(String elementName, Object elementValue, ToscaElementTypeEnum elementType, List<Object> returnedList) {
+ private static void handleElementNameNotFound(String elementName, Object elementValue,
+ ToscaElementTypeEnum elementType, List<Object> returnedList) {
if (elementValue instanceof Map) {
findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
} else if (elementValue instanceof List) {
@@ -196,15 +206,14 @@ public final class ImportUtils {
}
@SuppressWarnings("unchecked")
- private static void addFoundElementAccordingToItsType(String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList, Object elementValue) {
+ private static void addFoundElementAccordingToItsType(String elementName, ToscaElementTypeEnum elementType,
+ List<Object> returnedList, Object elementValue) {
if (elementValue instanceof Boolean) {
if (elementType == ToscaElementTypeEnum.BOOLEAN || elementType == ToscaElementTypeEnum.ALL) {
returnedList.add(elementValue);
}
- }
-
- else if (elementValue instanceof String) {
+ } else if (elementValue instanceof String) {
if (elementType == ToscaElementTypeEnum.STRING || elementType == ToscaElementTypeEnum.ALL) {
returnedList.add(elementValue);
}
@@ -227,11 +236,14 @@ public final class ImportUtils {
}
}
- private static void findAllToscaElementsInList(List<Object> list, String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList) {
+ private static void findAllToscaElementsInList(List<Object> list, String elementName,
+ ToscaElementTypeEnum elementType, List<Object> returnedList) {
list.forEach(elementValue -> handleElementNameNotFound(elementName, elementValue, elementType, returnedList));
}
- public static Either<Object, ResultStatusEnum> findToscaElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementName, ToscaElementTypeEnum elementType) {
+ public static Either<Object, ResultStatusEnum> findToscaElement(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum elementName,
+ ToscaElementTypeEnum elementType) {
List<Object> foundElements = new ArrayList<>();
findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements);
if (!isEmpty(foundElements)) {
@@ -242,21 +254,21 @@ public final class ImportUtils {
/**
* Recursively searches for all tosca elements with key equals to elementName and value equals to elementType. <br>
- * Returns Either element with:<br>
- * List with all value if values found<br>
- * Or ELEMENT_NOT_FOUND ActionStatus
+ * Returns Either element with:<br> List with all value if values found<br> Or ELEMENT_NOT_FOUND ActionStatus
*
* @param toscaJson
* @return
*/
- public static Either<List<Object>, ResultStatusEnum> findToscaElements(Map<String, Object> toscaJson, String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList) {
+ public static Either<List<Object>, ResultStatusEnum> findToscaElements(Map<String, Object> toscaJson,
+ String elementName,
+ ToscaElementTypeEnum elementType,
+ List<Object> returnedList) {
Either<List<Object>, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
String skipKey = null;
if (toscaJson.containsKey(elementName)) {
skipKey = handleFoundElement(toscaJson, elementName, elementType, returnedList);
}
-
Iterator<Entry<String, Object>> keyValItr = toscaJson.entrySet().iterator();
while (keyValItr.hasNext()) {
Entry<String, Object> keyValEntry = keyValItr.next();
@@ -272,7 +284,8 @@ public final class ImportUtils {
return returnedElement;
}
- private static String handleFoundElement(Map<String, Object> toscaJson, String elementName, ToscaElementTypeEnum elementType, List<Object> returnedList) {
+ private static String handleFoundElement(Map<String, Object> toscaJson, String elementName,
+ ToscaElementTypeEnum elementType, List<Object> returnedList) {
Object elementValue = toscaJson.get(elementName);
addFoundElementAccordingToItsType(elementName, elementType, returnedList, elementValue);
return elementName;
@@ -280,9 +293,11 @@ public final class ImportUtils {
}
@SuppressWarnings("unchecked")
- public static <T> Either<List<T>, ResultStatusEnum> findFirstToscaListElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) {
+ public static <T> Either<List<T>, ResultStatusEnum> findFirstToscaListElement(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum toscaTagName) {
Either<List<T>, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Object, ResultStatusEnum> findFirstToscaElement = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.LIST);
+ Either<Object, ResultStatusEnum> findFirstToscaElement = findToscaElement(toscaJson, toscaTagName,
+ ToscaElementTypeEnum.LIST);
if (findFirstToscaElement.isLeft()) {
returnedElement = Either.left((List<T>) findFirstToscaElement.left().value());
}
@@ -291,9 +306,11 @@ public final class ImportUtils {
}
@SuppressWarnings("unchecked")
- public static <T> Either<Map<String, T>, ResultStatusEnum> findFirstToscaMapElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) {
+ public static <T> Either<Map<String, T>, ResultStatusEnum> findFirstToscaMapElement(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum toscaTagName) {
Either<Map<String, T>, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Object, ResultStatusEnum> findFirstToscaElement = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.MAP);
+ Either<Object, ResultStatusEnum> findFirstToscaElement = findToscaElement(toscaJson, toscaTagName,
+ ToscaElementTypeEnum.MAP);
if (findFirstToscaElement.isLeft()) {
returnedElement = Either.left((Map<String, T>) findFirstToscaElement.left().value());
}
@@ -301,9 +318,11 @@ public final class ImportUtils {
}
- public static Either<String, ResultStatusEnum> findFirstToscaStringElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) {
+ public static Either<String, ResultStatusEnum> findFirstToscaStringElement(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum toscaTagName) {
Either<String, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.STRING);
+ Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName,
+ ToscaElementTypeEnum.STRING);
if (findFirstToscaElements.isLeft()) {
returnedElement = Either.left((String) findFirstToscaElements.left().value());
}
@@ -311,15 +330,18 @@ public final class ImportUtils {
}
/**
- * searches for first Tosca in Json map (toscaJson) boolean element by name (toscaTagName) returns found element or ELEMENT_NOT_FOUND status
+ * searches for first Tosca in Json map (toscaJson) boolean element by name (toscaTagName) returns found element or
+ * ELEMENT_NOT_FOUND status
*
* @param toscaJson
* @param toscaTagName
* @return
*/
- public static Either<String, ResultStatusEnum> findFirstToscaBooleanElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum toscaTagName) {
+ public static Either<String, ResultStatusEnum> findFirstToscaBooleanElement(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum toscaTagName) {
Either<String, ResultStatusEnum> returnedElement = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName, ToscaElementTypeEnum.BOOLEAN);
+ Either<Object, ResultStatusEnum> findFirstToscaElements = findToscaElement(toscaJson, toscaTagName,
+ ToscaElementTypeEnum.BOOLEAN);
if (findFirstToscaElements.isLeft()) {
returnedElement = Either.left(String.valueOf(findFirstToscaElements.left().value()));
}
@@ -333,16 +355,19 @@ public final class ImportUtils {
}
}
- private static List<PropertyConstraint> getPropertyConstraints(Map<String, Object> propertyValue, String propertyType) {
+ private static List<PropertyConstraint> getPropertyConstraints(Map<String, Object> propertyValue,
+ String propertyType) {
List<Object> propertyFieldConstraints = findCurrentLevelConstraintsElement(propertyValue);
if (CollectionUtils.isNotEmpty(propertyFieldConstraints)) {
List<PropertyConstraint> constraintList = new ArrayList<>();
Type constraintType = new TypeToken<PropertyConstraint>() {
}.getType();
- Gson gson = new GsonBuilder().registerTypeAdapter(constraintType, new PropertyConstraintDeserialiser()).create();
+ Gson gson = new GsonBuilder().registerTypeAdapter(constraintType, new PropertyConstraintDeserialiser())
+ .create();
for (Object constraintJson : propertyFieldConstraints) {
- PropertyConstraint propertyConstraint = validateAndGetPropertyConstraint(propertyType, constraintType, gson, constraintJson);
+ PropertyConstraint propertyConstraint = validateAndGetPropertyConstraint(propertyType, constraintType,
+ gson, constraintJson);
constraintList.add(propertyConstraint);
}
return constraintList;
@@ -355,29 +380,33 @@ public final class ImportUtils {
if (toscaJson.containsKey(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName())) {
try {
constraints = (List<Object>) toscaJson.get(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName());
- } catch (ClassCastException e){
- throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT, toscaJson.get(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName()).toString());
+ } catch (ClassCastException e) {
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT,
+ toscaJson.get(TypeUtils.ToscaTagNamesEnum.CONSTRAINTS.getElementName()).toString());
}
}
return constraints;
}
- private static PropertyConstraint validateAndGetPropertyConstraint(String propertyType, Type constraintType, Gson gson, Object constraintJson) {
+ private static PropertyConstraint validateAndGetPropertyConstraint(String propertyType, Type constraintType,
+ Gson gson, Object constraintJson) {
PropertyConstraint propertyConstraint;
- try{
+ try {
propertyConstraint = gson.fromJson(gson.toJson(constraintJson), constraintType);
- } catch (ClassCastException|JsonParseException e){
- throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT, constraintJson.toString());
+ } catch (ClassCastException | JsonParseException e) {
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS_FORMAT,
+ constraintJson.toString());
}
- if(propertyConstraint!= null && propertyConstraint instanceof ValidValuesConstraint){
+ if (propertyConstraint != null && propertyConstraint instanceof ValidValuesConstraint) {
try {
- ((ValidValuesConstraint)propertyConstraint).validateType(propertyType);
+ ((ValidValuesConstraint) propertyConstraint).validateType(propertyType);
} catch (ConstraintValueDoNotMatchPropertyTypeException e) {
BeEcompErrorManager.getInstance().logInternalFlowError("GetInitializedPropertyConstraint",
- e.getMessage(), BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS, ConstraintType.VALID_VALUES.name(),
- ((ValidValuesConstraint) propertyConstraint).getValidValues().toString(), propertyType);
+ e.getMessage(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_CONSTRAINTS,
+ ConstraintType.VALID_VALUES.name(),
+ ((ValidValuesConstraint) propertyConstraint).getValidValues().toString(), propertyType);
}
}
return propertyConstraint;
@@ -387,13 +416,17 @@ public final class ImportUtils {
PropertyDefinition propertyDef = new PropertyDefinition();
setField(propertyValue, TypeUtils.ToscaTagNamesEnum.TYPE, propertyDef::setType);
- setFieldBoolean(propertyValue, ToscaTagNamesEnum.REQUIRED, req -> propertyDef.setRequired(Boolean.parseBoolean(req)));
+ setFieldBoolean(propertyValue, ToscaTagNamesEnum.REQUIRED,
+ req -> propertyDef.setRequired(Boolean.parseBoolean(req)));
setField(propertyValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, propertyDef::setDescription);
- setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, propertyDef.getType(), propertyDef::setDefaultValue);
- setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.VALUE, propertyDef.getType(), propertyDef::setValue);
+ setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, propertyDef.getType(),
+ propertyDef::setDefaultValue);
+ setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.VALUE, propertyDef.getType(),
+ propertyDef::setValue);
- setFieldBoolean(propertyValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> propertyDef.setPassword(Boolean.parseBoolean(pass)));
+ setFieldBoolean(propertyValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD,
+ pass -> propertyDef.setPassword(Boolean.parseBoolean(pass)));
setField(propertyValue, TypeUtils.ToscaTagNamesEnum.STATUS, propertyDef::setStatus);
setScheme(propertyValue, propertyDef);
setPropertyConstraints(propertyValue, propertyDef);
@@ -401,16 +434,20 @@ public final class ImportUtils {
return propertyDef;
}
- private static void setJsonStringField(Map<String, Object> propertyValue, ToscaTagNamesEnum elementName, String type, Consumer<String> setter) {
- Either<Object, ResultStatusEnum> eitherValue = findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL);
+ private static void setJsonStringField(Map<String, Object> propertyValue, ToscaTagNamesEnum elementName,
+ String type, Consumer<String> setter) {
+ Either<Object, ResultStatusEnum> eitherValue = findToscaElement(propertyValue, elementName,
+ ToscaElementTypeEnum.ALL);
if (eitherValue.isLeft()) {
String propertyJsonStringValue = getPropertyJsonStringValue(eitherValue.left().value(), type);
setter.accept(propertyJsonStringValue);
}
}
- public static Annotation createModuleAnnotation(Map<String, Object> annotationMap, AnnotationTypeOperations annotationTypeOperations) {
- String parsedAnnotationType = findFirstToscaStringElement(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE).left().value();
+ public static Annotation createModuleAnnotation(Map<String, Object> annotationMap,
+ AnnotationTypeOperations annotationTypeOperations) {
+ String parsedAnnotationType = findFirstToscaStringElement(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE)
+ .left().value();
AnnotationTypeDefinition annotationTypeObject = annotationTypeOperations.getLatestType(parsedAnnotationType);
if (annotationTypeObject != null) {
Annotation annotation = new Annotation();
@@ -423,7 +460,8 @@ public final class ImportUtils {
return null;
}
- private static Either<Boolean, ResponseFormat> modifyPropertiesKeysToProperForm(Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties, Annotation annotation) {
+ private static Either<Boolean, ResponseFormat> modifyPropertiesKeysToProperForm(
+ Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties, Annotation annotation) {
Either<Boolean, ResponseFormat> result = Either.left(true);
if (properties.isLeft()) {
List<PropertyDataDefinition> propertiesList = new ArrayList<>();
@@ -432,8 +470,11 @@ public final class ImportUtils {
for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
String name = entry.getKey();
if (!PROPERTY_NAME_PATTERN_IGNORE_LENGTH.matcher(name).matches()) {
- log.debug("The property with invalid name {} occurred upon import resource {}. ", name, annotation.getName());
- result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, JsonPresentationFields.PROPERTY)));
+ log.debug("The property with invalid name {} occurred upon import resource {}. ", name,
+ annotation.getName());
+ result = Either.right(componentsUtils.getResponseFormat(componentsUtils
+ .convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME,
+ JsonPresentationFields.PROPERTY)));
}
PropertyDefinition propertyDefinition = entry.getValue();
propertyDefinition.setValue(propertyDefinition.getName());
@@ -442,23 +483,25 @@ public final class ImportUtils {
}
}
annotation.setProperties(propertiesList);
- }
- else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) {
- result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(properties
+ } else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) {
+ result = Either
+ .right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(properties
.right()
.value(), JsonPresentationFields.PROPERTY)));
}
return result;
}
- public static InputDefinition createModuleInput(Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations) {
+ public static InputDefinition createModuleInput(Map<String, Object> inputValue,
+ AnnotationTypeOperations annotationTypeOperations) {
InputDefinition inputDef = new InputDefinition();
setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType);
setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req)));
setField(inputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, inputDef::setDescription);
- setJsonStringField(inputValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, inputDef.getType(), inputDef::setDefaultValue);
+ setJsonStringField(inputValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, inputDef.getType(),
+ inputDef::setDefaultValue);
setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> inputDef.setPassword(Boolean.parseBoolean(pass)));
setField(inputValue, TypeUtils.ToscaTagNamesEnum.STATUS, inputDef::setStatus);
@@ -473,16 +516,22 @@ public final class ImportUtils {
}
- public static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations){
+ public static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef,
+ Map<String, Object> inputValue,
+ AnnotationTypeOperations annotationTypeOperations) {
Function<String, Annotation> elementGenByName = ImportUtils::createAnnotation;
- Function<Map<String, Object>, Annotation> func = annotation -> createModuleAnnotation(annotation, annotationTypeOperations);
+ Function<Map<String, Object>, Annotation> func = annotation -> createModuleAnnotation(annotation,
+ annotationTypeOperations);
return getElements(inputValue, TypeUtils.ToscaTagNamesEnum.ANNOTATIONS, elementGenByName, func).
- left().map( annotations -> modifyInputWithAnnotations(inputDef, annotations)).
- left().on(err -> { log.error("Parsing annotations or adding them to the PropertyDataDefinition object failed");
- return inputDef;});
+ left().map(annotations -> modifyInputWithAnnotations(inputDef, annotations)).
+ left().on(err -> {
+ log.error("Parsing annotations or adding them to the PropertyDataDefinition object failed");
+ return inputDef;
+ });
}
- private static InputDefinition modifyInputWithAnnotations(InputDefinition inputDef, Map<String, Annotation> annotationsMap) {
+ private static InputDefinition modifyInputWithAnnotations(InputDefinition inputDef,
+ Map<String, Annotation> annotationsMap) {
setAnnotationsName(annotationsMap);
inputDef.setAnnotationsToInput(annotationsMap.values());
return inputDef;
@@ -495,7 +544,8 @@ public final class ImportUtils {
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, attributeDef::setDescription);
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.STATUS, attributeDef::setStatus);
- setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(), attributeDef::set_default);
+ setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(),
+ attributeDef::set_default);
setScheme(attributeMap, attributeDef);
return attributeDef;
@@ -528,7 +578,8 @@ public final class ImportUtils {
return schema;
}
- public static void setField(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer<String> setter) {
+ private static void setField(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName,
+ Consumer<String> setter) {
Either<String, ResultStatusEnum> fieldStringValue = findFirstToscaStringElement(toscaJson, tagName);
if (fieldStringValue.isLeft()) {
setter.accept(fieldStringValue.left().value());
@@ -536,7 +587,8 @@ public final class ImportUtils {
}
- public static void setFieldBoolean(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName, Consumer<String> setter) {
+ public static void setFieldBoolean(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum tagName,
+ Consumer<String> setter) {
Either<String, ResultStatusEnum> fieldStringValue = findFirstToscaBooleanElement(toscaJson, tagName);
if (fieldStringValue.isLeft()) {
setter.accept(fieldStringValue.left().value());
@@ -590,8 +642,7 @@ public final class ImportUtils {
if (attribute != null) {
moduleAttributes.put(String.valueOf(attributeNameValue.getKey()), attribute);
}
- }
- else {
+ } else {
T element = elementGenByName.apply(String.valueOf(attributeNameValue.getValue()));
moduleAttributes.put(String.valueOf(attributeNameValue.getKey()), element);
}
@@ -634,8 +685,10 @@ public final class ImportUtils {
public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParameters(Map<String, Object> heatData, String artifactType) {
- Either<List<HeatParameterDefinition>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Map<String, Object>, ResultStatusEnum> toscaProperties = findFirstToscaMapElement(heatData, TypeUtils.ToscaTagNamesEnum.PARAMETERS);
+ Either<List<HeatParameterDefinition>, ResultStatusEnum> eitherResult = Either
+ .right(ResultStatusEnum.ELEMENT_NOT_FOUND);
+ Either<Map<String, Object>, ResultStatusEnum> toscaProperties = findFirstToscaMapElement(heatData,
+ TypeUtils.ToscaTagNamesEnum.PARAMETERS);
if (toscaProperties.isLeft()) {
Map<String, Object> jsonProperties = toscaProperties.left().value();
List<HeatParameterDefinition> moduleProperties = new ArrayList<>();
@@ -645,7 +698,8 @@ public final class ImportUtils {
if (propertyNameValue.getValue() instanceof Map || propertyNameValue.getValue() instanceof List) {
if (!artifactType.equals(ArtifactTypeEnum.HEAT_ENV.getType())) {
@SuppressWarnings("unchecked")
- Either<HeatParameterDefinition, ResultStatusEnum> propertyStatus = createModuleHeatParameter((Map<String, Object>) propertyNameValue.getValue());
+ Either<HeatParameterDefinition, ResultStatusEnum> propertyStatus = createModuleHeatParameter(
+ (Map<String, Object>) propertyNameValue.getValue());
if (propertyStatus.isRight()) {
return Either.right(propertyStatus.right().value());
}
@@ -670,44 +724,52 @@ public final class ImportUtils {
}
- private static void addHeatParamDefinition(List<HeatParameterDefinition> moduleProperties, Entry<String, Object> propertyNameValue, boolean isJson) {
+ private static void addHeatParamDefinition(List<HeatParameterDefinition> moduleProperties,
+ Entry<String, Object> propertyNameValue, boolean isJson) {
HeatParameterDefinition property = new HeatParameterDefinition();
Object value = propertyNameValue.getValue();
if (value != null) {
- property.setDefaultValue(isJson ? new Gson().toJson(value) : StringEscapeUtils.escapeJava(String.valueOf(value)));
+ property.setDefaultValue(
+ isJson ? new Gson().toJson(value) : StringEscapeUtils.escapeJava(String.valueOf(value)));
}
property.setName(String.valueOf(propertyNameValue.getKey()));
moduleProperties.add(property);
}
- private static Either<HeatParameterDefinition, ResultStatusEnum> createModuleHeatParameter(Map<String, Object> propertyValue) {
+ private static Either<HeatParameterDefinition, ResultStatusEnum> createModuleHeatParameter(
+ Map<String, Object> propertyValue) {
HeatParameterDefinition propertyDef = new HeatParameterDefinition();
String type;
- Either<String, ResultStatusEnum> propertyFieldType = findFirstToscaStringElement(propertyValue, TypeUtils.ToscaTagNamesEnum.TYPE);
+ Either<String, ResultStatusEnum> propertyFieldType = findFirstToscaStringElement(propertyValue,
+ TypeUtils.ToscaTagNamesEnum.TYPE);
if (propertyFieldType.isLeft()) {
type = propertyFieldType.left().value();
propertyDef.setType(type);
} else {
return Either.right(ResultStatusEnum.INVALID_PROPERTY_TYPE);
}
- Either<String, ResultStatusEnum> propertyFieldDescription = findFirstToscaStringElement(propertyValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION);
+ Either<String, ResultStatusEnum> propertyFieldDescription = findFirstToscaStringElement(propertyValue,
+ TypeUtils.ToscaTagNamesEnum.DESCRIPTION);
if (propertyFieldDescription.isLeft()) {
propertyDef.setDescription(propertyFieldDescription.left().value());
}
- Either<Object, ResultStatusEnum> propertyFieldDefaultVal = findToscaElement(propertyValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, ToscaElementTypeEnum.ALL);
+ Either<Object, ResultStatusEnum> propertyFieldDefaultVal = findToscaElement(propertyValue,
+ TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, ToscaElementTypeEnum.ALL);
if (propertyFieldDefaultVal.isLeft()) {
if (propertyFieldDefaultVal.left().value() == null) {
return Either.right(ResultStatusEnum.INVALID_PROPERTY_VALUE);
}
Object value = propertyFieldDefaultVal.left().value();
- String defaultValue = type.equals(HeatParameterType.JSON.getType()) ? new Gson().toJson(value) : StringEscapeUtils.escapeJava(String.valueOf(value));
+ String defaultValue = type.equals(HeatParameterType.JSON.getType()) ? new Gson().toJson(value)
+ : StringEscapeUtils.escapeJava(String.valueOf(value));
propertyDef.setDefaultValue(defaultValue);
propertyDef.setCurrentValue(defaultValue);
}
return Either.left(propertyDef);
}
+
public static boolean containsGetInput(Object propValue) {
String value = getPropertyJsonStringValue(propValue, ToscaPropertyType.MAP.getType());
return value != null && value.contains(TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
@@ -719,14 +781,16 @@ public final class ImportUtils {
return null;
}
ToscaPropertyType validType = ToscaPropertyType.isValidType(type);
- if (validType == null || validType == ToscaPropertyType.JSON || validType == ToscaPropertyType.MAP || validType == ToscaPropertyType.LIST) {
+ if (validType == null || validType == ToscaPropertyType.JSON || validType == ToscaPropertyType.MAP
+ || validType == ToscaPropertyType.LIST) {
return gson.toJson(value);
}
return value.toString();
}
/**
- * removes from Json map (toscaJson) first element found by name (elementName) note that this method could update the received argument toscaJson
+ * removes from Json map (toscaJson) first element found by name (elementName) note that this method could update
+ * the received argument toscaJson
*
* @param toscaJson
* @param elementName
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 35a0761ff1..8164bad477 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -4015,22 +4015,25 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
newResource.setAbstract(oldResource.isAbstract());
- if (CollectionUtils.isEmpty(newResource.getDerivedFrom())) {
+ if (CollectionUtils.isEmpty(newResource.getDerivedFrom())){
newResource.setDerivedFrom(oldResource.getDerivedFrom());
}
- if (StringUtils.isEmpty(newResource.getDerivedFromGenericType())) {
+ if (CollectionUtils.isEmpty(newResource.getDataTypes())){
+ newResource.setDataTypes(oldResource.getDataTypes());
+ }
+ if (StringUtils.isEmpty(newResource.getDerivedFromGenericType())){
newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
}
- if (StringUtils.isEmpty(newResource.getDerivedFromGenericVersion())) {
+ if (StringUtils.isEmpty(newResource.getDerivedFromGenericVersion())){
newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
}
// add for new)
// created without tosca artifacts - add the placeholders
- if (MapUtils.isEmpty(newResource.getToscaArtifacts())) {
+ if (MapUtils.isEmpty(newResource.getToscaArtifacts())){
setToscaArtifactsPlaceHolders(newResource, user);
}
- if (MapUtils.isEmpty(newResource.getInterfaces())) {
+ if (MapUtils.isEmpty(newResource.getInterfaces())){
newResource.setInterfaces(oldResource.getInterfaces());
}
if (CollectionUtils.isEmpty(newResource.getAttributes())) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 1a0dfaa9fd..dbcaee4d30 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -23,11 +23,16 @@
package org.openecomp.sdc.be.components.impl;
import static org.openecomp.sdc.be.components.impl.ImportUtils.Constants.QUOTE;
+import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataType;
+import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementOperation.createDataTypeDefinitionWithName;
import static org.openecomp.sdc.be.utils.TypeUtils.setField;
import fj.data.Either;
+import java.util.Collections;
import java.util.LinkedHashMap;
import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
@@ -37,12 +42,14 @@ import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.Constants;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
+import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
@@ -59,6 +66,7 @@ import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -241,7 +249,7 @@ public class ResourceImportManager {
componentsUtils
.getResponseFormat(((ComponentException) e).getActionStatus(), ((ComponentException) e).getParams())
:
- ((ComponentException) e).getResponseFormat();
+ ((ComponentException) e).getResponseFormat();
}
return null;
}
@@ -327,6 +335,15 @@ public class ResourceImportManager {
toscaJson.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(),
toscaJsonAll.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()));
}
+ final List<Object> foundElements = new ArrayList<>();
+ final Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(toscaJsonAll,
+ ToscaTagNamesEnum.DATA_TYPES.getElementName(), ToscaElementTypeEnum.MAP, foundElements);
+ if (toscaElements.isLeft()) {
+ final Map<String, Object> toscaAttributes = (Map<String, Object>) foundElements.get(0);
+ if (MapUtils.isNotEmpty(toscaAttributes)) {
+ resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes));
+ }
+ }
// Derived From
Resource parentResource = setDerivedFrom(toscaJson, resource);
if (StringUtils.isEmpty(resource.getToscaResourceName())) {
@@ -482,7 +499,7 @@ public class ResourceImportManager {
}
private boolean entryIsInterfaceType(final Entry<String, Object> entry) {
- if (entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
+ if(entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
if (entry.getValue() instanceof String) {
return true;
}
@@ -493,8 +510,8 @@ public class ResourceImportManager {
private boolean entryContainsImplementationForAKnownOperation(final Entry<String, Object> entry,
final String interfaceType) {
- if (entry.getValue() instanceof Map && ((Map<?, ?>) entry.getValue()).containsKey(IMPLEMENTATION)) {
- if (isAKnownOperation(interfaceType, entry.getKey())) {
+ if (entry.getValue() instanceof Map && ((Map<?, ?>)entry.getValue()).containsKey(IMPLEMENTATION)) {
+ if (isAKnownOperation(interfaceType, entry.getKey())){
return true;
}
throw new ByActionStatusComponentException(ActionStatus.INTERFACE_OPERATION_NOT_FOUND);
@@ -832,8 +849,8 @@ public class ResourceImportManager {
log.debug("Couldn't check whether imported resource capability derives from its parent's capability");
throw new ByActionStatusComponentException(
componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom
- .right()
- .value()));
+ .right()
+ .value()));
}
return capabilityTypeDerivedFrom.left().value();
}
@@ -858,7 +875,7 @@ public class ResourceImportManager {
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES.getElementName())) {
capabilityDefinition.setValidSourceTypes(
(List<String>) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES
- .getElementName()));
+ .getElementName()));
}
// ValidSourceTypes
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
@@ -1023,7 +1040,22 @@ public class ResourceImportManager {
final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
final Either<String, ResultStatusEnum> findFirstToscaStringElement =
ImportUtils.findFirstToscaStringElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
- return findFirstToscaStringElement.left().value();
+ if (findFirstToscaStringElement.isLeft()) {
+ return findFirstToscaStringElement.left().value();
+ } else {
+ return null;
+ }
+ }
+
+ private Map<String, Object> getDataTypes(final String payloadData) {
+ final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
+ final Either<Map<String, Object>, ResultStatusEnum> findFirstToscaStringElement =
+ ImportUtils.findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.DATA_TYPES);
+ if (findFirstToscaStringElement.isLeft()) {
+ return findFirstToscaStringElement.left().value();
+ } else {
+ return Collections.EMPTY_MAP;
+ }
}
private void calculateResourceIsAbstract(Resource resource, List<CategoryDefinition> categories) {
@@ -1172,4 +1204,29 @@ public class ResourceImportManager {
this.auditingManager = auditingManager;
}
+ private List<DataTypeDefinition> extractDataTypeFromJson(final ResourceBusinessLogic resourceBusinessLogic,
+ final Map<String, Object> foundElements) {
+ final List<DataTypeDefinition> dataTypeDefinitionList = new ArrayList<>();
+ if (MapUtils.isNotEmpty(foundElements)) {
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll =
+ resourceBusinessLogic.dataTypeCache.getAll();
+ if (dataTypeCacheAll.isLeft()) {
+ for (final Entry<String, Object> attributeNameValue : foundElements.entrySet()) {
+ final Object value = attributeNameValue.getValue();
+ if (value instanceof Map) {
+ final DataTypeDefinition dataTypeDefinition =
+ createDataTypeDefinitionWithName(attributeNameValue);
+ final DataTypeDefinition dataTypeDefinitionParent =
+ dataTypeCacheAll.left().value().get(dataTypeDefinition.getDerivedFromName());
+ dataTypeDefinition.setDerivedFrom(dataTypeDefinitionParent);
+
+ dataTypeDefinitionList.add(dataTypeDefinition);
+ } else {
+ dataTypeDefinitionList.add(createDataType(String.valueOf(value)));
+ }
+ }
+ }
+ }
+ return dataTypeDefinitionList;
+ }
}
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<>();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java
index 9b6b6f6e1b..12f4628a1a 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationTest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
import fj.data.Either;
+import java.util.Map.Entry;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -31,20 +32,25 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
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.ModelTestBase;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.resources.data.EntryData;
+import org.openecomp.sdc.be.utils.TypeUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
@@ -53,7 +59,7 @@ import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-context-test.xml")
-public class ToscaElementOperationTest extends ModelTestBase{
+public class ToscaElementOperationTest extends ModelTestBase {
private List<GraphVertex> allVertices = new ArrayList<>();
private boolean isInitialized = false;
@@ -65,7 +71,7 @@ public class ToscaElementOperationTest extends ModelTestBase{
private JanusGraphDao janusGraphDao;
@BeforeClass
- public static void initTest(){
+ public static void initTest() {
ModelTestBase.init();
}
@@ -83,11 +89,11 @@ public class ToscaElementOperationTest extends ModelTestBase{
}
}
-
@Test
public void testGetAllHighestResourcesNoFilter() {
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE, null, true);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.RESOURCE, null, true);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -99,13 +105,11 @@ public class ToscaElementOperationTest extends ModelTestBase{
}, null);
assertEquals(highestResources.stream().count(), highestResourcesExpectedCount);
}
-
-
-
@Test
public void testGetAllResourcesCertifiedNoFilter() {
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE, null, false);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.RESOURCE, null, false);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -140,7 +144,8 @@ public class ToscaElementOperationTest extends ModelTestBase{
assertTrue(genericTestGetResourcesWithExcludeList(excludeList));
// exclude CP & VL & VF & VFC
- excludeList = Arrays.asList(ResourceTypeEnum.VL, ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC);
+ excludeList = Arrays
+ .asList(ResourceTypeEnum.VL, ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC);
assertTrue(genericTestGetResourcesWithExcludeList(excludeList));
}
@@ -155,13 +160,15 @@ public class ToscaElementOperationTest extends ModelTestBase{
assertTrue(genericTestGetCertifiedResourcesWithExcludeList(excludeList));
// exclude CP & VL & VF & VFC
- excludeList = Arrays.asList(ResourceTypeEnum.VL, ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC);
+ excludeList = Arrays
+ .asList(ResourceTypeEnum.VL, ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC);
assertTrue(genericTestGetCertifiedResourcesWithExcludeList(excludeList));
}
@Test
public void testGetAllHighestServicesNoFilter() {
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.SERVICE, null, true);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.SERVICE, null, true);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -176,7 +183,8 @@ public class ToscaElementOperationTest extends ModelTestBase{
@Test
public void testGetAllCertifiedServicesNoFilter() {
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.SERVICE, null, false);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.SERVICE, null, false);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -202,7 +210,8 @@ public class ToscaElementOperationTest extends ModelTestBase{
@Test
public void testGetServicesExcludeList() {
List<ResourceTypeEnum> excludeList = Arrays.asList(ResourceTypeEnum.VF, ResourceTypeEnum.VFCMT);
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.SERVICE, excludeList, true);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.SERVICE, excludeList, true);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -218,7 +227,8 @@ public class ToscaElementOperationTest extends ModelTestBase{
@Test
public void testGetCertifiedServicesExcludeList() {
List<ResourceTypeEnum> excludeList = Arrays.asList(ResourceTypeEnum.VL);
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.SERVICE, excludeList, false);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.SERVICE, excludeList, false);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -253,8 +263,54 @@ public class ToscaElementOperationTest extends ModelTestBase{
assertEquals(null, result);
}
+ @Test
+ public void testCreateDataType() {
+ final String expected = "newDataType";
+ final DataTypeDefinition result = ToscaElementOperation.createDataType(expected);
+ assertNotNull(result);
+ assertEquals(expected, result.getName());
+ }
+
+ @Test
+ public void testCreateDataTypeDefinitionWithName() {
+ final String expected = "newDataType";
+ final String description = "DESCRIPTION";
+ final String derivedFromName = "DERIVED_FROM_NAME";
+ final String uniqueId = "UNIQUE_ID";
+
+ final Map<String, Object> attributeMap = new HashMap<>();
+ attributeMap.put(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName(), description);
+ attributeMap.put(TypeUtils.ToscaTagNamesEnum.DERIVED_FROM_NAME.getElementName(), derivedFromName);
+
+ final Map<String, Object> derivedFromMap = new HashMap<>();
+ derivedFromMap.put(JsonPresentationFields.NAME.getPresentation(), derivedFromName);
+ derivedFromMap.put(JsonPresentationFields.UNIQUE_ID.getPresentation(), uniqueId);
+ final long creationTime = System.currentTimeMillis();
+ derivedFromMap.put(JsonPresentationFields.CREATION_TIME.getPresentation(), creationTime);
+ final long modificationTime = System.currentTimeMillis();
+ derivedFromMap.put(JsonPresentationFields.MODIFICATION_TIME.getPresentation(), modificationTime);
+
+ attributeMap.put(JsonPresentationFields.DERIVED_FROM.getPresentation(), derivedFromMap);
+
+ final Entry<String, Object> attributeNameValue = new EntryData<>(expected, attributeMap);
+ final DataTypeDefinition result = ToscaElementOperation.createDataTypeDefinitionWithName(attributeNameValue);
+
+ assertNotNull(result);
+ assertEquals(derivedFromName, result.getDerivedFromName());
+ assertEquals(description, result.getDescription());
+
+ final DataTypeDefinition resultDerivedFrom = result.getDerivedFrom();
+ assertNotNull(resultDerivedFrom);
+ assertEquals(derivedFromName, resultDerivedFrom.getName());
+ assertEquals(uniqueId, resultDerivedFrom.getUniqueId());
+ assertEquals(creationTime, resultDerivedFrom.getCreationTime().longValue());
+ assertEquals(modificationTime, resultDerivedFrom.getModificationTime().longValue());
+
+ }
+
private boolean genericTestGetResourcesWithExcludeList(List<ResourceTypeEnum> excludeList) {
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE,excludeList, true);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.RESOURCE, excludeList, true);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -272,7 +328,8 @@ public class ToscaElementOperationTest extends ModelTestBase{
}
private boolean genericTestGetCertifiedResourcesWithExcludeList(List<ResourceTypeEnum> excludeList) {
- Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE, excludeList, false);
+ Either<List<ToscaElement>, StorageOperationStatus> highestResourcesRes = toscaElementOperation
+ .getElementCatalogData(ComponentTypeEnum.RESOURCE, excludeList, false);
assertTrue(highestResourcesRes.isLeft());
List<ToscaElement> highestResources = highestResourcesRes.left().value();
// calculate expected count value
@@ -313,34 +370,41 @@ public class ToscaElementOperationTest extends ModelTestBase{
{
put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
- }
+ }
};
// add vertices with higestVersion = true
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, highstVerticesProps, ResourceTypeEnum.VF));
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, highstVerticesProps, ResourceTypeEnum.VFC));
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, highstVerticesProps, ResourceTypeEnum.VFCMT));
+ allVertices
+ .add(GraphTestUtils.createResourceVertex(janusGraphDao, highstVerticesProps, ResourceTypeEnum.VFCMT));
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, highstVerticesProps, ResourceTypeEnum.VL));
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, highstVerticesProps, ResourceTypeEnum.CP));
allVertices.add(GraphTestUtils.createServiceVertex(janusGraphDao, highstVerticesProps));
// add vertices with non-additional properties
- for (int i=0 ; i<2 ; i++) {
+ for (int i = 0; i < 2; i++) {
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VF));
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VFC));
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VFCMT));
+ allVertices
+ .add(GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VFCMT));
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VL));
allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.CP));
allVertices.add(GraphTestUtils.createServiceVertex(janusGraphDao, new HashMap<>()));
}
// add certified vertices
- for (int i=0; i<3; i++) {
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VF));
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VFC));
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VFCMT));
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VL));
- allVertices.add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.CP));
+ for (int i = 0; i < 3; i++) {
+ allVertices
+ .add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VF));
+ allVertices
+ .add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VFC));
+ allVertices.add(
+ GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VFCMT));
+ allVertices
+ .add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.VL));
+ allVertices
+ .add(GraphTestUtils.createResourceVertex(janusGraphDao, certifiedVerticesProps, ResourceTypeEnum.CP));
allVertices.add(GraphTestUtils.createServiceVertex(janusGraphDao, certifiedVerticesProps));
}
//allVertices.stream().forEach( v -> System.out.println("type: "+v.getMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE)));
@@ -348,36 +412,36 @@ public class ToscaElementOperationTest extends ModelTestBase{
//System.out.println("graph is: " + result);
}
- private long calculateCount(HashMap<GraphPropertyEnum, Object> hasProps, Map<GraphPropertyEnum, Object> doesntHaveProps){
+ private long calculateCount(HashMap<GraphPropertyEnum, Object> hasProps,
+ Map<GraphPropertyEnum, Object> doesntHaveProps) {
return allVertices.stream().
- filter(v -> {
- Map<GraphPropertyEnum, Object> vertexProps = v.getMetadataProperties();
- if (hasProps != null) {
- for (Map.Entry<GraphPropertyEnum, Object> prop: hasProps.entrySet()){
- Object value = vertexProps.get(prop.getKey());
- if ( value == null || !value.equals(prop.getValue())) {
- return false;
- }
+ filter(v -> {
+ Map<GraphPropertyEnum, Object> vertexProps = v.getMetadataProperties();
+ if (hasProps != null) {
+ for (Map.Entry<GraphPropertyEnum, Object> prop : hasProps.entrySet()) {
+ Object value = vertexProps.get(prop.getKey());
+ if (value == null || !value.equals(prop.getValue())) {
+ return false;
}
}
-
- if (doesntHaveProps != null) {
- for (Map.Entry<GraphPropertyEnum, Object> prop : doesntHaveProps.entrySet()) {
- Object value = vertexProps.get(prop.getKey());
- Object propValue = prop.getValue();
- if ( value != null && propValue != null && propValue instanceof List ) {
- for (ResourceTypeEnum propVal : (List<ResourceTypeEnum>)propValue) {
- if (propVal.name().equals(value)) {
- return false;
- }
+ }
+
+ if (doesntHaveProps != null) {
+ for (Map.Entry<GraphPropertyEnum, Object> prop : doesntHaveProps.entrySet()) {
+ Object value = vertexProps.get(prop.getKey());
+ Object propValue = prop.getValue();
+ if (value != null && propValue != null && propValue instanceof List) {
+ for (ResourceTypeEnum propVal : (List<ResourceTypeEnum>) propValue) {
+ if (propVal.name().equals(value)) {
+ return false;
}
}
- else if (value != null && value.equals(propValue)){
- return false;
- }
+ } else if (value != null && value.equals(propValue)) {
+ return false;
}
}
- return true;
- }).count();
+ }
+ return true;
+ }).count();
}
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java
index 75b5e56719..0574d1377c 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java
@@ -20,10 +20,18 @@
package org.openecomp.sdc.be.datatypes.elements;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import java.util.List;
+@Getter
+@Setter
+@NoArgsConstructor
+@ToString
public class DataTypeDataDefinition extends ToscaDataDefinition {
private String name;
@@ -47,10 +55,6 @@ public class DataTypeDataDefinition extends ToscaDataDefinition {
private List<PropertyDataDefinition> propertiesData;
- public DataTypeDataDefinition() {
-
- }
-
public DataTypeDataDefinition(DataTypeDataDefinition p) {
this.name = p.name;
this.uniqueId = p.uniqueId;
@@ -60,67 +64,5 @@ public class DataTypeDataDefinition extends ToscaDataDefinition {
this.modificationTime = p.modificationTime;
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDerivedFromName() {
- return derivedFromName;
- }
-
- public void setDerivedFromName(String derivedFromName) {
- this.derivedFromName = derivedFromName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public List<PropertyDataDefinition> getPropertiesData() {
- return propertiesData;
- }
-
- public void setPropertiesData(List<PropertyDataDefinition> propertiesData) {
- this.propertiesData = propertiesData;
- }
-
- @Override
- public String toString() {
- return "DataTypeDataDefinition [name=" + name + ", uniqueId=" + uniqueId + ", derivedFromName="
- + derivedFromName + ", description=" + description + ", creationTime=" + creationTime
- + ", modificationTime=" + modificationTime + ", propertiesData=" + propertiesData + "]";
- }
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java
index 42696e4ac1..643c03fbe1 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java
@@ -15,6 +15,11 @@
package org.openecomp.sdc.be.datatypes.enums;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
public enum ComponentFieldsEnum {
PROPERTIES("properties"),
@@ -47,19 +52,9 @@ public enum ComponentFieldsEnum {
NODE_FILTER("nodeFilter"),
SUBSTITUTION_FILTER("substitutionFilter"),
COMPONENT_INSTANCES_INTERFACES("componentInstancesInterfaces"),
- DATA_TYPES("dataTypes");
-
-
- private String value;
-
- ComponentFieldsEnum(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
+ DATA_TYPES("data_types");
+ private final String value;
public static ComponentFieldsEnum findByValue(String value) {
ComponentFieldsEnum ret = null;
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
index 296b0067b8..1f1c01f9a4 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
@@ -17,6 +17,7 @@ package org.openecomp.sdc.be.datatypes.enums;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
public enum GraphPropertyEnum {
@@ -51,6 +52,9 @@ public enum GraphPropertyEnum {
//used for category (old format, no json for categories)
ICONS("icons", String.class, false, false),
USE_SUBSTITUTION_FOR_NESTED_SERVICES("useServiceSubstitutionForNestedServices", Boolean.class, false, false),
+
+ DATA_TYPES("data_types", Map.class, false, false),
+
//Archive/Restore
IS_ARCHIVED("isArchived", Boolean.class, false, true),
IS_VSP_ARCHIVED("isVspArchived", Boolean.class, false, true),
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index 2dca70cad1..58baeb549c 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -60,6 +60,8 @@ public enum JsonPresentationFields {
DERIVED_FROM_GENERIC_VERSION("derivedFromGenericVersion", null),
SERVICE_FUNCTION("serviceFunction", null),
+ DATA_TYPES("data_types", GraphPropertyEnum.DATA_TYPES),
+
////Inputs
ANNOTATIONS("annotations", null),
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
index 00e8a9ab09..66c64bd05f 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
@@ -21,6 +21,8 @@ package org.openecomp.sdc.be.utils;
import java.util.Map;
import java.util.function.Consumer;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
public class TypeUtils {
@@ -38,6 +40,8 @@ public class TypeUtils {
return FIRST_CERTIFIED_VERSION_VERSION;
}
+ @Getter
+ @AllArgsConstructor
public enum ToscaTagNamesEnum {
DERIVED_FROM("derived_from"), IS_PASSWORD("is_password"),
// Properties
@@ -64,17 +68,11 @@ public class TypeUtils {
//functions
GET_INPUT("get_input"),
// Definitions
- DATA_TYPES("data_types"), NODE_TYPES("node_types"), IMPORTS("imports");
+ DATA_TYPES("data_types"), NODE_TYPES("node_types"), IMPORTS("imports"),
- private final String elementName;
-
- ToscaTagNamesEnum(final String elementName) {
- this.elementName = elementName;
- }
+ DERIVED_FROM_NAME("derivedFromName");
- public String getElementName() {
- return elementName;
- }
+ private final String elementName;
}
}