summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java47
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java32
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java98
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java123
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java535
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java30
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java70
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java165
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java34
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java68
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java54
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java32
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java53
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java26
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java33
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java263
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java29
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java9
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java7
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java32
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java37
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java56
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java3
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java4
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java26
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java21
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java15
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java102
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java161
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java378
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java52
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java149
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java77
-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/datatypes/tosca/ToscaDataDefinition.java2
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java56
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java49
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java12
46 files changed, 1157 insertions, 1852 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index c0f08b0bb3..ef82eba0a4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -23,9 +23,10 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -59,7 +60,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
private static final String UPDATE_ATTRIBUTE = "UpdateAttribute";
private static final String DELETE_ATTRIBUTE = "DeleteAttribute";
- private static final Logger log = Logger.getLogger(AttributeBusinessLogic.class.getName());
+ private static final Logger log = Logger.getLogger(AttributeBusinessLogic.class);
private static final String FAILED_TO_LOCK_COMPONENT_ERROR = "Failed to lock component {}. Error - {}";
@Autowired
@@ -82,8 +83,8 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return AttributeDefinition if created successfully Or ResponseFormat
*/
- public Either<PropertyDefinition, ResponseFormat> createAttribute(String resourceId, PropertyDefinition newAttributeDef, String userId) {
- Either<PropertyDefinition, ResponseFormat> result = null;
+ public Either<AttributeDataDefinition, ResponseFormat> createAttribute(String resourceId, AttributeDataDefinition newAttributeDef, String userId) {
+ Either<AttributeDataDefinition, ResponseFormat> result = null;
validateUserExists(userId);
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
@@ -112,17 +113,17 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue((AttributeDefinition)newAttributeDef, eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- handleDefaultValue(newAttributeDef, eitherAllDataTypes);
+ handleDefaultValue((AttributeDefinition)newAttributeDef, eitherAllDataTypes);
// add the new attribute to resource on graph
// need to get StorageOpaerationStatus and convert to ActionStatus from
// componentsUtils
- Either<PropertyDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
+ Either<AttributeDataDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
if (either.isRight()) {
result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(either.right().value()), resource.getName()));
return result;
@@ -137,7 +138,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
- private boolean isAttributeExist(List<PropertyDefinition> attributes, String resourceUid, String propertyName) {
+ private boolean isAttributeExist(List<AttributeDataDefinition> attributes, String resourceUid, String propertyName) {
boolean isExist = false;
if (attributes != null) {
isExist = attributes.stream().anyMatch(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getParentUniqueId(), resourceUid));
@@ -152,7 +153,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<PropertyDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
+ public Either<AttributeDataDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
validateUserExists(userId);
@@ -163,15 +164,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
Resource resource = status.left().value();
- List<PropertyDefinition> attributes = resource.getAttributes();
+ List<AttributeDataDefinition> attributes = resource.getAttributes();
if (attributes == null) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, ""));
} else {
// verify attribute exist in resource
- Optional<PropertyDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && att.getParentUniqueId().equals(resourceId)).findAny();
- return optionalAtt.<Either<PropertyDefinition, ResponseFormat>>map(Either::left).orElseGet(() -> Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
+ Optional<AttributeDataDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && resourceId.equals(att.getParentUniqueId())).findAny();
+ return optionalAtt.<Either<AttributeDataDefinition, ResponseFormat>>map(Either::left).orElseGet(() -> Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
}
-
}
/**
@@ -183,8 +183,8 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<PropertyDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, PropertyDefinition newAttDef, String userId) {
- Either<PropertyDefinition, ResponseFormat> result = null;
+ public Either<AttributeDataDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, AttributeDataDefinition newAttDef, String userId) {
+ Either<AttributeDataDefinition, ResponseFormat> result = null;
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
if (lockResult != StorageOperationStatus.OK) {
@@ -206,27 +206,26 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
// verify attribute exist in resource
- Either<PropertyDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue((AttributeDefinition)newAttDef, eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- // add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty(newAttDef, eitherAllDataTypes);
+ // add the new property to resource on graph
+ StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty((AttributeDefinition)newAttDef, eitherAllDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
result = Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(validateAndUpdateAttribute), resource.getName()));
}
-
- Either<PropertyDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
+ Either<AttributeDataDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
if (eitherAttUpdate.isRight()) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, eitherAttUpdate.right().value());
@@ -251,9 +250,9 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<PropertyDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
+ public Either<AttributeDataDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
- Either<PropertyDefinition, ResponseFormat> result = null;
+ Either<AttributeDataDefinition, ResponseFormat> result = null;
validateUserExists(userId);
@@ -278,7 +277,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
// verify attribute exist in resource
- Either<PropertyDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
if (eitherAttributeExist.isRight()) {
return Either.right(eitherAttributeExist.right().value());
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 4ac3815a2b..ba1500c9be 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -49,6 +49,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
@@ -58,6 +59,7 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.facade.operations.CatalogOperation;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapReqDef;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -879,7 +881,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
clonedComponent.setDerivedFromGenericVersion(currentGenericVersion);
}
- private <T extends PropertyDataDefinition> Either<Map<String, T>, String> validateNoConflictingProperties(List<T> currentList, List<T> upgradedList) {
+ private <T extends ToscaDataDefinition> Either<Map<String, T>, String> validateNoConflictingProperties(List<T> currentList, List<T> upgradedList) {
Map<String, T> currentMap = ToscaDataDefinition.listToMapByName(currentList);
Map<String, T> upgradedMap = ToscaDataDefinition.listToMapByName(upgradedList);
return ToscaDataDefinition.mergeDataMaps(upgradedMap, currentMap, true);
@@ -888,15 +890,16 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
private boolean shouldUpgradeNodeType(Component componentToCheckOut, Resource latestGeneric){
List<PropertyDefinition> genericTypeProps = latestGeneric.getProperties();
- Either<Map<String, PropertyDefinition>, String> validMerge = validateNoConflictingProperties(genericTypeProps, ((Resource)componentToCheckOut).getProperties());
- if (validMerge.isRight()) {
- log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validMerge.right().value());
+ Either<Map<String, PropertyDefinition>, String> validPropertiesMerge = validateNoConflictingProperties(genericTypeProps, ((Resource)componentToCheckOut).getProperties());
+ if (validPropertiesMerge.isRight()) {
+ log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validPropertiesMerge.right().value());
return false;
}
- List<PropertyDefinition> genericTypeAttributes = latestGeneric.getAttributes();
- validMerge = validateNoConflictingProperties(genericTypeAttributes, ((Resource)componentToCheckOut).getAttributes());
- if (validMerge.isRight()) {
- log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validMerge.right().value());
+ List<AttributeDataDefinition> genericTypeAttributes = latestGeneric.getAttributes();
+ final Either<Map<String, AttributeDataDefinition>, String> validAttributesMerge = validateNoConflictingProperties(
+ genericTypeAttributes, ((Resource) componentToCheckOut).getAttributes());
+ if (validAttributesMerge.isRight()) {
+ log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validAttributesMerge.right().value());
return false;
}
return true;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index b0c9b308ab..e616ff87d3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -82,6 +82,7 @@ import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -133,7 +134,7 @@ import org.springframework.beans.factory.annotation.Autowired;
@org.springframework.stereotype.Component
public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
- private static final Logger log = Logger.getLogger(ComponentInstanceBusinessLogic.class.getName());
+ private static final Logger log = Logger.getLogger(ComponentInstanceBusinessLogic.class);
private static final String VF_MODULE = "org.openecomp.groups.VfModule";
private static final String TRY_TO_CREATE_ENTRY_ON_GRAPH = "Try to create entry on graph";
private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech";
@@ -2885,14 +2886,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
log.info("start to copy component instance with attributes");
- List<ComponentInstanceProperty> sourceAttributeList = null;
+ List<ComponentInstanceAttribute> sourceAttributeList = null;
if (sourceComponent.getComponentInstancesAttributes() != null
&& sourceComponent.getComponentInstancesAttributes().get(sourceComponentInstanceId) != null) {
sourceAttributeList = sourceComponent.getComponentInstancesAttributes().get(sourceComponentInstanceId);
log.info("sourceAttributes {}");
}
- List<ComponentInstanceProperty> destAttributeList = null;
+ List<ComponentInstanceAttribute> destAttributeList = null;
if (destComponent.getComponentInstancesAttributes() != null
&& destComponent.getComponentInstancesAttributes().get(destComponentInstanceId) != null) {
destAttributeList = destComponent.getComponentInstancesAttributes().get(destComponentInstanceId);
@@ -2901,18 +2902,18 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (null != sourceAttributeList && null != destAttributeList) {
log.info("set attribute");
- for (ComponentInstanceProperty sourceAttribute : sourceAttributeList) {
+ for (ComponentInstanceAttribute sourceAttribute : sourceAttributeList) {
String sourceAttributeName = sourceAttribute.getName();
- for (ComponentInstanceProperty destAttribute : destAttributeList) {
+ for (ComponentInstanceAttribute destAttribute : destAttributeList) {
if (sourceAttributeName.equals(destAttribute.getName())) {
- if (sourceAttribute.getValue() != null && !sourceAttribute.getValue().isEmpty()) {
+// if (sourceAttribute.getValue() != null && !sourceAttribute.getValue().isEmpty()) {
log.debug("Start to copy the attribute exists {}", sourceAttributeName);
sourceAttribute.setUniqueId(
UniqueIdBuilder.buildResourceInstanceUniuqeId(
"attribute" , destComponentInstanceId.split("\\.")[1] , sourceAttributeName));
- Either<ComponentInstanceProperty, ResponseFormat> updateAttributeValueEither =
+ Either<ComponentInstanceAttribute, ResponseFormat> updateAttributeValueEither =
createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum.SERVICE,
destComponent.getUniqueId(), destComponentInstanceId, sourceAttribute,
userId);
@@ -2923,7 +2924,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
"Failed to paste component instance to the canvas, attribute copy"));
}
break;
- }
+// }
}
}
}
@@ -2932,13 +2933,13 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return Either.left(COPY_COMPONENT_INSTANCE_OK);
}
- private Either<ComponentInstanceProperty, ResponseFormat> createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum componentTypeEnum,
+ private Either<ComponentInstanceAttribute, ResponseFormat> createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum componentTypeEnum,
String componentId,
String resourceInstanceId,
- ComponentInstanceProperty attribute,
+ ComponentInstanceAttribute attribute,
String userId) {
- Either<ComponentInstanceProperty, ResponseFormat> resultOp = null;
+ Either<ComponentInstanceAttribute, ResponseFormat> resultOp = null;
validateUserExists(userId);
@@ -2989,10 +2990,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
}
- List<ComponentInstanceProperty> instanceAttributes = containerComponent.
- getComponentInstancesAttributes().get(resourceInstanceId);
- Optional<ComponentInstanceProperty> instanceAttribute =
- instanceAttributes.stream().filter(p -> p.getUniqueId().equals(attribute.getUniqueId())).findAny();
+ List<ComponentInstanceAttribute> instanceAttributes = containerComponent.getComponentInstancesAttributes().get(resourceInstanceId);
+ Optional<ComponentInstanceAttribute> instanceAttribute = instanceAttributes.stream().filter(p -> p.getUniqueId().equals(attribute.getUniqueId())).findAny();
StorageOperationStatus status;
if (instanceAttribute.isPresent()) {
@@ -3024,9 +3023,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
resultOp = Either.left(attribute);
return resultOp;
-
-
-
}
private Either<String, ResponseFormat> updateComponentInstanceProperty(String containerComponentId,
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 cc6b359098..01698fa662 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
@@ -27,15 +27,19 @@ import com.google.gson.reflect.TypeToken;
import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
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.datatypes.elements.Annotation;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+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.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -86,7 +90,7 @@ public final class ImportUtils {
private static final CustomResolver customResolver = new CustomResolver();
private static final Yaml strictYamlLoader = new YamlLoader().getStrictYamlLoader();
- protected static ComponentsUtils componentsUtils;
+ private static ComponentsUtils componentsUtils;
private static final Logger log = Logger.getLogger(ImportUtils.class);
@@ -95,7 +99,7 @@ public final class ImportUtils {
@Autowired
public static void setComponentsUtils(ComponentsUtils componentsUtils) {
- ImportUtils.componentsUtils = componentsUtils;
+ componentsUtils = componentsUtils;
}
private static class CustomResolver extends Resolver {
@@ -112,7 +116,6 @@ public final class ImportUtils {
}
}
-
private static void buildMap(Map<String, Object> output, Map<String, Object> map) {
for (Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
@@ -186,9 +189,9 @@ public final class ImportUtils {
@SuppressWarnings("unchecked")
private static void handleElementNameNotFound(String elementName, Object elementValue, ToscaElementTypeEnum elementType, List<Object> returnedList) {
if (elementValue instanceof Map) {
- ImportUtils.findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
+ findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
} else if (elementValue instanceof List) {
- ImportUtils.findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
+ findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
}
}
@@ -209,13 +212,13 @@ public final class ImportUtils {
if (elementType == ToscaElementTypeEnum.MAP || elementType == ToscaElementTypeEnum.ALL) {
returnedList.add(elementValue);
}
- ImportUtils.findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
+ findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
} else if (elementValue instanceof List) {
if (elementType == ToscaElementTypeEnum.LIST || elementType == ToscaElementTypeEnum.ALL) {
returnedList.add(elementValue);
}
- ImportUtils.findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
+ findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
}
// For Integer, Double etc...
@@ -230,7 +233,7 @@ public final class ImportUtils {
public static Either<Object, ResultStatusEnum> findToscaElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementName, ToscaElementTypeEnum elementType) {
List<Object> foundElements = new ArrayList<>();
- ImportUtils.findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements);
+ findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements);
if (!isEmpty(foundElements)) {
return Either.left(foundElements.get(0));
}
@@ -398,24 +401,21 @@ 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 = ImportUtils.findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL);
+ 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();
AnnotationTypeDefinition annotationTypeObject = annotationTypeOperations.getLatestType(parsedAnnotationType);
if (annotationTypeObject != null) {
Annotation annotation = new Annotation();
- ImportUtils.setField(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE, annotation::setType);
- ImportUtils.setField(annotationMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, annotation::setDescription);
+ setField(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE, annotation::setType);
+ setField(annotationMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, annotation::setDescription);
Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = getProperties(annotationMap);
modifyPropertiesKeysToProperForm(properties, annotation);
return annotation;
@@ -454,26 +454,25 @@ public final class ImportUtils {
public static InputDefinition createModuleInput(Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations) {
InputDefinition inputDef = new InputDefinition();
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType);
- ImportUtils.setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req)));
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, inputDef::setDescription);
+ 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);
- ImportUtils.setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> inputDef.setPassword(Boolean.parseBoolean(pass)));
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.STATUS, inputDef::setStatus);
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.LABEL, inputDef::setLabel);
- ImportUtils.setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.HIDDEN, hidden -> inputDef.setHidden(Boolean.parseBoolean(hidden)));
- ImportUtils.setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IMMUTABLE, immutable -> inputDef.setImmutable(Boolean.parseBoolean(immutable)));
+ setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> inputDef.setPassword(Boolean.parseBoolean(pass)));
+ setField(inputValue, TypeUtils.ToscaTagNamesEnum.STATUS, inputDef::setStatus);
+ setField(inputValue, TypeUtils.ToscaTagNamesEnum.LABEL, inputDef::setLabel);
+ setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.HIDDEN, hidden -> inputDef.setHidden(Boolean.parseBoolean(hidden)));
+ setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IMMUTABLE, immutable -> inputDef.setImmutable(Boolean.parseBoolean(immutable)));
- ImportUtils.setScheme(inputValue, inputDef);
- ImportUtils.setPropertyConstraints(inputValue, inputDef);
+ setScheme(inputValue, inputDef);
+ setPropertyConstraints(inputValue, inputDef);
return parseAnnotationsAndAddItToInput(inputDef, inputValue, 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);
@@ -489,30 +488,29 @@ public final class ImportUtils {
return inputDef;
}
+ public static AttributeDefinition createModuleAttribute(Map<String, Object> attributeMap) {
- public static PropertyDefinition createModuleAttribute(Map<String, Object> attributeMap) {
-
- PropertyDefinition attributeDef = new PropertyDefinition();
+ AttributeDefinition attributeDef = new AttributeDefinition();
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.TYPE, attributeDef::setType);
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, attributeDef::setDescription);
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.STATUS, attributeDef::setStatus);
- setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(), attributeDef::setDefaultValue);
- setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.VALUE, attributeDef.getType(), attributeDef::setValue);
+ setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(), attributeDef::set_default);
setScheme(attributeMap, attributeDef);
return attributeDef;
}
- private static void setScheme(Map<String, Object> propertyValue, PropertyDefinition propertyDefinition) {
+ private static void setScheme(Map<String, Object> propertyValue,
+ ToscaDataDefinition toscaDataDefinition) {
Either<Object, ResultStatusEnum> schemaElementRes = findSchemaElement(propertyValue);
if (schemaElementRes.isLeft()) {
SchemaDefinition schemaDef = getSchema(schemaElementRes.left().value());
- propertyDefinition.setSchema(schemaDef);
+ toscaDataDefinition.setSchema(schemaDef);
}
}
- private static Either<Object,ResultStatusEnum> findSchemaElement(Map<String, Object> propertyValue) {
+ private static Either<Object, ResultStatusEnum> findSchemaElement(Map<String, Object> propertyValue) {
return findToscaElement(propertyValue, TypeUtils.ToscaTagNamesEnum.ENTRY_SCHEMA, ToscaElementTypeEnum.ALL);
}
@@ -546,8 +544,8 @@ public final class ImportUtils {
}
-
- public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getProperties(Map<String, Object> toscaJson) {
+ public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getProperties(
+ Map<String, Object> toscaJson) {
Function<String, PropertyDefinition> elementGenByName = ImportUtils::createProperties;
Function<Map<String, Object>, PropertyDefinition> func = ImportUtils::createModuleProperty;
@@ -555,25 +553,31 @@ public final class ImportUtils {
}
- public static Either<Map<String, InputDefinition>, ResultStatusEnum> getInputs(Map<String, Object> toscaJson, AnnotationTypeOperations annotationTypeOperations) {
+ public static Either<Map<String, InputDefinition>, ResultStatusEnum> getInputs(Map<String, Object> toscaJson,
+ AnnotationTypeOperations annotationTypeOperations) {
Function<String, InputDefinition> elementGenByName = ImportUtils::createInputs;
- Function<Map<String, Object>, InputDefinition> func = object -> createModuleInput(object, annotationTypeOperations);
+ Function<Map<String, Object>, InputDefinition> func = object -> createModuleInput(object,
+ annotationTypeOperations);
return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, elementGenByName, func);
}
- public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getAttributes(Map<String, Object> toscaJson) {
- Function<String, PropertyDefinition> elementGenByName = ImportUtils::createAttribute;
- Function<Map<String, Object>, PropertyDefinition> func = ImportUtils::createModuleAttribute;
+ public static Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> getAttributes(
+ Map<String, Object> toscaJson) {
+ Function<String, AttributeDataDefinition> elementGenByName = ImportUtils::createAttribute;
+ Function<Map<String, Object>, AttributeDataDefinition> func = ImportUtils::createModuleAttribute;
return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.ATTRIBUTES, elementGenByName, func);
}
- public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName, Function<String, T> elementGenByName,
+ public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum elementTagName,
+ Function<String, T> elementGenByName,
Function<Map<String, Object>, T> func) {
Either<Map<String, T>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson, elementTagName);
+ Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson,
+ elementTagName);
if (toscaAttributes.isLeft()) {
Map<String, Object> jsonAttributes = toscaAttributes.left().value();
Map<String, T> moduleAttributes = new HashMap<>();
@@ -583,7 +587,7 @@ public final class ImportUtils {
if (attributeNameValue.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
T attribute = func.apply((Map<String, Object>) attributeNameValue.getValue());
- if (attribute != null){
+ if (attribute != null) {
moduleAttributes.put(String.valueOf(attributeNameValue.getKey()), attribute);
}
}
@@ -601,8 +605,8 @@ public final class ImportUtils {
}
- private static PropertyDefinition createAttribute(String name) {
- PropertyDefinition attribute = new PropertyDefinition();
+ private static AttributeDefinition createAttribute(String name) {
+ AttributeDefinition attribute = new AttributeDefinition();
attribute.setName(name);
return attribute;
@@ -615,8 +619,6 @@ public final class ImportUtils {
return property;
}
-
-
private static InputDefinition createInputs(String name) {
InputDefinition input = new InputDefinition();
@@ -630,8 +632,6 @@ public final class ImportUtils {
return annotation;
}
-
-
public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParameters(Map<String, Object> heatData, String artifactType) {
Either<List<HeatParameterDefinition>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
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 6e3019c0c3..35a0761ff1 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
@@ -94,6 +94,7 @@ import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
@@ -109,6 +110,7 @@ import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
@@ -2617,8 +2619,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getUniqueId(), yamlName);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS,resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,"No instances found in the resource: {}, is empty, yaml template file name: {}",resource.getName(),yamlName);
BeEcompErrorManager.getInstance()
- .logInternalDataError("createResourceInstancesRelations",
- "No instances found in a resource or nn yaml template. ", ErrorSeverity.ERROR);
+ .logInternalDataError("createResourceInstancesRelations",
+ "No instances found in a resource or nn yaml template. ", ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
@@ -2626,17 +2628,17 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List<PropertyDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
log.debug("#createResourceInstancesRelations - Before get all datatypes. ");
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right()
- .value();
+ .value();
BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance",
+ .logInternalFlowError("UpdatePropertyValueOnComponentInstance",
"Failed to update property value on instance. Status is " + status, ErrorSeverity.ERROR);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS,resource.getComponentMetadataForSupportLog(),
StatusCode.ERROR,"ERROR while update property value on instance. Status is: "+status);
@@ -2683,32 +2685,39 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
- Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, List<ComponentInstanceInput>> instInputs, Map<String, List<PropertyDefinition>> instAttributes) {
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String,
+ List<ComponentInstanceProperty>> instProperties, Map<String,
+ List<ComponentInstanceInput>> instInputs,
+ Map<String, List<AttributeDataDefinition>> instAttributes) {
Optional<ComponentInstance> foundInstance = findInstance(oldResource, instance);
- if(foundInstance.isPresent()){
- if(MapUtils.isNotEmpty(foundInstance.get().getCapabilities())){
+ if (foundInstance.isPresent()) {
+ if (MapUtils.isNotEmpty(foundInstance.get().getCapabilities())) {
instCapabilities.put(instance, foundInstance.get().getCapabilities());
}
- if(MapUtils.isNotEmpty(foundInstance.get().getRequirements())){
+ if (MapUtils.isNotEmpty(foundInstance.get().getRequirements())) {
instRequirements.put(instance, foundInstance.get().getRequirements());
}
- if(MapUtils.isNotEmpty(foundInstance.get().getDeploymentArtifacts())){
+ if (MapUtils.isNotEmpty(foundInstance.get().getDeploymentArtifacts())) {
instDeploymentArtifacts.put(instance.getUniqueId(), foundInstance.get().getDeploymentArtifacts());
}
if(MapUtils.isNotEmpty(foundInstance.get().getArtifacts())){
instArtifacts.put(instance.getUniqueId(), foundInstance.get().getArtifacts());
}
- if(MapUtils.isNotEmpty(oldResource.getComponentInstancesProperties()) &&
- CollectionUtils.isNotEmpty(oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()))){
- instProperties.put(instance.getUniqueId(), oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()));
+ if (MapUtils.isNotEmpty(oldResource.getComponentInstancesProperties()) &&
+ CollectionUtils
+ .isNotEmpty(oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()))) {
+ instProperties.put(instance.getUniqueId(),
+ oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()));
}
- if(MapUtils.isNotEmpty(oldResource.getComponentInstancesInputs()) &&
- CollectionUtils.isNotEmpty(oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()))){
- instInputs.put(instance.getUniqueId(), oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()));
+ if (MapUtils.isNotEmpty(oldResource.getComponentInstancesInputs()) &&
+ CollectionUtils
+ .isNotEmpty(oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()))) {
+ instInputs.put(instance.getUniqueId(),
+ oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()));
}
if(MapUtils.isNotEmpty(oldResource.getComponentInstancesAttributes()) &&
CollectionUtils.isNotEmpty(oldResource.getComponentInstancesAttributes().get(foundInstance.get().getUniqueId()))){
- instAttributes.put(instance.getUniqueId(), oldResource.getComponentInstancesAttributes().get(foundInstance.get().getUniqueId()).stream().map(PropertyDefinition::new).collect(toList()));
+ instAttributes.put(instance.getUniqueId(), oldResource.getComponentInstancesAttributes().get(foundInstance.get().getUniqueId()).stream().map(AttributeDefinition::new).collect(toList()));
}
}
}
@@ -2735,14 +2744,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void associateInstAttributeToComponentToInstances(String yamlName, Resource resource,
- Map<String, List<PropertyDefinition>> instAttributes) {
+ Map<String, List<AttributeDataDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
- resource);
+ resource);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
- addArtToInst);
- throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName);
+ addArtToInst);
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(addArtToInst),
+ yamlName);
}
}
@@ -2890,7 +2900,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
Map<String, Map<String, ArtifactDefinition>> instArtifacts,
- Map<String, List<PropertyDefinition>> instAttributes, Map<String, Resource> originCompMap,
+ Map<String, List<AttributeDataDefinition>> instAttributes,
+ Map<String, Resource> originCompMap,
Map<String, List<ComponentInstanceInput>> instInputs,
UploadComponentInstanceInfo uploadComponentInstanceInfo) {
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
@@ -2914,24 +2925,22 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (isNotEmpty(originResource.getCapabilities())) {
processComponentInstanceCapabilities(allDataTypes, instCapabilties, uploadComponentInstanceInfo,
- currentCompInstance, originResource);
+ currentCompInstance, originResource);
}
if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts()
- .isEmpty()) {
+ .isEmpty()) {
instDeploymentArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
}
- if (originResource.getArtifacts() != null && !originResource.getArtifacts()
- .isEmpty()) {
+ if (originResource.getArtifacts() != null && !originResource.getArtifacts().isEmpty()) {
instArtifacts.put(resourceInstanceId, originResource.getArtifacts());
}
- if (originResource.getAttributes() != null && !originResource.getAttributes()
- .isEmpty()) {
+ if (originResource.getAttributes() != null && !originResource.getAttributes().isEmpty()) {
instAttributes.put(resourceInstanceId, originResource.getAttributes());
}
if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource,
- originResource, currentCompInstance, instProperties, allDataTypes.left()
- .value());
+ originResource, currentCompInstance, instProperties, allDataTypes.left()
+ .value());
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ByResponseFormatComponentException(addPropertiesValueToRiRes);
}
@@ -3982,11 +3991,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
mergeOldResourceMetadataWithNew(oldResource, newResource);
validateResourceFieldsBeforeUpdate(oldResource, newResource, inTransaction, isNested);
- validateCapabilityTypesCreate(user, getCapabilityTypeOperation(), newResource,
- AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
+ validateCapabilityTypesCreate(user, getCapabilityTypeOperation(), newResource, AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
// contact info normalization
- newResource.setContactId(newResource.getContactId()
- .toLowerCase());
+ newResource.setContactId(newResource.getContactId().toLowerCase());
PropertyConstraintsUtils.validatePropertiesConstraints(newResource, oldResource);
// non-updatable fields
newResource.setCreatorUserId(user.getUserId());
@@ -4008,58 +4015,56 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
newResource.setAbstract(oldResource.isAbstract());
- if (newResource.getDerivedFrom() == null || newResource.getDerivedFrom()
- .isEmpty()) {
+ if (CollectionUtils.isEmpty(newResource.getDerivedFrom())) {
newResource.setDerivedFrom(oldResource.getDerivedFrom());
}
- if (newResource.getDerivedFromGenericType() == null || newResource.getDerivedFromGenericType()
- .isEmpty()) {
+ if (StringUtils.isEmpty(newResource.getDerivedFromGenericType())) {
newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
}
- if (newResource.getDerivedFromGenericVersion() == null || newResource.getDerivedFromGenericVersion()
- .isEmpty()) {
+ if (StringUtils.isEmpty(newResource.getDerivedFromGenericVersion())) {
newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
}
// add for new)
// created without tosca artifacts - add the placeholders
- if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts()
- .isEmpty()) {
+ if (MapUtils.isEmpty(newResource.getToscaArtifacts())) {
setToscaArtifactsPlaceHolders(newResource, user);
}
- if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
+ if (MapUtils.isEmpty(newResource.getInterfaces())) {
newResource.setInterfaces(oldResource.getInterfaces());
}
+ if (CollectionUtils.isEmpty(newResource.getAttributes())) {
+ newResource.setAttributes(oldResource.getAttributes());
+ }
- if (CollectionUtils.isEmpty(newResource.getProperties())) {
- newResource.setProperties(oldResource.getProperties());
- }
+ if (CollectionUtils.isEmpty(newResource.getProperties())) {
+ newResource.setProperties(oldResource.getProperties());
+ }
- Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade
- .overrideComponent(newResource, oldResource);
+ Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade.overrideComponent(newResource, oldResource);
if (overrideResource.isRight()) {
ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(overrideResource.right()
- .value()), newResource);
+ .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(overrideResource.right()
+ .value()), newResource);
componentsUtils.auditResource(responseFormat, user, newResource, AuditingActionEnum.IMPORT_RESOURCE);
throwComponentException(responseFormat);
}
updateCatalog(overrideResource.left()
- .value(), ChangeTypeEnum.LIFECYCLE);
+ .value(), ChangeTypeEnum.LIFECYCLE);
log.debug("Resource updated successfully!!!");
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
componentsUtils.auditResource(responseFormat, user, newResource, AuditingActionEnum.IMPORT_RESOURCE,
- ResourceVersionInfo.newBuilder()
- .state(oldResource.getLifecycleState()
- .name())
- .version(oldResource.getVersion())
- .build());
+ ResourceVersionInfo.newBuilder()
+ .state(oldResource.getLifecycleState()
+ .name())
+ .version(oldResource.getVersion())
+ .build());
resourcePair = new ImmutablePair<>(overrideResource.left()
- .value(), ActionStatus.OK);
+ .value(), ActionStatus.OK);
return resourcePair;
} finally {
if (resourcePair == null) {
@@ -4439,7 +4444,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw e;
} finally {
- if (!inTransaction) {
+ if (!inTransaction) {
graphLockOperation.unlockComponentByName(resource.getSystemName(), resource.getUniqueId(),
NodeTypeEnum.Resource);
}
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 46942d96d4..1a0dfaa9fd 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,6 +23,7 @@
package org.openecomp.sdc.be.components.impl;
import static org.openecomp.sdc.be.components.impl.ImportUtils.Constants.QUOTE;
+import static org.openecomp.sdc.be.utils.TypeUtils.setField;
import fj.data.Either;
import java.util.LinkedHashMap;
@@ -43,6 +44,7 @@ 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.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
@@ -53,7 +55,9 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+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.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -100,6 +104,7 @@ import java.util.stream.Collectors;
@Component("resourceImportManager")
public class ResourceImportManager {
+
private static final Logger log = Logger.getLogger(ResourceImportManager.class);
static final Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern.compile("[\\w\\-\\_\\d\\:]+");
@@ -136,27 +141,46 @@ public class ResourceImportManager {
this.toscaOperationFacade = toscaOperationFacade;
}
- public ImmutablePair<Resource, ActionStatus> importNormativeResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
+ public ImmutablePair<Resource, ActionStatus> importNormativeResource(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator, boolean createNewVersion,
+ boolean needLock) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
lifecycleChangeInfo.setUserRemarks("certification on import");
- Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
+ Function<Resource, Boolean> validator = resource -> resourceBusinessLogic
+ .validatePropertiesDefaultValues(resource);
- return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false, null, null, false);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false,
+ createNewVersion, needLock, null, null, false, null, null, false);
}
- public ImmutablePair<Resource, ActionStatus> importNormativeResourceFromCsar(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
+ public ImmutablePair<Resource, ActionStatus> importNormativeResourceFromCsar(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator, boolean createNewVersion,
+ boolean needLock) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
lifecycleChangeInfo.setUserRemarks("certification on import");
- Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
+ Function<Resource, Boolean> validator = resource -> resourceBusinessLogic
+ .validatePropertiesDefaultValues(resource);
- return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false, null, null, false);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false,
+ createNewVersion, needLock, null, null, false, null, null, false);
}
- public ImmutablePair<Resource, ActionStatus> importCertifiedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator,
+ public ImmutablePair<Resource, ActionStatus> importCertifiedResource(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator,
Function<Resource, Boolean> validationFunction,
- LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean isInTransaction, boolean createNewVersion, boolean needLock, Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo, String nodeName, boolean isNested) {
+ LifecycleChangeInfoWithAction lifecycleChangeInfo,
+ boolean isInTransaction,
+ boolean createNewVersion, boolean needLock,
+ Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ boolean forceCertificationAllowed,
+ CsarInfo csarInfo, String nodeName,
+ boolean isNested) {
Resource resource = new Resource();
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> response = Either.left(responsePair);
@@ -170,32 +194,38 @@ public class ResourceImportManager {
populateResourceFromYaml(resourceYml, resource);
Boolean isValidResource = validationFunction.apply(resource);
- if (!createNewVersion) {
- Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade.getLatestByName(resource.getName());
- if (latestByName.isLeft()) {
- throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, resource.getName());
- }
+ if (!createNewVersion) {
+ Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade
+ .getLatestByName(resource.getName());
+ if (latestByName.isLeft()) {
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,
+ resource.getName());
}
- resource = resourceBusinessLogic.createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName, isNested).left;
- Resource changeStateResponse;
-
- if (nodeTypeArtifactsToHandle != null && !nodeTypeArtifactsToHandle.isEmpty()) {
- Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
- resourceBusinessLogic.handleNodeTypeArtifacts(resource, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, creator, isInTransaction, false);
- if (handleNodeTypeArtifactsRes.isRight()) {
- //TODO: should be used more correct action
- throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
- }
+ }
+ resource = resourceBusinessLogic
+ .createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName,
+ isNested).left;
+ Resource changeStateResponse;
+
+ if (nodeTypeArtifactsToHandle != null && !nodeTypeArtifactsToHandle.isEmpty()) {
+ Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
+ resourceBusinessLogic
+ .handleNodeTypeArtifacts(resource, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts,
+ creator, isInTransaction, false);
+ if (handleNodeTypeArtifactsRes.isRight()) {
+ //TODO: should be used more correct action
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
- latestCertifiedResourceId = getLatestCertifiedResourceId(resource);
- changeStateResponse = resourceBusinessLogic.propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock, forceCertificationAllowed);
- responsePair = new ImmutablePair<>(changeStateResponse, response.left()
- .value().right);
- }
- catch (RuntimeException e) {
+ }
+ latestCertifiedResourceId = getLatestCertifiedResourceId(resource);
+ changeStateResponse = resourceBusinessLogic
+ .propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock,
+ forceCertificationAllowed);
+ responsePair = new ImmutablePair<>(changeStateResponse, response.left()
+ .value().right);
+ } catch (RuntimeException e) {
handleImportResourceException(resourceMetaData, creator, true, e);
- }
- finally {
+ } finally {
if (latestCertifiedResourceId != null && needLock) {
log.debug("unlock resource {}", latestCertifiedResourceId);
graphLockOperation.unlockComponent(latestCertifiedResourceId, NodeTypeEnum.Resource);
@@ -206,9 +236,11 @@ public class ResourceImportManager {
}
private ResponseFormat getResponseFormatFromComponentException(RuntimeException e) {
- if(e instanceof ComponentException){
+ if (e instanceof ComponentException) {
return ((ComponentException) e).getResponseFormat() == null ?
- componentsUtils.getResponseFormat(((ComponentException) e).getActionStatus(), ((ComponentException) e).getParams()) :
+ componentsUtils
+ .getResponseFormat(((ComponentException) e).getActionStatus(), ((ComponentException) e).getParams())
+ :
((ComponentException) e).getResponseFormat();
}
return null;
@@ -225,8 +257,7 @@ public class ResourceImportManager {
}
}
return allVersions.get(String.valueOf(latestCertifiedVersion));
- }
- else {
+ } else {
return null;
}
}
@@ -250,7 +281,9 @@ public class ResourceImportManager {
}
}
- public ImmutablePair<Resource, ActionStatus> importUserDefinedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean isInTransaction) {
+ public ImmutablePair<Resource, ActionStatus> importUserDefinedResource(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator, boolean isInTransaction) {
Resource resource = new Resource();
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
@@ -271,10 +304,9 @@ public class ResourceImportManager {
Boolean validatePropertiesTypes = resourceBusinessLogic.validatePropertiesDefaultValues(resource);
responsePair = resourceBusinessLogic.createOrUpdateResourceByImport(resource, creator,
- false, isInTransaction, true, null, null, false);
+ false, isInTransaction, true, null, null, false);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
handleImportResourceException(resourceMetaData, creator, false, e);
}
return responsePair;
@@ -289,9 +321,11 @@ public class ResourceImportManager {
Map<String, Object> toscaJson = toscaJsonAll;
// Checks if exist and builds the node_types map
- if (toscaJsonAll.containsKey(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()) && resource.getResourceType() != ResourceTypeEnum.CVFC) {
+ if (toscaJsonAll.containsKey(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName())
+ && resource.getResourceType() != ResourceTypeEnum.CVFC) {
toscaJson = new HashMap<>();
- toscaJson.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(), toscaJsonAll.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()));
+ toscaJson.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(),
+ toscaJsonAll.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()));
}
// Derived From
Resource parentResource = setDerivedFrom(toscaJson, resource);
@@ -303,15 +337,15 @@ public class ResourceImportManager {
setProperties(toscaJson, resource);
setRequirements(toscaJson, resource, parentResource);
setInterfaceLifecycle(toscaJson, resource);
- }
- else {
+ } else {
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
}
private void setToscaResourceName(Map<String, Object> toscaJson, Resource resource) {
- Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils.findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
+ Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils
+ .findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
if (toscaElement.isLeft() || toscaElement.left().value().size() == 1) {
String toscaResourceName = toscaElement.left().value().keySet().iterator().next();
resource.setToscaResourceName(toscaResourceName);
@@ -319,7 +353,8 @@ public class ResourceImportManager {
}
private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource) {
- Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils.findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.INTERFACES);
+ Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils
+ .findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.INTERFACES);
if (toscaInterfaces.isLeft()) {
Map<String, Object> jsonInterfaces = toscaInterfaces.left().value();
Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>();
@@ -327,11 +362,11 @@ public class ResourceImportManager {
while (interfacesNameValue.hasNext()) {
Entry<String, Object> interfaceNameValue = interfacesNameValue.next();
Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue
- .getValue(), resource);
+ .getValue(), resource);
if (eitherInterface.isRight()) {
- log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(), resource.getName());
- }
- else {
+ log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(),
+ resource.getName());
+ } else {
moduleInterfaces.put(interfaceNameValue.getKey(), eitherInterface.left().value());
}
@@ -342,7 +377,8 @@ public class ResourceImportManager {
}
}
- private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(Object interfaceJson, Resource resource) {
+ private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(Object interfaceJson,
+ Resource resource) {
final InterfaceDefinition interf = new InterfaceDefinition();
Either<InterfaceDefinition, ResultStatusEnum> result = Either.left(interf);
@@ -384,8 +420,7 @@ public class ResourceImportManager {
result = Either.right(ResultStatusEnum.GENERAL_ERROR);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
BeEcompErrorManager.getInstance().logBeSystemError("Import Resource- create interface");
log.debug("error when creating interface, message:{}", e.getMessage(), e);
result = Either.right(ResultStatusEnum.GENERAL_ERROR);
@@ -405,7 +440,8 @@ public class ResourceImportManager {
return implementation;
}
- private ListDataDefinition<OperationInputDefinition> handleInterfaceInput(final Map<String, Object> interfaceInputs) {
+ private ListDataDefinition<OperationInputDefinition> handleInterfaceInput(
+ final Map<String, Object> interfaceInputs) {
final ListDataDefinition<OperationInputDefinition> inputs = new ListDataDefinition<>();
for (final Entry<String, Object> interfaceInput : interfaceInputs.entrySet()) {
final OperationInputDefinition operationInput = new OperationInputDefinition();
@@ -446,52 +482,60 @@ public class ResourceImportManager {
}
private boolean entryIsInterfaceType(final Entry<String, Object> entry) {
- if(entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
- if (entry.getValue() instanceof String) {
- return true;
- }
- throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
- }
- return false;
+ if (entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
+ if (entry.getValue() instanceof String) {
+ return true;
+ }
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
+ }
+ return false;
}
-
- 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())){
- return true;
- }
- throw new ByActionStatusComponentException(ActionStatus.INTERFACE_OPERATION_NOT_FOUND);
- }
- return false;
+
+ 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())) {
+ return true;
+ }
+ throw new ByActionStatusComponentException(ActionStatus.INTERFACE_OPERATION_NOT_FOUND);
+ }
+ return false;
}
-
- private boolean isAKnownOperation(String interfaceType, String operation) {
- Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
- if (interfaceLifecycleTypes.isRight() || interfaceLifecycleTypes.left().value() == null) {
- return false;
- }
-
- for (Entry<String, InterfaceDefinition> interfaceLifecycleType : interfaceLifecycleTypes.left().value().entrySet()) {
- if (interfaceTypeAndOperationMatches(interfaceLifecycleType, interfaceType, operation)) {
- return true;
- }
- }
- return false;
+
+ private boolean isAKnownOperation(String interfaceType, String operation) {
+ Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = interfaceOperationBusinessLogic
+ .getAllInterfaceLifecycleTypes();
+ if (interfaceLifecycleTypes.isRight() || interfaceLifecycleTypes.left().value() == null) {
+ return false;
+ }
+
+ for (Entry<String, InterfaceDefinition> interfaceLifecycleType : interfaceLifecycleTypes.left().value()
+ .entrySet()) {
+ if (interfaceTypeAndOperationMatches(interfaceLifecycleType, interfaceType, operation)) {
+ return true;
+ }
+ }
+ return false;
}
-
- private boolean interfaceTypeAndOperationMatches(Entry<String, InterfaceDefinition> interfaceLifecycleType, String interfaceType, String operation) {
- if (interfaceLifecycleType.getKey().equalsIgnoreCase(interfaceType) && interfaceLifecycleType.getValue().getOperations() != null) {
- for (String interfaceLifecycleTypeOperation : interfaceLifecycleType.getValue().getOperations().keySet()) {
- if (interfaceLifecycleTypeOperation != null && interfaceLifecycleTypeOperation.equalsIgnoreCase(operation)){
- return true;
- }
- }
- }
- return false;
+
+ private boolean interfaceTypeAndOperationMatches(Entry<String, InterfaceDefinition> interfaceLifecycleType,
+ String interfaceType, String operation) {
+ if (interfaceLifecycleType.getKey().equalsIgnoreCase(interfaceType)
+ && interfaceLifecycleType.getValue().getOperations() != null) {
+ for (String interfaceLifecycleTypeOperation : interfaceLifecycleType.getValue().getOperations().keySet()) {
+ if (interfaceLifecycleTypeOperation != null && interfaceLifecycleTypeOperation
+ .equalsIgnoreCase(operation)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
- private void setRequirements(Map<String, Object> toscaJson, Resource resource, Resource parentResource) {// Note that parentResource can be null
- Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils.findFirstToscaListElement(toscaJson, TypeUtils.ToscaTagNamesEnum.REQUIREMENTS);
+ private void setRequirements(Map<String, Object> toscaJson, Resource resource,
+ Resource parentResource) {// Note that parentResource can be null
+ Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils
+ .findFirstToscaListElement(toscaJson, TypeUtils.ToscaTagNamesEnum.REQUIREMENTS);
if (toscaRequirements.isLeft()) {
List<Object> jsonRequirements = toscaRequirements.left().value();
Map<String, List<RequirementDefinition>> moduleRequirements = new HashMap<>();
@@ -506,17 +550,19 @@ public class ResourceImportManager {
String requirementName = requirementJsonWrapper.keySet().iterator().next();
String reqNameLowerCase = requirementName.toLowerCase();
if (reqNames.contains(reqNameLowerCase)) {
- log.debug("More than one requirement with same name {} (case-insensitive) in imported TOSCA file is invalid", reqNameLowerCase);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "requirement", reqNameLowerCase);
+ log.debug(
+ "More than one requirement with same name {} (case-insensitive) in imported TOSCA file is invalid",
+ reqNameLowerCase);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME,
+ "requirement", reqNameLowerCase);
}
reqNames.add(reqNameLowerCase);
RequirementDefinition requirementDef = createRequirementFromImportFile(requirementJsonWrapper
- .get(requirementName));
+ .get(requirementName));
requirementDef.setName(requirementName);
if (moduleRequirements.containsKey(requirementDef.getCapability())) {
moduleRequirements.get(requirementDef.getCapability()).add(requirementDef);
- }
- else {
+ } else {
List<RequirementDefinition> list = new ArrayList<>();
list.add(requirementDef);
moduleRequirements.put(requirementDef.getCapability(), list);
@@ -524,13 +570,15 @@ public class ResourceImportManager {
// Validating against req/cap of "derived from" node
Boolean validateVsParentCap = validateCapNameVsDerived(reqName2TypeMap, requirementDef
- .getCapability(), requirementDef.getName());
+ .getCapability(), requirementDef.getName());
if (!validateVsParentCap) {
String parentResourceName = parentResource != null ? parentResource.getName() : "";
- log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(), parentResourceName);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "requirement", requirementDef
- .getName()
- .toLowerCase(), parentResourceName);
+ log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(),
+ parentResourceName);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
+ "requirement", requirementDef
+ .getName()
+ .toLowerCase(), parentResourceName);
}
}
if (moduleRequirements.size() > 0) {
@@ -538,7 +586,7 @@ public class ResourceImportManager {
}
}
- }
+ }
private RequirementDefinition createRequirementFromImportFile(Object requirementJson) {
RequirementDefinition requirement = new RequirementDefinition();
@@ -546,11 +594,11 @@ public class ResourceImportManager {
if (requirementJson instanceof String) {
String requirementJsonString = (String) requirementJson;
requirement.setCapability(requirementJsonString);
- }
- else if (requirementJson instanceof Map) {
+ } else if (requirementJson instanceof Map) {
Map<String, Object> requirementJsonMap = (Map<String, Object>) requirementJson;
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.CAPABILITY.getElementName())) {
- requirement.setCapability((String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.CAPABILITY.getElementName()));
+ requirement.setCapability(
+ (String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.CAPABILITY.getElementName()));
}
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.NODE.getElementName())) {
@@ -558,16 +606,17 @@ public class ResourceImportManager {
}
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.RELATIONSHIP.getElementName())) {
- requirement.setRelationship((String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.RELATIONSHIP.getElementName()));
+ requirement.setRelationship(
+ (String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.RELATIONSHIP.getElementName()));
}
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
- List<Object> occurrencesList = (List) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
+ List<Object> occurrencesList = (List) requirementJsonMap
+ .get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
validateOccurrences(occurrencesList);
requirement.setMinOccurrences(occurrencesList.get(0).toString());
requirement.setMaxOccurrences(occurrencesList.get(1).toString());
}
- }
- else {
+ } else {
throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
}
return requirement;
@@ -576,7 +625,8 @@ public class ResourceImportManager {
private void setProperties(Map<String, Object> toscaJson, Resource resource) {
Map<String, Object> reducedToscaJson = new HashMap<>(toscaJson);
ImportUtils.removeElementFromJsonMap(reducedToscaJson, "capabilities");
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(reducedToscaJson);
+ Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils
+ .getProperties(reducedToscaJson);
if (properties.isLeft()) {
List<PropertyDefinition> propertiesList = new ArrayList<>();
Map<String, PropertyDefinition> value = properties.left().value();
@@ -584,8 +634,11 @@ public class ResourceImportManager {
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 {} occured upon import resource {}. ", name, resource.getName());
- throw new ByActionStatusComponentException(componentsUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, JsonPresentationFields.PROPERTY));
+ log.debug("The property with invalid name {} occured upon import resource {}. ", name,
+ resource.getName());
+ throw new ByActionStatusComponentException(componentsUtils
+ .convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME,
+ JsonPresentationFields.PROPERTY));
}
PropertyDefinition propertyDefinition = entry.getValue();
propertyDefinition.setName(name);
@@ -593,44 +646,45 @@ public class ResourceImportManager {
}
}
resource.setProperties(propertiesList);
- }
- else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) {
+ } else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) {
throw new ByActionStatusComponentException(componentsUtils.convertFromResultStatusEnum(properties
- .right()
- .value(), JsonPresentationFields.PROPERTY));
+ .right()
+ .value(), JsonPresentationFields.PROPERTY));
}
}
private ResultStatusEnum setAttributes(Map<String, Object> toscaJson, Resource resource) {
ResultStatusEnum result = ResultStatusEnum.OK;
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> attributes = ImportUtils.getAttributes(toscaJson);
+ Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> attributes = ImportUtils
+ .getAttributes(toscaJson);
if (attributes.isLeft()) {
- List<PropertyDefinition> attributeList = new ArrayList<>();
- Map<String, PropertyDefinition> value = attributes.left().value();
+ List<AttributeDataDefinition> attributeList = new ArrayList<>();
+ Map<String, AttributeDataDefinition> value = attributes.left().value();
if (value != null) {
- for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
+ for (Entry<String, AttributeDataDefinition> entry : value.entrySet()) {
String name = entry.getKey();
- PropertyDefinition attributeDef = entry.getValue();
+ AttributeDataDefinition attributeDef = entry.getValue();
attributeDef.setName(name);
attributeList.add(attributeDef);
}
}
resource.setAttributes(attributeList);
- }
- else {
+ } else {
result = attributes.right().value();
}
return result;
}
private Resource setDerivedFrom(Map<String, Object> toscaJson, Resource resource) {
- Either<String, ResultStatusEnum> toscaDerivedFromElement = ImportUtils.findFirstToscaStringElement(toscaJson, TypeUtils.ToscaTagNamesEnum.DERIVED_FROM);
+ Either<String, ResultStatusEnum> toscaDerivedFromElement = ImportUtils
+ .findFirstToscaStringElement(toscaJson, TypeUtils.ToscaTagNamesEnum.DERIVED_FROM);
Resource derivedFromResource = null;
if (toscaDerivedFromElement.isLeft()) {
String derivedFrom = toscaDerivedFromElement.left().value();
log.debug("Derived from TOSCA name is {}", derivedFrom);
resource.setDerivedFrom(Arrays.asList(new String[]{derivedFrom}));
- Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade.getLatestByToscaResourceName(derivedFrom);
+ Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade
+ .getLatestByToscaResourceName(derivedFrom);
if (latestByToscaResourceName.isRight()) {
StorageOperationStatus operationStatus = latestByToscaResourceName.right().value();
@@ -640,7 +694,7 @@ public class ResourceImportManager {
log.debug("Error when fetching parent resource {}, error: {}", derivedFrom, operationStatus);
ActionStatus convertFromStorageResponse = componentsUtils.convertFromStorageResponse(operationStatus);
BeEcompErrorManager.getInstance()
- .logBeComponentMissingError("Import TOSCA YAML", "resource", derivedFrom);
+ .logBeComponentMissingError("Import TOSCA YAML", "resource", derivedFrom);
throw new ByActionStatusComponentException(convertFromStorageResponse, derivedFrom);
}
derivedFromResource = latestByToscaResourceName.left().value();
@@ -648,8 +702,10 @@ public class ResourceImportManager {
return derivedFromResource;
}
- private void setCapabilities(Map<String, Object> toscaJson, Resource resource, Resource parentResource) {// Note that parentResource can be null
- Either<Map<String, Object>, ResultStatusEnum> toscaCapabilities = ImportUtils.findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.CAPABILITIES);
+ private void setCapabilities(Map<String, Object> toscaJson, Resource resource,
+ Resource parentResource) {// Note that parentResource can be null
+ Either<Map<String, Object>, ResultStatusEnum> toscaCapabilities = ImportUtils
+ .findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.CAPABILITIES);
if (toscaCapabilities.isLeft()) {
Map<String, Object> jsonCapabilities = toscaCapabilities.left().value();
Map<String, List<CapabilityDefinition>> moduleCapabilities = new HashMap<>();
@@ -664,18 +720,20 @@ public class ResourceImportManager {
// Validating that no req/cap duplicates exist in imported YAML
String capNameLowerCase = capabilityNameValue.getKey().toLowerCase();
if (capNames.contains(capNameLowerCase)) {
- log.debug("More than one capability with same name {} (case-insensitive) in imported TOSCA file is invalid", capNameLowerCase);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "capability", capNameLowerCase);
+ log.debug(
+ "More than one capability with same name {} (case-insensitive) in imported TOSCA file is invalid",
+ capNameLowerCase);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "capability",
+ capNameLowerCase);
}
capNames.add(capNameLowerCase);
CapabilityDefinition capabilityDef = createCapabilityFromImportFile(capabilityNameValue
- .getValue());
+ .getValue());
capabilityDef.setName(capabilityNameValue.getKey());
if (moduleCapabilities.containsKey(capabilityDef.getType())) {
moduleCapabilities.get(capabilityDef.getType()).add(capabilityDef);
- }
- else {
+ } else {
List<CapabilityDefinition> list = new ArrayList<>();
list.add(capabilityDef);
moduleCapabilities.put(capabilityDef.getType(), list);
@@ -683,17 +741,19 @@ public class ResourceImportManager {
// Validating against req/cap of "derived from" node
Boolean validateVsParentCap = validateCapNameVsDerived(capName2TypeMap, capabilityDef
- .getType(), capabilityDef.getName());
+ .getType(), capabilityDef.getName());
if (!validateVsParentCap) {
// Here parentResource is for sure not null, so it's
// null-safe
// Check added to avoid sonar warning
String parentResourceName = parentResource != null ? parentResource.getName() : "";
- log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(), parentResourceName);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "capability", capabilityDef
- .getName()
- .toLowerCase(), parentResourceName);
+ log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(),
+ parentResourceName);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
+ "capability", capabilityDef
+ .getName()
+ .toLowerCase(), parentResourceName);
}
}
if (moduleCapabilities.size() > 0) {
@@ -712,9 +772,12 @@ public class ResourceImportManager {
String nameLowerCase = capDefinition.getName().toLowerCase();
if (capName2type.get(nameLowerCase) != null) {
String parentResourceName = parentResource.getName();
- log.debug("Resource with name {} has more than one capability with name {}, ignoring case", parentResourceName, nameLowerCase);
+ log.debug("Resource with name {} has more than one capability with name {}, ignoring case",
+ parentResourceName, nameLowerCase);
BeEcompErrorManager.getInstance()
- .logInternalDataError("Import resource", "Parent resource " + parentResourceName + " of imported resource has one or more capabilities with name " + nameLowerCase, ErrorSeverity.ERROR);
+ .logInternalDataError("Import resource", "Parent resource " + parentResourceName
+ + " of imported resource has one or more capabilities with name " + nameLowerCase,
+ ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
capName2type.put(nameLowerCase, capDefinition.getType());
@@ -735,9 +798,12 @@ public class ResourceImportManager {
String nameLowerCase = reqDefinition.getName().toLowerCase();
if (reqName2type.get(nameLowerCase) != null) {
String parentResourceName = parentResource.getName();
- log.debug("Resource with name {} has more than one requirement with name {}, ignoring case", parentResourceName, nameLowerCase);
+ log.debug("Resource with name {} has more than one requirement with name {}, ignoring case",
+ parentResourceName, nameLowerCase);
BeEcompErrorManager.getInstance()
- .logInternalDataError("Import resource", "Parent resource " + parentResourceName + " of imported resource has one or more requirements with name " + nameLowerCase, ErrorSeverity.ERROR);
+ .logInternalDataError("Import resource", "Parent resource " + parentResourceName
+ + " of imported resource has one or more requirements with name " + nameLowerCase,
+ ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
reqName2type.put(nameLowerCase, reqDefinition.getCapability());
@@ -748,19 +814,24 @@ public class ResourceImportManager {
return reqName2type;
}
- private Boolean validateCapNameVsDerived(Map<String, String> parentCapName2Type, String childCapabilityType, String reqCapName) {
+ private Boolean validateCapNameVsDerived(Map<String, String> parentCapName2Type, String childCapabilityType,
+ String reqCapName) {
String capNameLowerCase = reqCapName.toLowerCase();
log.trace("Validating capability {} vs parent resource", capNameLowerCase);
String parentCapType = parentCapName2Type.get(capNameLowerCase);
if (parentCapType != null) {
if (childCapabilityType.equals(parentCapType)) {
- log.debug("Capability with name {} is of same type {} for imported resource and its parent - this is OK", capNameLowerCase, childCapabilityType);
+ log.debug(
+ "Capability with name {} is of same type {} for imported resource and its parent - this is OK",
+ capNameLowerCase, childCapabilityType);
return true;
}
- Either<Boolean, StorageOperationStatus> capabilityTypeDerivedFrom = capabilityTypeOperation.isCapabilityTypeDerivedFrom(childCapabilityType, parentCapType);
+ Either<Boolean, StorageOperationStatus> capabilityTypeDerivedFrom = capabilityTypeOperation
+ .isCapabilityTypeDerivedFrom(childCapabilityType, parentCapType);
if (capabilityTypeDerivedFrom.isRight()) {
log.debug("Couldn't check whether imported resource capability derives from its parent's capability");
- throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom
+ throw new ByActionStatusComponentException(
+ componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom
.right()
.value()));
}
@@ -776,69 +847,73 @@ public class ResourceImportManager {
if (capabilityJson instanceof String) {
String capabilityJsonString = (String) capabilityJson;
capabilityDefinition.setType(capabilityJsonString);
- }
- else if (capabilityJson instanceof Map) {
+ } else if (capabilityJson instanceof Map) {
Map<String, Object> capabilityJsonMap = (Map<String, Object>) capabilityJson;
// Type
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
- capabilityDefinition.setType((String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName()));
+ capabilityDefinition
+ .setType((String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName()));
}
// ValidSourceTypes
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES.getElementName())) {
- capabilityDefinition.setValidSourceTypes((List<String>) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES
+ capabilityDefinition.setValidSourceTypes(
+ (List<String>) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES
.getElementName()));
}
// ValidSourceTypes
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
- capabilityDefinition.setDescription((String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName()));
+ capabilityDefinition.setDescription(
+ (String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName()));
}
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
- List<Object> occurrencesList = (List) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
+ List<Object> occurrencesList = (List) capabilityJsonMap
+ .get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
validateOccurrences(occurrencesList);
capabilityDefinition.setMinOccurrences(occurrencesList.get(0).toString());
capabilityDefinition.setMaxOccurrences(occurrencesList.get(1).toString());
}
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.PROPERTIES.getElementName())) {
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> propertiesRes = ImportUtils.getProperties(capabilityJsonMap);
+ Either<Map<String, PropertyDefinition>, ResultStatusEnum> propertiesRes = ImportUtils
+ .getProperties(capabilityJsonMap);
if (propertiesRes.isRight()) {
throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND);
- }
- else {
+ } else {
propertiesRes.left()
- .value()
- .entrySet()
- .stream()
- .forEach(e -> e.getValue().setName(e.getKey().toLowerCase()));
+ .value()
+ .entrySet()
+ .stream()
+ .forEach(e -> e.getValue().setName(e.getKey().toLowerCase()));
List<ComponentInstanceProperty> capabilityProperties = propertiesRes.left()
- .value()
- .values()
- .stream()
- .map(p -> new ComponentInstanceProperty(p, p
- .getDefaultValue(), null))
- .collect(Collectors.toList());
+ .value()
+ .values()
+ .stream()
+ .map(p -> new ComponentInstanceProperty(p, p
+ .getDefaultValue(), null))
+ .collect(Collectors.toList());
capabilityDefinition.setProperties(capabilityProperties);
}
}
- }
- else if (!(capabilityJson instanceof List)) {
+
+ } else if (!(capabilityJson instanceof List)) {
throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
}
return capabilityDefinition;
}
- private void handleImportResourceException(UploadResourceInfo resourceMetaData, User user, boolean isNormative, RuntimeException e) {
+ private void handleImportResourceException(UploadResourceInfo resourceMetaData, User user, boolean isNormative,
+ RuntimeException e) {
ResponseFormat responseFormat;
ComponentException newException;
if (e instanceof ComponentException) {
- ComponentException componentException = (ComponentException)e;
+ ComponentException componentException = (ComponentException) e;
responseFormat = componentException.getResponseFormat();
if (responseFormat == null) {
- responseFormat = getResponseFormatManager().getResponseFormat(componentException.getActionStatus(), componentException.getParams());
+ responseFormat = getResponseFormatManager()
+ .getResponseFormat(componentException.getActionStatus(), componentException.getParams());
}
newException = componentException;
- }
- else{
+ } else {
responseFormat = getResponseFormatManager().getResponseFormat(ActionStatus.GENERAL_ERROR);
newException = new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
@@ -849,13 +924,13 @@ public class ResourceImportManager {
throw newException;
}
- private void auditErrorImport(UploadResourceInfo resourceMetaData, User user, ResponseFormat errorResponseWrapper, boolean isNormative) {
+ private void auditErrorImport(UploadResourceInfo resourceMetaData, User user, ResponseFormat errorResponseWrapper,
+ boolean isNormative) {
String version, lifeCycleState;
if (isNormative) {
version = TypeUtils.getFirstCertifiedVersionVersion();
lifeCycleState = LifecycleStateEnum.CERTIFIED.name();
- }
- else {
+ } else {
version = "";
lifeCycleState = LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name();
@@ -867,23 +942,22 @@ public class ResourceImportManager {
}
message += errorResponseWrapper.getFormattedMessage();
-
AuditEventFactory factory = new AuditImportResourceAdminEventFactory(
- CommonAuditData.newBuilder()
- .status(errorResponseWrapper.getStatus())
- .description(message)
- .requestId(ThreadLocalsHolder.getUuid())
- .build(),
- new ResourceCommonInfo(resourceMetaData.getName(), ComponentTypeEnum.RESOURCE.getValue()),
- ResourceVersionInfo.newBuilder()
- .state(lifeCycleState)
- .version(version)
- .build(),
- ResourceVersionInfo.newBuilder()
- .state("")
- .version("")
- .build(),
- "", user, "");
+ CommonAuditData.newBuilder()
+ .status(errorResponseWrapper.getStatus())
+ .description(message)
+ .requestId(ThreadLocalsHolder.getUuid())
+ .build(),
+ new ResourceCommonInfo(resourceMetaData.getName(), ComponentTypeEnum.RESOURCE.getValue()),
+ ResourceVersionInfo.newBuilder()
+ .state(lifeCycleState)
+ .version(version)
+ .build(),
+ ResourceVersionInfo.newBuilder()
+ .state("")
+ .version("")
+ .build(),
+ "", user, "");
getAuditingManager().auditEvent(factory);
}
@@ -895,15 +969,58 @@ public class ResourceImportManager {
final String payloadData = resourceMetaData.getPayloadData();
if (payloadData != null) {
resource.setToscaVersion(getToscaVersion(payloadData));
+ resource.setAttributes(getAttributes(payloadData));
}
final List<CategoryDefinition> categories = resourceMetaData.getCategories();
calculateResourceIsAbstract(resource, categories);
}
- private String getToscaVersion(final String payloadData) {
+ private List<AttributeDataDefinition> getAttributes(final String payloadData) {
+ final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
+
+ final List<AttributeDataDefinition> attributeDataDefinitionList = new ArrayList<>();
+
+ final Either<Map<String, Object>, ResultStatusEnum> firstToscaMapElement = ImportUtils
+ .findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.ATTRIBUTES);
+ if (firstToscaMapElement.isRight()) {
+ return attributeDataDefinitionList;
+ }
+ final Map<String, Object> attributes = firstToscaMapElement.left().value();
+
+ final Iterator<Entry<String, Object>> propertiesNameValue = attributes.entrySet().iterator();
+ while (propertiesNameValue.hasNext()) {
+ final Entry<String, Object> attributeNameValue = propertiesNameValue.next();
+ final Object value = attributeNameValue.getValue();
+ final String key = attributeNameValue.getKey();
+ if (value instanceof Map) {
+
+ final Map<String, Object> attributeMap = (Map<String, Object>) value;
+
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName(key);
+
+ setField(attributeMap, ToscaTagNamesEnum.DESCRIPTION, attributeDefinition::setDescription);
+ setField(attributeMap, ToscaTagNamesEnum.TYPE, attributeDefinition::setType);
+ setField(attributeMap, ToscaTagNamesEnum.STATUS, attributeDefinition::setStatus);
+ setField(attributeMap, ToscaTagNamesEnum.ENTRY_SCHEMA, attributeDefinition::setEntry_schema);
+ attributeDataDefinitionList.add(attributeDefinition);
+ } else {
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName(key);
+ attributeDataDefinitionList.add(attributeDefinition);
+ }
+ }
+ return attributeDataDefinitionList;
+ }
+
+ private Map<String, Object> decodePayload(final String payloadData) {
final String decodedPayload = new String(Base64.decodeBase64(payloadData));
- final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(decodedPayload);
+ return (Map<String, Object>) new Yaml().load(decodedPayload);
+ }
+
+ private String getToscaVersion(final String payloadData) {
+ final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
final Either<String, ResultStatusEnum> findFirstToscaStringElement =
ImportUtils.findFirstToscaStringElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
return findFirstToscaStringElement.left().value();
@@ -914,7 +1031,7 @@ public class ResourceImportManager {
CategoryDefinition categoryDef = categories.get(0);
resource.setAbstract(false);
if (categoryDef != null && categoryDef.getName() != null && categoryDef.getName()
- .equals(Constants.ABSTRACT_CATEGORY_NAME)) {
+ .equals(Constants.ABSTRACT_CATEGORY_NAME)) {
SubCategoryDefinition subCategoryDef = categoryDef.getSubcategories().get(0);
if (subCategoryDef != null && subCategoryDef.getName().equals(Constants.ABSTRACT_SUBCATEGORY)) {
resource.setAbstract(true);
@@ -929,8 +1046,7 @@ public class ResourceImportManager {
if (shouldBeCertified) {
version = TypeUtils.getFirstCertifiedVersionVersion();
state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE;
- }
- else {
+ } else {
version = ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION;
state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE_NOT_CERTIFIED_CHECKOUT;
}
@@ -959,8 +1075,7 @@ public class ResourceImportManager {
Integer maxOccurrences;
if (minObj instanceof Integer) {
minOccurrences = (Integer) minObj;
- }
- else {
+ } else {
log.debug("Invalid occurrenses format. low_bound occurrense must be Integer {}", minObj);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
@@ -969,23 +1084,22 @@ public class ResourceImportManager {
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
- if (maxObj instanceof String){
- if(!"UNBOUNDED".equals(maxObj)) {
+ if (maxObj instanceof String) {
+ if (!"UNBOUNDED".equals(maxObj)) {
log.debug("Invalid occurrenses format. Max occurrence is {}", maxObj);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
- }
- else {
+ } else {
if (maxObj instanceof Integer) {
maxOccurrences = (Integer) maxObj;
- }
- else {
+ } else {
log.debug("Invalid occurrenses format. Max occurrence is {}", maxObj);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
if (maxOccurrences <= 0 || maxOccurrences < minOccurrences) {
- log.debug("Invalid occurrenses format. min occurrence is {}, Max occurrence is {}", minOccurrences, maxOccurrences);
+ log.debug("Invalid occurrenses format. min occurrence is {}, Max occurrence is {}", minOccurrences,
+ maxOccurrences);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
}
@@ -1004,7 +1118,8 @@ public class ResourceImportManager {
}
private ResourceBusinessLogic getResourceBL(ServletContext context) {
- WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(org.openecomp.sdc.common.api.Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
+ WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context
+ .getAttribute(org.openecomp.sdc.common.api.Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(context);
return webApplicationContext.getBean(ResourceBusinessLogic.class);
}
@@ -1033,7 +1148,7 @@ public class ResourceImportManager {
public void setResourceBusinessLogic(ResourceBusinessLogic resourceBusinessLogic) {
this.resourceBusinessLogic = resourceBusinessLogic;
}
-
+
@Autowired
public void setInterfaceOperationBusinessLogic(InterfaceOperationBusinessLogic interfaceOperationBusinessLogic) {
this.interfaceOperationBusinessLogic = interfaceOperationBusinessLogic;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
index 3050128531..9f54f1fae8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
@@ -31,9 +31,7 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.servers.Server;
-import io.swagger.v3.oas.annotations.servers.Servers;
import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.tags.Tags;
import org.openecomp.sdc.be.components.impl.AttributeBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
@@ -41,9 +39,10 @@ import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
-import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.Constants;
@@ -76,8 +75,8 @@ import java.io.IOException;
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDC Internal APIs")})
-@Servers({@Server(url = "/sdc2/rest")})
+@Tag(name = "SDC Internal APIs")
+@Server(url = "/sdc2/rest")
@Controller
public class AttributeServlet extends AbstractValidationsServlet {
private static final Logger log = Logger.getLogger(AttributeServlet.class);
@@ -124,13 +123,13 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<PropertyDefinition> attributesWrapper = new Wrapper<>();
+ Wrapper<AttributeDataDefinition> attributesWrapper = new Wrapper<>();
// convert json to AttributeDefinition
buildAttributeFromString(data, attributesWrapper, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<PropertyDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
+ Either<AttributeDataDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
if (createAttribute.isRight()) {
errorWrapper.setInnerElement(createAttribute.right().value());
} else {
@@ -143,7 +142,7 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info("Failed to create Attribute. Reason - ", errorWrapper.getInnerElement());
response = buildErrorResponse(errorWrapper.getInnerElement());
} else {
- PropertyDefinition createdAttDef = attributesWrapper.getInnerElement();
+ AttributeDataDefinition createdAttDef = attributesWrapper.getInnerElement();
log.debug("Attribute {} created successfully with id {}", createdAttDef.getName(), createdAttDef.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.CREATED);
response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(createdAttDef));
@@ -200,14 +199,14 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
// convert json to PropertyDefinition
Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<PropertyDefinition> attributesWrapper = new Wrapper<>();
+ Wrapper<AttributeDataDefinition> attributesWrapper = new Wrapper<>();
// convert json to AttributeDefinition
buildAttributeFromString(data, attributesWrapper, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<PropertyDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
// update property
if (eitherUpdateAttribute.isRight()) {
errorWrapper.setInnerElement(eitherUpdateAttribute.right().value());
@@ -221,7 +220,7 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info("Failed to update Attribute. Reason - ", errorWrapper.getInnerElement());
response = buildErrorResponse(errorWrapper.getInnerElement());
} else {
- PropertyDefinition updatedAttribute = attributesWrapper.getInnerElement();
+ AttributeDataDefinition updatedAttribute = attributesWrapper.getInnerElement();
log.debug("Attribute id {} updated successfully ", updatedAttribute.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(updatedAttribute));
@@ -271,15 +270,14 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.debug("modifier id is {}", userId);
try {
-
// delete the property
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<PropertyDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
log.debug("Failed to delete Attribute. Reason - ", eitherAttribute.right().value());
return buildErrorResponse(eitherAttribute.right().value());
}
- PropertyDefinition attributeDefinition = eitherAttribute.left().value();
+ AttributeDataDefinition attributeDefinition = eitherAttribute.left().value();
String name = attributeDefinition.getName();
log.debug("Attribute {} deleted successfully with id {}", name, attributeDefinition.getUniqueId());
@@ -293,11 +291,11 @@ public class AttributeServlet extends AbstractValidationsServlet {
}
}
- private void buildAttributeFromString(String data, Wrapper<PropertyDefinition> attributesWrapper,
+ private void buildAttributeFromString(String data, Wrapper<AttributeDataDefinition> attributesWrapper,
Wrapper<ResponseFormat> errorWrapper) {
try {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
- final PropertyDefinition attribute = gson.fromJson(data, PropertyDefinition.class);
+ final AttributeDataDefinition attribute = gson.fromJson(data, AttributeDefinition.class);
if (attribute == null) {
log.info(ATTRIBUTE_CONTENT_IS_INVALID, data);
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 13a90a822f..518ed5726c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -54,6 +54,7 @@ import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundExcept
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
@@ -1060,6 +1061,14 @@ public class ToscaExportHandler {
: NATIVE_ROOT;
toscaNodeType.setDerived_from(derivedFrom);
}
+ if (component instanceof Resource) {
+ final List<AttributeDataDefinition> attributes = ((Resource) component).getAttributes();
+ if (CollectionUtils.isNotEmpty(attributes)) {
+ final Map<String, AttributeDataDefinition> attributeDataDefinitionMap
+ = attributes.stream().collect(Collectors.toMap(AttributeDataDefinition::getName, a -> a));
+ toscaNodeType.setAttributes(attributeDataDefinitionMap);
+ }
+ }
return toscaNodeType;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
index b7fe3bc13a..04515b297c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.tosca.model;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@@ -31,6 +32,7 @@ import java.util.Map;
@Getter
@Setter
+@NoArgsConstructor
public class ToscaNodeTemplate {
private String type;
@@ -45,11 +47,7 @@ public class ToscaNodeTemplate {
private Map<String, Object> interfaces;
public void setDirectives(List<String> directives) {
- if (CollectionUtils.isEmpty(directives)) {
- this.directives = null;
- return;
- }
- this.directives = directives;
+ this.directives = CollectionUtils.isEmpty(directives) ? null : directives;
}
public void addInterface(String interfaceName, Object interfaceDataDefinition) {
@@ -60,4 +58,3 @@ public class ToscaNodeTemplate {
this.interfaces.put(interfaceName, interfaceDataDefinition);
}
}
-
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
index 0d0cfb27b7..b5e5866fe4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
@@ -22,75 +22,25 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+
+@Getter
+@Setter
+@NoArgsConstructor
public class ToscaNodeType {
- public ToscaNodeType() {
- }
-
private ToscaMetadata metadata;
private String derived_from;
private String description;
private Map<String, ToscaProperty> properties;
- private Map<String, Object> interfaces; //ToscaInterfaceDefinition
+ private Map<String, Object> interfaces;
private Map<String, ToscaCapability> capabilities;
private List<Map<String, ToscaRequirement>> requirements;
+ private Map<String, AttributeDataDefinition> attributes;
- public Map<String, ToscaProperty> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, ToscaProperty> properties) {
- this.properties = properties;
- }
-
- public Map<String, ToscaCapability> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, ToscaCapability> capabilities) {
- this.capabilities = capabilities;
- }
-
- public List<Map<String, ToscaRequirement>> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(List<Map<String, ToscaRequirement>> requirements) {
- this.requirements = requirements;
- }
-
- public String getDerived_from() {
- return derived_from;
- }
-
- public void setDerived_from(String derived_from) {
- this.derived_from = derived_from;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public ToscaMetadata getMetadata() {
- return metadata;
- }
-
- public void setMetadata(ToscaMetadata metadata) {
- this.metadata = metadata;
- }
-
- public Map<String, Object> getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(Map<String, Object> interfaces) {
- this.interfaces = interfaces;
- }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
index 57af76a103..db4c699d04 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
@@ -31,9 +31,10 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
@@ -53,6 +54,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.Mockito.when;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@@ -74,7 +76,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
AttributeBusinessLogic attributeBusinessLogic=createTestSubject();
IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
-
@Before
public void setup() throws Exception{
@@ -107,23 +108,21 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
baseBusinessLogic.set(attributeBusinessLogic, propertyOperation);
}
-
@Test
public void testCreateAttribute() throws Exception {
AttributeBusinessLogic testSubject;
String resourceId = "";
PropertyDefinition newAttributeDef = null;
String userId = "";
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
// default test
testSubject = createTestSubject();
}
-
@Test
public void testIsAttributeExist() throws Exception {
- AttributeBusinessLogic testSubject;List<PropertyDefinition> attributes = null;
+ AttributeBusinessLogic testSubject;List<AttributeDataDefinition> attributes = null;
String resourceUid = "";
String propertyName = "";
boolean result;
@@ -132,7 +131,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
testSubject=createTestSubject();attributes = null;
}
-
@Test
public void testGetAttribute() throws Exception {
AttributeBusinessLogic testSubject;
@@ -145,7 +143,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
}
-
@Test
public void testUpdateAttribute() throws Exception {
AttributeBusinessLogic testSubject;
@@ -159,7 +156,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
}
-
@Test
public void testDeleteAttribute() throws Exception {
AttributeBusinessLogic testSubject;
@@ -172,11 +168,10 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
testSubject = createTestSubject();
}
-
@Test
public void createAttribute_lockfail() throws Exception {
- Either<PropertyDefinition, ResponseFormat> response;
- PropertyDefinition prop= new PropertyDefinition();
+ Either<AttributeDataDefinition, ResponseFormat> response;
+ AttributeDataDefinition prop= new AttributeDataDefinition();
response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
@@ -187,36 +182,36 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void createAttribute_Success() throws Exception {
- Component resource= new Resource();
+ Component resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
- PropertyDefinition prop= new PropertyDefinition();
- prop.setType(ToscaPropertyType.STRING.getType());
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setType(ToscaPropertyType.STRING.getType());
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
//Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- PropertyDefinition propertyDefinition = new PropertyDefinition();
- Either<PropertyDefinition, StorageOperationStatus> either = Either.left(propertyDefinition);
- when(toscaOperationFacade.addAttributeOfResource(anyObject(),anyObject())).thenReturn(either);
+ AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition();
+ Either<AttributeDataDefinition, StorageOperationStatus> either = Either.left(attributeDataDefinition);
+ when(toscaOperationFacade.addAttributeOfResource(anyObject(), anyObject())).thenReturn(either);
when(propertyOperation.isPropertyTypeValid(anyObject())).thenReturn(true);
- Map<String,DataTypeDefinition> data=new HashMap<>();
- data.put("ONE",new DataTypeDefinition());
+ Map<String, DataTypeDefinition> data = new HashMap<>();
+ data.put("ONE", new DataTypeDefinition());
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
- when(propertyOperation.isPropertyDefaultValueValid(anyObject(),anyObject())).thenReturn(true);
- Either<PropertyDefinition, ResponseFormat> response;
+ when(propertyOperation.isPropertyDefaultValueValid(anyObject(), anyObject())).thenReturn(true);
+ Either<AttributeDataDefinition, ResponseFormat> response;
- response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
+ response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- Assert.assertEquals(true,response.isLeft());
+ Assert.assertEquals(true, response.isLeft());
}
@@ -230,8 +225,8 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
- Either<PropertyDefinition, ResponseFormat> response;
- PropertyDefinition prop= new PropertyDefinition();
+ Either<AttributeDataDefinition, ResponseFormat> response;
+ AttributeDataDefinition prop= new AttributeDataDefinition();
baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade");
baseBusinessLogic.setAccessible(true);
@@ -256,8 +251,8 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
- Either<PropertyDefinition, ResponseFormat> response;
- PropertyDefinition prop= new PropertyDefinition();
+ Either<AttributeDataDefinition, ResponseFormat> response;
+ AttributeDataDefinition prop= new AttributeDataDefinition();
//Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
@@ -272,73 +267,71 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void createAttribute_componentalreadyexist_fails() throws Exception {
- Either<PropertyDefinition, ResponseFormat> response;
- PropertyDefinition prop= new PropertyDefinition();
- prop.setName("RES01");
- prop.setParentUniqueId("RES01");
+ Either<AttributeDataDefinition, ResponseFormat> response;
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setName("RES01");
+ attrib.setParentUniqueId("RES01");
- List<PropertyDefinition> attributes = new ArrayList<>();
- attributes.add(prop);
+ List<AttributeDataDefinition> attributes = new ArrayList<>();
+ attributes.add(attrib);
- Component resource= new Resource();
+ Component resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
((Resource) resource).setAttributes(attributes);
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
//Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
+ response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- Assert.assertEquals(true,response.isRight());
+ Assert.assertEquals(true, response.isRight());
}
-
@Test
public void createAttribute_addresourcetostoragefails() throws Exception {
- Component resource= new Resource();
+ Component resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
- PropertyDefinition prop= new PropertyDefinition();
- prop.setType(ToscaPropertyType.STRING.getType());
-
IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
//Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY);
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- PropertyDefinition propertyDefinition = new PropertyDefinition();
- Either<PropertyDefinition, StorageOperationStatus> either = Either.right(StorageOperationStatus.CONNECTION_FAILURE);
- when(toscaOperationFacade.addAttributeOfResource(anyObject(),anyObject())).thenReturn(either);
+ AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition();
+ Either<AttributeDataDefinition, StorageOperationStatus> either = Either
+ .right(StorageOperationStatus.CONNECTION_FAILURE);
+ when(toscaOperationFacade.addAttributeOfResource(anyObject(), anyObject())).thenReturn(either);
when(propertyOperation.isPropertyTypeValid(anyObject())).thenReturn(true);
- Map<String,DataTypeDefinition> data=new HashMap<>();
- data.put("ONE",new DataTypeDefinition());
+ Map<String, DataTypeDefinition> data = new HashMap<>();
+ data.put("ONE", new DataTypeDefinition());
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
- when(propertyOperation.isPropertyDefaultValueValid(anyObject(),anyObject())).thenReturn(true);
- Either<PropertyDefinition, ResponseFormat> response;
+ when(propertyOperation.isPropertyDefaultValueValid(anyObject(), anyObject())).thenReturn(true);
+ Either<AttributeDataDefinition, ResponseFormat> response;
- response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
+ AttributeDataDefinition attrib = new AttributeDefinition();
+ response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- Assert.assertEquals(true,response.isRight());
+ Assert.assertEquals(true, response.isRight());
}
@Test
public void testgetAttribute_ATTRIBUTE_NOT_FOUND() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
Component resource= new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
@@ -353,31 +346,31 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void testgetAttribute_success() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
- Component resource= new Resource();
+ Component resource = new Resource();
resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
- PropertyDefinition prop= new PropertyDefinition();
- prop.setUniqueId("ATTR01");
- prop.setParentUniqueId("RES01");
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setUniqueId("ATTR01");
+ attrib.setParentUniqueId("RES01");
- List<PropertyDefinition> attr = new ArrayList<>();
- attr.add(prop);
+ List<AttributeDataDefinition> attr = new ArrayList<>();
+ attr.add(attrib);
((Resource) resource).setAttributes(attr);
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- result=attributeBusinessLogic.getAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isLeft());
+ result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01");
+ Assert.assertEquals(true, result.isLeft());
}
@Test
public void testgetAttribute_RESOURCE_NOT_FOUND() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
@@ -388,7 +381,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void testdeleteAttribute_FAILED_TO_LOCK_COMPONENT() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
Assert.assertEquals(true,result.isRight());
@@ -396,7 +389,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void testdeleteAttribute_get_RESOURCE_from_DB_failed() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.CONNECTION_FAILURE);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
@@ -407,7 +400,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void testdeleteAttribute_get_RESOURCE_verification_failed() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
Component resource= new Resource();
@@ -430,7 +423,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void testdeleteAttribute_nonexistingresource() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
Component resource= new Resource();
@@ -449,7 +442,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
@Test
public void testdeleteAttribute_success() throws Exception {
- Either<PropertyDefinition, ResponseFormat> result;
+ Either<AttributeDataDefinition, ResponseFormat> result;
Component resource= new Resource();
@@ -457,23 +450,21 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{
resource.setIsDeleted(false);
resource.setLastUpdaterUserId("USR01");
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
-
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- when(toscaOperationFacade.deleteAttributeOfResource(any(),any())).thenReturn(StorageOperationStatus.OK);
+ when(toscaOperationFacade.deleteAttributeOfResource(any(), any())).thenReturn(StorageOperationStatus.OK);
- PropertyDefinition prop= new PropertyDefinition();
- prop.setUniqueId("ATTR01");
- prop.setParentUniqueId("RES01");
- List<PropertyDefinition> attributes = new ArrayList<>();
- attributes.add(prop);
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setUniqueId("ATTR01");
+ attrib.setParentUniqueId("RES01");
+ List<AttributeDataDefinition> attributes = new ArrayList<>();
+ attributes.add(attrib);
((Resource) resource).setAttributes(attributes);
- result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- Assert.assertEquals(true,result.isLeft());
+ result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
+ Assert.assertEquals(true, result.isLeft());
}
-
-} \ No newline at end of file
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
index 127e1d9aba..f213835406 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
@@ -22,9 +22,12 @@ package org.openecomp.sdc.be.components.impl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anySet;
@@ -57,6 +60,8 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
@@ -88,6 +93,7 @@ import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
@@ -120,6 +126,7 @@ import org.openecomp.sdc.exception.ResponseFormat;
*/
@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
class ComponentInstanceBusinessLogicTest {
private final static String USER_ID = "jh0003";
@@ -486,8 +493,7 @@ class ComponentInstanceBusinessLogicTest {
ComponentInstance responseFormatEither = componentInstanceBusinessLogic
.deleteForwardingPathsRelatedTobeDeletedComponentInstance(
containerComponentID, containerComponentType, ci);
- assertThat(!responseFormatEither.isEmpty()).isEqualTo(true);
-
+ assertFalse(responseFormatEither.isEmpty());
}
@Test
@@ -624,7 +630,7 @@ class ComponentInstanceBusinessLogicTest {
componentInstanceBusinessLogic
.getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
} catch (ByActionStatusComponentException e) {
- assertSame(e.getActionStatus(), ActionStatus.USER_NOT_FOUND);
+ assertSame(ActionStatus.USER_NOT_FOUND, e.getActionStatus());
}
}
@@ -887,7 +893,7 @@ class ComponentInstanceBusinessLogicTest {
// default test
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "validateParent", new Object[]{resource, nodeTemplateId});
- assertNotNull(result);
+ assertFalse(result);
}
@Test
@@ -940,6 +946,7 @@ class ComponentInstanceBusinessLogicTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "findRelation",
new Object[]{relationId, requirementCapabilityRelations});
+ assertNull(result);
}
@Test
@@ -990,6 +997,7 @@ class ComponentInstanceBusinessLogicTest {
testSubject = createTestSubject();
result = Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent",
new Object[]{property, newValue, resource, toInstance, capabilityType, capabilityName});
+ assertNull(result);
}
@Test
@@ -1224,7 +1232,7 @@ class ComponentInstanceBusinessLogicTest {
@Test
void testCreateOrUpdateAttributeValueForCopyPaste() {
ComponentInstance serviceComponentInstance = createComponetInstanceFromComponent(service);
- ComponentInstanceProperty attribute = new ComponentInstanceProperty();
+ ComponentInstanceAttribute attribute = new ComponentInstanceAttribute();
attribute.setType("string");
attribute.setUniqueId("testCreateOrUpdateAttributeValueForCopyPaste");
SchemaDefinition def = Mockito.mock(SchemaDefinition.class);
@@ -1234,9 +1242,9 @@ class ComponentInstanceBusinessLogicTest {
service.setLastUpdaterUserId(USER_ID);
service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- Map<String, List<ComponentInstanceProperty>> instAttrsMap = new HashMap<>();
- List<ComponentInstanceProperty> instAttrsList = new ArrayList<>();
- ComponentInstanceProperty prop = new ComponentInstanceProperty();
+ Map<String, List<ComponentInstanceAttribute>> instAttrsMap = new HashMap<>();
+ List<ComponentInstanceAttribute> instAttrsList = new ArrayList<>();
+ ComponentInstanceAttribute prop = new ComponentInstanceAttribute();
prop.setUniqueId(attribute.getUniqueId());
instAttrsList.add(prop);
instAttrsMap.put(toInstance.getUniqueId(), instAttrsList);
@@ -1250,7 +1258,7 @@ class ComponentInstanceBusinessLogicTest {
when(toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(service))
.thenReturn(serviceEitherLeft);
- Either<ComponentInstanceProperty, ResponseFormat> result = Deencapsulation
+ Either<ComponentInstanceAttribute, ResponseFormat> result = Deencapsulation
.invoke(componentInstanceBusinessLogic,
"createOrUpdateAttributeValueForCopyPaste",
ComponentTypeEnum.SERVICE,
@@ -1264,8 +1272,8 @@ class ComponentInstanceBusinessLogicTest {
service.setLifecycleState(oldLifeCycleState);
assertThat(result.isLeft()).isTrue();
- ComponentInstanceProperty resultProp = result.left().value();
- assertEquals(resultProp.getPath().size(), 1);
+ ComponentInstanceAttribute resultProp = result.left().value();
+ assertEquals(1, resultProp.getPath().size());
assertEquals(resultProp.getPath().get(0), toInstance.getUniqueId());
}
@@ -1496,8 +1504,8 @@ class ComponentInstanceBusinessLogicTest {
Optional<ComponentInstanceProperty> propertyCandidate =
getComponentInstanceProperty(PROP_NAME);
- assertThat(propertyCandidate.isPresent()).isTrue();
- assertEquals(propertyCandidate.get().getName(), PROP_NAME);
+ assertThat(propertyCandidate).isPresent();
+ assertEquals(PROP_NAME, propertyCandidate.get().getName());
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index e47cdc999e..3783c5e1fd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -28,10 +28,12 @@ import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations;
import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.utils.TypeUtils;
@@ -305,7 +307,7 @@ public class ImportUtilsTest {
public void testGetAttributesFromYml() throws IOException {
Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaWithAttribute.yml");
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
+ Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
assertTrue(actualAttributes.isLeft());
Map<String, Map<String, Object>> expectedAttributes = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.ATTRIBUTES);
compareAttributes(expectedAttributes, actualAttributes.left().value());
@@ -364,10 +366,10 @@ public class ImportUtilsTest {
}
- private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, PropertyDefinition> actual) {
+ private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, AttributeDataDefinition> actual) {
Map<String, Object> singleExpectedAttribute;
- PropertyDefinition actualAttribute, expectedAttributeModel;
+ AttributeDataDefinition actualAttribute, expectedAttributeModel;
// attributes of resource
for (Map.Entry<String, Map<String, Object>> expectedAttribute : expected.entrySet()) {
@@ -379,11 +381,11 @@ public class ImportUtilsTest {
expectedAttributeModel = ImportUtils.createModuleAttribute(singleExpectedAttribute);
expectedAttributeModel.setName(expectedAttribute.getKey().toString());
- assertEquals(expectedAttributeModel.getDefaultValue(), actualAttribute.getDefaultValue());
- assertEquals(expectedAttributeModel.getDescription(), actualAttribute.getDescription());
- assertEquals(expectedAttributeModel.getName(), actualAttribute.getName());
- assertEquals(expectedAttributeModel.getStatus(), actualAttribute.getStatus());
- assertEquals(expectedAttributeModel.getType(), actualAttribute.getType());
+ assertEquals(((AttributeDefinition)expectedAttributeModel).getDefaultValue(), ((AttributeDefinition)actualAttribute).getDefaultValue());
+ assertEquals(((AttributeDefinition)expectedAttributeModel).getDescription(), ((AttributeDefinition)actualAttribute).getDescription());
+ assertEquals(((AttributeDefinition)expectedAttributeModel).getName(), ((AttributeDefinition)actualAttribute).getName());
+ assertEquals(((AttributeDefinition)expectedAttributeModel).getStatus(), ((AttributeDefinition)actualAttribute).getStatus());
+ assertEquals(((AttributeDefinition)expectedAttributeModel).getType(), ((AttributeDefinition)actualAttribute).getType());
compareSchemas(expectedAttributeModel.getSchema(), actualAttribute.getSchema());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
index e266a21ce6..79c2ec460f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java
@@ -24,6 +24,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
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.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
@@ -60,7 +61,7 @@ public enum VertexTypeEnum {
CAPABILITIES ("capabilities", ListCapabilityDataDefinition.class),
CAPABILITIES_PROPERTIES ("capabilities_properties", MapPropertiesDataDefinition.class),
REQUIREMENTS ("requirements", ListRequirementDataDefinition.class),
- ATTRIBUTES ("attributes", PropertyDataDefinition.class),
+ ATTRIBUTES ("attributes", AttributeDataDefinition.class),
RESOURCE_CATEGORY ("resourceNewCategory", null),
RESOURCE_SUBCATEGORY ("resourceSubcategory", null),
SERVICE_CATEGORY ("serviceNewCategory", null),
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
new file mode 100644
index 0000000000..a353ae9033
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.sdc.tosca.datatypes.model.EntrySchema;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+
+@Getter
+@Setter
+@ToString
+public class AttributeDefinition extends AttributeDataDefinition implements IOperationParameter, IComplexDefaultValue {
+
+ // All names are according to TOSCA spec from
+ // https://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.3/os/TOSCA-Simple-Profile-YAML-v1.3-os.html#DEFN_ELEMENT_ATTRIBUTE_DEFN
+ private String type;
+ private String description;
+ private Object _default;
+ private String status;
+ private EntrySchema entry_schema;
+
+ public AttributeDefinition() {
+ toscaPresentation = null;
+ }
+
+ public AttributeDefinition(final AttributeDefinition attributeDefinition) {
+ this.type = attributeDefinition.getType();
+ this.description = attributeDefinition.getDescription();
+ this._default = attributeDefinition.get_default();
+ this.status = attributeDefinition.getStatus();
+ this.entry_schema = attributeDefinition.getEntry_schema();
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return String.valueOf(_default);
+ }
+
+ @Override
+ public void setDefaultValue(final String value) {
+ this._default = value;
+ }
+
+ @Override
+ public boolean isDefinition() {
+ return false;
+ }
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java
index a74243eb7e..061262eec0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityDefinition.java
@@ -21,6 +21,11 @@
package org.openecomp.sdc.be.model;
import com.google.common.collect.Lists;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections.SetUtils;
@@ -31,9 +36,15 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+
/**
* Specifies the capabilities that the Node Type exposes.
*/
+@Getter
+@Setter
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@ToString
public class CapabilityDefinition extends CapabilityDataDefinition {
/**
@@ -42,11 +53,6 @@ public class CapabilityDefinition extends CapabilityDataDefinition {
*/
private List<ComponentInstanceProperty> properties;
-
- public CapabilityDefinition() {
- super();
- }
-
public CapabilityDefinition(CapabilityDataDefinition cap) {
super(cap);
}
@@ -70,44 +76,6 @@ public class CapabilityDefinition extends CapabilityDataDefinition {
}
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((properties == null) ? 0 : properties.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- CapabilityDefinition other = (CapabilityDefinition) obj;
- if (properties == null) {
- if (other.properties != null)
- return false;
- } else if (!SetUtils.isEqualSet(properties, other.getProperties()))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "CapabilityDefinition [properties=" + properties + "]";
- }
-
- public List<ComponentInstanceProperty> getProperties() {
- return properties;
- }
-
- public void setProperties(List<ComponentInstanceProperty> properties) {
- this.properties = properties;
- }
-
public void updateCapabilityProperties(CapabilityDefinition capabilityDefinition) {
if(CollectionUtils.isNotEmpty(getProperties()) && capabilityDefinition!= null && CollectionUtils.isNotEmpty(capabilityDefinition.getProperties())){
Map<String, ComponentInstanceProperty> propertiesInfo = capabilityDefinition.getProperties()
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java
index 016c117e84..f7627e76df 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CapabilityTypeDefinition.java
@@ -20,6 +20,10 @@
package org.openecomp.sdc.be.model;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition;
import org.openecomp.sdc.be.resources.data.CapabilityTypeData;
@@ -30,32 +34,16 @@ import java.util.stream.Collectors;
* Specifies the capabilities that the Node Type exposes.
*/
@SuppressWarnings("serial")
+@Getter
+@Setter
+@NoArgsConstructor
+@ToString(callSuper = true)
public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition {
private String derivedFrom;
private Map<String, PropertyDefinition> properties;
- public String getDerivedFrom() {
- return derivedFrom;
- }
-
- public void setDerivedFrom(String derivedFrom) {
- this.derivedFrom = derivedFrom;
- }
-
- public Map<String, PropertyDefinition> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, PropertyDefinition> properties) {
- this.properties = properties;
- }
-
- public CapabilityTypeDefinition() {
- super();
- }
-
public CapabilityTypeDefinition(CapabilityTypeDataDefinition p) {
super(p);
}
@@ -75,8 +63,4 @@ public class CapabilityTypeDefinition extends CapabilityTypeDataDefinition {
this.setValidSourceTypes( ctd.getCapabilityTypeDataDefinition().getValidSourceTypes());
}
- @Override
- public String toString() {
- return super.toString() + " [ derivedFrom=" + derivedFrom + ", properties=" + properties + " ]";
- }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
index dc0fb51d7c..ba73e77e05 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
@@ -73,7 +73,7 @@ public abstract class Component implements PropertiesOwner {
private List<RequirementCapabilityRelDef> componentInstancesRelations;
private Map<String, List<ComponentInstanceInput>> componentInstancesInputs;
private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties;
- private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes;
+ private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes;
private Map<String, List<CapabilityDefinition>> capabilities;
private Map<String, List<RequirementDefinition>> requirements;
private Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
new file mode 100644
index 0000000000..91a7b9c14f
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
+
+@Getter
+@Setter
+public class ComponentInstanceAttribute extends AttributeDefinition implements IComponentInstanceConnectedElement, IAttributeInputCommon {
+
+ public ComponentInstanceAttribute(final AttributeDataDefinition value) {
+ }
+ public ComponentInstanceAttribute() {
+ super();
+ }
+
+ /**
+ * The unique id of the property value on graph
+ */
+ private String valueUniqueUid;
+
+ private List<String> path;
+
+ private List<PropertyRule> rules ;
+
+ private String componentInstanceName;
+
+ private String componentInstanceId;
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java
index c5a008085b..487d642a5c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java
@@ -16,17 +16,19 @@
package org.openecomp.sdc.be.model;
-import com.google.common.annotations.VisibleForTesting;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
+@Getter
+@Setter
+@NoArgsConstructor
public class ComponentInstanceInterface extends InterfaceDefinition {
private String interfaceId;
private InterfaceInstanceDataDefinition interfaceInstanceDataDefinition;
- @VisibleForTesting
- ComponentInstanceInterface() {}
-
public ComponentInstanceInterface(String interfaceId,
InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) {
this.interfaceId = interfaceId;
@@ -38,20 +40,4 @@ public class ComponentInstanceInterface extends InterfaceDefinition {
this.interfaceId = interfaceId;
}
- public String getInterfaceId() {
- return interfaceId;
- }
-
- public void setInterfaceId(String interfaceId) {
- this.interfaceId = interfaceId;
- }
-
- public InterfaceInstanceDataDefinition getInterfaceInstanceDataDefinition() {
- return interfaceInstanceDataDefinition;
- }
-
- public void setInterfaceInstanceDataDefinition(
- InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) {
- this.interfaceInstanceDataDefinition = interfaceInstanceDataDefinition;
- }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java
new file mode 100644
index 0000000000..fa8c162485
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/IAttributeInputCommon.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model;
+
+import java.util.List;
+import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+
+public interface IAttributeInputCommon {
+
+ String getType();
+ ToscaDataDefinition getSchema();
+ List<PropertyRule> getRules();
+ String getName();
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
index 44d6eff4fb..a3d871a511 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
@@ -32,6 +32,7 @@ import lombok.ToString;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -57,7 +58,7 @@ public class Resource extends Component {
private Map<String, String> derivedFromMapOfIdToName;
- private List<PropertyDefinition> attributes;
+ private List<AttributeDataDefinition> attributes;
private String toscaVersion;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java
index 296e80b674..a1b07bc58d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeType.java
@@ -24,8 +24,8 @@ import java.util.List;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
@Getter
@Setter
@@ -38,6 +38,6 @@ public class NodeType extends ToscaElement {
private List<String> derivedFrom;
private List<String> derivedList;
private Map<String, String> derivedFromMapOfIdToName;
- private Map<String, PropertyDataDefinition> attributes;
+ private Map<String, AttributeDataDefinition> attributes;
private Map<String, InterfaceDataDefinition> interfaceArtifacts;
}
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 db330e9b19..7b9fd6fa05 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
@@ -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.
@@ -20,26 +20,48 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.collections.MapUtils;
-import org.openecomp.sdc.be.datatypes.elements.*;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
+import org.openecomp.sdc.be.datatypes.elements.MapComponentInstanceExternalRefs;
+import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.model.MapInterfaceInstanceDataDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum;
-import java.util.HashMap;
-import java.util.Map;
-
-public class TopologyTemplate extends ToscaElement{
+@Getter
+@Setter
+public class TopologyTemplate extends ToscaElement {
public TopologyTemplate() {
super(ToscaElementTypeEnum.TOPOLOGY_TEMPLATE);
}
+
private Map<String, PropertyDataDefinition> inputs;
private Map<String, MapPropertiesDataDefinition> instInputs;
private Map<String, ? extends ToscaDataDefinition> heatParameters;
- private Map<String, MapPropertiesDataDefinition> instAttributes;
+ private Map<String, MapAttributesDataDefinition> instAttributes;
private Map<String, MapPropertiesDataDefinition> instProperties;
private Map<String, GroupDataDefinition> groups;
private Map<String, PolicyDataDefinition> policies;
@@ -58,238 +80,61 @@ public class TopologyTemplate extends ToscaElement{
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;
+
//Component Instances External References (instanceId -> ExternalRefsMap)
//-----------------------------------------------------------------------
private Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs;
-
- public Map<String, MapComponentInstanceExternalRefs> getMapComponentInstancesExternalRefs() {
- return this.mapComponentInstancesExternalRefs;
- }
-
- public void setComponentInstancesExternalRefs(Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs) {
- this.mapComponentInstancesExternalRefs = mapComponentInstancesExternalRefs;
- }
//-----------------------------------------------------------------------
- public Map<String, InterfaceDataDefinition> getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(Map<String, InterfaceDataDefinition> interfaces) {
- this.interfaces = interfaces;
- }
-
- public Map<String, MapInterfaceInstanceDataDefinition> getInstInterfaces() {
- return instInterfaces;
- }
-
- public void setInstInterfaces(
- Map<String, MapInterfaceInstanceDataDefinition> instInterfaces) {
- this.instInterfaces = instInterfaces;
- }
-
public void addInstInterface(String compId, MapInterfaceInstanceDataDefinition
- mapInterfaceInstanceDataDefinition) {
- if(MapUtils.isEmpty(this.instInterfaces)) {
+ mapInterfaceInstanceDataDefinition) {
+ if (MapUtils.isEmpty(this.instInterfaces)) {
this.instInterfaces = new HashMap<>();
}
this.instInterfaces.put(compId, mapInterfaceInstanceDataDefinition);
}
- public Map<String, MapInterfaceDataDefinition> getComponentInstInterfaces() {
- return componentInstInterfaces;
- }
-
- public void setComponentInstInterfaces(
- Map<String, MapInterfaceDataDefinition> componentInstInterfaces) {
- this.componentInstInterfaces = componentInstInterfaces;
- }
-
public void addComponentInstanceInterfaceMap(String componentInstanceId, MapInterfaceDataDefinition
- mapInterfaceDataDefinition) {
- if(MapUtils.isEmpty(this.componentInstInterfaces)) {
+ mapInterfaceDataDefinition) {
+ if (MapUtils.isEmpty(this.componentInstInterfaces)) {
this.componentInstInterfaces = new HashMap<>();
}
this.componentInstInterfaces.put(componentInstanceId, mapInterfaceDataDefinition);
}
-
- public Map<String, PropertyDataDefinition> getInputs() {
- return inputs;
- }
- public void setInputs(Map<String, PropertyDataDefinition> inputs) {
- this.inputs = inputs;
- }
- public Map<String, MapPropertiesDataDefinition> getInstInputs() {
- return instInputs;
- }
- public void setInstInputs(Map<String, MapPropertiesDataDefinition> instInputs) {
- this.instInputs = instInputs;
- }
- public Map<String, ? extends ToscaDataDefinition> getHeatParameters() {
- return heatParameters;
- }
- public void setHeatParameters(Map<String, ? extends ToscaDataDefinition> heatParameters) {
- this.heatParameters = heatParameters;
- }
- public Map<String, MapPropertiesDataDefinition> getInstAttributes() {
- return instAttributes;
- }
- public void setInstAttributes(Map<String, MapPropertiesDataDefinition> instAttributes) {
- this.instAttributes = instAttributes;
- }
- public Map<String, MapPropertiesDataDefinition> getInstProperties() {
- return instProperties;
- }
- public void setInstProperties(Map<String, MapPropertiesDataDefinition> instProperties) {
- this.instProperties = instProperties;
- }
- public Map<String, GroupDataDefinition> getGroups() {
- return groups;
- }
- public void setGroups(Map<String, GroupDataDefinition> groups) {
- this.groups = groups;
- }
- public Map<String, PolicyDataDefinition> getPolicies() {
- return policies;
- }
- public void setPolicies(Map<String, PolicyDataDefinition> policies) {
- this.policies = policies;
- }
- public Map<String, MapGroupsDataDefinition> getInstGroups() {
- return instGroups;
- }
- public void setInstGroups(Map<String, MapGroupsDataDefinition> instGroups) {
- this.instGroups = instGroups;
- }
- public Map<String, ArtifactDataDefinition> getServiceApiArtifacts() {
- return serviceApiArtifacts;
- }
- public void setServiceApiArtifacts(Map<String, ArtifactDataDefinition> serviceApiArtifacts) {
- this.serviceApiArtifacts = serviceApiArtifacts;
- }
- public Map<String, CompositionDataDefinition> getCompositions() {
- return compositions;
- }
- public void setCompositions(Map<String, CompositionDataDefinition> compositions) {
- this.compositions = compositions;
- }
- public Map<String, MapListCapabilityDataDefinition> getCalculatedCapabilities() {
- return calculatedCapabilities;
- }
- public void setCalculatedCapabilities(Map<String, MapListCapabilityDataDefinition> calculatedCapabilities) {
- this.calculatedCapabilities = calculatedCapabilities;
- }
- public Map<String, MapListRequirementDataDefinition> getCalculatedRequirements() {
- return calculatedRequirements;
- }
- public void setCalculatedRequirements(Map<String, MapListRequirementDataDefinition> calculatedRequirements) {
- this.calculatedRequirements = calculatedRequirements;
- }
- public Map<String, MapListCapabilityDataDefinition> getFullfilledCapabilities() {
- return fullfilledCapabilities;
- }
- public void setFullfilledCapabilities(Map<String, MapListCapabilityDataDefinition> fullfilledCapabilities) {
- this.fullfilledCapabilities = fullfilledCapabilities;
- }
- public Map<String, MapListRequirementDataDefinition> getFullfilledRequirements() {
- return fullfilledRequirements;
- }
- public void setFullfilledRequirements(Map<String, MapListRequirementDataDefinition> fullfilledRequirements) {
- this.fullfilledRequirements = fullfilledRequirements;
- }
-
- public Map<String, MapArtifactDataDefinition> getInstDeploymentArtifacts() {
- return instDeploymentArtifacts;
- }
- public void setInstDeploymentArtifacts(Map<String, MapArtifactDataDefinition> instDeploymentArtifacts) {
- this.instDeploymentArtifacts = instDeploymentArtifacts;
- }
-
- public Map<String, MapCapabilityProperty> getCalculatedCapabilitiesProperties() {
- return calculatedCapabilitiesProperties;
- }
- public void setCalculatedCapabilitiesProperties(Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties) {
- this.calculatedCapabilitiesProperties = calculatedCapabilitiesProperties;
- }
-
- public Map<String, MapArtifactDataDefinition> getInstanceArtifacts() {
- return instanceArtifacts;
- }
- public void setInstanceArtifacts(Map<String, MapArtifactDataDefinition> instanceArtifacts) {
- this.instanceArtifacts = instanceArtifacts;
- }
-
- public Map<String, ForwardingPathDataDefinition> getForwardingPaths() {
- return forwardingPaths;
- }
-
- public void setForwardingPaths(Map<String, ForwardingPathDataDefinition> forwardingPaths) {
- this.forwardingPaths = forwardingPaths;
- }
-
- public Map<String, CINodeFilterDataDefinition> getNodeFilterComponents() {
- return nodeFilterComponents;
- }
-
- public void setNodeFilterComponents(Map<String, CINodeFilterDataDefinition> nodeFilters) {
- this.nodeFilterComponents = nodeFilters;
- }
-
- public Map<String, SubstitutionFilterDataDefinition> getSubstitutionFilterDataDefinitionMap() {
- return substitutionFilterDataDefinitionMap;
- }
-
- public void setSubstitutionFilterDataDefinitionMap(
- Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap) {
- this.substitutionFilterDataDefinitionMap = substitutionFilterDataDefinitionMap;
- }
-
- /**
- * Gets data types.
- * @return Current data types.
- */
- public Map<String, DataTypeDataDefinition> getDataTypes() {
- return dataTypes;
- }
-
/**
- * Sets data types.
- * @param dataTypes New data types.
- */
- public void setDataTypes(Map<String, DataTypeDataDefinition> dataTypes) {
- this.dataTypes = dataTypes;
- }
-
- /**
- * Adds component instance to composition of topology template
- * Note that component instance will be overrided in case if the topology template already contains a component instance with the same name
+ * Adds component instance to composition of topology template Note that component instance will be overrided in
+ * case if the topology template already contains a component instance with the same name
+ *
* @param componentInstance
*/
- public void addComponentInstance(ComponentInstanceDataDefinition componentInstance){
- if(getCompositions() == null){
+ public void addComponentInstance(ComponentInstanceDataDefinition componentInstance) {
+ if (getCompositions() == null) {
compositions = new HashMap<>();
}
- if(MapUtils.isEmpty(getCompositions())){
+ if (MapUtils.isEmpty(getCompositions())) {
compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition());
}
- if(MapUtils.isEmpty(getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances())){
+ if (MapUtils
+ .isEmpty(getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances())) {
getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(new HashMap<>());
}
- getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances().put(componentInstance.getUniqueId(), componentInstance);
+ getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances()
+ .put(componentInstance.getUniqueId(), componentInstance);
}
+
/**
* Returns map of component instances from composition
+ *
* @return
*/
public Map<String, ComponentInstanceDataDefinition> getComponentInstances() {
Map<String, ComponentInstanceDataDefinition> instances = null;
- if(getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){
+ if (getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null) {
instances = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances();
}
return instances;
@@ -297,22 +142,24 @@ public class TopologyTemplate extends ToscaElement{
/**
- * Sets map of component instances to composition of topology template
- * Note that component instances will be overrided in case if the topology template already contains a component instances
+ * Sets map of component instances to composition of topology template Note that component instances will be
+ * overrided in case if the topology template already contains a component instances
+ *
* @param instances
*/
public void setComponentInstances(Map<String, ComponentInstanceDataDefinition> instances) {
- if(getCompositions() == null){
+ if (getCompositions() == null) {
compositions = new HashMap<>();
}
- if(MapUtils.isEmpty(getCompositions())){
+ if (MapUtils.isEmpty(getCompositions())) {
compositions.put(JsonConstantKeysEnum.COMPOSITION.getValue(), new CompositionDataDefinition());
}
getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).setComponentInstances(instances);
}
+
public Map<String, RelationshipInstDataDefinition> getRelations() {
Map<String, RelationshipInstDataDefinition> relations = null;
- if( getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null ){
+ if (getCompositions() != null && getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()) != null) {
relations = getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getRelations();
}
return relations;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
index 930ba791d5..9cadd4e107 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperation.java
@@ -63,6 +63,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
@@ -78,23 +79,7 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceInput;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.GroupInstance;
-import org.openecomp.sdc.be.model.InputDefinition;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RelationshipImpl;
-import org.openecomp.sdc.be.model.RelationshipInfo;
-import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.NodeType;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
@@ -958,8 +943,8 @@ public class NodeTemplateOperation extends BaseOperation {
}
if(MapUtils.isNotEmpty(originNodeType.getAttributes())){
- MapPropertiesDataDefinition instAttributes =
- new MapPropertiesDataDefinition(originNodeType.getAttributes());
+ MapAttributesDataDefinition instAttributes =
+ new MapAttributesDataDefinition(originNodeType.getAttributes());
status = addToscaDataDeepElementsBlockToToscaElement(updatedContainerVertex, EdgeLabelEnum.INST_ATTRIBUTES,
VertexTypeEnum.INST_ATTRIBUTES, instAttributes, componentInstance.getUniqueId());
if (status != StorageOperationStatus.OK) {
@@ -2199,16 +2184,16 @@ public class NodeTemplateOperation extends BaseOperation {
return updateToscaDataDeepElementsOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, properties, pathKeys, JsonPresentationFields.NAME);
}
- public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){
+ public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME);
}
- public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){
+ public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
- return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, property, pathKeys, JsonPresentationFields.NAME);
+ return addToscaDataDeepElementToToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, attribute, pathKeys, JsonPresentationFields.NAME);
}
public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
index 9a70e9c837..004451c667 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
@@ -389,7 +389,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
}
private JanusGraphOperationStatus setResourceAttributesFromGraph(GraphVertex componentV, NodeType toscaElement) {
- Either<Map<String, PropertyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES);
+ Either<Map<String, AttributeDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES);
if (result.isLeft()) {
toscaElement.setAttributes(result.left().value());
} else {
@@ -531,13 +531,13 @@ public class NodeTypeOperation extends ToscaElementOperation {
private StorageOperationStatus associateAttributesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, PropertyDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES);
+ Either<Map<String, AttributeDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
- Map<String, PropertyDataDefinition> attributesAll = dataFromDerived.left().value();
+ Map<String, AttributeDataDefinition> attributesAll = dataFromDerived.left().value();
- Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes();
+ Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes();
if (attributes != null) {
attributes.values().stream().filter(p -> p.getUniqueId() == null).forEach(p -> {
String uid = UniqueIdBuilder.buildAttributeUid(nodeTypeVertex.getUniqueId(), p.getName());
@@ -660,6 +660,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
nodeTypeVertex.setLabel(VertexTypeEnum.NODE_TYPE);
fillCommonMetadata(nodeTypeVertex, nodeType);
+ nodeTypeVertex.setJsonMetadataField(JsonPresentationFields.ATTRIBUTES, nodeType.getAttributes());
return nodeTypeVertex;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
index cc6cd1d430..af6ddd82e5 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
@@ -39,6 +39,9 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
+import org.openecomp.sdc.be.datatypes.elements.MapListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
@@ -537,7 +540,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
}
private StorageOperationStatus associateInstAttributesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
- Map<String, MapPropertiesDataDefinition> instAttr = topologyTemplate.getInstAttributes();
+ Map<String, MapAttributesDataDefinition> instAttr = topologyTemplate.getInstAttributes();
return associateInstAttributeToComponent(nodeTypeVertex, instAttr);
}
@@ -551,7 +554,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
return StorageOperationStatus.OK;
}
- public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instAttr) {
+ public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapAttributesDataDefinition> instAttr) {
if (instAttr != null && !instAttr.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INST_ATTRIBUTES, EdgeLabelEnum.INST_ATTRIBUTES, instAttr);
if (assosiateElementToData.isRight()) {
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 ec1185a706..90111e80ac 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
@@ -25,6 +25,7 @@ import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -41,12 +42,14 @@ import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils;
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.PropertyDataDefinition;
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.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
@@ -92,7 +95,6 @@ public abstract class ToscaElementOperation extends BaseOperation {
return gson;
}
-
protected Either<GraphVertex, StorageOperationStatus> getComponentByLabelAndId(String uniqueId, ToscaElementTypeEnum nodeType, JsonParseFlagEnum parseFlag) {
Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
@@ -912,6 +914,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
switch (label) {
case NODE_TYPE:
toscaElement = new NodeType();
+ ((NodeType) toscaElement).setAttributes(getAttributesFromComponentV(componentV));
break;
case TOPOLOGY_TEMPLATE:
toscaElement = new TopologyTemplate();
@@ -923,8 +926,8 @@ public abstract class ToscaElementOperation extends BaseOperation {
if (toscaElement != null) {
final Map<String, Object> jsonMetada = componentV.getMetadataJson();
+ if (MapUtils.isNotEmpty(jsonMetada)) {
toscaElement.setMetadata(jsonMetada);
- if (jsonMetada != null) {
final Object toscaVersion = jsonMetada.get(ToscaTagNamesEnum.TOSCA_VERSION.getElementName());
if (toscaVersion != null) {
toscaElement.setToscaVersion((String) toscaVersion);
@@ -934,6 +937,28 @@ public abstract class ToscaElementOperation extends BaseOperation {
return (T) toscaElement;
}
+ private Map<String, AttributeDataDefinition> getAttributesFromComponentV(final GraphVertex componentV) {
+ final Map<String, Object> jsonMetada = componentV.getMetadataJson();
+ final Map<String, AttributeDataDefinition> attributeDataDefinitionMap = new HashMap<>();
+ if (MapUtils.isNotEmpty(jsonMetada)) {
+ final Object attributes = jsonMetada.get(ToscaTagNamesEnum.ATTRIBUTES.getElementName());
+ if (attributes instanceof Map) {
+ final Map<String, Object> map = (Map<String, Object>) attributes;
+ attributeDataDefinitionMap.putAll(map.values().stream().map(attributeMap -> {
+ final AttributeDefinition attributeDef = new AttributeDefinition();
+ final String name = (String) ((Map<String, Object>) attributeMap).get("name");
+ attributeDef.setName(name);
+ final String type = (String) ((Map<String, Object>) attributeMap).get("type");
+ attributeDef.setType(type);
+ final String description = (String) ((Map<String, Object>) attributeMap).get("description");
+ attributeDef.setDescription(description);
+ return attributeDef;
+ }).collect(Collectors.toMap(AttributeDefinition::getName, a -> a)));
+ }
+ }
+ return attributeDataDefinitionMap;
+ }
+
protected JanusGraphOperationStatus setResourceCategoryFromGraphV(Vertex vertex, CatalogComponent catalogComponent) {
List<CategoryDefinition> categories = new ArrayList<>();
SubCategoryDefinition subcategory;
@@ -1320,8 +1345,9 @@ public abstract class ToscaElementOperation extends BaseOperation {
ResourceTypeEnum resourceType = ResourceTypeEnum.getType((String) resourceTypeStr);
if (!CollectionUtils.isEmpty(excludeTypes)) {
Optional<ResourceTypeEnum> op = excludeTypes.stream().filter(rt -> rt == resourceType).findAny();
- if (op.isPresent())
+ if (op.isPresent()) {
isAddToCatalog = false;
+ }
}
}
return isAddToCatalog;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index 427939f2f8..5b4388226b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -1472,7 +1472,7 @@ public class ToscaOperationFacade {
}
- public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<PropertyDefinition>> instArttributes, Component component) {
+ public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<AttributeDataDefinition>> instArttributes, Component component) {
Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
if (getVertexEither.isRight()) {
@@ -1482,24 +1482,24 @@ public class ToscaOperationFacade {
}
GraphVertex vertex = getVertexEither.left().value();
- Map<String, MapPropertiesDataDefinition> instAttr = new HashMap<>();
+ Map<String, MapAttributesDataDefinition> instAttr = new HashMap<>();
if (instArttributes != null) {
- MapPropertiesDataDefinition attributesMap;
- for (Entry<String, List<PropertyDefinition>> entry : instArttributes.entrySet()) {
- attributesMap = new MapPropertiesDataDefinition();
- attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e)));
+ MapAttributesDataDefinition attributesMap;
+ for (Entry<String, List<AttributeDataDefinition>> entry : instArttributes.entrySet()) {
+ final List<AttributeDataDefinition> value = entry.getValue();
+ attributesMap = new MapAttributesDataDefinition();
+ attributesMap.setMapToscaDataDefinition(value.stream().map(AttributeDataDefinition::new).collect(Collectors.toMap(AttributeDataDefinition::getName, e -> e)));
instAttr.put(entry.getKey(), attributesMap);
}
}
setComponentInstanceAttributesOnComponent(component, instAttr);
return topologyTemplateOperation.associateInstAttributeToComponent(vertex, instAttr);
-
}
// endregion
- private void setComponentInstanceAttributesOnComponent(Component resource, Map<String, MapPropertiesDataDefinition> instAttr) {
- Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes = resource.getComponentInstancesAttributes();
+ private void setComponentInstanceAttributesOnComponent(Component resource, Map<String, MapAttributesDataDefinition> instAttr) {
+ Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes = resource.getComponentInstancesAttributes();
if (componentInstancesAttributes == null)
componentInstancesAttributes = new HashMap<>();
componentInstancesAttributes.putAll(ModelConverter.getComponentInstancesAttributes(instAttr));
@@ -2382,11 +2382,10 @@ public class ToscaOperationFacade {
}
-
- public Either<PropertyDefinition, StorageOperationStatus> addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) {
+ public Either<AttributeDataDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
- Either<PropertyDefinition, StorageOperationStatus> result = null;
+ Either<AttributeDataDefinition, StorageOperationStatus> result = null;
if (newAttributeDef.getUniqueId() == null || newAttributeDef.getUniqueId().isEmpty()) {
String attUniqueId = UniqueIdBuilder.buildAttributeUid(component.getUniqueId(), newAttributeDef.getName());
newAttributeDef.setUniqueId(attUniqueId);
@@ -2407,7 +2406,7 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<PropertyDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+ Optional<AttributeDataDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
if (newAttribute.isPresent()) {
result = Either.left(newAttribute.get());
} else {
@@ -2418,10 +2417,10 @@ public class ToscaOperationFacade {
return result;
}
- public Either<PropertyDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, PropertyDefinition newAttributeDef) {
+ public Either<AttributeDataDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
- Either<PropertyDefinition, StorageOperationStatus> result = null;
+ Either<AttributeDataDefinition, StorageOperationStatus> result = null;
StorageOperationStatus status = getToscaElementOperation(component).updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME);
if (status != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newAttributeDef.getName(), component.getName(), status);
@@ -2437,7 +2436,7 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<PropertyDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+ Optional<AttributeDataDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
if (newProperty.isPresent()) {
result = Either.left(newProperty.get());
} else {
@@ -2536,12 +2535,12 @@ public class ToscaOperationFacade {
return nodeTemplateOperation.addComponentInstanceProperty(containerComponent, componentInstanceId, property);
}
- public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){
+ public StorageOperationStatus updateComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute property){
return nodeTemplateOperation.updateComponentInstanceAttribute(containerComponent, componentInstanceId, property);
}
- public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property){
- return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, property);
+ public StorageOperationStatus addComponentInstanceAttribute(Component containerComponent, String componentInstanceId, ComponentInstanceAttribute attribute){
+ return nodeTemplateOperation.addComponentInstanceAttribute(containerComponent, componentInstanceId, attribute);
}
public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
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 c278632dad..5ceb7f194c 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
@@ -48,6 +48,7 @@ import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
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.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
@@ -60,6 +61,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabilityProperty;
import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition;
@@ -79,10 +81,12 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFieldsExtractor;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -177,8 +181,6 @@ public class ModelConverter {
return vertexType;
}
-
-
private static Service convertToService(ToscaElement toscaElement) {
Service service = new Service();
convertComponentFields(service, toscaElement);
@@ -308,9 +310,10 @@ public class ModelConverter {
}
private static void convertAttributes(NodeType nodeType, Resource resource) {
- Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes();
+ Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes();
if (attributes != null) {
- List<PropertyDefinition> attrs = attributes.values().stream().map(dataDef -> ModelConverter.fromDataDefinition(resource.getUniqueId(), dataDef)).collect(Collectors.toList());
+ final List<AttributeDataDefinition> attrs = attributes.values().stream()
+ .collect(Collectors.toList());
resource.setAttributes(attrs);
}
}
@@ -984,9 +987,10 @@ public class ModelConverter {
}
private static void convertAttributes(Resource component, NodeType nodeType) {
- List<PropertyDefinition> attributes = component.getAttributes();
+ List<AttributeDataDefinition> attributes = component.getAttributes();
if (attributes != null) {
- Map<String, PropertyDataDefinition> attrsByName = attributes.stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity()));
+ Map<String, AttributeDataDefinition> attrsByName = attributes.stream()
+ .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity()));
nodeType.setAttributes(attrsByName);
}
}
@@ -1434,8 +1438,10 @@ public class ModelConverter {
for (Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstProperties().entrySet()) {
if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
String key = entry.getKey();
- List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue())))
- .collect(Collectors.toList());
+ List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue()
+ .getMapToscaDataDefinition().entrySet().stream()
+ .map(e -> new ComponentInstanceProperty(new PropertyDefinition(e.getValue())))
+ .collect(Collectors.toList());
properties.put(key, componentInstanceAttributes);
}
}
@@ -1443,13 +1449,16 @@ public class ModelConverter {
}
}
- public static Map<String, List<ComponentInstanceProperty>> getComponentInstancesAttributes(Map<String, MapPropertiesDataDefinition> mapPropertiesDataDefinition) {
- Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>();
- for (Map.Entry<String, MapPropertiesDataDefinition> entry : mapPropertiesDataDefinition.entrySet()) {
+ public static Map<String, List<ComponentInstanceAttribute>> getComponentInstancesAttributes(
+ Map<String, MapAttributesDataDefinition> mapAttributesDataDefinitionMap) {
+ Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>();
+ for (Map.Entry<String, MapAttributesDataDefinition> entry : mapAttributesDataDefinitionMap.entrySet()) {
if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
String key = entry.getKey();
- List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue())))
- .collect(Collectors.toList());
+ List<ComponentInstanceAttribute> componentInstanceAttributes = entry.getValue()
+ .getMapToscaDataDefinition().entrySet().stream()
+ .map(e -> new ComponentInstanceAttribute(new ComponentInstanceAttribute(e.getValue())))
+ .collect(Collectors.toList());
attributes.put(key, componentInstanceAttributes);
}
}
@@ -1490,12 +1499,15 @@ public class ModelConverter {
private static void setComponentInstancesAttributesToComponent(TopologyTemplate topologyTemplate, Component component) {
if (topologyTemplate.getInstAttributes() != null) {
- Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>();
- for (Map.Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) {
+ Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>();
+ for (Map.Entry<String, MapAttributesDataDefinition> entry : topologyTemplate.getInstAttributes()
+ .entrySet()) {
if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
String key = entry.getKey();
- List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue())))
- .collect(Collectors.toList());
+ List<ComponentInstanceAttribute> componentInstanceAttributes = entry.getValue()
+ .getMapToscaDataDefinition().entrySet().stream()
+ .map(e -> new ComponentInstanceAttribute(new ComponentInstanceAttribute(e.getValue())))
+ .collect(Collectors.toList());
attributes.put(key, componentInstanceAttributes);
}
}
@@ -1857,11 +1869,13 @@ public class ModelConverter {
if (component.getComponentInstancesAttributes() != null) {
topologyTemplate.setInstAttributes(new HashMap<>());
- MapPropertiesDataDefinition attributesMap;
- for (Entry<String, List<ComponentInstanceProperty>> entry : component.getComponentInstancesAttributes().entrySet()) {
- attributesMap = new MapPropertiesDataDefinition();
+ MapAttributesDataDefinition attributesMap;
+ for (Entry<String, List<ComponentInstanceAttribute>> entry : component.getComponentInstancesAttributes()
+ .entrySet()) {
+ attributesMap = new MapAttributesDataDefinition();
- attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity())));
+ attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(AttributeDefinition::new)
+ .collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity())));
topologyTemplate.getInstAttributes().put(entry.getKey(), attributesMap);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
index f03a5e724f..d499dfe799 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
@@ -32,6 +32,7 @@ import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -63,7 +64,7 @@ public class UiComponentDataTransfer {
private List<RequirementCapabilityRelDef> componentInstancesRelations;
private Map<String, List<ComponentInstanceInput>> componentInstancesInputs;
private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties;
- private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes;
+ private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes;
private Map<String, List<CapabilityDefinition>> capabilities;
private List<PolicyDefinition> policies;
private Map<String, List<RequirementDefinition>> requirements;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
index 380593b4b3..a51c368c71 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
@@ -25,6 +25,8 @@ import java.util.Map;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -41,7 +43,7 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer {
private List<PropertyDefinition> properties;
- private List<PropertyDefinition> attributes;
+ private List<AttributeDataDefinition> attributes;
private Map<String, InterfaceDefinition> interfaces;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java
index 41de118272..569691869f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityDefinitionTest.java
@@ -21,12 +21,7 @@
*/
package org.openecomp.sdc.be.model;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsFor;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeFor;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanToStringFor;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.HashMap;
@@ -46,27 +41,6 @@ public class CapabilityDefinitionTest {
private static final String VALUE = "VALUE";
@Test
- public void hasValidGettersAndSettersTest() {
- assertThat(CapabilityDefinition.class,
- hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty", "version"));
- }
-
- @Test
- public void shouldHaveValidToString() {
- assertThat(CapabilityDefinition.class, hasValidBeanToStringFor(PROPERTIES));
- }
-
- @Test
- public void shouldHaveEquals() {
- assertThat(CapabilityDefinition.class, hasValidBeanEqualsFor(PROPERTIES));
- }
-
- @Test
- public void shouldHaveHashCode() {
- assertThat(CapabilityDefinition.class, hasValidBeanHashCodeFor(PROPERTIES));
- }
-
- @Test
public void testParamConstructor() {
EqualConstraint equalConstraint = new EqualConstraint(EQ);
CapabilityDefinition capabilityDefinition = createCapabilityDefinition(equalConstraint);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java
index 2a90d937dc..cf3bbf53a2 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/CapabilityTypeDefinitionTest.java
@@ -22,11 +22,8 @@
package org.openecomp.sdc.be.model;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import java.util.Collections;
import org.junit.Test;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition.OwnerType;
import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition;
@@ -42,24 +39,6 @@ public class CapabilityTypeDefinitionTest {
private static final String UNIQUE_ID = "UNIQUE_ID";
@Test
- public void hasValidGettersAndSettersTest() {
- assertThat(CapabilityTypeDefinition.class,
- hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty"));
- }
-
- @Test
- public void shouldHaveValidToString() {
- CapabilityDefinition capabilityDefinition = new CapabilityDefinition(
- new CapabilityTypeDefinition(), OWNER_NAME, NAME, RESOURCE);
- capabilityDefinition.setProperties(Collections.emptyList());
- capabilityDefinition.setType(TYPE);
- capabilityDefinition.setDescription(DESCRIPTION);
- CapabilityTypeDefinition capabilityTypeDefinitionTest = new CapabilityTypeDefinition(capabilityDefinition);
- String toStringRepr = capabilityTypeDefinitionTest.toString();
- assertEquals(toStringRepr, "CapabilityTypeDataDefinition [uniqueId=null, description=DESCRIPTION, type=TYPE, validSourceTypes=[], version=null, creationTime=null, modificationTime=null] [ derivedFrom=null, properties={} ]");
- }
-
- @Test
public void shouldCreateCapabilityTypeDefinitionFromCapabilityTypeData() {
CapabilityTypeData capabilityTypeData = new CapabilityTypeData();
CapabilityTypeDataDefinition capabilityTypeDataDefinition = new CapabilityTypeDataDefinition();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java
index 044e9e0c57..d0c1a666f4 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java
@@ -19,9 +19,7 @@
*/
package org.openecomp.sdc.be.model;
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
@@ -35,17 +33,6 @@ public class ComponentInstanceInterfaceBeanTest {
private static final String ID = "ID";
@Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(ComponentInstanceInterface.class,
- hasValidGettersAndSettersExcluding(
- "definition",
- "ownerIdIfEmpty",
- "empty",
- "operationsMap",
- "version"));
- }
-
- @Test
public void verifyConstructors() {
INTERFACE_DATA_DEFINITION.setUniqueId(ID);
ComponentInstanceInterface componentInstanceInterface1 = new ComponentInstanceInterface(INTERFACE_ID,
@@ -58,4 +45,4 @@ public class ComponentInstanceInterfaceBeanTest {
assertEquals(componentInstanceInterface1.getUniqueId(), ID);
assertEquals(componentInstanceInterface2.getInterfaceInstanceDataDefinition(), INTERFACE_INSTANCE_DATA_DEFINITION);
}
-} \ No newline at end of file
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
index cb50c9601c..447b053fea 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.openecomp.sdc.be.config.Configuration;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.unittests.utils.ModelConfDependentTest;
@@ -45,66 +46,6 @@ public class ResourceTest extends ModelConfDependentTest {
}
@Test
- public void testGetProperties() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProperties();
- }
-
- @Test
- public void testSetProperties() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProperties(properties);
- }
-
- @Test
- public void testGetAttributes() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAttributes();
- }
-
- @Test
- public void testSetAttributes() throws Exception {
- Resource testSubject;
- List<PropertyDefinition> attributes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAttributes(attributes);
- }
-
- @Test
- public void testGetInterfaces() throws Exception {
- Resource testSubject;
- Map<String, InterfaceDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInterfaces();
- }
-
- @Test
- public void testSetInterfaces() throws Exception {
- Resource testSubject;
- Map<String, InterfaceDefinition> interfaces = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInterfaces(interfaces);
- }
-
- @Test
public void testIsAbstract() throws Exception {
Resource testSubject;
Boolean result;
@@ -165,47 +106,6 @@ public class ResourceTest extends ModelConfDependentTest {
}
@Test
- public void testHashCode() throws Exception {
- Resource testSubject;
- int result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
- @Test
- public void testEquals() throws Exception {
- Resource testSubject;
- Object obj = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- obj = new Object();
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- result = testSubject.equals(testSubject);
- Assert.assertEquals(true, result);
-
- Resource testSubject2 = createTestSubject();
- result = testSubject.equals(testSubject2);
- Assert.assertEquals(true, result);
- }
-
- @Test
- public void testToString() throws Exception {
- Resource testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-
- @Test
public void testGetToscaResourceName() throws Exception {
Resource testSubject;
String result;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java
index 011214a7c9..9473b1cd45 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/NodeTypeTest.java
@@ -20,16 +20,8 @@
package org.openecomp.sdc.be.model.jsonjanusgraph.datamodel;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class NodeTypeTest {
@@ -37,157 +29,14 @@ public class NodeTypeTest {
return new NodeType();
}
-
- @Test
- public void testGetDerivedList() throws Exception {
- NodeType testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDerivedList();
- }
-
-
- @Test
- public void testSetDerivedList() throws Exception {
- NodeType testSubject;
- List<String> derivedList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDerivedList(derivedList);
- }
-
-
- @Test
- public void testGetDerivedFrom() throws Exception {
- NodeType testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDerivedFrom();
- }
-
-
- @Test
- public void testSetDerivedFrom() throws Exception {
- NodeType testSubject;
- List<String> derivedFrom = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDerivedFrom(derivedFrom);
- }
-
-
- @Test
- public void testGetAttributes() throws Exception {
- NodeType testSubject;
- Map<String, PropertyDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAttributes();
- }
-
-
- @Test
- public void testSetAttributes() throws Exception {
- NodeType testSubject;
- Map<String, PropertyDataDefinition> attributes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAttributes(attributes);
- }
-
-
- @Test
- public void testGetCapabilties() throws Exception {
- NodeType testSubject;
- Map<String, ListCapabilityDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCapabilities();
- }
-
-
- @Test
- public void testSetCapabilties() throws Exception {
- NodeType testSubject;
- Map<String, ListCapabilityDataDefinition> capabilties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCapabilities(capabilties);
- }
-
-
- @Test
- public void testGetRequirements() throws Exception {
- NodeType testSubject;
- Map<String, ListRequirementDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRequirements();
- }
-
-
- @Test
- public void testSetRequirements() throws Exception {
- NodeType testSubject;
- Map<String, ListRequirementDataDefinition> requirements = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRequirements(requirements);
- }
-
-
- @Test
- public void testGetCapabiltiesProperties() throws Exception {
- NodeType testSubject;
- Map<String, MapPropertiesDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCapabilitiesProperties();
- }
-
-
@Test
- public void testSetCapabiltiesProperties() throws Exception {
+ public void testCTOR() throws Exception {
NodeType testSubject;
- Map<String, MapPropertiesDataDefinition> capabiltiesProperties = null;
// default test
testSubject = createTestSubject();
- testSubject.setCapabilitiesProperties(capabiltiesProperties);
+ Assertions.assertNotNull(testSubject);
+ Assertions.assertEquals(ToscaElementTypeEnum.NODE_TYPE, testSubject.getToscaType());
}
-
- @Test
- public void testGetInterfaceArtifacts() throws Exception {
- NodeType testSubject;
- Map<String, InterfaceDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInterfaceArtifacts();
- }
-
-
- @Test
- public void testSetInterfaceArtifacts() throws Exception {
- NodeType testSubject;
- Map<String, InterfaceDataDefinition> interfaceArtifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInterfaceArtifacts(interfaceArtifacts);
- }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java
index 4ea05e5925..d9beb9d644 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplateTest.java
@@ -26,388 +26,12 @@ import org.junit.Test;
import org.openecomp.sdc.be.datatypes.elements.*;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-
public class TopologyTemplateTest {
private TopologyTemplate createTestSubject() {
return new TopologyTemplate();
}
-
- @Test
- public void testGetInputs() throws Exception {
- TopologyTemplate testSubject;
- Map<String, PropertyDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInputs();
- }
-
-
- @Test
- public void testSetInputs() throws Exception {
- TopologyTemplate testSubject;
- Map<String, PropertyDataDefinition> inputs = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInputs(inputs);
- }
-
-
- @Test
- public void testGetInstInputs() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapPropertiesDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstInputs();
- }
-
-
- @Test
- public void testSetInstInputs() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapPropertiesDataDefinition> instInputs = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstInputs(instInputs);
- }
-
-
- @Test
- public void testGetHeatParameters() throws Exception {
- TopologyTemplate testSubject;
- Map<String, ? extends ToscaDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getHeatParameters();
- }
-
-
- @Test
- public void testSetHeatParameters() throws Exception {
- TopologyTemplate testSubject;
- Map<String, ? extends ToscaDataDefinition> heatParameters = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setHeatParameters(heatParameters);
- }
-
-
- @Test
- public void testGetInstAttributes() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapPropertiesDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstAttributes();
- }
-
-
- @Test
- public void testSetInstAttributes() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapPropertiesDataDefinition> instAttributes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstAttributes(instAttributes);
- }
-
-
- @Test
- public void testGetInstProperties() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapPropertiesDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstProperties();
- }
-
-
- @Test
- public void testSetInstProperties() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapPropertiesDataDefinition> instProperties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstProperties(instProperties);
- }
-
-
- @Test
- public void testGetGroups() throws Exception {
- TopologyTemplate testSubject;
- Map<String, GroupDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getGroups();
- }
-
-
- @Test
- public void testSetGroups() throws Exception {
- TopologyTemplate testSubject;
- Map<String, GroupDataDefinition> groups = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setGroups(groups);
- }
-
-
- @Test
- public void testGetInstGroups() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapGroupsDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstGroups();
- }
-
-
- @Test
- public void testSetInstGroups() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapGroupsDataDefinition> instGroups = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstGroups(instGroups);
- }
-
-
- @Test
- public void testGetServiceApiArtifacts() throws Exception {
- TopologyTemplate testSubject;
- Map<String, ArtifactDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServiceApiArtifacts();
- }
-
-
- @Test
- public void testSetServiceApiArtifacts() throws Exception {
- TopologyTemplate testSubject;
- Map<String, ArtifactDataDefinition> serviceApiArtifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServiceApiArtifacts(serviceApiArtifacts);
- }
-
-
- @Test
- public void testGetCompositions() throws Exception {
- TopologyTemplate testSubject;
- Map<String, CompositionDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCompositions();
- }
-
-
- @Test
- public void testSetCompositions() throws Exception {
- TopologyTemplate testSubject;
- Map<String, CompositionDataDefinition> compositions = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCompositions(compositions);
- }
-
-
- @Test
- public void testGetCalculatedCapabilities() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListCapabilityDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCalculatedCapabilities();
- }
-
-
- @Test
- public void testSetCalculatedCapabilities() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListCapabilityDataDefinition> calculatedCapabilities = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCalculatedCapabilities(calculatedCapabilities);
- }
-
-
- @Test
- public void testGetCalculatedRequirements() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListRequirementDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCalculatedRequirements();
- }
-
-
- @Test
- public void testSetCalculatedRequirements() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListRequirementDataDefinition> calculatedRequirements = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCalculatedRequirements(calculatedRequirements);
- }
-
-
- @Test
- public void testGetFullfilledCapabilities() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListCapabilityDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getFullfilledCapabilities();
- }
-
-
- @Test
- public void testSetFullfilledCapabilities() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListCapabilityDataDefinition> fullfilledCapabilities = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setFullfilledCapabilities(fullfilledCapabilities);
- }
-
-
- @Test
- public void testGetFullfilledRequirements() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListRequirementDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getFullfilledRequirements();
- }
-
-
- @Test
- public void testSetFullfilledRequirements() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapListRequirementDataDefinition> fullfilledRequirements = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setFullfilledRequirements(fullfilledRequirements);
- }
-
-
- @Test
- public void testGetInstDeploymentArtifacts() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapArtifactDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstDeploymentArtifacts();
- }
-
-
- @Test
- public void testSetInstDeploymentArtifacts() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstDeploymentArtifacts(instDeploymentArtifacts);
- }
-
-
- @Test
- public void testGetCalculatedCapabilitiesProperties() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapCapabilityProperty> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCalculatedCapabilitiesProperties();
- }
-
-
- @Test
- public void testSetCalculatedCapabilitiesProperties() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapCapabilityProperty> calculatedCapabilitiesProperties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCalculatedCapabilitiesProperties(calculatedCapabilitiesProperties);
- }
-
-
- @Test
- public void testGetInstanceArtifacts() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapArtifactDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInstanceArtifacts();
- }
-
-
- @Test
- public void testSetInstanceArtifacts() throws Exception {
- TopologyTemplate testSubject;
- Map<String, MapArtifactDataDefinition> instanceArtifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInstanceArtifacts(instanceArtifacts);
- }
-
-
- @Test
- public void testGetDataTypes() throws Exception {
- TopologyTemplate testSubject;
- Map<String, DataTypeDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDataTypes();
- }
-
-
- @Test
- public void testSetDataTypes() throws Exception {
- TopologyTemplate testSubject;
- Map<String, DataTypeDataDefinition> dataTypes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDataTypes(dataTypes);
- }
-
-
@Test
public void testGetComponentInstances() throws Exception {
TopologyTemplate testSubject;
@@ -418,7 +42,6 @@ public class TopologyTemplateTest {
result = testSubject.getComponentInstances();
}
-
@Test
public void testSetComponentInstances() throws Exception {
TopologyTemplate testSubject;
@@ -429,7 +52,6 @@ public class TopologyTemplateTest {
testSubject.setComponentInstances(instances);
}
-
@Test
public void testGetRelations() throws Exception {
TopologyTemplate testSubject;
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
new file mode 100644
index 0000000000..b619c66ee0
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.datatypes.elements;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class AttributeDataDefinition extends ToscaDataDefinition{
+
+ private String uniqueId;
+ private String name;
+ private SchemaDefinition schema;
+ private String value;
+
+ public AttributeDataDefinition(final AttributeDataDefinition attributeDataDefinition) {
+ super();
+ this.setUniqueId(attributeDataDefinition.getUniqueId());
+ this.setName(attributeDataDefinition.getName());
+ this.setSchema(attributeDataDefinition.getSchema());
+ this.setValue(attributeDataDefinition.getValue());
+ }
+
+ public String getParentUniqueId() {
+ return getOwnerId();
+ }
+
+ public void setParentUniqueId(final String parentUniqueId) {
+ setOwnerId(parentUniqueId);
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java
index 2b3b5fbbbf..80eadc2489 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java
@@ -20,8 +20,19 @@
package org.openecomp.sdc.be.datatypes.elements;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.commons.lang3.builder.HashCodeExclude;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+@Getter
+@Setter
+@EqualsAndHashCode
+@ToString
+@NoArgsConstructor
public class ConsumerDataDefinition extends ToscaDataDefinition {
// ECOMP Consumer Name - UTF-8 string up to 255 characters containing the
@@ -55,10 +66,6 @@ public class ConsumerDataDefinition extends ToscaDataDefinition {
private Long consumerDetailsLastupdatedtime;
private String lastModfierAtuid;
- public ConsumerDataDefinition() {
-
- }
-
public ConsumerDataDefinition(ConsumerDataDefinition a) {
this.consumerName = a.consumerName;
this.consumerPassword = a.consumerPassword;
@@ -69,138 +76,4 @@ public class ConsumerDataDefinition extends ToscaDataDefinition {
}
- public String getConsumerName() {
- return consumerName;
- }
-
- public void setConsumerName(String consumerName) {
- this.consumerName = consumerName;
- }
-
- public String getConsumerPassword() {
- return consumerPassword;
- }
-
- public void setConsumerPassword(String consumerPassword) {
- this.consumerPassword = consumerPassword;
- }
-
- public String getConsumerSalt() {
- return consumerSalt;
- }
-
- public void setConsumerSalt(String consumerSalt) {
- this.consumerSalt = consumerSalt;
- }
-
- public Long getConsumerLastAuthenticationTime() {
- return consumerLastAuthenticationTime;
- }
-
- public void setConsumerLastAuthenticationTime(Long consumerLastAuthenticationTime) {
- this.consumerLastAuthenticationTime = consumerLastAuthenticationTime;
- }
-
- public Long getConsumerDetailsLastupdatedtime() {
- return consumerDetailsLastupdatedtime;
- }
-
- public void setConsumerDetailsLastupdatedtime(Long consumerDetailsLastupdatedtime) {
- this.consumerDetailsLastupdatedtime = consumerDetailsLastupdatedtime;
- }
-
- public String getLastModfierAtuid() {
- return lastModfierAtuid;
- }
-
- public void setLastModfierAtuid(String lastModfierAtuid) {
- this.lastModfierAtuid = lastModfierAtuid;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("ConsumerDataDefinition [").append("consumerName=").append(consumerName).append(",")
- .append("consumerPassword=").append(consumerPassword).append(",").append("consumerSalt=")
- .append(consumerSalt).append(",").append("consumerLastAuthenticationTime=")
- .append(consumerLastAuthenticationTime).append(",").append("consumerDetailsLastupdatedtime=")
- .append(consumerDetailsLastupdatedtime).append(",").append("lastModfierAtuid=").append(lastModfierAtuid)
- .append("]");
- return sb.toString();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((consumerName == null) ? 0 : consumerName.hashCode());
- result = prime * result + ((consumerPassword == null) ? 0 : consumerPassword.hashCode());
- result = prime * result + ((consumerSalt == null) ? 0 : consumerSalt.hashCode());
- result = prime * result
- + ((consumerLastAuthenticationTime == null) ? 0 : consumerLastAuthenticationTime.hashCode());
- result = prime * result
- + ((consumerDetailsLastupdatedtime == null) ? 0 : consumerDetailsLastupdatedtime.hashCode());
- result = prime * result + ((lastModfierAtuid == null) ? 0 : lastModfierAtuid.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ConsumerDataDefinition other = (ConsumerDataDefinition) obj;
- if (consumerName == null) {
- if (other.consumerName != null) {
- return false;
- }
- } else if (!consumerName.equals(other.consumerName)) {
- return false;
- }
- if (consumerPassword == null) {
- if (other.consumerPassword != null) {
- return false;
- }
- } else if (!consumerPassword.equals(other.consumerPassword)) {
- return false;
- }
-
- if (consumerSalt == null) {
- if (other.consumerSalt != null) {
- return false;
- }
- } else if (!consumerSalt.equals(other.consumerSalt)) {
- return false;
- }
-
- if (consumerLastAuthenticationTime == null) {
- if (other.consumerLastAuthenticationTime != null) {
- return false;
- }
- } else if (!consumerLastAuthenticationTime.equals(other.consumerLastAuthenticationTime)) {
- return false;
- }
-
- if (consumerDetailsLastupdatedtime == null) {
- if (other.consumerDetailsLastupdatedtime != null) {
- return false;
- }
- } else if (!consumerDetailsLastupdatedtime.equals(other.consumerDetailsLastupdatedtime)) {
- return false;
- }
-
- if (lastModfierAtuid == null) {
- return other.lastModfierAtuid == null;
- } else {
- return lastModfierAtuid.equals(other.lastModfierAtuid);
- }
-
- }
-
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java
new file mode 100644
index 0000000000..31c791681c
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.datatypes.elements;
+
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapAttributesDataDefinition extends MapDataDefinition<AttributeDataDefinition> {
+
+ private String parentName;
+
+ public MapAttributesDataDefinition(MapDataDefinition cdt, String parentName) {
+ super(cdt);
+ this.parentName = parentName;
+ }
+
+ @JsonCreator
+ public MapAttributesDataDefinition(Map<String, AttributeDataDefinition> mapToscaDataDefinition) {
+ super(mapToscaDataDefinition);
+ }
+
+ /**
+ * Copy Constructor
+ */
+ public MapAttributesDataDefinition(MapAttributesDataDefinition toBeDeepCopiedMapPropertiesDataDefinition) {
+ this.parentName = toBeDeepCopiedMapPropertiesDataDefinition.parentName;
+ this.toscaPresentation = toBeDeepCopiedMapPropertiesDataDefinition.toscaPresentation == null ? null : new HashMap(toBeDeepCopiedMapPropertiesDataDefinition.toscaPresentation);
+ this.mapToscaDataDefinition = toBeDeepCopiedMapPropertiesDataDefinition.mapToscaDataDefinition == null ? null : new HashMap(toBeDeepCopiedMapPropertiesDataDefinition.mapToscaDataDefinition);
+ }
+
+ public MapAttributesDataDefinition() {
+ super();
+
+ }
+
+ @JsonValue
+ @Override
+ public Map<String, AttributeDataDefinition> getMapToscaDataDefinition() {
+ return mapToscaDataDefinition;
+ }
+
+
+ public void setMapToscaDataDefinition(Map<String, AttributeDataDefinition> mapToscaDataDefinition) {
+ this.mapToscaDataDefinition = mapToscaDataDefinition;
+ }
+
+ public String getParentName() {
+ return parentName;
+ }
+
+ public void setParentName(String parentName) {
+ this.parentName = parentName;
+ }
+
+
+}
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 027519500f..2dca70cad1 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
@@ -248,6 +248,8 @@ public enum JsonPresentationFields {
GET_INPUT("get_input", null),
GET_OPERATION_OUTPUT("get_operation_output", null),
+ ATTRIBUTES("attributes", null),
+
TOSCA_DEFINITIONS_VERSION("tosca_definitions_version", null);
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
index 4637231de6..c1e6dbaa43 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.datatypes.tosca;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import fj.data.Either;
+import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import java.util.HashMap;
@@ -133,4 +134,5 @@ public abstract class ToscaDataDefinition {
return false;
}
+ public void setSchema(final SchemaDefinition schemaDef){};
}
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java
deleted file mode 100644
index b8b55369c5..0000000000
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.datatypes.elements;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.junit.Assert.assertThat;
-
-public class ConsumerDataDefinitionTest {
-
- private ConsumerDataDefinition createTestSubject() {
- return new ConsumerDataDefinition();
- }
-
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(ConsumerDataDefinition.class,
- hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty", "type", "version"));
- }
-
- @Test
- public void testEquals() throws Exception {
- ConsumerDataDefinition testSubject;
- Object obj = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- obj = null;
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- result = testSubject.equals(testSubject);
- Assert.assertEquals(true, result);
- result = testSubject.equals(new ConsumerDataDefinition(testSubject));
- Assert.assertEquals(true, result);
- }
-}
diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
index 26873b359a..00abcea757 100644
--- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
+++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
@@ -20,29 +20,28 @@
package org.onap.sdc.backend.ci.tests.execute.attribute;
+import static org.junit.Assert.assertEquals;
+import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.io.File;
+import java.util.function.Function;
import org.junit.Rule;
import org.junit.rules.TestName;
+import org.onap.sdc.backend.ci.tests.api.ComponentBaseTest;
+import org.onap.sdc.backend.ci.tests.api.Urls;
import org.onap.sdc.backend.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
+import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils;
+import org.onap.sdc.backend.ci.tests.utils.rest.BaseRestUtils;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.Resource;
-import org.onap.sdc.backend.ci.tests.api.ComponentBaseTest;
-import org.onap.sdc.backend.ci.tests.api.Urls;
-import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils;
-import org.onap.sdc.backend.ci.tests.utils.rest.BaseRestUtils;
import org.testng.annotations.Test;
-import java.io.File;
-import java.util.function.Function;
-
-import static org.junit.Assert.assertEquals;
-import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.swallowException;
-
public class ComponentInstanceAttributeTest extends ComponentBaseTest {
public static Gson gson = new GsonBuilder().setPrettyPrinting().create();
@@ -55,34 +54,34 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
// Prepare VF with vfc instance with Attributes
String testResourcesPath = config.getResourceConfigDir() + File.separator + "importToscaResourceByCreateUrl";
final Resource vfcWithAttributes = AtomicOperationUtils
- .importResource(testResourcesPath, "CPWithAttributes.yml").left().value();
+ .importResource(testResourcesPath, "CPWithAttributes.yml").left().value();
swallowException(() -> AtomicOperationUtils.changeComponentState(vfcWithAttributes, UserRoleEnum.DESIGNER,
- LifeCycleStatesEnum.CHECKIN, false));
+ LifeCycleStatesEnum.CHECKIN, false));
Resource vf = AtomicOperationUtils.createResourceByType(ResourceTypeEnum.VF, UserRoleEnum.DESIGNER, false)
- .left().value();
+ .left().value();
ComponentInstance vfcInstance = AtomicOperationUtils
- .addComponentInstanceToComponentContainer(vfcWithAttributes, vf).left().value();
+ .addComponentInstanceToComponentContainer(vfcWithAttributes, vf).left().value();
// util method to get the specific attribute from the vf
- Function<Resource, ComponentInstanceProperty> attributeGetter = resourceVf -> resourceVf
- .getComponentInstancesAttributes().values().iterator().next().stream()
- .filter(att -> att.getName().equals("private_address")).findAny().get();
+ Function<Resource, ComponentInstanceAttribute> attributeGetter = resourceVf -> resourceVf
+ .getComponentInstancesAttributes().values().iterator().next().stream()
+ .filter(att -> att.getName().equals("private_address")).findAny().get();
// update attribute on vfc instance
final Resource vfWithInsatncePreUpdate = swallowException(
- () -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
- ComponentInstanceProperty attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate);
+ () -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
+ ComponentInstanceAttribute attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate);
final String newAttValue = "NewValue";
attributeOfRI.setValue(newAttValue);
String body = gson.toJson(attributeOfRI);
String url = String.format(Urls.UPDATE_ATTRIBUTE_ON_RESOURCE_INSTANCE, config.getCatalogBeHost(),
- config.getCatalogBePort(), ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE),
- vf.getUniqueId(), vfcInstance.getUniqueId());
+ config.getCatalogBePort(), ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE),
+ vf.getUniqueId(), vfcInstance.getUniqueId());
swallowException(() -> BaseRestUtils.sendPost(url, body, UserRoleEnum.DESIGNER.getUserId(),
- BaseRestUtils.acceptHeaderData));
+ BaseRestUtils.acceptHeaderData));
// Retrieve updated vf and verify attribute was updated
final Resource vfWithInsatncePostUpdate = swallowException(
- () -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
- ComponentInstanceProperty updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate);
+ () -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
+ ComponentInstanceAttribute updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate);
assertEquals(updatedAttribute.getValue(), newAttValue);
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
index 0033e37932..89d629d36c 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/attribute/ComponentInstanceAttributeTest.java
@@ -27,7 +27,7 @@ import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
@@ -68,15 +68,15 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
.addComponentInstanceToComponentContainer(vfcWithAttributes, vf).left().value();
// util method to get the specific attribute from the vf
- Function<Resource, ComponentInstanceProperty> attributeGetter = resourceVf -> resourceVf
+ Function<Resource, ComponentInstanceAttribute> attributeGetter = resourceVf -> resourceVf
.getComponentInstancesAttributes().values().iterator().next().stream()
.filter(att -> att.getName().equals("private_address")).findAny().get();
// update attribute on vfc instance
final Resource vfWithInsatncePreUpdate = swallowException(
() -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
- ComponentInstanceProperty attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate);
+ ComponentInstanceAttribute attributeOfRI = attributeGetter.apply(vfWithInsatncePreUpdate);
final String newAttValue = "NewValue";
- attributeOfRI.setValue(newAttValue);
+ attributeOfRI.setValueUniqueUid(newAttValue);
String body = gson.toJson(attributeOfRI);
String url = String.format(Urls.UPDATE_ATTRIBUTE_ON_RESOURCE_INSTANCE, config.getCatalogBeHost(),
config.getCatalogBePort(), ComponentTypeEnum.findParamByType(ComponentTypeEnum.RESOURCE),
@@ -86,8 +86,8 @@ public class ComponentInstanceAttributeTest extends ComponentBaseTest {
// Retrieve updated vf and verify attribute was updated
final Resource vfWithInsatncePostUpdate = swallowException(
() -> (Resource) AtomicOperationUtils.getComponentObject(vf, UserRoleEnum.DESIGNER));
- ComponentInstanceProperty updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate);
- assertEquals(updatedAttribute.getValue(), newAttValue);
+ ComponentInstanceAttribute updatedAttribute = attributeGetter.apply(vfWithInsatncePostUpdate);
+ assertEquals(updatedAttribute.getValueUniqueUid(), newAttValue);
}
}