aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-07-15 09:18:37 +0100
committeraribeiro <anderson.ribeiro@est.tech>2021-08-06 17:22:20 +0100
commit47bcc63a9daff1f310125fed006f27c93656fa83 (patch)
tree3c61670b039c0e63d14880f909e6047d54776492
parent0ed125f98ae8ea9e80c855a640c328654660d081 (diff)
Retrieve data types based on component model
Issue-ID: SDC-3660 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I09c533eb39277532b29e581e4dd57e9df952e8e6
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java41
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java25
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java52
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java23
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java4
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java6
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java13
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java10
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java55
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java37
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java97
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java16
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java24
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java124
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java45
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java34
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java38
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java1
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationCache.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java89
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java126
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupInstanceOperation.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupOperation.java12
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java84
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java36
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java174
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java48
-rw-r--r--catalog-ui/src/app/app.ts2
-rw-r--r--catalog-ui/src/app/models/components/component.ts1
-rw-r--r--catalog-ui/src/app/models/data-types.ts3
-rw-r--r--catalog-ui/src/app/models/model.ts11
-rw-r--r--catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts5
-rw-r--r--catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts7
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts5
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts5
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html2
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts15
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts55
-rw-r--r--catalog-ui/src/app/ng2/services/data-type.service.ts4
-rw-r--r--catalog-ui/src/app/ng2/services/model.service.ts1
-rw-r--r--catalog-ui/src/app/ng2/services/responses/component-generic-response.ts1
-rw-r--r--catalog-ui/src/app/services/data-types-service.ts32
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts2
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts5
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts8
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html2
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java2
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java2
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java11
73 files changed, 1016 insertions, 676 deletions
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
index df13e80fe8..cbbd5eeef6 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
@@ -2536,3 +2536,12 @@ errors:
message: "Error: Component '%1' with Vendor Release '%2' already exists.",
messageId: "SVC4152"
}
+
+ #-----------SVC4153---------------------------
+ # %1 - "Model name"
+ DATA_TYPES_NOT_LOADED: {
+ code: 500,
+ message: "Error: Could not fetch data types from data base with model %1",
+ messageId: "SVC4153"
+ }
+
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
index f8d487169a..953f5e3804 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AnnotationBusinessLogic.java
@@ -54,7 +54,7 @@ public class AnnotationBusinessLogic {
if (isNotEmpty(inputAnnotationList)) {
for (Annotation annotation : inputAnnotationList) {
AnnotationTypeDefinition dbAnnotationTypeDefinition = annotationTypeOperations.getLatestType(annotation.getType());
- validateMergeAndSetAnnoProps(annotation, dbAnnotationTypeDefinition);
+ validateMergeAndSetAnnoProps(annotation, dbAnnotationTypeDefinition, input.getModel());
}
}
input.setAnnotations(inputAnnotationList);
@@ -66,15 +66,16 @@ public class AnnotationBusinessLogic {
return annotationTypeOperations;
}
- private void validateMergeAndSetAnnoProps(Annotation annotation, AnnotationTypeDefinition dbAnnotationTypeDefinition) {
- annotationValidator.validateAnnotationsProperties(annotation, dbAnnotationTypeDefinition);
+ private void validateMergeAndSetAnnoProps(final Annotation annotation, final AnnotationTypeDefinition dbAnnotationTypeDefinition,
+ final String model) {
+ annotationValidator.validateAnnotationsProperties(annotation, dbAnnotationTypeDefinition, model);
List<PropertyDataDefinition> mergedPropertiesList = mergePropsOfAnnoDataTypeWithParsedAnnoProps(annotation.getProperties(),
dbAnnotationTypeDefinition.getProperties());
annotation.setProperties(mergedPropertiesList);
}
- private List<PropertyDataDefinition> mergePropsOfAnnoDataTypeWithParsedAnnoProps(List<PropertyDataDefinition> annoProperties,
- List<PropertyDefinition> typePropertiesList) {
+ private List<PropertyDataDefinition> mergePropsOfAnnoDataTypeWithParsedAnnoProps(final List<PropertyDataDefinition> annoProperties,
+ final List<PropertyDefinition> typePropertiesList) {
Set<PropertyDataDefinition> mergedPropertiesSet = new HashSet<>(typePropertiesList);
Map<String, PropertyDefinition> typePropsMap = MapUtil.toMap(typePropertiesList, PropertyDefinition::getName);
for (PropertyDataDefinition propertyDataDefinitionObject : annoProperties) {
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 687a5d56ef..2380d48deb 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
@@ -104,13 +104,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
if (isAttributeExist(resource.getAttributes(), resourceId, newAttributeDef.getName())) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_ALREADY_EXIST, newAttributeDef.getName()));
}
- Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
+ // fetch DataTypes by Model Name
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel());
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, allDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- handleAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ handleAttributeDefaultValue(newAttributeDef, allDataTypes);
// add the new attribute to resource on graph
// need to get StorageOperationStatus and convert to ActionStatus from
@@ -252,14 +253,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
- Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel());
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, allDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
// add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, eitherAllDataTypes);
+ StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, allDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
result = Either.right(componentsUtils
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 792e6963c0..3cb76806c8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -118,7 +118,6 @@ public abstract class BaseBusinessLogic {
protected AttributeOperation attributeOperation;
protected ApplicationDataTypeCache applicationDataTypeCache;
protected ToscaOperationFacade toscaOperationFacade;
- protected ApplicationDataTypeCache dataTypeCache;
protected IGroupOperation groupOperation;
protected IGroupInstanceOperation groupInstanceOperation;
protected InterfaceLifecycleOperation interfaceLifecycleTypeOperation;
@@ -191,11 +190,6 @@ public abstract class BaseBusinessLogic {
}
@Autowired
- public void setDataTypeCache(ApplicationDataTypeCache dataTypeCache) {
- this.dataTypeCache = dataTypeCache;
- }
-
- @Autowired
public void setPropertyOperation(PropertyOperation propertyOperation) {
this.propertyOperation = propertyOperation;
}
@@ -341,21 +335,12 @@ public abstract class BaseBusinessLogic {
}
<T extends PropertyDataDefinition> String updateInputPropertyObjectValue(T property) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance", "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
String propertyType = property.getType();
String innerType = getInnerType(property);
// Specific Update Logic
Either<Object, Boolean> isValid = propertyOperation
- .validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType, allDataTypes);
+ .validateAndUpdatePropertyValue(propertyType, property.getValue(), true, innerType,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel()));
String newValue = property.getValue();
if (isValid.isRight()) {
Boolean res = isValid.right().value();
@@ -433,21 +418,6 @@ public abstract class BaseBusinessLogic {
return null;
}
- protected Map<String, DataTypeDefinition> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus operationStatus = allDataTypes.right().value();
- if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
- BeEcompErrorManager.getInstance().logInternalDataError("FetchDataTypes", "Data types are not loaded", ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.DATA_TYPE_CANNOT_BE_EMPTY);
- } else {
- BeEcompErrorManager.getInstance().logInternalFlowError("FetchDataTypes", "Failed to fetch data types", ErrorSeverity.ERROR);
- throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
- }
- }
- return allDataTypes.left().value();
- }
-
Either<Boolean, ResponseFormat> validatePropertyDefaultValue(IComplexDefaultValue property, Map<String, DataTypeDefinition> dataTypes) {
String type;
String innerType = null;
@@ -706,7 +676,8 @@ public abstract class BaseBusinessLogic {
if (inputPathArr.length > 1) {
inputPathArr = ArrayUtils.remove(inputPathArr, 0);
}
- Map<String, DataTypeDefinition> dataTypeDefinitionMap = applicationDataTypeCache.getAll().left().value();
+ final Map<String, DataTypeDefinition> dataTypeDefinitionMap =
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, inputDefinition.getModel());
String propertyType = inputDefinition.getParentPropertyType();
for (String anInputPathArr : inputPathArr) {
if (ToscaType.isPrimitiveType(propertyType)) {
@@ -774,4 +745,8 @@ public abstract class BaseBusinessLogic {
}
return result.left().value();
}
+
+ public String getComponentModelByComponentId(final String componentId) throws BusinessLogicException {
+ return getComponent(componentId).getModel();
+ }
}
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 bce343efaf..e2c3df172d 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
@@ -2227,16 +2227,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> Either<String, ResponseFormat> validatePropertyObjectValue(T property, String newValue, boolean isInput) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
+ final Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
String propertyType = property.getType();
String innerType = getInnerType(property);
@@ -2275,16 +2266,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends PropertyDefinition> Either<String, ResponseFormat> updatePropertyObjectValue(T property, boolean isInput) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update property value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
- Map<String, DataTypeDefinition> allDataTypes = allDataTypesEither.left().value();
+ final Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
String innerType = null;
String propertyType = property.getType();
ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
@@ -2341,15 +2323,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
private <T extends AttributeDefinition> Either<String, ResponseFormat> updateAttributeObjectValue(final T attribute) {
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypesEither = dataTypeCache.getAll();
- if (allDataTypesEither.isRight()) {
- JanusGraphOperationStatus status = allDataTypesEither.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError(UPDATE_PROPERTY_CONTEXT, "Failed to update attribute value on instance. Status is " + status,
- ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
String innerType = null;
final String attributeType = attribute.getType();
final ToscaPropertyType type = ToscaPropertyType.isValidType(attributeType);
@@ -2374,7 +2347,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
// Specific Update Logic
String newValue = attribute.getValue();
- final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType, allDataTypesEither.left().value());
+ final var isValid = attributeOperation.validateAndUpdateAttributeValue(attribute, innerType,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, attribute.getModel()));
if (isValid.isRight()) {
final Boolean res = isValid.right().value();
if (!Boolean.TRUE.equals(res)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
index be61e7b112..db53800d7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypesService.java
@@ -40,7 +40,7 @@ public class DataTypesService {
}
public Either<Map<String, DataTypeDefinition>, ResponseFormat> getAllDataTypes(ApplicationDataTypeCache applicationDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(null);
if (allDataTypes.isRight()) {
JanusGraphOperationStatus operationStatus = allDataTypes.right().value();
if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index 0d85675c45..ae9ab04a87 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -1068,19 +1068,13 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
boolean fromCsar) {
Map<String, GroupDataDefinition> groups = new HashMap<>();
Either<List<GroupDefinition>, ResponseFormat> result = null;
- Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("AddPropertyToGroup", "Failed to add property to group. Status is " + status, ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
+ Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult;
+
// handle groups and convert to tosca data
if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
for (GroupDefinition groupDefinition : groupDefinitions) {
- Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition, allDataTypes.left().value());
+ Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel()));
if (handleGroupRes.isRight()) {
result = Either.right(handleGroupRes.right().value());
break;
@@ -1150,18 +1144,11 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
Either<List<GroupDefinition>, ResponseFormat> result = null;
Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
List<GroupDataDefinition> groups = new ArrayList<>();
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .logInternalFlowError("AddPropertyToGroup", "Failed to add property to group. Status is " + status, ErrorSeverity.ERROR);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status))));
- }
// handle groups and convert to tosca data
if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
for (GroupDefinition groupDefinition : groupDefinitions) {
- Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition, allDataTypes.left().value());
+ Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, groupDefinition,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel()));
if (handleGroupRes.isRight()) {
result = Either.right(handleGroupRes.right().value());
break;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 0d9681a8dc..28faf73c21 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -289,14 +289,14 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
}
//Validate value and Constraint of input
- Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs);
+ Either<Boolean, ResponseFormat> constraintValidatorResponse = validateInputValueConstraint(inputs, component.getModel());
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
return Either.right(constraintValidatorResponse.right().value());
}
validateCanWorkOnComponent(component, userId);
Map<String, DataTypeDefinition> dataTypes;
- dataTypes = getAllDataTypes(applicationDataTypeCache);
+ dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
List<InputDefinition> componentsOldInputs = Optional.ofNullable(component.getInputs()).orElse(Collections.emptyList());
for (InputDefinition newInput : inputs) {
InputDefinition currInput = getInputFromInputsListById(componentsOldInputs, newInput);
@@ -335,7 +335,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
return result;
}
- private Either<Boolean, ResponseFormat> validateInputValueConstraint(List<InputDefinition> inputs) {
+ private Either<Boolean, ResponseFormat> validateInputValueConstraint(List<InputDefinition> inputs, final String model) {
PropertyValueConstraintValidationUtil propertyValueConstraintValidationUtil = PropertyValueConstraintValidationUtil.getInstance();
List<InputDefinition> inputDefinitions = new ArrayList<>();
for (InputDefinition inputDefinition : inputs) {
@@ -350,7 +350,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
inputDefinitions.add(inputDef);
}
- return propertyValueConstraintValidationUtil.validatePropertyConstraints(inputDefinitions, applicationDataTypeCache);
+ return propertyValueConstraintValidationUtil.validatePropertyConstraints(inputDefinitions, applicationDataTypeCache, model);
}
public Either<List<ComponentInstanceInput>, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) {
@@ -571,7 +571,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
List<InputDefinition> resourceProperties = component.getInputs();
- Map<String, DataTypeDefinition> dataTypes = getAllDataTypes(applicationDataTypeCache);
+ final Map<String, DataTypeDefinition> dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
String inputName = inputDefinition.getKey();
@@ -609,8 +609,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
log.trace("#createListInputsInGraph: enter");
- Map<String, DataTypeDefinition> dataTypes = getAllDataTypes(
- applicationDataTypeCache);
+ Map<String, DataTypeDefinition> dataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
dataTypes.putAll(privateDataTypes);
for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
@@ -829,7 +828,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUT_ALREADY_EXIST, inputName));
return result;
}
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
// validate input default values
Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newInputDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
index d7564ed50e..bbdae470e1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PropertyBusinessLogic.java
@@ -78,10 +78,6 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
artifactToscaOperation);
}
- public Map<String, DataTypeDefinition> getAllDataTypes() {
- return getAllDataTypes(applicationDataTypeCache);
- }
-
/**
* Create new property on component in graph
*
@@ -123,7 +119,7 @@ public class PropertyBusinessLogic extends BaseBusinessLogic {
result = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, propertyName));
return result;
} else {
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel());
// validate property default values
Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newPropertyDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
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 2435b5e937..c401948495 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
@@ -83,7 +83,6 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
@@ -152,7 +151,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
@@ -2301,21 +2299,10 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, List<AttributeDefinition>> 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();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance()
- .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);
- throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName);
- }
Resource finalResource = resource;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, resource.getModel()), instProperties, instCapabilities,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, existingNodeTypesByResourceNames, instInputs, i));
resource.getComponentInstances().stream().filter(i -> !i.isCreatedFromCsar()).forEach(
i -> processUiComponentInstance(oldResource, i, instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts,
@@ -2536,7 +2523,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void processComponentInstance(String yamlName, Resource resource, List<ComponentInstance> componentInstancesList,
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<ComponentInstanceProperty>> instProperties,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
@@ -2574,12 +2561,12 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource,
- currentCompInstance, instProperties, allDataTypes.left().value());
+ currentCompInstance, instProperties, allDataTypes);
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ByResponseFormatComponentException(addPropertiesValueToRiRes);
}
} else {
- addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, instInputs, allDataTypes);
}
}
@@ -2602,7 +2589,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
return originResource;
}
- private void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ private void processComponentInstanceCapabilities(Map<String, DataTypeDefinition> allDataTypes,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
UploadComponentInstanceInfo uploadComponentInstanceInfo, ComponentInstance currentCompInstance,
Resource originResource) {
@@ -2612,18 +2599,18 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
originResource.getCapabilities().forEach((k, v) -> addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values().forEach(l -> addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ updateCapabilityPropertiesValues(originCapabilities, newPropertiesMap, allDataTypes);
} else {
originCapabilities = originResource.getCapabilities();
}
instCapabilties.put(currentCompInstance, originCapabilities);
}
- private void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
- Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ private void updateCapabilityPropertiesValues(Map<String, List<CapabilityDefinition>> originCapabilities,
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap,
+ Map<String, DataTypeDefinition> allDataTypes) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
private void addCapabilitiesProperties(Map<String, Map<String, UploadPropInfo>> newPropertiesMap, List<UploadCapInfo> capabilities) {
@@ -4931,7 +4918,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
log.info("Invalid type for property {}", property);
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName());
}
- Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
+ Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
type = property.getType();
if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
ResponseFormat responseFormat = validateMapOrListPropertyType(property, innerType, allDataTypes);
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 6efdab4a96..9f1669c135 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
@@ -320,7 +320,7 @@ public class ResourceImportManager {
if (toscaElements.isLeft()) {
final Map<String, Object> toscaAttributes = (Map<String, Object>) foundElements.get(0);
if (MapUtils.isNotEmpty(toscaAttributes)) {
- resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes));
+ resource.setDataTypes(extractDataTypeFromJson(resourceBusinessLogic, toscaAttributes, resource.getModel()));
}
}
// Derived From
@@ -914,10 +914,12 @@ public class ResourceImportManager {
}
private List<DataTypeDefinition> extractDataTypeFromJson(final ResourceBusinessLogic resourceBusinessLogic,
- final Map<String, Object> foundElements) {
+ final Map<String, Object> foundElements,
+ final String model) {
final List<DataTypeDefinition> dataTypeDefinitionList = new ArrayList<>();
if (MapUtils.isNotEmpty(foundElements)) {
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll = resourceBusinessLogic.dataTypeCache.getAll();
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheAll =
+ resourceBusinessLogic.applicationDataTypeCache.getAll(model);
if (dataTypeCacheAll.isLeft()) {
for (final Entry<String, Object> attributeNameValue : foundElements.entrySet()) {
final Object value = attributeNameValue.getValue();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 21d27f3fa0..50cf5d8c65 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -382,11 +382,11 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (STATIC.equals(sourceValue)) {
// Validate constraint on input value
Either<Boolean, ResponseFormat> constraintValidationResult = validateOperationInputConstraint(operationInputDefinition, consumptionValue,
- type);
+ type, containerService.getModel());
if (constraintValidationResult.isRight()) {
return Either.right(constraintValidationResult.right().value());
}
- return handleConsumptionStaticValue(consumptionValue, type, operation, operationInputDefinition);
+ return handleConsumptionStaticValue(consumptionValue, type, operation, operationInputDefinition, containerService.getModel());
}
if (Objects.isNull(sourceValue)) {
List<PropertyDefinition> propertyDefinitions;
@@ -523,13 +523,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
public Either<Operation, ResponseFormat> handleConsumptionStaticValue(String value, String type, Operation operation,
- OperationInputDefinition operationInputDefinition) {
+ OperationInputDefinition operationInputDefinition, String model) {
boolean isInputTypeSimilarToOperation = isAssignedValueFromValidType(type, value);
if (!isInputTypeSimilarToOperation) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONSUMPTION_TYPE, type));
}
//Validate Constraint and Value
- Either<Boolean, ResponseFormat> constraintValidationResponse = validateOperationInputConstraint(operationInputDefinition, value, type);
+ Either<Boolean, ResponseFormat> constraintValidationResponse = validateOperationInputConstraint(operationInputDefinition, value, type, model);
if (constraintValidationResponse.isRight()) {
return Either.right(constraintValidationResponse.right().value());
}
@@ -538,7 +538,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
private Either<Boolean, ResponseFormat> validateOperationInputConstraint(OperationInputDefinition operationInputDefinition, String value,
- String type) {
+ String type, String model) {
ComponentInstanceProperty propertyDefinition = new ComponentInstanceProperty();
propertyDefinition.setType(operationInputDefinition.getParentPropertyType());
InputDefinition inputDefinition = new InputDefinition();
@@ -548,8 +548,8 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (Objects.nonNull(operationInputDefinition.getParentPropertyType())) {
inputDefinition.setProperties(Collections.singletonList(propertyDefinition));
}
- return PropertyValueConstraintValidationUtil.getInstance()
- .validatePropertyConstraints(Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ return PropertyValueConstraintValidationUtil.getInstance().validatePropertyConstraints(Collections.singletonList(inputDefinition),
+ applicationDataTypeCache, model);
}
private void addStaticValueToInputOperation(String value, Operation operation, OperationInputDefinition operationInputDefinition) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index c0c68d6c47..1a5a996a46 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -66,7 +66,6 @@ import org.openecomp.sdc.be.components.validation.component.ComponentValidator;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
@@ -108,6 +107,7 @@ import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -120,7 +120,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.CsarUtils;
@@ -965,20 +964,14 @@ public class ServiceImportBusinessLogic {
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
+
log.debug("enter ServiceImportBusinessLogic createResourceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
- if (serviceBusinessLogic.dataTypeCache != null) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = serviceBusinessLogic.dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)),
- yamlName));
- }
+ final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
+ if (applicationDataTypeCache != null) {
Resource finalResource = resource;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties, instCapabilities,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
@@ -1333,20 +1326,13 @@ public class ServiceImportBusinessLogic {
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
log.debug("enter ServiceImportBusinessLogic createServiceInstancesRelations#createResourceInstancesRelations - Before get all datatypes. ");
- if (serviceBusinessLogic.dataTypeCache != null) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = serviceBusinessLogic.dataTypeCache.getAll();
- if (allDataTypes.isRight()) {
- JanusGraphOperationStatus status = allDataTypes.right().value();
- BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
- throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)),
- yamlName));
- }
+ final ApplicationDataTypeCache applicationDataTypeCache = serviceBusinessLogic.applicationDataTypeCache;
+ if (applicationDataTypeCache != null) {
Service finalResource = service;
uploadResInstancesMap.values().forEach(
- i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes, instProperties, instCapabilities,
- instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
+ i -> processComponentInstance(yamlName, finalResource, componentInstancesList,
+ componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties,
+ instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, i));
}
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, service, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
@@ -1376,7 +1362,7 @@ public class ServiceImportBusinessLogic {
}
protected void processComponentInstance(String yamlName, Component component, List<ComponentInstance> componentInstancesList,
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<ComponentInstanceProperty>> instProperties,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
@@ -1416,12 +1402,12 @@ public class ServiceImportBusinessLogic {
}
if (originResource.getResourceType() != ResourceTypeEnum.VF) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, component, originResource,
- currentCompInstance, instProperties, allDataTypes.left().value());
+ currentCompInstance, instProperties, allDataTypes);
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ComponentException(addPropertiesValueToRiRes);
}
} else {
- addInputsValuesToRi(uploadComponentInstanceInfo, component, originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ addInputsValuesToRi(uploadComponentInstanceInfo, component, originResource, currentCompInstance, instInputs, allDataTypes);
}
}
@@ -1557,7 +1543,7 @@ public class ServiceImportBusinessLogic {
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
- protected void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ protected void processComponentInstanceCapabilities(Map<String, DataTypeDefinition> allDataTypes,
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
UploadComponentInstanceInfo uploadComponentInstanceInfo,
ComponentInstance currentCompInstance, Resource originResource) {
@@ -1569,18 +1555,18 @@ public class ServiceImportBusinessLogic {
originResource.getCapabilities().forEach((k, v) -> serviceImportParseLogic.addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values()
.forEach(l -> serviceImportParseLogic.addCapabilitiesProperties(newPropertiesMap, l));
- updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap, originResource.getModel());
} else {
originCapabilities = originResource.getCapabilities();
}
instCapabilties.put(currentCompInstance, originCapabilities);
}
- protected void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ protected void updateCapabilityPropertiesValues(Map<String, DataTypeDefinition> allDataTypes,
Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap, String model) {
originCapabilities.values().stream().flatMap(Collection::stream).filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes));
}
protected void updatePropertyValues(List<ComponentInstanceProperty> properties, Map<String, UploadPropInfo> newProperties,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
index 9888129071..272798f869 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogic.java
@@ -43,15 +43,15 @@ public class PropertyDataValueMergeBusinessLogic {
private static final Logger LOGGER = Logger.getLogger(PropertyDataValueMergeBusinessLogic.class);
private final PropertyValueMerger propertyValueMerger;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
private final PropertyConvertor propertyConvertor;
private final Gson gson = new Gson();
@Autowired
- public PropertyDataValueMergeBusinessLogic(PropertyValueMerger propertyValueMerger, ApplicationDataTypeCache dataTypeCache,
+ public PropertyDataValueMergeBusinessLogic(PropertyValueMerger propertyValueMerger, ApplicationDataTypeCache applicationDataTypeCache,
PropertyConvertor propertyConvertor) {
this.propertyValueMerger = propertyValueMerger;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
}
@@ -60,7 +60,7 @@ public class PropertyDataValueMergeBusinessLogic {
* @param newProp the new property to merge value into
*/
public void mergePropertyValue(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, List<String> getInputNamesToMerge) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(oldProp.getModel());
if (dataTypesEither.isRight()) {
LOGGER.debug("failed to fetch data types, skip merging of previous property values. status: {}", dataTypesEither.right().value());
} else {
@@ -116,4 +116,5 @@ public class PropertyDataValueMergeBusinessLogic {
String getInputEntry = "\"%s\":\"%s\"";
return value != null && value.contains(String.format(getInputEntry, ToscaFunctions.GET_INPUT.getFunctionName(), inputName));
}
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
index b4f6bbe7db..a443e5f90b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/AnnotationValidator.java
@@ -21,52 +21,49 @@ package org.openecomp.sdc.be.components.validation;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.be.components.impl.utils.ExceptionUtils;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
@Component
public class AnnotationValidator {
- private static final Logger log = Logger.getLogger(ResourceImportManager.class);
private final PropertyValidator propertyValidator;
private final ExceptionUtils exceptionUtils;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
private final ComponentsUtils componentsUtils;
- public AnnotationValidator(PropertyValidator propertyValidator, ExceptionUtils exceptionUtils, ApplicationDataTypeCache dataTypeCache,
+ public AnnotationValidator(PropertyValidator propertyValidator, ExceptionUtils exceptionUtils, ApplicationDataTypeCache applicationDataTypeCache,
ComponentsUtils componentsUtils) {
this.propertyValidator = propertyValidator;
this.exceptionUtils = exceptionUtils;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.componentsUtils = componentsUtils;
}
- public List<Annotation> validateAnnotationsProperties(Annotation annotation, AnnotationTypeDefinition dbAnnotationTypeDefinition) {
+ public List<Annotation> validateAnnotationsProperties(final Annotation annotation, final AnnotationTypeDefinition dbAnnotationTypeDefinition,
+ final String model) {
List<Annotation> validAnnotations = new ArrayList<>();
- if (annotation != null && propertiesValidator(annotation.getProperties(), dbAnnotationTypeDefinition.getProperties())) {
+ if (annotation != null && propertiesValidator(annotation.getProperties(), dbAnnotationTypeDefinition.getProperties(), model)) {
validAnnotations.add(annotation);
}
return validAnnotations;
}
- private boolean propertiesValidator(List<PropertyDataDefinition> properties, List<PropertyDefinition> dbAnnotationTypeDefinitionProperties) {
+ private boolean propertiesValidator(final List<PropertyDataDefinition> properties,
+ final List<PropertyDefinition> dbAnnotationTypeDefinitionProperties, final String model) {
List<PropertyDefinition> propertyDefinitionsList = new ArrayList<>();
if (properties == null || dbAnnotationTypeDefinitionProperties == null) {
return false;
}
properties.stream().forEach(property -> propertyDefinitionsList.add(new PropertyDefinition(property)));
- Map<String, DataTypeDefinition> allDataTypes = dataTypeCache.getAll().left().on(error -> exceptionUtils.rollBackAndThrow(error));
- propertyValidator.thinPropertiesValidator(propertyDefinitionsList, dbAnnotationTypeDefinitionProperties, allDataTypes);
+ propertyValidator.thinPropertiesValidator(propertyDefinitionsList, dbAnnotationTypeDefinitionProperties,
+ applicationDataTypeCache.getAll(model).left().on(error -> exceptionUtils.rollBackAndThrow(error)));
return true;
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
index 9569247047..e7c6ef386d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtil.java
@@ -62,10 +62,11 @@ public class PropertyValueConstraintValidationUtil {
return new PropertyValueConstraintValidationUtil();
}
- public Either<Boolean, ResponseFormat> validatePropertyConstraints(Collection<? extends PropertyDefinition> propertyDefinitionList,
- ApplicationDataTypeCache applicationDataTypeCache) {
+ public Either<Boolean, ResponseFormat> validatePropertyConstraints(final Collection<? extends PropertyDefinition> propertyDefinitionList,
+ final ApplicationDataTypeCache applicationDataTypeCache,
+ final String model) {
ResponseFormatManager responseFormatManager = getResponseFormatManager();
- dataTypeDefinitionCache = applicationDataTypeCache.getAll().left().value();
+ dataTypeDefinitionCache = applicationDataTypeCache.getAll(model).left().value();
CollectionUtils.emptyIfNull(propertyDefinitionList).stream().filter(this::isValuePresent)
.forEach(this::evaluatePropertyTypeForConstraintValidation);
if (CollectionUtils.isNotEmpty(errorMessages)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
index 607497ca26..3b55e67c75 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
@@ -75,9 +75,11 @@ import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentEx
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ConstraintConvertor;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
@@ -97,6 +99,7 @@ import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser;
@@ -1542,4 +1545,20 @@ public class ComponentsUtils {
return uiConstraintsMaps.stream().map(dataMap -> new com.fasterxml.jackson.databind.ObjectMapper().convertValue(dataMap, UIConstraint.class))
.collect(Collectors.toList());
}
+
+ public Map<String, DataTypeDefinition> getAllDataTypes(final ApplicationDataTypeCache applicationDataTypeCache, final String model) {
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(model);
+ if (allDataTypes.isRight()) {
+ final var operationStatus = allDataTypes.right().value();
+ if (operationStatus == JanusGraphOperationStatus.NOT_FOUND) {
+ BeEcompErrorManager.getInstance().logInternalDataError("FetchDataTypes", "Data types are not loaded", ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.DATA_TYPES_NOT_LOADED, model);
+ } else {
+ BeEcompErrorManager.getInstance().logInternalFlowError("FetchDataTypes", "Failed to fetch data types", ErrorSeverity.ERROR);
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
+ }
+ }
+ return allDataTypes.left().value();
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
index 6d82e2b239..fec5dd8b7b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentPropertyServlet.java
@@ -315,9 +315,10 @@ public class ComponentPropertyServlet extends BeGenericServlet {
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
return buildErrorResponse(responseFormat);
}
- //Validate value and Constraint of property
+ //Validate value and Constraint of property and Fetch all data types from cache
Either<Boolean, ResponseFormat> constraintValidatorResponse = PropertyValueConstraintValidationUtil.getInstance()
- .validatePropertyConstraints(properties.values(), applicationDataTypeCache);
+ .validatePropertyConstraints(properties.values(), applicationDataTypeCache,
+ propertyBusinessLogic.getComponentModelByComponentId(componentId));
if (constraintValidatorResponse.isRight()) {
log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
return buildErrorResponse(constraintValidatorResponse.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index ac195f9315..9d3817431f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -120,7 +120,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Data types not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
- public Response getAllDataTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ public Response getAllDataTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+ @Parameter(description = "model") @QueryParam("model") String modelName) {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
init();
@@ -128,7 +129,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
if (responseWrapper.isEmpty()) {
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {} - modifier id is {}", url, userId);
- Map<String, DataTypeDefinition> dataTypes = propertyBusinessLogic.getAllDataTypes();
+ final Map<String, DataTypeDefinition> dataTypes = resourceBusinessLogic.getComponentsUtils()
+ .getAllDataTypes(resourceBusinessLogic.getApplicationDataTypeCache(), modelName);
String dataTypeJson = gson.toJson(dataTypes);
Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson);
responseWrapper.setInnerElement(okResponse);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
index 0b0ecd21d1..30420876b7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/GroupExportParserImpl.java
@@ -66,17 +66,17 @@ public class GroupExportParserImpl implements GroupExportParser {
private static final Logger log = Logger.getLogger(GroupExportParserImpl.class);
private final PropertyConvertor propertyConvertor;
private Map<String, DataTypeDefinition> dataTypes;
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Autowired
- public GroupExportParserImpl(ApplicationDataTypeCache dataTypeCache, PropertyConvertor propertyConvertor) {
- this.dataTypeCache = dataTypeCache;
+ public GroupExportParserImpl(ApplicationDataTypeCache applicationDataTypeCache, PropertyConvertor propertyConvertor) {
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
this.dataTypes = getDataTypes();
}
private Map<String, DataTypeDefinition> getDataTypes() {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(null);
if (dataTypesEither.isRight()) {
log.error("Failed to retrieve all data types {}", dataTypesEither.right().value());
throw new SdcResourceNotFoundException();
@@ -86,7 +86,7 @@ public class GroupExportParserImpl implements GroupExportParser {
@EventListener
public void onDataTypesCacheChangedEvent(ApplicationDataTypeCache.DataTypesCacheChangedEvent dataTypesCacheChangedEvent) {
- dataTypes = dataTypesCacheChangedEvent.getNewData();
+ dataTypes = dataTypesCacheChangedEvent.getNewData().get(null);
log.debug("Data types cache updated.");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
index d544d34b66..7fe8e941a5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PolicyExportParserImpl.java
@@ -52,19 +52,19 @@ import org.springframework.context.event.EventListener;
public class PolicyExportParserImpl implements PolicyExportParser {
private static final Logger log = Logger.getLogger(PolicyExportParserImpl.class);
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
private Map<String, DataTypeDefinition> dataTypes;
private PropertyConvertor propertyConvertor;
@Autowired
- public PolicyExportParserImpl(ApplicationDataTypeCache dataTypeCache, PropertyConvertor propertyConvertor) {
- this.dataTypeCache = dataTypeCache;
+ public PolicyExportParserImpl(ApplicationDataTypeCache applicationDataTypeCache, PropertyConvertor propertyConvertor) {
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.propertyConvertor = propertyConvertor;
this.dataTypes = getDataTypes();
}
private Map<String, DataTypeDefinition> getDataTypes() {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(null);
if (dataTypesEither.isRight()) {
log.error("Failed to retrieve all data types {}", dataTypesEither.right().value());
throw new SdcResourceNotFoundException();
@@ -74,7 +74,7 @@ public class PolicyExportParserImpl implements PolicyExportParser {
@EventListener
public void onDataTypesCacheChangedEvent(ApplicationDataTypeCache.DataTypesCacheChangedEvent dataTypesCacheChangedEvent) {
- dataTypes = dataTypesCacheChangedEvent.getNewData();
+ dataTypes = dataTypesCacheChangedEvent.getNewData().get(null);
log.debug("Data types cache updated.");
}
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 3fe3bd5c42..ef5192c048 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
@@ -157,7 +157,7 @@ public class ToscaExportHandler {
.of("Service Function", "Service Role", "Naming Policy", "Service Type");
private static final YamlUtil yamlUtil = new YamlUtil();
private static final String COULD_NOT_PARSE_COMPONENT_ATTRIBUTES_COMPONENT_UNIQUE_ID = "Could not parse component '{}' attributes. Component unique id '{}'.";
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
private ToscaOperationFacade toscaOperationFacade;
private CapabilityRequirementConverter capabilityRequirementConverter;
private PolicyExportParser policyExportParser;
@@ -170,7 +170,7 @@ public class ToscaExportHandler {
private InterfacesOperationsConverter interfacesOperationsConverter;
@Autowired
- public ToscaExportHandler(final ApplicationDataTypeCache dataTypeCache,
+ public ToscaExportHandler(final ApplicationDataTypeCache applicationDataTypeCache,
final ToscaOperationFacade toscaOperationFacade,
final CapabilityRequirementConverter capabilityRequirementConverter,
final PolicyExportParser policyExportParser,
@@ -181,7 +181,7 @@ public class ToscaExportHandler {
final OutputConverter outputConverter,
final InterfaceLifecycleOperation interfaceLifecycleOperation,
final InterfacesOperationsConverter interfacesOperationsConverter) {
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
this.toscaOperationFacade = toscaOperationFacade;
this.capabilityRequirementConverter = capabilityRequirementConverter;
this.policyExportParser = policyExportParser;
@@ -323,7 +323,7 @@ public class ToscaExportHandler {
if (MapUtils.isNotEmpty(proxyInterfaceTypes)) {
toscaNode.setInterface_types(proxyInterfaceTypes);
}
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -701,7 +701,7 @@ public class ToscaExportHandler {
List<String> allGlobalInterfaceTypes = lifecycleTypeEither.left().value().values().stream().map(InterfaceDataDefinition::getType)
.collect(Collectors.toList());
toscaNode.setInterface_types(addInterfaceTypeElement(component, allGlobalInterfaceTypes));
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(component.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to fetch all data types :", dataTypesEither.right().value());
return Either.right(ToscaError.GENERAL_ERROR);
@@ -1182,7 +1182,7 @@ public class ToscaExportHandler {
String derivedFrom = ((Resource) origComponent).getToscaResourceName();
toscaNodeType.setDerived_from(derivedFrom);
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypesEither = applicationDataTypeCache.getAll(origComponent.getModel());
if (dataTypesEither.isRight()) {
log.debug("Failed to retrieve all data types {}", dataTypesEither.right().value());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
index 834964b5a2..341dce9f49 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java
@@ -246,7 +246,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock {
when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
when(toscaOperationFacade.validateCsarUuidUniqueness(Mockito.anyString())).thenReturn(StorageOperationStatus.OK);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<String, DataTypeDefinition>();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(emptyDataTypes));
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
Either<Component, StorageOperationStatus> resourceStorageOperationStatusEither = Either
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 7b0b40cc8b..7db449df6a 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
@@ -135,7 +135,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock {
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(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
Either<AttributeDefinition, ResponseFormat> response;
@@ -237,7 +237,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock {
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(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
Either<AttributeDefinition, ResponseFormat> response;
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 5c8b6ce6d2..a2996c531d 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
@@ -186,7 +186,7 @@ class ComponentInstanceBusinessLogicTest {
@Mock
private JanusGraphDao janusGraphDao;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyOperation propertyOperation;
@Mock
@@ -321,7 +321,7 @@ class ComponentInstanceBusinessLogicTest {
.thenReturn(Either.left(component));
when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
.thenReturn(StorageOperationStatus.OK);
- when(dataTypeCache.getAll()).thenReturn(Either.left(types));
+ when(componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel())).thenReturn(types);
when(propertyOperation.validateAndUpdatePropertyValue(property.getType(), "newVal", true, null, types))
.thenReturn(Either.left("newVal"));
when(propertyOperation.validateAndUpdateRules("string", property.getRules(),
@@ -420,7 +420,7 @@ class ComponentInstanceBusinessLogicTest {
.thenReturn(Either.left(component));
when(graphLockOperation.lockComponent(containerComponentID, NodeTypeEnum.ResourceInstance))
.thenReturn(StorageOperationStatus.OK);
- when(dataTypeCache.getAll()).thenReturn(Either.left(types));
+ when(componentsUtils.getAllDataTypes(applicationDataTypeCache, component.getModel())).thenReturn(types);
when(propertyOperation.validateAndUpdatePropertyValue(property.getType(), "newVal", true, null, types))
.thenReturn(Either.right(false));
when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.BAD_REQUEST))
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
index 0349985608..46326c350c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/DataTypesServiceTest.java
@@ -20,7 +20,11 @@
package org.openecomp.sdc.be.components.impl;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.HashMap;
+import java.util.Map;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -30,11 +34,6 @@ import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.mockito.Mockito.when;
-
public class DataTypesServiceTest {
ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
@@ -48,7 +47,7 @@ public class DataTypesServiceTest {
public void setup() {
mapreturn.put("Demo",new DataTypeDefinition());
allDataTypes = Either.left(mapreturn);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
}
@@ -60,7 +59,7 @@ public class DataTypesServiceTest {
@Test
public void getAllDataTypes_failure() {
allDataTypes = Either.right(janusGraphOperationStatus);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(allDataTypes);
Assert.assertEquals(true,dataTypesService.getAllDataTypes(applicationDataTypeCache).isRight());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
index 2520e44aca..e7cadc4b98 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
@@ -95,7 +95,7 @@ class GroupBusinessLogicTest {
@InjectMocks
private GroupBusinessLogic test;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private ComponentsUtils componentsUtils;
@Mock
@@ -115,7 +115,7 @@ class GroupBusinessLogicTest {
@BeforeEach
public void setUp() throws Exception {
- test.setDataTypeCache(dataTypeCache);
+ test.setApplicationDataTypeCache(applicationDataTypeCache);
test.setToscaOperationFacade(toscaOperationFacade);
test.setPropertyOperation(propertyOperation);
test.setComponentsUtils(componentsUtils);
@@ -129,7 +129,6 @@ class GroupBusinessLogicTest {
List<GroupDefinition> groupDefinitions = new ArrayList<>();
GroupDefinition groupDefinition = new GroupDefinition();
groupDefinitions.add(groupDefinition);
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
result = test.createGroups(component, groupDefinitions, true);
assertThat(result.isRight()).isTrue();
}
@@ -146,8 +145,8 @@ class GroupBusinessLogicTest {
groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition();
Map<String, DataTypeDefinition> map = new HashMap<>();
- when(dataTypeCache.getAll()).thenReturn(Either.left(map));
- when(groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, null, true)).thenReturn(Either.left(groupTypeDefinition));
+ when(groupTypeOperation.getLatestGroupTypeByType(Constants.DEFAULT_GROUP_VF_MODULE, component.getModel(), true))
+ .thenReturn(Either.left(groupTypeDefinition));
when(groupsOperation.createGroups(any(Component.class), anyMap())).thenReturn(Either.left(groupDefinitions));
when(groupsOperation.addCalculatedCapabilitiesWithProperties(anyString(), anyMap(), anyMap())).thenReturn(StorageOperationStatus.OK);
result = test.createGroups(component, groupDefinitions, true);
@@ -203,7 +202,6 @@ class GroupBusinessLogicTest {
Map<String, Set<String>> excludedGroupTypesMap = new HashMap<>();
GroupTypeDefinition groupTypeDefinition = new GroupTypeDefinition();
Map<String, DataTypeDefinition> map = new HashMap<>();
- when(dataTypeCache.getAll()).thenReturn(Either.left(map));
when(accessValidations.validateUserCanWorkOnComponent(componentId, compTypeEnum, userId, "CreateGroup")).thenReturn(component);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
index 308d272a79..b9f6bf004c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogicTest.java
@@ -17,7 +17,26 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
@@ -65,26 +84,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
public class InputsBusinessLogicTest {
@@ -467,7 +466,7 @@ public class InputsBusinessLogicTest {
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
when(propertyDeclarationOrchestrator.declarePropertiesToListInput(service, componentInstInputsMap, listInput)).thenReturn(Either.left(listInput));
// for BaseOperation.getAllDataTypes:
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
// for BaseOperation.validatePropertyDefaultValue:
when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(true);
when(propertyOperation.isPropertyInnerTypeValid(any(),any())).thenReturn(new ImmutablePair<>(listInput.getSchemaType(), true));
@@ -540,14 +539,16 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.addDataTypesToComponent(dataTypesMapCaptor.capture(), eq(COMPONENT_ID))).thenReturn(Either.left(new ArrayList<>()));
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(applicationDataTypeCache.getAll(service.getModel())).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(componentsUtilsMock.getAllDataTypes(applicationDataTypeCache, service.getModel()))
+ .thenThrow(new ByActionStatusComponentException(ActionStatus.DATA_TYPES_NOT_LOADED));
try {
Either<List<InputDefinition>, ResponseFormat> result =
testInstance.createListInput(USER_ID, COMPONENT_ID, ComponentTypeEnum.SERVICE, createListInputParams, true, false);
} catch (ByActionStatusComponentException e) {
- assertEquals(ActionStatus.DATA_TYPE_CANNOT_BE_EMPTY, e.getActionStatus());
- verify(applicationDataTypeCache, times(1)).getAll();
+ assertEquals(ActionStatus.DATA_TYPES_NOT_LOADED, e.getActionStatus());
+ verify(componentsUtilsMock, times(1)).getAllDataTypes(applicationDataTypeCache, service.getModel());
return;
}
fail();
@@ -563,7 +564,7 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.addDataTypesToComponent(dataTypesMapCaptor.capture(), eq(COMPONENT_ID))).thenReturn(Either.left(new ArrayList<>()));
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
// for BaseOperation.validatePropertyDefaultValue:
when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(false);
@@ -583,7 +584,7 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacadeMock.addDataTypesToComponent(dataTypesMapCaptor.capture(), eq(COMPONENT_ID))).thenReturn(Either.left(new ArrayList<>()));
when(propertyDeclarationOrchestrator.getPropOwnerId(componentInstInputsMap)).thenReturn(COMPONENT_INSTANCE_ID);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>())); // don't use Collections.emptyMap
// for BaseOperation.validatePropertyDefaultValue:
when(propertyOperation.isPropertyTypeValid(any(), any())).thenReturn(true);
when(propertyOperation.isPropertyInnerTypeValid(any(),any())).thenReturn(new ImmutablePair<>(listInput.getSchemaType(), true));
@@ -788,7 +789,7 @@ public class InputsBusinessLogicTest {
when(graphLockOperation.lockComponent(COMPONENT_ID, NodeTypeEnum.Service)).thenReturn(StorageOperationStatus.OK);
// used in validateInputValueConstraint
Map<String, DataTypeDefinition> dataTypeMap = new HashMap<>();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypeMap)); // don't use Collections.emptyMap
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypeMap)); // don't use Collections.emptyMap
// used in updateInputObjectValue
when(propertyOperation.validateAndUpdatePropertyValue(INPUT_TYPE, NEW_VALUE, true, null, dataTypeMap))
.thenReturn(Either.left(NEW_VALUE));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
index 627c536720..a183d52913 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
@@ -17,8 +17,23 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -70,22 +85,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class PolicyBusinessLogicTest {
@@ -104,7 +103,7 @@ public class PolicyBusinessLogicTest {
@Mock
private JanusGraphDao janusGraphDao;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyOperation propertyOperation;
@Mock
@@ -151,7 +150,7 @@ public class PolicyBusinessLogicTest {
businessLogic.setUserValidations(userValidations);
businessLogic.setGraphLockOperation(graphLockOperation);
businessLogic.setPolicyTypeOperation(policyTypeOperation);
- businessLogic.setDataTypeCache(dataTypeCache);
+ businessLogic.setApplicationDataTypeCache(applicationDataTypeCache);
businessLogic.setPropertyOperation(propertyOperation);
businessLogic.setPropertyDeclarationOrchestrator(propertyDeclarationOrchestrator);
}
@@ -205,7 +204,6 @@ public class PolicyBusinessLogicTest {
when(toscaOperationFacade.associatePolicyToComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), eq(0))).thenReturn(Either.left(policy));
when(toscaOperationFacade.getToscaFullElement(eq(COMPONENT_ID))).thenReturn(Either.left(newResource));
when(toscaOperationFacade.updatePolicyOfComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), any(PromoteVersionEnum.class))).thenReturn(Either.left(policy));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
when(propertyOperation.validateAndUpdatePropertyValue(eq(null), eq(prop1), anyBoolean(), eq(null), anyMap())).thenReturn(Either.left(prop1));
when(propertyOperation.validateAndUpdatePropertyValue(eq(null), eq(prop2), anyBoolean(), eq(null), anyMap())).thenReturn(Either.left(prop2));
@@ -318,7 +316,6 @@ public class PolicyBusinessLogicTest {
@Test
public void updatePolicyPropertiesSuccessTest(){
stubValidateAndLockSuccess(CREATE_POLICY);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
String prop1 = "Name";
String prop2 = "Type";
when(propertyOperation.validateAndUpdatePropertyValue(eq(null), eq(prop1), anyBoolean(), eq(null), anyMap())).thenReturn(Either.left(prop1));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
index f0900f7589..a2893af2ba 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
@@ -30,11 +30,9 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
import fj.data.Either;
import java.io.File;
@@ -71,7 +69,6 @@ import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOpera
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
-import org.openecomp.sdc.be.components.impl.utils.YamlTemplateParsingHandlerTest;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic;
@@ -114,7 +111,6 @@ import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
-import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
@@ -181,8 +177,7 @@ public class ResourceBusinessLogicTest {
private final CatalogOperation catalogOperation = Mockito.mock(CatalogOperation.class);
private final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
private final PropertyOperation propertyOperation = Mockito.mock(PropertyOperation.class);
- private final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
- private final ApplicationDataTypeCache dataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
+ private final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
private final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
private final UserValidations userValidations = Mockito.mock(UserValidations.class);
private final WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
@@ -307,8 +302,7 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
when(catalogOperation.updateCatalog(Mockito.any(), Mockito.any())).thenReturn(ActionStatus.OK);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<>();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
- when(dataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(emptyDataTypes));
when(mockJanusGraphDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
// BL object
@@ -329,8 +323,7 @@ public class ResourceBusinessLogicTest {
bl.setGraphLockOperation(graphLockOperation);
bl.setPropertyOperation(propertyOperation);
bl.setJanusGraphDao(mockJanusGraphDao);
- bl.setApplicationDataTypeCache(applicationDataTypeCache);
- bl.setDataTypeCache(dataTypeCache);
+ bl.setApplicationDataTypeCache(applicationDataTypeCache);
bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
bl.setCatalogOperations(catalogOperation);
toscaOperationFacade.setNodeTypeOperation(nodeTypeOperation);
@@ -440,7 +433,7 @@ public class ResourceBusinessLogicTest {
}
return resource;
}
-
+
private Resource createResourceObjectWithModel(boolean afterCreate) {
Resource resource = new Resource();
resource.setName(RESOURCE_NAME);
@@ -1454,19 +1447,19 @@ public class ResourceBusinessLogicTest {
public void createResourceFromCsarTest() {
bl.createResourceFromCsar(resourceResponse, user, new HashMap<>(), "");
}
-
+
@Test()
public void testCreateResourceFromCsarWithModel() throws URISyntaxException, ZipException {
-
+
final File csarFile = new File(
ResourceBusinessLogicTest.class.getClassLoader().getResource("csars/nonOnapCsar.csar").toURI());
final Map<String, byte[]> csar = ZipUtils.readZip(csarFile, false);
-
+
String resourceYml = new String(csar.get("Definitions/my_vnf.yaml"));
-
+
YamlTemplateParsingHandler yamlTemplateParser = new YamlTemplateParsingHandler(mockJanusGraphDao, null, Mockito.mock(AnnotationBusinessLogic.class), null);
final ParsedToscaYamlInfo parsedToscaYamlInfo = yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml, Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse);
-
+
when(toscaOperationFacade.getLatestByToscaResourceName(anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Resource vduCp = new Resource();
vduCp.setToscaResourceName("tosca.nodes.nfv.VduCp");
@@ -1498,7 +1491,7 @@ public class ResourceBusinessLogicTest {
vduCp.getProperties().add(roleProp);
when(toscaOperationFacade.getByToscaResourceNameMatchingVendorRelease("tosca.nodes.nfv.VduCp", "1.0.0")).thenReturn(Either.left(vduCp));
-
+
when(yamlTemplateParsingHandler.parseResourceInfoFromYAML(any(), any(), any(), any(), any(), any())).thenReturn(parsedToscaYamlInfo);
UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
@@ -1509,7 +1502,7 @@ public class ResourceBusinessLogicTest {
resourceResponse.setModel("testModel");
resourceResponse.setResourceType(ResourceTypeEnum.VF);
resourceResponse.setProperties(new ArrayList<>());
-
+
Resource derivedFrom = new Resource();
List<PropertyDefinition> properties = new ArrayList<>();
PropertyDefinition baseTypeProp = new PropertyDefinition();
@@ -1518,7 +1511,7 @@ public class ResourceBusinessLogicTest {
properties.add(baseTypeProp);
derivedFrom.setProperties(properties );
when(genericTypeBusinessLogic.fetchDerivedFromGenericType(any(), eq("tosca.nodes.nfv.VNF"))).thenReturn(Either.left(derivedFrom));
-
+
when(toscaOperationFacade
.validateComponentNameAndModelExists("myVnf", "testModel", ResourceTypeEnum.VF, ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(false));
@@ -1528,6 +1521,7 @@ public class ResourceBusinessLogicTest {
when(toscaOperationFacade.associateDeploymentArtifactsToInstances(any(), any(), any())).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.associateInstAttributeToComponentToInstances(any(), any())).thenReturn(StorageOperationStatus.OK);
when(toscaOperationFacade.associateResourceInstances(any(Component.class), anyString(), anyList())).thenReturn(Either.left(Collections.EMPTY_LIST));
+ when(applicationDataTypeCache.getAll(resourceResponse.getModel())).thenReturn(Either.left(emptyDataTypes));
doAnswer(invocation -> {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instReqs = invocation.getArgument(1);
@@ -1538,10 +1532,10 @@ public class ResourceBusinessLogicTest {
}).
when(toscaOperationFacade).associateOrAddCalculatedCapReq(any(), any(), any());
-
+
when(toscaOperationFacade.updateCalculatedCapabilitiesRequirements(any(), any(), any())).thenReturn(StorageOperationStatus.OK);
when(groupBusinessLogic.validateUpdateVfGroupNames(any(), any())).thenReturn(Either.left(Collections.EMPTY_MAP));
-
+
ComponentInstance ci = new ComponentInstance();
List<ComponentInstance> cis = new ArrayList<>();
cis.add(ci);
@@ -1558,10 +1552,10 @@ public class ResourceBusinessLogicTest {
doAnswer(invocation -> {
return Either.left(resourceResponse);
}).when(toscaOperationFacade).getToscaFullElement("myVnf");
-
-
+
+
Resource result = bl.createResourceFromCsar(resourceResponse, user, csar, "1234");
-
+
assertEquals("myDomain.myVnf", result.getToscaResourceName());
List<String> propIds = result.getProperties().stream().map(prop -> prop.getUniqueId()).collect(Collectors.toList());
assertTrue(propIds.contains("myVnf.propInBase"));
@@ -1573,7 +1567,7 @@ public class ResourceBusinessLogicTest {
assertTrue(propIds.contains("myVnf.provider"));
assertTrue(propIds.contains("myVnf.software_version"));
assertTrue(propIds.contains("myVnf.vnfm_info"));
-
+
final List<String> reqsName = new ArrayList<>();
final List<ComponentInstance> cisWithExtReq = result.getComponentInstances().stream().filter(instance -> instance.getRequirements().get("tosca.nodes.nfv.VduCp").get(0).isExternal()).collect(Collectors.toList());
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index 6655ee2b1f..adfd5de888 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -17,7 +17,33 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyBoolean;
+import static org.mockito.Mockito.anyList;
+import static org.mockito.Mockito.anyMap;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -42,7 +68,35 @@ import org.openecomp.sdc.be.externalapi.servlet.ArtifactExternalServlet;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
-import org.openecomp.sdc.be.model.*;
+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.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.ComponentMetadataDefinition;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.IPropertyInputCommon;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
+import org.openecomp.sdc.be.model.PolicyDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
+import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadPropInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
+import org.openecomp.sdc.be.model.UploadResourceInfo;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -55,33 +109,6 @@ import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
-import static org.mockito.Mockito.anyList;
-import static org.mockito.Mockito.anyMap;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
private final static String DEFAULT_ICON = "defaulticon";
@@ -829,7 +856,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
Assertions.assertNotNull(resource);
Assertions.assertNotNull(yamlName);
- sIB1.processComponentInstance(yamlName, resource, componentInstancesList, allDataTypes, instProperties,
+ sIB1.processComponentInstance(yamlName, resource, componentInstancesList, allDataTypes.left().value(), instProperties,
instCapabilties, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes,
originCompMap, instInputs, uploadComponentInstanceInfo);
}
@@ -854,7 +881,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb0");
Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName,
- resource, componentInstancesList, allDataTypes, instProperties, instCapabilties,
+ resource, componentInstancesList, null, instProperties, instCapabilties,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap,
instInputs, uploadComponentInstanceInfo));
}
@@ -1175,7 +1202,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
Assertions.assertNotNull(service);
- sIB1.processComponentInstance(yamlName, service, componentInstancesList, allDataTypes,
+ sIB1.processComponentInstance(yamlName, service, componentInstancesList, allDataTypes.left().value(),
instProperties, instCapabilties, instRequirements, instDeploymentArtifacts,
instArtifacts, instAttributes, originCompMap, instInputs,
uploadComponentInstanceInfo);
@@ -1201,7 +1228,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb0");
Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName,
- service, componentInstancesList, allDataTypes, instProperties, instCapabilties,
+ service, componentInstancesList, null, instProperties, instCapabilties,
instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap,
instInputs, uploadComponentInstanceInfo));
}
@@ -1382,7 +1409,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
ComponentInstance currentCompInstance = new ComponentInstance();
Resource originResource = createParseResourceObject(false);
Assertions.assertNotNull(originResource);
- sIB1.processComponentInstanceCapabilities(allDataTypes, instCapabilties,
+ sIB1.processComponentInstanceCapabilities(null, instCapabilties,
uploadComponentInstanceInfo, currentCompInstance, originResource);
}
@@ -1395,7 +1422,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Resource originResource = createParseResourceObject(false);
Assertions.assertNotNull(originResource);
- sIB1.processComponentInstanceCapabilities(allDataTypes, instCapabilties, uploadComponentInstanceInfo,
+ sIB1.processComponentInstanceCapabilities(null, instCapabilties, uploadComponentInstanceInfo,
currentCompInstance, originResource);
}
@@ -1405,7 +1432,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
Assertions.assertNull(allDataTypes);
- sIB1.updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
+ sIB1.updateCapabilityPropertiesValues(null, originCapabilities, newPropertiesMap, null);
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
index bded51db11..400b20cdc0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/property/PropertyDataValueMergeBusinessLogicTest.java
@@ -178,7 +178,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
myType.setProperties(Arrays.asList(mac_range_plan, mac_count_required));
Map<String, DataTypeDefinition> dataTypes = Collections.singletonMap(myType.getName(), myType);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
@@ -230,7 +230,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
myType.setProperties(Arrays.asList(mac_range_plan, mymap, mac_count_required));
Map<String, DataTypeDefinition> dataTypes = Collections.singletonMap(myType.getName(), myType);
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
@@ -264,7 +264,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
PropertyDataDefinition newProp = createProp("prop1", "list", "myType", "[{\"prop2\":{\"prop3\":false}}]");
Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
assertEquals("myType", "[{\"prop2\":{\"prop3\":false}}]", newProp.getValue());
}
@@ -300,7 +300,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
myType.setName("myType");
Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
assertEquals("lprop", "[{\"prop2\":{\"prop4\":45,\"prop3\":true},\"prop1\":\"val1\"},{\"prop2\":{\"prop3\":false},\"prop1\":\"val2\"}]", newProp.getValue());
}
@@ -311,7 +311,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
PropertyDataDefinition newProp = createProp("value_spec", "list", "json", "[{\"prop22\":{\"prop221\":45,\"prop222\":\"val222\",\"prop223\":\"false\"}}]");
Map<String, DataTypeDefinition> dataTypes = buildDataTypes();
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
assertEquals("value_spec", "[{\"prop22\":{\"prop223\":\"false\",\"prop221\":45,\"prop222\":\"val222\"}}]", newProp.getValue());
}
@@ -397,7 +397,7 @@ public class PropertyDataValueMergeBusinessLogicTest {
Map<String, DataTypeDefinition> dataTypes = Stream.of(complexType, myType, myInnerType)
.collect(Collectors.toMap(DataTypeDefinition::getName, Function.identity()));
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(dataTypes));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(dataTypes));
testInstance.mergePropertyValue(oldProp, newProp, Collections.emptyList());
@@ -525,14 +525,14 @@ public class PropertyDataValueMergeBusinessLogicTest {
}
private void testMergeProps(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, String expectedValue, List<String> getInputsToMerge) {
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(Collections.emptyMap()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(Collections.emptyMap()));
testInstance.mergePropertyValue(oldProp, newProp, getInputsToMerge);
assertEquals(expectedValue, newProp.getValue());
}
private String getMergedMapProp(PropertyDataDefinition oldProp, PropertyDataDefinition newProp, List<String> getInputsToMerge) {
- when(applicationDataTypeCache.getAll()).thenReturn(Either.left(Collections.emptyMap()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(Collections.emptyMap()));
testInstance.mergePropertyValue(oldProp, newProp, getInputsToMerge);
return newProp.getValue();
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
index 4b33e2d2be..9577bc6a11 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/AnnotationValidatorTest.java
@@ -19,7 +19,14 @@
*/
package org.openecomp.sdc.be.components.validation;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,14 +43,6 @@ import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
@RunWith(MockitoJUnitRunner.class)
public class AnnotationValidatorTest {
@@ -62,7 +61,7 @@ public class AnnotationValidatorTest {
@Mock
private ComponentsUtils componentsUtils;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyValidator propertyValidator;
@Mock
@@ -70,10 +69,10 @@ public class AnnotationValidatorTest {
@Before
public void setUp() throws Exception {
- annotationValidator = new AnnotationValidator(propertyValidator, exceptionUtils, dataTypeCache, componentsUtils);
+ annotationValidator = new AnnotationValidator(propertyValidator, exceptionUtils, applicationDataTypeCache, componentsUtils);
allData = Collections.emptyMap();
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> cacheResponse = Either.left(allData);
- Mockito.when(dataTypeCache.getAll()).thenReturn(cacheResponse);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(cacheResponse);
annotationTypeProperties = Collections.emptyList();
propertyDataDefinitions = new ArrayList<>();
}
@@ -85,8 +84,7 @@ public class AnnotationValidatorTest {
List<PropertyDefinition> properties = new ArrayList<>();
properties.add(new PropertyDefinition(propertyDataDefinition));
- List<Annotation> annotations = annotationValidator
- .validateAnnotationsProperties(annotation, annotationTypeDefinition);
+ List<Annotation> annotations = annotationValidator.validateAnnotationsProperties(annotation, annotationTypeDefinition, null);
Mockito.verify(propertyValidator).thinPropertiesValidator(properties, annotationTypeProperties, allData);
assertThat(annotations.get(0), is(annotation));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java
index acb3d39b79..a8dcf8acce 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java
@@ -20,10 +20,24 @@
package org.openecomp.sdc.be.datamodel.utils;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import fj.data.Either;
+import java.io.BufferedReader;
+import java.io.File;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -44,21 +58,6 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.BufferedReader;
-import java.io.File;
-import java.lang.reflect.Type;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-
public class PropertyValueConstraintValidationUtilTest {
@Mock
@@ -75,7 +74,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Before
public void init() {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
ResponseFormatManager responseFormatManagerMock = Mockito.mock(ResponseFormatManager.class);
when(responseFormatManagerMock.getResponseFormat(any())).thenReturn(new ResponseFormat());
when(responseFormatManagerMock.getResponseFormat(any(), any())).thenReturn(new ResponseFormat());
@@ -88,7 +87,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void primitiveValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("integer");
@@ -96,7 +95,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -104,15 +103,14 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void primitiveValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("integer");
propertyDefinition.setValue("abcd");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -120,7 +118,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithValidValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -128,7 +126,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -136,15 +134,14 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithValidValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
propertyDefinition.setValue("{\"prefixlen\":\"5\"}");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil
+ .validatePropertyConstraints(Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -152,7 +149,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithListWithPrimitiveValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -160,7 +157,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -168,7 +165,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithListWithPrimitiveValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -176,7 +173,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -184,7 +181,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithMapWithPrimitiveValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -192,7 +189,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -200,7 +197,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void complexWithMapWithPrimitiveValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -208,7 +205,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -216,7 +213,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void inputValidValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
InputDefinition inputDefinition = new InputDefinition();
inputDefinition.setInputPath("propetyName#ipv6_ra_mode");
@@ -228,7 +225,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ Collections.singletonList(inputDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -236,7 +233,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void inputValidValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
InputDefinition inputDefinition = new InputDefinition();
inputDefinition.setInputPath("propetyName#ipv6_ra_mode");
@@ -247,7 +244,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(inputDefinition), applicationDataTypeCache);
+ Collections.singletonList(inputDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -255,7 +252,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void serviceConsumptionValidValueSuccessTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -264,14 +261,14 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@Test
public void serviceConsumptionValidValueFailTest() {
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("org.openecomp.datatypes.heat.network.neutron.Subnet");
@@ -280,7 +277,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -288,33 +285,30 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthTypeValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
propertyDefinition.setValue("{\"bandwidth_type\":\"guaranteed\"}");
propertyDefinition.setName("bandwidth_type");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
-
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@Test
public void bandwidthTypeValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
propertyDefinition.setValue("{\"bandwidth_type\":\"incorrectValue\"}");
propertyDefinition.setName("bandwidth_type");
- Either<Boolean, ResponseFormat> responseEither =
- propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Either<Boolean, ResponseFormat> responseEither = propertyValueConstraintValidationUtil.validatePropertyConstraints(
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -322,7 +316,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthDownstreamValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -331,7 +325,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -339,7 +333,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthDownstreamValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -348,7 +342,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -356,7 +350,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUpstreamValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -365,7 +359,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -373,7 +367,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUpstreamValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -382,7 +376,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
@@ -390,7 +384,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUnitsValueSuccessTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -399,7 +393,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isLeft());
}
@@ -407,7 +401,7 @@ public class PropertyValueConstraintValidationUtilTest {
@Test
public void bandwidthUnitsValueFailTest(){
Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap);
- Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either);
+ Mockito.when(applicationDataTypeCache.getAll(null)).thenReturn(either);
PropertyDefinition propertyDefinition = new PropertyDefinition();
propertyDefinition.setType("onap.datatypes.partner.bandwidth");
@@ -416,7 +410,7 @@ public class PropertyValueConstraintValidationUtilTest {
Either<Boolean, ResponseFormat> responseEither =
propertyValueConstraintValidationUtil.validatePropertyConstraints(
- Collections.singletonList(propertyDefinition), applicationDataTypeCache);
+ Collections.singletonList(propertyDefinition), applicationDataTypeCache, null);
Assert.assertTrue(responseEither.isRight());
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
index b8f60fe5b7..dcc5f6a29b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/GroupExportParserImplTest.java
@@ -20,36 +20,38 @@
package org.openecomp.sdc.be.tosca;
+import static java.util.Collections.singletonList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.Pair;
-
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException;
import org.openecomp.sdc.be.components.utils.GroupDefinitionBuilder;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.tosca.model.ToscaGroupTemplate;
import org.openecomp.sdc.be.tosca.model.ToscaTemplateCapability;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.Mockito.when;
-
@ExtendWith(MockitoExtension.class)
public class GroupExportParserImplTest {
@@ -67,7 +69,7 @@ public class GroupExportParserImplTest {
private GroupExportParser groupExportParser;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private Component component;
@Mock
@@ -79,14 +81,15 @@ public class GroupExportParserImplTest {
}
private void initGroupExportParser() {
- when(dataTypeCache.getAll()).thenReturn(Either.left(null));
- groupExportParser = new GroupExportParserImpl(dataTypeCache, propertyConvertor);
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(null));
+ groupExportParser = new GroupExportParserImpl(applicationDataTypeCache, propertyConvertor);
}
@Test
public void failToGetAllDataTypes() {
- when(dataTypeCache.getAll()).thenReturn(Either.right(null));
- assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> groupExportParser = new GroupExportParserImpl(dataTypeCache,
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(null));
+ assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> groupExportParser = new GroupExportParserImpl(
+ applicationDataTypeCache,
propertyConvertor));
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java
index b499830138..d7f70ae8a7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/PolicyExportParserImplTest.java
@@ -20,7 +20,16 @@
package org.openecomp.sdc.be.tosca;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -35,16 +44,6 @@ import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.tosca.model.ToscaMetadata;
import org.openecomp.sdc.be.tosca.model.ToscaPolicyTemplate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public class PolicyExportParserImplTest {
@@ -62,7 +61,7 @@ public class PolicyExportParserImplTest {
private PolicyExportParser policiyExportParser;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private PropertyConvertor propertyConvertor;
@@ -72,17 +71,18 @@ public class PolicyExportParserImplTest {
@Test
public void failToGetAllDataTypes() {
- when(dataTypeCache.getAll()).thenReturn(Either.right(null));
- assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> policiyExportParser = new PolicyExportParserImpl(dataTypeCache,
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(null));
+ assertThatExceptionOfType(SdcResourceNotFoundException.class).isThrownBy(() -> policiyExportParser = new PolicyExportParserImpl(
+ applicationDataTypeCache,
propertyConvertor));
}
@Test
public void noPoliciesInComponent() {
- when(dataTypeCache.getAll()).thenReturn(Either.left(null));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(null));
when(component.getPolicies()).thenReturn(null);
- policiyExportParser = new PolicyExportParserImpl(dataTypeCache, propertyConvertor);
+ policiyExportParser = new PolicyExportParserImpl(applicationDataTypeCache, propertyConvertor);
Map<String, ToscaPolicyTemplate> policies = policiyExportParser.getPolicies(component);
assertThat(policies).isEqualTo(null);
}
@@ -102,13 +102,13 @@ public class PolicyExportParserImplTest {
}
private void testPoliciesInComponent(List<Integer> constIndexes) {
- when(dataTypeCache.getAll()).thenReturn(Either.left(null));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(null));
Map<String, PolicyDefinition> policiesToAdd = getPolicies(constIndexes);
when(component.getPolicies()).thenReturn(policiesToAdd);
when(component.getComponentInstances()).thenReturn(getComponentInstances());
when(component.getGroups()).thenReturn(getGroups());
- policiyExportParser = new PolicyExportParserImpl(dataTypeCache, propertyConvertor);
+ policiyExportParser = new PolicyExportParserImpl(applicationDataTypeCache, propertyConvertor);
Map<String, ToscaPolicyTemplate> policies = policiyExportParser.getPolicies(component);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 5c8d522482..38c72922fd 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -129,7 +129,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
private ToscaExportHandler testSubject;
@Mock
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
@Mock
private ToscaOperationFacade toscaOperationFacade;
@@ -236,7 +236,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
Component component = getNewResource();
Either<ToscaRepresentation, ToscaError> result;
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
@@ -249,7 +249,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component = getNewService();
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Service.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
// default test when component is Service
result = testSubject.exportComponent(component);
@@ -263,14 +263,14 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
((Resource) component).setInterfaces(new HashMap<>());
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
// default test when convertInterfaceNodeType is right
result = testSubject.exportComponentInterface(component, false);
Assert.assertNotNull(result);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -298,7 +298,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
// when convertRequirements is called, make it return the same value as 3rd (index=2) argument.
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenAnswer(i -> Either.left(i.getArgument(2)));
@@ -392,7 +392,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
component.setComponentInstances(resourceInstances);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false));
final Map<String, ToscaProperty> map = new HashMap<>();
@@ -431,7 +431,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
any(Component.class), any(SubstitutionMapping.class)))
.thenReturn(Either.left(new SubstitutionMapping()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(inputConverter.convertInputs(any(List.class), any(Map.class))).thenReturn(new HashMap<>());
@@ -473,7 +473,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertSubstitutionMappingRequirements(anyMap(), any(Component.class), any(SubstitutionMapping.class)))
.thenReturn(Either.left(new SubstitutionMapping()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(inputConverter.convertInputs(anyList(), anyMap())).thenReturn(new HashMap<>());
final Map<String, ToscaProperty> map = new HashMap<>();
@@ -580,7 +580,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
Either<ToscaTemplate, ToscaError> result;
- when(dataTypeCache.getAll()).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.right(JanusGraphOperationStatus.ALREADY_EXIST));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
// default test
@@ -599,7 +599,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
inputs.add(new InputDefinition());
component.setInputs(inputs);
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
@@ -730,7 +730,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
.thenReturn(Either.left(new ToscaNodeTemplate()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class)))
.thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
@@ -854,7 +854,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
.thenReturn(Either.left(new ToscaNodeTemplate()));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class), any(ToscaNodeType.class)))
.thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaFullElement("uid")).thenReturn(Either.left(component));
@@ -917,7 +917,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
.convertComponentInstanceCapabilities(any(ComponentInstance.class), any(Map.class), any(ToscaNodeTemplate.class)))
.thenReturn(Either.right(ToscaError.GENERAL_ERROR));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -968,7 +968,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.right(false));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -1023,7 +1023,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
doReturn(Either.left(component)).when(toscaOperationFacade).getToscaFullElement("id");
when(capabilityRequirementConverter.getOriginComponent(any(Map.class), any(ComponentInstance.class))).thenReturn(Either.left(component));
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Resource.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
when(toscaOperationFacade.getToscaElement(any(String.class), any(ComponentParametersView.class)))
@@ -1165,7 +1165,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(any()))
.thenReturn(Either.left(Collections.emptyMap()));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
when(capabilityRequirementConverter.convertRequirements(any(Map.class), any(Service.class),
any(ToscaNodeType.class))).thenReturn(Either.left(new ToscaNodeType()));
@@ -1198,7 +1198,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
any(ComponentParametersView.class)))
.thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
// test when getLatestByName is left
result = Deencapsulation.invoke(testSubject, "createProxyNodeTypes", componentCache, container);
@@ -1213,7 +1213,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
ComponentInstance instance = new ComponentInstance();
ToscaNodeType result;
- when(dataTypeCache.getAll()).thenReturn(Either.left(new HashMap<>()));
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
// default test
result = Deencapsulation.invoke(testSubject, "createProxyNodeType", componentCache, origComponent,
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index 50f2ae9bd0..731ff63c4f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -74,6 +74,7 @@ public enum ActionStatus {
EMPTY_OCCURRENCES_LIST, INVALID_OCCURRENCES, NOT_TOPOLOGY_TOSCA_TEMPLATE, INVALID_NODE_TEMPLATE,
// Data type related
DATA_TYPE_ALREADY_EXIST, DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY, DATA_TYPE_DERIVED_IS_MISSING, DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR, DATA_TYPE_DUPLICATE_PROPERTY, DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE, DATA_TYPE_CANNOT_HAVE_PROPERTIES, DATA_TYPE_CANNOT_BE_EMPTY, DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST,
+ DATA_TYPES_NOT_LOADED,
// Policy Type related
TARGETS_EMPTY, TARGETS_NON_VALID, POLICY_TYPE_ALREADY_EXIST,
// Group Type related
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java
index 95b22a8ac3..e482fb55b6 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java
@@ -49,6 +49,7 @@ public class DataTypeData extends GraphNode {
dataTypeDataDefinition.setDerivedFromName((String) properties.get(GraphPropertiesDictionary.DERIVED_FROM.getProperty()));
dataTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
dataTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ dataTypeDataDefinition.setModel((String) properties.get(GraphPropertiesDictionary.MODEL.getProperty()));
}
@Override
@@ -60,6 +61,7 @@ public class DataTypeData extends GraphNode {
addIfExists(map, GraphPropertiesDictionary.DERIVED_FROM, dataTypeDataDefinition.getDerivedFromName());
addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, dataTypeDataDefinition.getCreationTime());
addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, dataTypeDataDefinition.getModificationTime());
+ addIfExists(map, GraphPropertiesDictionary.MODEL, dataTypeDataDefinition.getModel());
return map;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java
index 01f6cd1b40..bf9f4d79a6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/DataTypeDefinition.java
@@ -36,7 +36,6 @@ public class DataTypeDefinition extends DataTypeDataDefinition {
private DataTypeDefinition derivedFrom;
private List<PropertyConstraint> constraints;
private List<PropertyDefinition> properties;
- private String model;
public DataTypeDefinition(final DataTypeDataDefinition dataTypeDataDefinition) {
super(dataTypeDataDefinition);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationCache.java
index d0a071909c..bfb20a2f14 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationCache.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationCache.java
@@ -22,10 +22,11 @@ package org.openecomp.sdc.be.model.cache;
import fj.data.Either;
import java.util.Map;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
public interface ApplicationCache<T> {
- Either<Map<String, T>, JanusGraphOperationStatus> getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> getAll(final String model);
- Either<T, JanusGraphOperationStatus> get(String uniqueId);
+ Either<T, JanusGraphOperationStatus> get(final String model, final String uniqueId);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java
index a1bafbc6f2..070ebf72e3 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.model.cache;
import fj.data.Either;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -43,6 +44,7 @@ import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheInfo;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.operations.impl.DataTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
@@ -64,13 +66,16 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
private final ScheduledExecutorService scheduledPollingService;
@Getter(AccessLevel.PACKAGE)
private ScheduledFuture<?> scheduledFuture = null;
- private Map<String, DataTypeDefinition> dataTypesCacheMap = new HashMap<>();
+ private Map<String, Map<String, DataTypeDefinition>> dataTypesByModelCacheMap = new HashMap<>();
+ private final DataTypeOperation dataTypeOperation;
private int firstRunDelayInSec = 30;
private int pollingIntervalInSec = 60;
- public ApplicationDataTypeCache(final PropertyOperation propertyOperation, final ApplicationEventPublisher applicationEventPublisher) {
+ public ApplicationDataTypeCache(final PropertyOperation propertyOperation, final ApplicationEventPublisher applicationEventPublisher,
+ final DataTypeOperation dataTypeOperation) {
this.propertyOperation = propertyOperation;
this.applicationEventPublisher = applicationEventPublisher;
+ this.dataTypeOperation = dataTypeOperation;
scheduledPollingService = Executors
.newScheduledThreadPool(1, new BasicThreadFactory.Builder().namingPattern("ApplicationDataTypeCacheThread-%d").build());
}
@@ -156,32 +161,34 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
}
}
- private Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> getAllDataTypesFromGraph() {
+ private Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> getAllDataTypesFromGraph() {
return propertyOperation.getAllDataTypes();
}
- @Override
- public Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> getAll() {
+ public Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> getAll(final String model) {
try {
readWriteLock.readLock().lock();
- if (MapUtils.isEmpty(dataTypesCacheMap)) {
- return getAllDataTypesFromGraph();
+ if (MapUtils.isEmpty(dataTypesByModelCacheMap)) {
+ final var dataTypesFound = getAllDataTypesFromGraph();
+ if (dataTypesFound.isRight()) {
+ return Either.right(dataTypesFound.right().value());
+ }
+ dataTypesByModelCacheMap = dataTypesFound.left().value();
}
- return Either.left(new HashMap<>(dataTypesCacheMap));
+ return Either.left(getDataTypeDefinitionMapByModel(model));
} finally {
readWriteLock.readLock().unlock();
}
}
@Override
- public Either<DataTypeDefinition, JanusGraphOperationStatus> get(String uniqueId) {
+ public Either<DataTypeDefinition, JanusGraphOperationStatus> get(final String model, final String uniqueId) {
try {
readWriteLock.readLock().lock();
- if (MapUtils.isEmpty(dataTypesCacheMap)) {
+ if (MapUtils.isEmpty(dataTypesByModelCacheMap)) {
return propertyOperation.getDataTypeByUid(uniqueId);
}
-
- final Optional<DataTypeDefinition> dataTypeDefinition = dataTypesCacheMap.values().stream()
+ final Optional<DataTypeDefinition> dataTypeDefinition = getDataTypeDefinitionMapByModel(model).values().stream()
.filter(p -> p.getUniqueId().equals(uniqueId)).findFirst();
if (dataTypeDefinition.isEmpty()) {
return propertyOperation.getDataTypeByUid(uniqueId);
@@ -192,6 +199,10 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
}
}
+ private Map<String, DataTypeDefinition> getDataTypeDefinitionMapByModel(final String model) {
+ return dataTypesByModelCacheMap.containsKey(model) ? dataTypesByModelCacheMap.get(model) : new HashMap<>();
+ }
+
@Override
public void run() {
try {
@@ -218,10 +229,9 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
private boolean hasDataTypesChanged() {
final List<DataTypeData> dataTypeListFromDatabase = findAllDataTypesLazy();
- final Map<String, DataTypeDefinition> dataTypesCacheCopyMap = copyDataTypeCache();
-
- if (dataTypeListFromDatabase.size() != dataTypesCacheCopyMap.size()) {
- log.debug("Total of cached data types '{}' differs from the actual '{}'", dataTypeListFromDatabase.size(), dataTypesCacheCopyMap.size());
+ final int dataTypesCacheCopyMap = dataTypesCacheMapSize();
+ if (dataTypeListFromDatabase.size() != dataTypesCacheCopyMap) {
+ log.debug("Total of cached data types '{}' differs from the actual '{}'", dataTypeListFromDatabase.size(), dataTypesCacheCopyMap);
return true;
}
@@ -230,13 +240,23 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
return false;
}
- return hasDataTypesChanged(dataTypeListFromDatabase, dataTypesCacheCopyMap);
+ return hasDataTypesChanged(dataTypeListFromDatabase, copyDataTypeCache());
}
- private boolean hasDataTypesChanged(final List<DataTypeData> dataTypeListFromDatabase, final Map<String, DataTypeDefinition> dataTypesCacheCopyMap) {
+ private int dataTypesCacheMapSize() {
+ var count = 0;
+ for (var i = 0; i < copyDataTypeCache().size(); i++) {
+ count += new ArrayList<>(copyDataTypeCache().values()).get(i).size();
+
+ }
+ return count;
+ }
+
+ private boolean hasDataTypesChanged(final List<DataTypeData> dataTypeListFromDatabase, final Map<String, Map<String, DataTypeDefinition>> dataTypesCacheCopyMap) {
return dataTypeListFromDatabase.stream().map(DataTypeData::getDataTypeDataDefinition).anyMatch(actualDataTypeDefinition -> {
final String dataTypeName = actualDataTypeDefinition.getName();
- final DataTypeDefinition cachedDataTypeDefinition = dataTypesCacheCopyMap.get(dataTypeName);
+ final String model = actualDataTypeDefinition.getModel();
+ final DataTypeDefinition cachedDataTypeDefinition = dataTypesCacheCopyMap.get(model).get(dataTypeName);
if (cachedDataTypeDefinition == null) {
log.debug("Datatype '{}' is not present in the cache. ", dataTypeName);
return true;
@@ -245,8 +265,8 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
final long cachedCreationTime = cachedDataTypeDefinition.getCreationTime() == null ? 0 : cachedDataTypeDefinition.getCreationTime();
final long actualCreationTime = actualDataTypeDefinition.getCreationTime() == null ? 0 : actualDataTypeDefinition.getCreationTime();
if (cachedCreationTime != actualCreationTime) {
- log.debug("Datatype '{}' was updated. Cache/database creation time '{}'/'{}'.",
- dataTypeName, cachedCreationTime, actualCreationTime);
+ log.debug("Datatype '{}' with model '{}' was updated. Cache/database creation time '{}'/'{}'.",
+ dataTypeName, model, cachedCreationTime, actualCreationTime);
return true;
}
final long cachedModificationTime =
@@ -263,23 +283,23 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
});
}
- private Map<String, DataTypeDefinition> copyDataTypeCache() {
+ private Map<String, Map<String, DataTypeDefinition>> copyDataTypeCache() {
try {
readWriteLock.readLock().lock();
- return new HashMap<>(this.dataTypesCacheMap);
+ return new HashMap<>(this.dataTypesByModelCacheMap);
} finally {
readWriteLock.readLock().unlock();
}
}
private void refreshDataTypesCache() {
- final Map<String, DataTypeDefinition> dataTypesDefinitionMap = findAllDataTypesEager();
+ final Map<String, Map<String, DataTypeDefinition>> dataTypesDefinitionMap = findAllDataTypesEager();
if (dataTypesDefinitionMap.isEmpty()) {
return;
}
try {
readWriteLock.writeLock().lock();
- dataTypesCacheMap = dataTypesDefinitionMap;
+ dataTypesByModelCacheMap = dataTypesDefinitionMap;
onDataChangeEventEmit();
BeEcompErrorManager.getInstance()
.logInternalFlowError("ReplaceDataTypesCache", "Succeed to replace the data types cache", ErrorSeverity.INFO);
@@ -288,10 +308,10 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
}
}
- private Map<String, DataTypeDefinition> findAllDataTypesEager() {
+ private Map<String, Map<String, DataTypeDefinition>> findAllDataTypesEager() {
log.trace("Fetching data types from database, eager mode");
final long startTime = System.currentTimeMillis();
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = propertyOperation.getAllDataTypes();
+ final Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> allDataTypes = propertyOperation.getAllDataTypes();
log.trace("Finish fetching data types from database. Took {}ms", (System.currentTimeMillis() - startTime));
if (allDataTypes.isRight()) {
final JanusGraphOperationStatus status = allDataTypes.right().value();
@@ -306,16 +326,9 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
private List<DataTypeData> findAllDataTypesLazy() {
log.trace("Fetching data types from database, lazy mode");
final long startTime = System.currentTimeMillis();
- final Either<List<DataTypeData>, JanusGraphOperationStatus> allDataTypes = propertyOperation.getAllDataTypeNodes();
+ final List<DataTypeData> allDataTypes = dataTypeOperation.getAllDataTypeNodes();
log.trace("Finish fetching data types from database. Took {}ms", (System.currentTimeMillis() - startTime));
- if (allDataTypes.isRight()) {
- final JanusGraphOperationStatus status = allDataTypes.right().value();
- var errorMsg= String.format("Failed to fetch data types from database. Status is %s", status);
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, ApplicationDataTypeCache.class.getName(), errorMsg);
- BeEcompErrorManager.getInstance().logInternalConnectionError(APPLICATION_DATA_TYPES_CACHE, errorMsg, ErrorSeverity.ERROR);
- return Collections.emptyList();
- }
- return allDataTypes.left().value();
+ return allDataTypes;
}
private void onDataChangeEventEmit() {
@@ -329,9 +342,9 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
public static class DataTypesCacheChangedEvent extends ApplicationEvent {
@Getter
- private final Map<String, DataTypeDefinition> newData;
+ private final Map<String, Map<String, DataTypeDefinition>> newData;
- public DataTypesCacheChangedEvent(final Object source, final Map<String, DataTypeDefinition> newData) {
+ public DataTypesCacheChangedEvent(final Object source, final Map<String, Map<String, DataTypeDefinition>> newData) {
super(source);
this.newData = newData;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
index 1097e5d204..97dd3ea718 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
@@ -70,7 +70,7 @@ public class ComponentInstanceOperation extends AbstractOperation {
@Autowired
private IInputsOperation inputOperation;
@Autowired
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
public ComponentInstanceOperation() {
super();
@@ -408,7 +408,8 @@ public class ComponentInstanceOperation extends AbstractOperation {
innerType = propDef.getType();
}
log.debug("Before validateAndUpdatePropertyValue");
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes =
+ applicationDataTypeCache.getAll(resourceInstanceInput.getModel());
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right().value();
BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
new file mode 100644
index 0000000000..158cb2569b
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
@@ -0,0 +1,126 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model.operations.impl;
+
+import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
+import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component("dataType-operation")
+public class DataTypeOperation extends AbstractOperation {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DataTypeOperation.class);
+
+ private final ModelOperation modelOperation;
+
+ @Autowired
+ public DataTypeOperation(final HealingJanusGraphGenericDao janusGraphGenericDao,
+ final ModelOperation modelOperation) {
+ this.janusGraphGenericDao = janusGraphGenericDao;
+ this.modelOperation = modelOperation;
+ }
+
+ public List<DataTypeData> getAllDataTypeNodes() {
+ final List<DataTypeData> dataTypesFound = new ArrayList<>();
+ final Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypesWithNullModel =
+ janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class);
+
+ final var dataTypesValidated = validateDataType(getAllDataTypesWithNullModel, null);
+ if (CollectionUtils.isNotEmpty(dataTypesValidated)) {
+ dataTypesFound.addAll(dataTypesValidated);
+ }
+
+ final List<DataTypeData> allDataTypeNodesWithModel = getAllDataTypesWithModel();
+ if(CollectionUtils.isNotEmpty(allDataTypeNodesWithModel)) {
+ dataTypesFound.addAll(allDataTypeNodesWithModel);
+ }
+ return dataTypesFound;
+ }
+
+ public List<DataTypeData> getAllDataTypesWithModel() {
+ final List<DataTypeData> dataTypesWithModel = new ArrayList<>();
+ modelOperation.findAllModels()
+ .forEach(model -> {
+ final var modelName = model.getName();
+ final Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypesByModel = janusGraphGenericDao
+ .getByCriteriaForModel(NodeTypeEnum.DataType, null, modelName, DataTypeData.class);
+ final var dataTypesValidated = validateDataType(getAllDataTypesByModel, modelName);
+ dataTypesWithModel.addAll(dataTypesValidated);
+ });
+ return dataTypesWithModel;
+ }
+
+ private List<DataTypeData> validateDataType(final Either<List<DataTypeData>, JanusGraphOperationStatus> getDataTypes, final String modelName) {
+ if (getDataTypes.isRight() && getDataTypes.right().value() == JanusGraphOperationStatus.NOT_FOUND) {
+ return Collections.emptyList();
+ }
+ if (getDataTypes.isRight()) {
+ final var status = getDataTypes.right().value();
+ if (LOGGER.isErrorEnabled()) {
+ final var errorMsg= String.format("Failed to fetch data types from database with model %s. Status is %s", modelName, status);
+ LOGGER.error(String.valueOf(EcompLoggerErrorCode.UNKNOWN_ERROR), DataTypeOperation.class.getName(), errorMsg);
+ BeEcompErrorManager.getInstance().logInternalConnectionError(DataTypeOperation.class.getName(), errorMsg, ErrorSeverity.ERROR);
+ }
+ return Collections.emptyList();
+ }
+ return getDataTypes.left().value();
+ }
+
+ public Map<String, Map<String, DataTypeDefinition>> mapDataTypesDefinitionByModel(final Map<String, DataTypeDefinition> allDataTypes) {
+ final Map<String, DataTypeDefinition> dataTypesWithNullModelMap = new HashMap<>();
+ final Map<String, DataTypeDefinition> dataTypesWithModelMap = new HashMap<>();
+ final Map<String, Map<String, DataTypeDefinition>> dataTypesMappedByModel = new HashMap<>();
+ allDataTypes.values().stream().forEach(dataTypeDefinition -> {
+ final var model = dataTypeDefinition.getModel();
+ final var dataTypeDefinitionName = dataTypeDefinition.getName();
+ if (model == null) {
+ dataTypesWithNullModelMap.put(dataTypeDefinitionName, dataTypeDefinition);
+ } else {
+ dataTypesWithModelMap.put(dataTypeDefinitionName, dataTypeDefinition);
+ if (dataTypesMappedByModel.containsKey(model)) {
+ dataTypesMappedByModel.get(model).put(dataTypeDefinitionName, dataTypeDefinition);
+ } else {
+ dataTypesMappedByModel.put(model, dataTypesWithModelMap);
+ }
+ }
+ });
+ if(MapUtils.isNotEmpty(dataTypesWithNullModelMap)) {
+ dataTypesMappedByModel.put(null, dataTypesWithNullModelMap);
+ }
+ return dataTypesMappedByModel;
+ }
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupInstanceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupInstanceOperation.java
index 45df37c4b8..c463af691c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupInstanceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupInstanceOperation.java
@@ -76,7 +76,7 @@ public class GroupInstanceOperation extends AbstractOperation implements IGroupI
@Autowired
PropertyOperation propertyOperation;
@javax.annotation.Resource
- private ApplicationDataTypeCache dataTypeCache;
+ private ApplicationDataTypeCache applicationDataTypeCache;
public Either<List<GroupInstance>, StorageOperationStatus> getAllGroupInstances(String parentId, NodeTypeEnum parentType) {
Either<List<GroupInstance>, StorageOperationStatus> result = null;
@@ -285,7 +285,8 @@ public class GroupInstanceOperation extends AbstractOperation implements IGroupI
innerType = propDef.getType();
}
log.debug("Before validateAndUpdatePropertyValue");
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes =
+ applicationDataTypeCache.getAll(groupInstanceProperty.getModel());
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right().value();
BeEcompErrorManager.getInstance()
@@ -388,7 +389,8 @@ public class GroupInstanceOperation extends AbstractOperation implements IGroupI
innerType = propDef.getType();
}
// Specific Update Logic
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes =
+ applicationDataTypeCache.getAll(groupInstanceProerty.getModel());
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right().value();
BeEcompErrorManager.getInstance()
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupOperation.java
index effdbebf4c..b9378b8eca 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/GroupOperation.java
@@ -72,15 +72,15 @@ public class GroupOperation extends AbstractOperation implements IGroupOperation
private final TopologyTemplateOperation topologyTemplateOperation;
private final PropertyOperation propertyOperation;
private final GroupTypeOperation groupTypeOperation;
- private final ApplicationDataTypeCache dataTypeCache;
+ private final ApplicationDataTypeCache applicationDataTypeCache;
public GroupOperation(JanusGraphDao janusGraphDao, TopologyTemplateOperation topologyTemplateOperation, PropertyOperation propertyOperation,
- GroupTypeOperation groupTypeOperation, ApplicationDataTypeCache dataTypeCache) {
+ GroupTypeOperation groupTypeOperation, ApplicationDataTypeCache applicationDataTypeCache) {
this.janusGraphDao = janusGraphDao;
this.topologyTemplateOperation = topologyTemplateOperation;
this.propertyOperation = propertyOperation;
this.groupTypeOperation = groupTypeOperation;
- this.dataTypeCache = dataTypeCache;
+ this.applicationDataTypeCache = applicationDataTypeCache;
}
private GroupDefinition convertGroupDataToGroupDefinition(GroupData groupData) {
@@ -485,7 +485,7 @@ public class GroupOperation extends AbstractOperation implements IGroupOperation
StorageOperationStatus result = null;
String innerType =
property.getSchema() == null ? null : property.getSchema().getProperty() == null ? null : property.getSchema().getProperty().getType();
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = applicationDataTypeCache.getAll(property.getModel());
Either<Object, Boolean> isValid = null;
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right().value();
@@ -493,8 +493,8 @@ public class GroupOperation extends AbstractOperation implements IGroupOperation
result = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
}
if (result == null) {
- isValid = propertyOperation
- .validateAndUpdatePropertyValue(property.getType(), property.getValue(), innerType, allDataTypes.left().value());
+ isValid = propertyOperation.validateAndUpdatePropertyValue(property.getType(), property.getValue(), innerType,
+ allDataTypes.left().value());
if (isValid.isRight()) {
log.debug("Failed to validate property value {}. Status is {}. ", property.getValue(), StorageOperationStatus.INVALID_PROPERTY);
result = StorageOperationStatus.INVALID_PROPERTY;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index 1f4fca0685..726efcf847 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -21,6 +21,20 @@ package org.openecomp.sdc.be.model.operations.impl;
import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR;
+import com.fasterxml.jackson.core.ObjectCodec;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Maps;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import fj.data.Either;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -82,6 +96,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.openecomp.sdc.be.resources.data.ModelData;
import org.openecomp.sdc.be.resources.data.PropertyData;
import org.openecomp.sdc.be.resources.data.PropertyValueData;
import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
@@ -89,20 +104,6 @@ import org.openecomp.sdc.be.resources.data.UniqueIdData;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Maps;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-import fj.data.Either;
@Component("property-operation")
public class PropertyOperation extends AbstractOperation implements IPropertyOperation {
@@ -120,11 +121,14 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
private static final String UPDATE_DATA_TYPE = "UpdateDataType";
private static Logger log = Logger.getLogger(PropertyOperation.class.getName());
private DerivedFromOperation derivedFromOperation;
+ private DataTypeOperation dataTypeOperation;
@Autowired
- public PropertyOperation(HealingJanusGraphGenericDao janusGraphGenericDao, DerivedFromOperation derivedFromOperation) {
+ public PropertyOperation(HealingJanusGraphGenericDao janusGraphGenericDao, DerivedFromOperation derivedFromOperation,
+ DataTypeOperation dataTypeOperation) {
this.janusGraphGenericDao = janusGraphGenericDao;
this.derivedFromOperation = derivedFromOperation;
+ this.dataTypeOperation = dataTypeOperation;
}
public PropertyDefinition convertPropertyDataToPropertyDefinition(PropertyData propertyDataResult, String propertyName, String resourceId) {
@@ -1506,28 +1510,21 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
return Either.left(true);
}
- public Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> getAllDataTypes() {
- Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> result = Either.left(dataTypes);
- Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypes = janusGraphGenericDao
- .getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class);
- if (getAllDataTypes.isRight()) {
- JanusGraphOperationStatus status = getAllDataTypes.right().value();
- if (status != JanusGraphOperationStatus.NOT_FOUND) {
- return Either.right(status);
- } else {
- return result;
- }
- }
- List<DataTypeData> list = getAllDataTypes.left().value();
+ public Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> getAllDataTypes() {
+ final Map<String, Map<String, DataTypeDefinition>> dataTypes = new HashMap<>();
+ Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> result = Either.left(dataTypes);
+ final Map<String, DataTypeDefinition> allDataTypesFound = new HashMap<>();
+ final List<DataTypeData> list = dataTypeOperation.getAllDataTypeNodes();
if (list != null) {
log.trace("Number of data types to load is {}", list.size());
List<String> collect = list.stream().map(p -> p.getDataTypeDataDefinition().getName()).collect(Collectors.toList());
log.trace("The data types to load are {}", collect);
for (DataTypeData dataTypeData : list) {
- log.trace("Going to fetch data type {}. uid is {}", dataTypeData.getDataTypeDataDefinition().getName(), dataTypeData.getUniqueId());
+ final String dataTypeName = dataTypeData.getDataTypeDataDefinition().getName();
+ final String dataTypeUniqueId = dataTypeData.getUniqueId();
+ log.trace("Going to fetch data type {}. uid is {}", dataTypeName, dataTypeUniqueId);
Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeByUid = this
- .getAndAddDataTypeByUid(dataTypeData.getUniqueId(), dataTypes);
+ .getAndAddDataTypeByUid(dataTypeUniqueId, allDataTypesFound);
if (dataTypeByUid.isRight()) {
JanusGraphOperationStatus status = dataTypeByUid.right().value();
if (status == JanusGraphOperationStatus.NOT_FOUND) {
@@ -1535,13 +1532,14 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
return Either.right(status);
}
+ result = Either.left(dataTypeOperation.mapDataTypesDefinitionByModel(allDataTypesFound));
}
}
if (log.isTraceEnabled()) {
if (result.isRight()) {
log.trace("After fetching all data types {}", result);
} else {
- Map<String, DataTypeDefinition> map = result.left().value();
+ Map<String, Map<String, DataTypeDefinition>> map = result.left().value();
if (map != null) {
String types = map.keySet().stream().collect(Collectors.joining(",", "[", "]"));
log.trace("After fetching all data types {} ", types);
@@ -1577,7 +1575,7 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
log.error(FAILED_TO_FETCH_PROPERTIES_OF_DATA_TYPE, uniqueId);
return Either.right(propertiesStatus);
}
- allDataTypes.put(dataTypeDefinition.getName(), dataTypeDefinition);
+ allDataTypes.put(dataTypeDefinition.getUniqueId(), dataTypeDefinition);
String derivedFrom = dataTypeDefinition.getDerivedFromName();
if (allDataTypes.containsKey(derivedFrom)) {
DataTypeDefinition parentDataTypeDefinition = allDataTypes.get(derivedFrom);
@@ -1606,26 +1604,28 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
DataTypeDefinition parentDataTypeDefinition = dataTypeByUid.left().value();
dataTypeDefinition.setDerivedFrom(parentDataTypeDefinition);
+ final var model = getModel(uniqueId);
+ if (StringUtils.isNotEmpty(model)) {
+ dataTypeDefinition.setModel(model);
+ }
}
result = Either.left(dataTypeDefinition);
return result;
}
+ private String getModel(final String uniqueId) {
+ final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> model = janusGraphGenericDao.getParentNode(
+ UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.DataType), uniqueId, GraphEdgeLabels.MODEL_ELEMENT,
+ NodeTypeEnum.Model, ModelData.class);
+ return model.isLeft() ? model.left().value().getLeft().getName() : StringUtils.EMPTY;
+ }
+
public Either<String, JanusGraphOperationStatus> checkInnerType(PropertyDataDefinition propDataDef) {
String propertyType = propDataDef.getType();
ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
return getInnerType(type, propDataDef::getSchema);
}
- public Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypeNodes() {
- final Either<List<DataTypeData>, JanusGraphOperationStatus> getAllDataTypes =
- janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class);
- if (getAllDataTypes.isRight() && getAllDataTypes.right().value() == JanusGraphOperationStatus.NOT_FOUND) {
- return Either.left(Collections.emptyList());
- }
- return getAllDataTypes;
- }
-
public Either<Object, Boolean> validateAndUpdatePropertyValue(String propertyType, String value, boolean isValidate, String innerType,
Map<String, DataTypeDefinition> dataTypes) {
log.trace("Going to validate property value and its type. type = {}, value = {}", propertyType, value);
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java
index 9126b64659..75a47db634 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java
@@ -49,6 +49,7 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.operations.impl.DataTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.springframework.context.ApplicationEventPublisher;
@@ -59,6 +60,9 @@ class ApplicationDataTypeCacheTest {
private PropertyOperation propertyOperation;
@Mock
+ private DataTypeOperation dataTypeOperation;
+
+ @Mock
private ApplicationEventPublisher applicationEventPublisher;
@InjectMocks
@@ -150,18 +154,19 @@ class ApplicationDataTypeCacheTest {
final DataTypeDefinition testDataType1 = createDataTypeDefinition("test.data.type1", "test.data.type1", 101L, 1000L);
final DataTypeDefinition testDataType2 = createDataTypeDefinition("test.data.type2", "test.data.type2", 101L, 1002L);
- final Map<String, DataTypeDefinition> modifiedDataTypeDefinitionMap =
- Map.of(testDataType1.getName(), testDataType1, testDataType2.getName(), testDataType2);
+ final Map<String, DataTypeDefinition> dataTypeDefinitionMap = Map.of(testDataType1.getName(), testDataType1, testDataType2.getName(), testDataType2);
+ final Map<String, Map<String, DataTypeDefinition>> modifiedDataTypeDefinitionMap = new HashMap<>();
+ modifiedDataTypeDefinitionMap.put(null, dataTypeDefinitionMap);
when(propertyOperation.getAllDataTypes()).thenReturn(Either.left(modifiedDataTypeDefinitionMap));
final DataTypeData dataTypeData1 = createDataTypeData("test.data.type1", "test.data.type1", 101L, 101L);
final DataTypeData dataTypeData2 = createDataTypeData("test.data.type2", "test.data.type2", 101L, 1002L);
- when(propertyOperation.getAllDataTypeNodes()).thenReturn(Either.left(List.of(dataTypeData1, dataTypeData2)));
+ when(dataTypeOperation.getAllDataTypeNodes()).thenReturn(List.of(dataTypeData1, dataTypeData2));
await().atMost(Duration.ofSeconds(schedulerPollIntervalInSec + 1)).until(() -> scheduledFuture.getDelay(TimeUnit.SECONDS) == 0);
await().atMost(Duration.ofSeconds(schedulerPollIntervalInSec + 1)).until(() -> scheduledFuture.getDelay(TimeUnit.SECONDS) != 0);
- assertDataTypeCache(modifiedDataTypeDefinitionMap);
+ assertDataTypeCache(modifiedDataTypeDefinitionMap.get(null));
}
@Test
@@ -172,17 +177,19 @@ class ApplicationDataTypeCacheTest {
await().until(() -> scheduledFuture.getDelay(TimeUnit.SECONDS) != 0);
assertDataTypeCache(dataTypeDefinitionMap);
+ final Map<String, Map<String, DataTypeDefinition>> dataTypesMappedByModel = new HashMap<>();
final Map<String, DataTypeDefinition> modifiedDataTypeDefinitionMap = new HashMap<>();
final DataTypeDefinition testDataType1 = createDataTypeDefinition("test.data.type1", "test.data.type1", 1L, 1L);
modifiedDataTypeDefinitionMap.put(testDataType1.getName(), testDataType1);
final DataTypeDefinition testDataType3 = createDataTypeDefinition("test.data.type3", "test.data.type3", 1L, 1L);
modifiedDataTypeDefinitionMap.put(testDataType3.getName(), testDataType3);
- when(propertyOperation.getAllDataTypes()).thenReturn(Either.left(modifiedDataTypeDefinitionMap));
+ dataTypesMappedByModel.put(null, modifiedDataTypeDefinitionMap);
+ when(propertyOperation.getAllDataTypes()).thenReturn(Either.left(dataTypesMappedByModel));
final DataTypeData dataTypeData1 = createDataTypeData("test.data.type1", "test.data.type1", 1L, 1L);
final DataTypeData dataTypeData3 = createDataTypeData("test.data.type3", "test.data.type3", 1L, 1L);
- when(propertyOperation.getAllDataTypeNodes()).thenReturn(Either.left(List.of(dataTypeData1, dataTypeData3)));
+ when(dataTypeOperation.getAllDataTypeNodes()).thenReturn(List.of(dataTypeData1, dataTypeData3));
await().atMost(Duration.ofSeconds(schedulerPollIntervalInSec + 1)).until(() -> scheduledFuture.getDelay(TimeUnit.SECONDS) == 0);
await().atMost(Duration.ofSeconds(schedulerPollIntervalInSec + 1)).until(() -> scheduledFuture.getDelay(TimeUnit.SECONDS) != 0);
@@ -191,9 +198,9 @@ class ApplicationDataTypeCacheTest {
@Test
void testGetAllWithNoInitialization() {
- final Map<String, DataTypeDefinition> dataTypeDefinitionMap = new HashMap<>();
+ final Map<String, Map<String, DataTypeDefinition>> dataTypeDefinitionMap = new HashMap<>();
when(propertyOperation.getAllDataTypes()).thenReturn(Either.left(dataTypeDefinitionMap));
- final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> response = applicationDataTypeCache.getAll();
+ final Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> response = applicationDataTypeCache.getAll(null);
assertNotNull(response);
assertTrue(response.isLeft());
}
@@ -202,7 +209,7 @@ class ApplicationDataTypeCacheTest {
void testGetWhenCacheIsEmpty() {
var dataTypeDefinition = new DataTypeDefinition();
when(propertyOperation.getDataTypeByUid("uniqueId")).thenReturn(Either.left(dataTypeDefinition));
- final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeEither = applicationDataTypeCache.get("uniqueId");
+ final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeEither = applicationDataTypeCache.get(null, "uniqueId");
assertNotNull(dataTypeEither);
assertTrue(dataTypeEither.isLeft());
assertEquals(dataTypeDefinition, dataTypeEither.left().value());
@@ -213,7 +220,8 @@ class ApplicationDataTypeCacheTest {
defaultInit();
final ScheduledFuture<?> scheduledFuture = applicationDataTypeCache.getScheduledFuture();
await().atMost(Duration.ofSeconds(schedulerPollIntervalInSec + 1)).until(() -> scheduledFuture.getDelay(TimeUnit.SECONDS) != 0);
- final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeEither = applicationDataTypeCache.get("test.data.type1");
+ final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeEither =
+ applicationDataTypeCache.get(null, "test.data.type1");
assertNotNull(dataTypeEither);
assertTrue(dataTypeEither.isLeft());
final DataTypeDefinition actualDataTypeDefinition = dataTypeEither.left().value();
@@ -236,12 +244,14 @@ class ApplicationDataTypeCacheTest {
dataTypeDefinitionMap.put(testDataType1.getName(), testDataType1);
final DataTypeDefinition testDataType2 = createDataTypeDefinition("test.data.type2", "test.data.type2", 101L, 1001L);
dataTypeDefinitionMap.put(testDataType2.getName(), testDataType2);
- when(propertyOperation.getAllDataTypes()).thenReturn(Either.left(dataTypeDefinitionMap));
+ final Map<String, Map<String, DataTypeDefinition>> dataTypesMappedByModel = new HashMap<>();
+ dataTypesMappedByModel.put(null, dataTypeDefinitionMap);
+ when(propertyOperation.getAllDataTypes()).thenReturn(Either.left(dataTypesMappedByModel));
final DataTypeData dataTypeData1 = createDataTypeData("test.data.type1", testDataType1.getName(), 100L, 1000L);
final DataTypeData dataTypeData2 = createDataTypeData("test.data.type2", testDataType2.getName(), 101L, 1001L);
- when(propertyOperation.getAllDataTypeNodes()).thenReturn(Either.left(List.of(dataTypeData1, dataTypeData2)));
+ when(dataTypeOperation.getAllDataTypeNodes()).thenReturn(List.of(dataTypeData1, dataTypeData2));
applicationDataTypeCache.init();
}
@@ -286,7 +296,7 @@ class ApplicationDataTypeCacheTest {
}
public void assertDataTypeCache(final Map<String, DataTypeDefinition> expectedDataTypeCache) {
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheMapEither = applicationDataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> dataTypeCacheMapEither = applicationDataTypeCache.getAll(null);
assertNotNull(dataTypeCacheMapEither);
assertTrue(dataTypeCacheMapEither.isLeft());
final Map<String, DataTypeDefinition> actualDataTypeMap = dataTypeCacheMapEither.left().value();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
new file mode 100644
index 0000000000..015aedc6a3
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
@@ -0,0 +1,174 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.model.operations.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.Model;
+import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.springframework.test.context.ContextConfiguration;
+
+@ContextConfiguration("classpath:application-context-test.xml")
+class DataTypeOperationTest {
+
+ @InjectMocks
+ private DataTypeOperation dataTypeOperation;
+ @Mock
+ private ModelOperation modelOperation;
+ @Mock
+ private HealingJanusGraphGenericDao janusGraphGenericDao;
+ @Mock
+ private ApplicationDataTypeCache applicationDataTypeCache;
+
+ private final String modelName = "ETSI-SDC-MODEL-TEST";
+ private final List<DataTypeData> dataTypesWithoutModel = new ArrayList<>();
+ private final List<DataTypeData> dataTypesWithModel = new ArrayList<>();
+ final Map<String, Map<String, DataTypeDefinition>> dataTypesMappedByModel = new HashMap<>();
+ final Map<String, DataTypeDefinition> allDataTypesFoundDefinitionMap = new HashMap<>();
+ private Model model;
+
+
+ @BeforeEach
+ void beforeEachInit() {
+ MockitoAnnotations.openMocks(this);
+ initTestData();
+ }
+
+ @Test
+ void getAllDataTypeNodesTest() {
+ when(janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class))
+ .thenReturn(Either.left(dataTypesWithoutModel));
+ when(modelOperation.findAllModels()).thenReturn(Collections.singletonList(model));
+ when(janusGraphGenericDao.getByCriteriaForModel(NodeTypeEnum.DataType, null, modelName, DataTypeData.class))
+ .thenReturn(Either.left(dataTypesWithModel));
+ final var dataTypesFound = dataTypeOperation.getAllDataTypeNodes();
+ assertThat(dataTypesFound.size()).isEqualTo(4);
+ assertThat(dataTypesFound.containsAll(dataTypesWithoutModel)).isTrue();
+ assertThat(dataTypesFound.containsAll(dataTypesWithModel)).isTrue();
+ }
+
+ @Test
+ void getAllDataTypesWithModelTest() {
+ when(janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class))
+ .thenReturn(Either.left(Collections.emptyList()));
+ when(modelOperation.findAllModels()).thenReturn(Collections.singletonList(model));
+ when(janusGraphGenericDao.getByCriteriaForModel(NodeTypeEnum.DataType, null, modelName, DataTypeData.class))
+ .thenReturn(Either.left(dataTypesWithModel));
+ final var dataTypesFound = dataTypeOperation.getAllDataTypeNodes();
+ assertThat(dataTypesFound.size()).isEqualTo(2);
+ assertThat(dataTypesFound.containsAll(dataTypesWithModel)).isTrue();
+ assertThat(dataTypesFound.containsAll(dataTypesWithoutModel)).isFalse();
+ }
+
+ @Test
+ void getAllDataTypeNodesWithValidationErrorTest() {
+ when(janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class))
+ .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ final var dataTypesFound = dataTypeOperation.getAllDataTypeNodes();
+ assertThat(dataTypesFound.isEmpty()).isTrue();
+ }
+
+ @Test
+ void getAllDataTypesWithModelWithValidationErrorTest() {
+ when(janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class))
+ .thenReturn(Either.left(Collections.emptyList()));
+ when(modelOperation.findAllModels()).thenReturn(Collections.singletonList(model));
+ when(janusGraphGenericDao.getByCriteriaForModel(NodeTypeEnum.DataType, null, modelName, DataTypeData.class))
+ .thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR));
+ final var dataTypesFound = dataTypeOperation.getAllDataTypeNodes();
+ assertThat(dataTypesFound).isEmpty();
+ }
+
+ @Test
+ void mapDataTypesDefinitionByModelTest() {
+ final var allDataTypesMappedByModel =
+ dataTypeOperation.mapDataTypesDefinitionByModel(allDataTypesFoundDefinitionMap);
+ assertThat(allDataTypesMappedByModel.get(modelName).size()).isEqualTo(2);
+ assertThat(allDataTypesMappedByModel.get(null)).isNotEmpty();
+ }
+
+
+ private void initTestData() {
+ model = new Model(modelName);
+ final String TEST_DATA_TYPE_001 = "test.data.type001";
+ final String TEST_DATA_TYPE_002 = "test.data.type002";
+ final String TEST_DATA_TYPE_003 = "test.data.type003";
+ final String TEST_DATA_TYPE_004 = "test.data.type004";
+ final DataTypeData dataTypeData1 = createDataTypeData("test.data.type1", TEST_DATA_TYPE_001, 101L,
+ 101L, null);
+ final DataTypeData dataTypeData2 = createDataTypeData("test.data.type2", TEST_DATA_TYPE_002, 101L,
+ 1002L, null);
+ dataTypesWithoutModel.add(dataTypeData1);
+ dataTypesWithoutModel.add(dataTypeData2);
+
+ final DataTypeData dataTypeWithModel1 = createDataTypeData("test.data.type1", TEST_DATA_TYPE_003, 101L,
+ 101L, modelName);
+ final DataTypeData dataTypeWithModel2 = createDataTypeData("test.data.type2", TEST_DATA_TYPE_004, 101L,
+ 1002L, modelName);
+ dataTypesWithModel.add(dataTypeWithModel1);
+ dataTypesWithModel.add(dataTypeWithModel2);
+
+ allDataTypesFoundDefinitionMap.put(TEST_DATA_TYPE_001, createDataTypeDefinition("test.data.type1", TEST_DATA_TYPE_001,
+ 101L, 101L, null));
+ allDataTypesFoundDefinitionMap.put(TEST_DATA_TYPE_002, createDataTypeDefinition("test.data.type2", TEST_DATA_TYPE_002,
+ 101L, 101L, null));
+ allDataTypesFoundDefinitionMap.put(TEST_DATA_TYPE_003, createDataTypeDefinition("test.data.type1", TEST_DATA_TYPE_003,
+ 101L, 101L, modelName));
+ allDataTypesFoundDefinitionMap.put(TEST_DATA_TYPE_004, createDataTypeDefinition("test.data.type2", TEST_DATA_TYPE_004,
+ 101L, 101L, modelName));
+
+ dataTypesMappedByModel.put(null, allDataTypesFoundDefinitionMap);
+ }
+
+ private DataTypeData createDataTypeData(final String name, final String uniqueId, final long creationTime, final long modificationTime,
+ final String model) {
+ final DataTypeData dataTypeData = new DataTypeData();
+ dataTypeData.setDataTypeDataDefinition(createDataTypeDefinition(name, uniqueId, creationTime, modificationTime, model));
+ return dataTypeData;
+ }
+
+ private DataTypeDefinition createDataTypeDefinition(final String name, final String uniqueId, final long creationTime,
+ final long modificationTime, String model) {
+ final DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
+ dataTypeDefinition.setName(name);
+ dataTypeDefinition.setUniqueId(uniqueId);
+ dataTypeDefinition.setCreationTime(creationTime);
+ dataTypeDefinition.setModificationTime(modificationTime);
+ dataTypeDefinition.setModel(model);
+ return dataTypeDefinition;
+ }
+
+}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
index 6812b44b41..793af71bbd 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
@@ -20,14 +20,27 @@
package org.openecomp.sdc.be.model.operations.impl;
-import org.janusgraph.core.JanusGraphVertex;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.janusgraph.core.JanusGraphVertex;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
@@ -38,7 +51,12 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.IComplexDefaultValue;
+import org.openecomp.sdc.be.model.ModelTestBase;
+import org.openecomp.sdc.be.model.PropertyConstraint;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.ToscaType;
@@ -48,16 +66,14 @@ import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.openecomp.sdc.be.resources.data.PropertyData;
import org.openecomp.sdc.be.resources.data.PropertyValueData;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
public class PropertyOperationTest extends ModelTestBase {
HealingJanusGraphGenericDao janusGraphGenericDao = mock(HealingJanusGraphGenericDao.class);
- PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null);
+ final DataTypeOperation dataTypeOperation = mock(DataTypeOperation.class);
+
+ PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null, dataTypeOperation);
@Before
public void setup() {
@@ -441,7 +457,7 @@ public class PropertyOperationTest extends ModelTestBase {
}
private PropertyOperation createTestSubject() {
- return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null);
+ return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null, dataTypeOperation);
}
@Test
@@ -937,7 +953,7 @@ public class PropertyOperationTest extends ModelTestBase {
@Test
public void testGetAllDataTypes() throws Exception {
PropertyOperation testSubject;
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> result;
+ Either<Map<String, Map<String, DataTypeDefinition>>, JanusGraphOperationStatus> result;
// default test
testSubject = createTestSubject();
@@ -956,18 +972,6 @@ public class PropertyOperationTest extends ModelTestBase {
result = testSubject.checkInnerType(propDataDef);
}
-
- @Test
- public void testGetAllDataTypeNodes() throws Exception {
- PropertyOperation testSubject;
- Either<List<DataTypeData>, JanusGraphOperationStatus> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAllDataTypeNodes();
- }
-
-
@Test
public void testValidateAndUpdatePropertyValue() throws Exception {
PropertyOperation testSubject;
diff --git a/catalog-ui/src/app/app.ts b/catalog-ui/src/app/app.ts
index 5cb4e8d4d0..87930fd12e 100644
--- a/catalog-ui/src/app/app.ts
+++ b/catalog-ui/src/app/app.ts
@@ -663,7 +663,7 @@ ng1appModule.run([
// $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w';
$http.defaults.headers.common[cookieService.getUserIdSuffix()] = cookieService.getUserId();
- DataTypesService.initDataTypes();
+ DataTypesService.fetchDataTypesByModel(null);
//handle stateChangeStart
let internalDeregisterStateChangeStartWatcher: Function = (): void => {
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index a60d7be6f7..a2d28ebeac 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.ts
@@ -36,6 +36,7 @@ import {Relationship} from "../graph/relationship";
import { PolicyInstance } from "app/models/graph/zones/policy-instance";
import { GroupInstance } from "../graph/zones/group-instance";
import { Metadata } from "app/models/metadata";
+import {Model} from "../model";
// import {}
diff --git a/catalog-ui/src/app/models/data-types.ts b/catalog-ui/src/app/models/data-types.ts
index d72211cc57..7004b43cbc 100644
--- a/catalog-ui/src/app/models/data-types.ts
+++ b/catalog-ui/src/app/models/data-types.ts
@@ -24,6 +24,7 @@
'use strict';
import {PropertyBEModel} from "./properties-inputs/property-be-model";
import {AttributeBEModel} from "./attributes-outputs/attribute-be-model";
+import {Model} from "./model";
export class DataTypeModel {
@@ -36,6 +37,7 @@ export class DataTypeModel {
modificationTime:string;
properties: Array<PropertyBEModel>;
attributes: Array<AttributeBEModel>;
+ model: Model;
constructor(dataType:DataTypeModel) {
if (dataType) {
@@ -46,6 +48,7 @@ export class DataTypeModel {
this.modificationTime = dataType.modificationTime;
this.properties = dataType.properties;
this.attributes = dataType.attributes;
+ this.model = this.model;
}
}
diff --git a/catalog-ui/src/app/models/model.ts b/catalog-ui/src/app/models/model.ts
index 239d86e827..a5e6021284 100644
--- a/catalog-ui/src/app/models/model.ts
+++ b/catalog-ui/src/app/models/model.ts
@@ -17,6 +17,13 @@
* ============LICENSE_END=========================================================
*/
-interface Model {
- name:string;
+export class Model {
+ name: string;
+
+ constructor(param?: any) {
+ if (param) {
+ this.name = param;
+ }
+ }
+
}
diff --git a/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts b/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts
index 5fc3d5b5ac..96ec935202 100644
--- a/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts
+++ b/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts
@@ -27,6 +27,7 @@ import * as _ from 'lodash';
import {PROPERTY_TYPES} from '../../../../utils';
import {AttributeBEModel} from "../../../../models/attributes-outputs/attribute-be-model";
import {Validation} from "../../../../view-models/workspace/tabs/general/general-view-model";
+import {WorkspaceService} from "../../workspace/workspace.service";
@Component({
selector: 'attribute-creator',
@@ -43,7 +44,7 @@ export class AttributeCreatorComponent {
dataTypes: DataTypesMap;
isLoading: boolean;
- constructor(protected dataTypeService: DataTypeService) {
+ constructor(protected dataTypeService: DataTypeService, protected workspaceService: WorkspaceService) {
}
ngOnInit() {
@@ -51,7 +52,7 @@ export class AttributeCreatorComponent {
this.attributeModel.type = '';
this.attributeModel.schema.property.type = '';
const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list
- this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service
+ this.dataTypes = this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model); // Get all data types in service
const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => {
return types.indexOf(type) === -1;
});
diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts
index 76cf73ff17..8227229c26 100644
--- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts
+++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts
@@ -3,6 +3,7 @@ import {PROPERTY_DATA} from "app/utils";
import {DataTypeService} from "app/ng2/services/data-type.service";
import {OperationModel, OperationParameter, InputBEModel, DataTypeModel, Capability} from 'app/models';
import {DropdownValue} from "app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component";
+import {WorkspaceService} from "../../../workspace/workspace.service";
class DropdownValueType extends DropdownValue {
type: String;
@@ -37,7 +38,7 @@ export class ParamRowComponent {
filteredInputProps: Array<DropdownValue> = [];
filteredCapabilitiesProps: Array<{capabilityName: string, properties: Array<DropdownValueType>}> = [];
- constructor(private dataTypeService:DataTypeService) {}
+ constructor(private dataTypeService:DataTypeService, protected workspaceService: WorkspaceService) {}
ngOnInit() {
if (this.isInputParam) {
@@ -58,7 +59,7 @@ export class ParamRowComponent {
)
);
} else {
- const dataTypes: Array<DataTypeModel> = _.toArray(this.dataTypeService.getAllDataTypes());
+ const dataTypes: Array<DataTypeModel> = _.toArray(this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model));
this.propTypeEnum = _.concat(
_.map(
_.filter(
@@ -170,7 +171,7 @@ export class ParamRowComponent {
getPrimitiveSubtypes(): Array<InputBEModel> {
const flattenedProps: Array<any> = [];
- const dataTypes = this.dataTypeService.getAllDataTypes();
+ const dataTypes = this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model);
_.forEach(this.inputProps, prop => {
const type:DataTypeModel = _.find(
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts
index 8ca4f44116..cb90b8b83e 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts
@@ -29,6 +29,7 @@ import { ModalService } from 'app/ng2/services/modal.service';
import { PROPERTY_DATA } from 'app/utils';
import * as _ from 'lodash';
import { PROPERTY_TYPES } from '../../../../utils';
+import {WorkspaceService} from "../../workspace/workspace.service";
@Component({
selector: 'declare-list',
@@ -50,7 +51,7 @@ export class DeclareListComponent {
propertiesListString: string;
privateDataType: DataTypeModel;
- constructor(protected dataTypeService: DataTypeService, private modalService: ModalService) {}
+ constructor(protected dataTypeService: DataTypeService, private modalService: ModalService, private workspaceService: WorkspaceService) {}
ngOnInit() {
console.log('DeclareListComponent.ngOnInit() - enter');
@@ -59,7 +60,7 @@ export class DeclareListComponent {
this.propertyModel.schema.property.type = '';
this.propertyModel.required = false;
const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list
- this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service
+ this.dataTypes = this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model); // Get all data types in service
const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => {
return types.indexOf(type) === -1;
});
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
index ae4aa57572..10273e2636 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
@@ -36,12 +36,13 @@ import {ComponentModeService} from "../../services/component-services/component-
import {SdcUiComponentsModule} from "onap-ui-angular";
import {ModalFormsModule} from "app/ng2/components/ui/forms/modal-forms.module";
import {HierarchyNavigationModule} from "../../components/logic/hierarchy-navigtion/hierarchy-navigation.module";
+import {PropertyCreatorComponent} from "./property-creator/property-creator.component";
@NgModule({
declarations: [
PropertiesAssignmentComponent,
InputsTableComponent,
- FilterPropertiesAssignmentComponent
+ FilterPropertiesAssignmentComponent,
],
imports: [
BrowserModule,
@@ -59,7 +60,7 @@ import {HierarchyNavigationModule} from "../../components/logic/hierarchy-navigt
exports: [
PropertiesAssignmentComponent
],
- providers: [PropertiesService, HierarchyNavService, PropertiesUtils, InputsUtils, DataTypeService, ComponentModeService]
+ providers: [PropertiesService, HierarchyNavService, PropertiesUtils, InputsUtils, DataTypeService, ComponentModeService, PropertyCreatorComponent]
})
export class PropertiesAssignmentModule {
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
index 8847e96d18..b54cbc97c2 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
@@ -87,7 +87,7 @@
</div>
<div class="right-column">
<div *ngIf="!isReadonly && !isInputsTabSelected" class="add-btn"
- (click)="addProperty()" data-tests-id="properties-add-button" [ngClass]="{'disabled': !isSelf()}">Add Property</div>
+ (click)="addProperty(component.model)" data-tests-id="properties-add-button" [ngClass]="{'disabled': !isSelf()}">Add Property</div>
<div *ngIf="!isReadonly && isInputsTabSelected" class="add-btn"
(click)="addInput()" [ngClass]="{'disabled': !isSelf()}">Add Input</div>
<tabs #hierarchyNavTabs tabStyle="simple-tabs" class="gray-border">
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
index 6d009a8039..fbbc4d8b0e 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
@@ -67,6 +67,7 @@ import {ToscaPresentationData} from "../../../models/tosca-presentation";
import {Observable} from "rxjs";
import {ToscaGetFunctionType} from "../../../models/tosca-get-function-type.enum";
import {TranslateService} from "../../shared/translator/translate.service";
+import {Model} from '../../../models/model';
const SERVICE_SELF_TITLE = "SELF";
@Component({
@@ -130,6 +131,7 @@ export class PropertiesAssignmentComponent {
private inputsUtils: InputsUtils,
private componentServiceNg2: ComponentServiceNg2,
private componentInstanceServiceNg2: ComponentInstanceServiceNg2,
+ private propertyCreatorComponent: PropertyCreatorComponent,
@Inject("$stateParams") _stateParams,
@Inject("$scope") private $scope: ng.IScope,
@Inject("$state") private $state: ng.ui.IStateService,
@@ -220,6 +222,8 @@ export class PropertiesAssignmentComponent {
});
}
});
+
+ this.loadDataTypesByComponentModel(this.component.model);
};
ngOnDestroy() {
@@ -1142,7 +1146,8 @@ export class PropertiesAssignmentComponent {
}
/*** addProperty ***/
- addProperty = () => {
+ addProperty = (model: Model) => {
+ this.loadDataTypesByComponentModel(model)
let modalTitle = 'Add Property';
let modal = this.ModalService.createCustomModal(new ModalModel(
'sm',
@@ -1172,8 +1177,8 @@ export class PropertiesAssignmentComponent {
],
null
));
- this.ModalService.addDynamicContentToModal(modal, PropertyCreatorComponent, {});
modal.instance.open();
+ this.ModalService.addDynamicContentToModal(modal, PropertyCreatorComponent, {});
}
/*** addInput ***/
@@ -1245,6 +1250,10 @@ export class PropertiesAssignmentComponent {
private isInput = (instanceType:string):boolean =>{
return instanceType === ResourceType.VF || instanceType === ResourceType.PNF || instanceType === ResourceType.CVFC || instanceType === ResourceType.CR;
}
-
+
+ loadDataTypesByComponentModel(model:Model) {
+ let modelName = new Model(model).name;
+ this.propertyCreatorComponent.filterDataTypesByModel(modelName);
+ }
}
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
index 8167caa959..57c9f97387 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts
@@ -7,6 +7,7 @@ import { PROPERTY_DATA } from 'app/utils';
import * as _ from 'lodash';
import { PROPERTY_TYPES } from '../../../../utils';
import {Validation} from "../../../../view-models/workspace/tabs/general/general-view-model";
+import {WorkspaceService} from "../../workspace/workspace.service";
@Component({
selector: 'property-creator',
@@ -23,14 +24,38 @@ export class PropertyCreatorComponent {
dataTypes: DataTypesMap;
isLoading: boolean;
- constructor(protected dataTypeService: DataTypeService) {}
+ constructor(protected dataTypeService: DataTypeService, private workspaceService: WorkspaceService) {
+ this.filterDataTypesByModel(this.workspaceService.metadata.model);
+ }
+
+ checkFormValidForSubmit() {
+ const showSchema: boolean = this.showSchema();
+ const isSchemaValid: boolean = (showSchema && !this.propertyModel.schema.property.type) ? false : true;
+ if (!showSchema) {
+ this.propertyModel.schema.property.type = '';
+ }
+ return this.propertyModel.name && this.propertyModel.type && isSchemaValid;
+ }
+
+ showSchema(): boolean {
+ return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.propertyModel.type) > -1;
+ }
+
+ onSchemaTypeChange(): void {
+ if (this.propertyModel.type === PROPERTY_TYPES.MAP) {
+ this.propertyModel.value = JSON.stringify({'': null});
+ } else if (this.propertyModel.type === PROPERTY_TYPES.LIST) {
+ this.propertyModel.value = JSON.stringify([]);
+ }
+ }
- ngOnInit() {
+ public filterDataTypesByModel = (modelName: string) => {
+ this.dataTypes = new DataTypesMap(null);
+ this.dataTypes = this.dataTypeService.getDataTypeByModel(modelName);
this.propertyModel = new PropertyBEModel();
this.propertyModel.type = '';
this.propertyModel.schema.property.type = '';
const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list
- this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service
const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => {
return types.indexOf(type) === -1;
});
@@ -43,35 +68,13 @@ export class PropertyCreatorComponent {
);
const nonPrimitiveTypesValues = _.map(nonPrimitiveTypes,
(type: string) => new DropdownValue(type,
- type.replace('org.openecomp.datatypes.heat.', ''))
+ type.replace('org.openecomp.datatypes.heat.', ''))
)
.sort((a, b) => a.label.localeCompare(b.label));
this.typesProperties = _.concat(this.typesProperties, nonPrimitiveTypesValues);
this.typesSchemaProperties = _.concat(typesSimpleProperties, nonPrimitiveTypesValues);
this.typesProperties.unshift(new DropdownValue('', 'Select Type...'));
this.typesSchemaProperties.unshift(new DropdownValue('', 'Select Schema Type...'));
-
- }
-
- checkFormValidForSubmit() {
- const showSchema: boolean = this.showSchema();
- const isSchemaValid: boolean = (showSchema && !this.propertyModel.schema.property.type) ? false : true;
- if (!showSchema) {
- this.propertyModel.schema.property.type = '';
- }
- return this.propertyModel.name && this.propertyModel.type && isSchemaValid;
- }
-
- showSchema(): boolean {
- return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.propertyModel.type) > -1;
- }
-
- onSchemaTypeChange(): void {
- if (this.propertyModel.type === PROPERTY_TYPES.MAP) {
- this.propertyModel.value = JSON.stringify({'': null});
- } else if (this.propertyModel.type === PROPERTY_TYPES.LIST) {
- this.propertyModel.value = JSON.stringify([]);
- }
}
}
diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts
index 30eb6f0c77..85c8b898aa 100644
--- a/catalog-ui/src/app/ng2/services/data-type.service.ts
+++ b/catalog-ui/src/app/ng2/services/data-type.service.ts
@@ -47,8 +47,8 @@ export class DataTypeService {
return this.dataTypes[typeName];
}
- public getAllDataTypes(): DataTypesMap {
- return this.dataTypes;
+ public getDataTypeByModel(modelName: string): DataTypesMap {
+ return this.dataTypeService.getAllDataTypesFromModel(modelName);
}
public getConstraintsByParentTypeAndUniqueID(rootPropertyType, propertyName){
diff --git a/catalog-ui/src/app/ng2/services/model.service.ts b/catalog-ui/src/app/ng2/services/model.service.ts
index 33d57295bf..10ad4142de 100644
--- a/catalog-ui/src/app/ng2/services/model.service.ts
+++ b/catalog-ui/src/app/ng2/services/model.service.ts
@@ -20,6 +20,7 @@ import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { ISdcConfig, SdcConfigToken } from '../config/sdc-config.config';
+import {Model} from "../../models/model";
@Injectable()
export class ModelService {
diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
index 96a21262e8..fa3de88c7b 100644
--- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
+++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
@@ -31,6 +31,7 @@ import { GroupInstance } from "../../../models/graph/zones/group-instance";
import { InputsGroup } from "../../../models/inputs";
import { InterfaceModel } from "../../../models/operation";
import { OutputBEModel } from "app/models/attributes-outputs/output-be-model";
+import {Model} from "../../../models/model";
export class ComponentGenericResponse implements Serializable<ComponentGenericResponse> {
diff --git a/catalog-ui/src/app/services/data-types-service.ts b/catalog-ui/src/app/services/data-types-service.ts
index 0237b2f3de..08b49ae422 100644
--- a/catalog-ui/src/app/services/data-types-service.ts
+++ b/catalog-ui/src/app/services/data-types-service.ts
@@ -20,7 +20,15 @@
'use strict';
import { DataTypePropertyModel } from "../models/data-type-properties";
-import {ComponentInstance, InputModel, DataTypesMap, PropertyModel, InputPropertyBase, IAppConfigurtaion, SchemaProperty} from "../models";
+import {
+ ComponentInstance,
+ InputModel,
+ DataTypesMap,
+ PropertyModel,
+ InputPropertyBase,
+ IAppConfigurtaion,
+ SchemaProperty
+} from "../models";
import {PROPERTY_DATA} from "../utils/constants";
export interface IDataTypesService {
@@ -32,7 +40,7 @@ export interface IDataTypesService {
selectedInstance:ComponentInstance;
selectedComponentInputs:Array<InputModel>;
//declare methods
- initDataTypes():void;
+ fetchDataTypesByModel(modelName:string):void;
getAllDataTypes():DataTypesMap;
getFirsLevelOfDataTypeProperties(dataTypeName:string):Array<DataTypePropertyModel>;
isDataTypeForSchemaType(property:SchemaProperty):boolean;
@@ -51,9 +59,10 @@ export class DataTypesService implements IDataTypesService {
constructor(private sdcConfig:IAppConfigurtaion,
private $q:ng.IQService,
private $http:ng.IHttpService) {
-
}
+ private baseUrl = this.sdcConfig.api.root + this.sdcConfig.api.component_api_root;
+
dataTypes:DataTypesMap; //Data type map
selectedPropertiesName:string;
selectedInput:PropertyModel;
@@ -61,16 +70,23 @@ export class DataTypesService implements IDataTypesService {
selectedInstance:ComponentInstance;
selectedComponentInputs:Array<InputModel>;
- public initDataTypes = ():void => {
- this.$http({
- url: this.sdcConfig.api.root + this.sdcConfig.api.component_api_root + "dataTypes",
- method: "get"
- }).then((response:any) => {
+ public fetchDataTypesByModel = (modelName: string):void => {
+ let model;
+ if (modelName) {
+ model = {'model': modelName}
+ }
+ this.$http.get(this.baseUrl+"dataTypes", {params: model})
+ .then((response:any) => {
this.dataTypes = response.data;
delete this.dataTypes['tosca.datatypes.Root'];
});
};
+ public getAllDataTypesFromModel = (modelName: string): DataTypesMap => {
+ this.fetchDataTypesByModel(modelName);
+ return this.dataTypes;
+ }
+
public getAllDataTypes = ():DataTypesMap => {
return this.dataTypes;
};
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts
index 1f922cdaf9..5e48dc8115 100644
--- a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts
+++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts
@@ -135,7 +135,7 @@ export abstract class PropertyFormBaseView {
this.$scope.property = new PropertyModel(this.originalProperty); //we create a new Object so if user press cance we won't update the property
this.$scope.types = PROPERTY_DATA.TYPES; //All types - simple type + map + list
this.$scope.simpleTypes = PROPERTY_DATA.SIMPLE_TYPES; //All simple types
- this.$scope.dataTypes = this.DataTypesService.getAllDataTypes(); //Get all data types in service
+ this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.component.model.name); //Get all data types in service
this.$scope.modalPropertyFormBase = this.$uibModalInstance;
this.$scope.isNew = !angular.isDefined(this.$scope.property.name);
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
index c63dd8a208..c36a242c2a 100644
--- a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
+++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
@@ -59,6 +59,7 @@ interface IPropertyFormViewModelScope extends ng.IScope {
isPropertyValueOwner:boolean;
isVnfConfiguration:boolean;
constraints:string[];
+ modelNameFilter:string;
validateJson(json:string):boolean;
save(doNotCloseModal?:boolean):void;
@@ -125,7 +126,6 @@ export class PropertyFormViewModel {
private workspaceService: WorkspaceService) {
this.formState = angular.isDefined(property.name) ? FormState.UPDATE : FormState.CREATE;
-
this.initScope();
}
@@ -203,9 +203,10 @@ export class PropertyFormViewModel {
this.$scope.modalInstanceProperty = this.$uibModalInstance;
this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, i=> i.name == this.property.name);
this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1);
- this.$scope.dataTypes = this.DataTypesService.getAllDataTypes();
+ this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.workspaceService.metadata.model);
this.$scope.isPropertyValueOwner = this.isPropertyValueOwner;
this.$scope.propertyOwnerType = this.propertyOwnerType;
+ this.$scope.modelNameFilter = this.workspaceService.metadata.model;
this.$scope.editPropertyModel = {
property : new PropertyModel(this.property),
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts
index ab4b033c0e..9be3b642b4 100644
--- a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts
+++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts
@@ -20,7 +20,7 @@
'use strict';
import {DataTypesService} from "app/services/data-types-service";
-import {PropertyModel, InputPropertyBase, Component} from "app/models";
+import {PropertyModel, InputPropertyBase, Component, DataTypesMap} from "app/models";
import {IPropertyFormBaseViewScope, PropertyFormBaseView} from "../base-property-form/property-form-base-model";
import {PROPERTY_TYPES} from "app/utils/constants";
@@ -31,6 +31,7 @@ interface ISelectDataTypeViewModelScope extends IPropertyFormBaseViewScope {
isTypeDataType:boolean;
myValue:any;
isReadOnly:boolean;
+ modelNameFilter:string;
}
export class SelectDataTypeViewModel extends PropertyFormBaseView {
@@ -62,6 +63,7 @@ export class SelectDataTypeViewModel extends PropertyFormBaseView {
this.$templateCache.put("select-datatype-modal-view.html", require('app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html'));
this.$scope.innerViewSrcUrl = "select-datatype-modal-view.html";
+ this.$scope.modelNameFilter = this.component.model.name;
this.initChildScope();
}
@@ -114,4 +116,8 @@ export class SelectDataTypeViewModel extends PropertyFormBaseView {
this.initForNotSimpleType();
this.removeSelected();
}
+
+ public getAllDataTypesFromModel = (modelName: string): DataTypesMap => {
+ return this.DataTypesService.getAllDataTypesFromModel(modelName);
+ }
}
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html
index d22741f81a..f95a7e0782 100644
--- a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html
+++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html
@@ -13,7 +13,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<div data-ng-if="dataTypes" class="default-value-section i-sdc-form-item">
+<div data-ng-if="getAllDataTypesFromModel(modelNameFilter)" class="default-value-section i-sdc-form-item">
<label class="i-sdc-form-label">Default Value</label>
<div data-ng-if="isTypeDataType">
<select-fields-structure value-obj-ref="myValue"
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index 391b6ee2b7..20eaec6aad 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -38,6 +38,7 @@ import {Component, IAppConfigurtaion, ICsarComponent, IMainCategory, IMetadataKe
import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
import {CATEGORY_SERVICE_METADATA_KEYS, PREVIOUS_CSAR_COMPONENT} from "../../../../utils/constants";
import {Observable} from "rxjs";
+import {Model} from "../../../../models/model";
export class Validation {
componentNameValidationPattern:RegExp;
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
index cffab12f90..ee78821b23 100644
--- 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
@@ -40,6 +40,7 @@ public class AttributeDataDefinition extends ToscaDataDefinition {
private String outputPath;
private String instanceUniqueId;
private String attributeId;
+ private String model;
private String parentUniqueId;
public AttributeDataDefinition(final AttributeDataDefinition attributeDataDefinition) {
@@ -57,6 +58,7 @@ public class AttributeDataDefinition extends ToscaDataDefinition {
this.setOutputPath(attributeDataDefinition.getOutputPath());
this.setInstanceUniqueId(attributeDataDefinition.getInstanceUniqueId());
this.setAttributeId(attributeDataDefinition.getAttributeId());
+ this.setModel(attributeDataDefinition.getModel());
this.setParentUniqueId(attributeDataDefinition.getParentUniqueId());
this.setOutputId(attributeDataDefinition.getOutputId());
if (CollectionUtils.isNotEmpty(attributeDataDefinition.getGetOutputValues())) {
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java
index 7baf8c8f3f..51f710ba04 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java
@@ -38,6 +38,7 @@ public class DataTypeDataDefinition extends ToscaDataDefinition {
// "boolean", "string", "float", "integer", "version" })
private String derivedFromName;
private String description;
+ private String model;
/**
* Timestamp of data type creation
*/
@@ -55,5 +56,6 @@ public class DataTypeDataDefinition extends ToscaDataDefinition {
this.description = p.description;
this.creationTime = p.creationTime;
this.modificationTime = p.modificationTime;
+ this.model = p.model;
}
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
index 871492c4bd..969d986c4d 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java
@@ -20,9 +20,7 @@
package org.openecomp.sdc.be.datatypes.elements;
-import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import java.util.ArrayList;
import java.util.HashMap;
@@ -32,9 +30,10 @@ import java.util.Map;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
-
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
-import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
@EqualsAndHashCode(callSuper = false)
@@ -62,6 +61,7 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
private String status;
private String inputId;
private String instanceUniqueId;
+ private String model;
private String propertyId;
private String parentPropertyType;
private String subPropertyInputPath;
@@ -109,6 +109,7 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
this.setStatus(propertyDataDefinition.getStatus());
this.setInputId(propertyDataDefinition.getInputId());
this.setInstanceUniqueId(propertyDataDefinition.getInstanceUniqueId());
+ this.setModel(propertyDataDefinition.getModel());
this.setPropertyId(propertyDataDefinition.getPropertyId());
this.setToscaGetFunctionType(propertyDataDefinition.getToscaGetFunctionType());
this.parentPropertyType = propertyDataDefinition.getParentPropertyType();