aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyConstraint.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java58
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java67
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java29
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java58
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/DataTypeValidatorConverter.java23
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/MapValidator.java9
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/validation/FilterConstraintValidator.java39
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java124
24 files changed, 298 insertions, 146 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java
index 6af88e1215..326cfca202 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java
@@ -24,7 +24,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterPropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
@ToString
@Getter
@@ -37,6 +37,6 @@ public class ParsedToscaYamlInfo {
Map<String, GroupDefinition> groups;
Map<String, PolicyDefinition> policies;
Map<String, PropertyDefinition> properties;
- ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> substitutionFilterProperties;
+ ListDataDefinition<SubstitutionFilterPropertyDataDefinition> substitutionFilterProperties;
String substitutionMappingNodeType;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyConstraint.java
index 6bc8083118..12a79ec90e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyConstraint.java
@@ -21,7 +21,7 @@ package org.openecomp.sdc.be.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openecomp.sdc.be.model.tosca.ToscaType;
-import org.openecomp.sdc.be.model.tosca.constraints.ConstraintType;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java
index 14c95757c7..6626d9aa3d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java
@@ -26,6 +26,7 @@ package org.openecomp.sdc.be.model;
*/
public interface ToscaPropertyData {
String getUniqueId();
+ String getName();
String getType();
String getSchemaType();
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java
new file mode 100644
index 0000000000..b9ceb11276
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java
@@ -0,0 +1,58 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.dto;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Optional;
+import lombok.Data;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
+import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
+import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
+
+@Data
+public class FilterConstraintDto {
+
+ private String propertyName;
+ private String capabilityName;
+ private PropertyFilterTargetType targetType;
+ private ConstraintType operator;
+ private FilterValueType valueType;
+ private Object value;
+
+ public boolean isCapabilityPropertyFilter() {
+ return capabilityName != null;
+ }
+
+ public Optional<ToscaGetFunctionDataDefinition> getAsToscaGetFunction() {
+ if (value instanceof ToscaGetFunctionDataDefinition) {
+ return Optional.of((ToscaGetFunctionDataDefinition) value);
+ }
+ try {
+ return Optional.of(new ObjectMapper().convertValue(value, ToscaGetFunctionDataDefinition.class));
+ } catch (final Exception ignored) {
+ return Optional.empty();
+ }
+ }
+
+}
+
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java
index 2d0693af76..3dc2a73466 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeFilterOperation.java
@@ -19,8 +19,6 @@
*/
package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import fj.data.Either;
import java.util.ArrayList;
import java.util.List;
@@ -33,8 +31,8 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterCapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeFilterConstraintType;
import org.openecomp.sdc.be.model.Component;
@@ -69,7 +67,7 @@ public class NodeFilterOperation extends BaseOperation {
public Either<String, StorageOperationStatus> deleteNodeFilter(final Component component, final String componentInstanceId) {
final Either<Set<String>, StorageOperationStatus> listStorageOperationStatusEither = deleteNodeFilters(component,
- ImmutableSet.of(componentInstanceId));
+ Set.of(componentInstanceId));
if (listStorageOperationStatusEither.isRight()) {
return Either.right(listStorageOperationStatusEither.right().value());
}
@@ -86,7 +84,7 @@ public class NodeFilterOperation extends BaseOperation {
final int propertyIndex,
final NodeFilterConstraintType nodeFilterConstraintType) {
if (NodeFilterConstraintType.PROPERTIES.equals(nodeFilterConstraintType)) {
- final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> properties = nodeFilterDataDefinition.getProperties();
+ final ListDataDefinition<PropertyFilterDataDefinition> properties = nodeFilterDataDefinition.getProperties();
properties.getListToscaDataDefinition().remove(propertyIndex);
nodeFilterDataDefinition.setProperties(properties);
} else if (NodeFilterConstraintType.CAPABILITIES.equals(nodeFilterConstraintType)) {
@@ -97,22 +95,22 @@ public class NodeFilterOperation extends BaseOperation {
return addOrUpdateNodeFilter(true, serviceId, componentInstanceId, nodeFilterDataDefinition);
}
- public Either<CINodeFilterDataDefinition, StorageOperationStatus> addNewProperty(final String componentId, final String componentInstanceId,
- final CINodeFilterDataDefinition nodeFilterDataDefinition,
- final RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition) {
- ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> properties = nodeFilterDataDefinition.getProperties();
+ public Either<CINodeFilterDataDefinition, StorageOperationStatus> addPropertyFilter(final String componentId, final String componentInstanceId,
+ final CINodeFilterDataDefinition nodeFilterDataDefinition,
+ final PropertyFilterDataDefinition propertyFilterDataDefinition) {
+ ListDataDefinition<PropertyFilterDataDefinition> properties = nodeFilterDataDefinition.getProperties();
if (properties == null) {
properties = new ListDataDefinition<>();
nodeFilterDataDefinition.setProperties(properties);
}
- properties.getListToscaDataDefinition().add(requirementNodeFilterPropertyDataDefinition);
+ properties.getListToscaDataDefinition().add(propertyFilterDataDefinition);
nodeFilterDataDefinition.setProperties(properties);
return addOrUpdateNodeFilter(true, componentId, componentInstanceId, nodeFilterDataDefinition);
}
- public Either<CINodeFilterDataDefinition, StorageOperationStatus> addNewCapabilities(final String componentId, final String componentInstanceId,
- final CINodeFilterDataDefinition nodeFilterDataDefinition,
- final RequirementNodeFilterCapabilityDataDefinition requirementNodeFilterCapabilityDataDefinition) {
+ public Either<CINodeFilterDataDefinition, StorageOperationStatus> addCapabilities(final String componentId, final String componentInstanceId,
+ final CINodeFilterDataDefinition nodeFilterDataDefinition,
+ final RequirementNodeFilterCapabilityDataDefinition requirementNodeFilterCapabilityDataDefinition) {
ListDataDefinition<RequirementNodeFilterCapabilityDataDefinition> capabilities = nodeFilterDataDefinition.getCapabilities();
if (capabilities == null) {
capabilities = new ListDataDefinition<>();
@@ -124,9 +122,9 @@ public class NodeFilterOperation extends BaseOperation {
.filter(def -> def.getName().equals(requirementNodeFilterCapabilityDataDefinition.getName())).findAny();
if (existingCap.isPresent()) {
- final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> newProperties = requirementNodeFilterCapabilityDataDefinition.getProperties();
- final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> existingProperties = existingCap.get().getProperties();
- newProperties.getListToscaDataDefinition().stream().forEach((prop -> existingProperties.add(prop))) ;
+ final ListDataDefinition<PropertyFilterDataDefinition> newProperties = requirementNodeFilterCapabilityDataDefinition.getProperties();
+ final ListDataDefinition<PropertyFilterDataDefinition> existingProperties = existingCap.get().getProperties();
+ newProperties.getListToscaDataDefinition().forEach((existingProperties::add)) ;
} else {
capabilities.getListToscaDataDefinition().add(requirementNodeFilterCapabilityDataDefinition);
}
@@ -134,26 +132,6 @@ public class NodeFilterOperation extends BaseOperation {
return addOrUpdateNodeFilter(true, componentId, componentInstanceId, nodeFilterDataDefinition);
}
- public Either<CINodeFilterDataDefinition, StorageOperationStatus> updateProperties(final String componentId, final String componentInstanceId,
- final CINodeFilterDataDefinition nodeFilterDataDefinition,
- final List<RequirementNodeFilterPropertyDataDefinition> requirementNodeFilterPropertyDataDefinition) {
- final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> properties = nodeFilterDataDefinition.getProperties();
- properties.getListToscaDataDefinition().clear();
- properties.getListToscaDataDefinition().addAll(requirementNodeFilterPropertyDataDefinition);
- nodeFilterDataDefinition.setProperties(properties);
- return addOrUpdateNodeFilter(true, componentId, componentInstanceId, nodeFilterDataDefinition);
- }
-
- public Either<CINodeFilterDataDefinition, StorageOperationStatus> updateCapabilities(final String componentId, final String componentInstanceId,
- final CINodeFilterDataDefinition nodeFilterDataDefinition,
- final List<RequirementNodeFilterCapabilityDataDefinition> requirementNodeFilterCapabilityDataDefinitions) {
- final ListDataDefinition<RequirementNodeFilterCapabilityDataDefinition> capabilities = nodeFilterDataDefinition.getCapabilities();
- capabilities.getListToscaDataDefinition().clear();
- capabilities.getListToscaDataDefinition().addAll(requirementNodeFilterCapabilityDataDefinitions);
- nodeFilterDataDefinition.setCapabilities(capabilities);
- return addOrUpdateNodeFilter(true, componentId, componentInstanceId, nodeFilterDataDefinition);
- }
-
public Either<CINodeFilterDataDefinition, StorageOperationStatus> updateNodeFilter(final String serviceId, final String componentInstanceId,
final CINodeFilterDataDefinition ciNodeFilterDataDefinition) {
return addOrUpdateNodeFilter(true, serviceId, componentInstanceId, ciNodeFilterDataDefinition);
@@ -169,20 +147,19 @@ public class NodeFilterOperation extends BaseOperation {
private Either<CINodeFilterDataDefinition, StorageOperationStatus> addOrUpdateNodeFilter(final boolean isUpdateAction, final String componentId,
final String componentInstanceId,
final CINodeFilterDataDefinition ciNodeFilterDataDefinition) {
- StorageOperationStatus statusRes;
- Either<GraphVertex, JanusGraphOperationStatus> getToscaElementRes;
- getToscaElementRes = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
- if (getToscaElementRes.isRight()) {
- JanusGraphOperationStatus status = getToscaElementRes.right().value();
+
+ final Either<GraphVertex, JanusGraphOperationStatus> serviceVertexEither =
+ janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+ if (serviceVertexEither.isRight()) {
+ JanusGraphOperationStatus status = serviceVertexEither.right().value();
CommonUtility
.addRecordToLog(logger, CommonUtility.LogLevelEnum.DEBUG, "Failed to get tosca element {} upon adding the properties. Status is {}. ",
componentId, status);
- statusRes = DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
- return Either.right(statusRes);
+ return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
- GraphVertex serviceVertex = getToscaElementRes.left().value();
+ final GraphVertex serviceVertex = serviceVertexEither.left().value();
ciNodeFilterDataDefinition.setID(componentInstanceId);
- statusRes = performUpdateToscaAction(isUpdateAction, serviceVertex, ImmutableList.of(ciNodeFilterDataDefinition));
+ final StorageOperationStatus statusRes = performUpdateToscaAction(isUpdateAction, serviceVertex, List.of(ciNodeFilterDataDefinition));
if (!statusRes.equals(StorageOperationStatus.OK)) {
janusGraphDao.rollback();
logger.error(" Failed to perform tosca update for node filter in service {} , component instance {}. status is {}", componentId,
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java
index b4873fa78a..ca50f42453 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/SubstitutionFilterOperation.java
@@ -18,7 +18,6 @@
*/
package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
-import com.google.common.collect.ImmutableList;
import fj.data.Either;
import java.util.List;
import java.util.Objects;
@@ -28,8 +27,8 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.RequirementSubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
@@ -50,7 +49,7 @@ public class SubstitutionFilterOperation extends BaseOperation {
public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> deleteConstraint(final String serviceId,
final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
final int propertyIndex) {
- final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties = substitutionFilterDataDefinition.getProperties();
+ final ListDataDefinition<SubstitutionFilterPropertyDataDefinition> properties = substitutionFilterDataDefinition.getProperties();
properties.getListToscaDataDefinition().remove(propertyIndex);
substitutionFilterDataDefinition.setProperties(properties);
return addOrUpdateSubstitutionFilter(true, serviceId, substitutionFilterDataDefinition);
@@ -58,26 +57,34 @@ public class SubstitutionFilterOperation extends BaseOperation {
public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> addPropertyFilter(final String componentId,
final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
- final RequirementSubstitutionFilterPropertyDataDefinition substitutionFilterPropertyDataDefinition) {
+ final SubstitutionFilterPropertyDataDefinition substitutionFilterPropertyDataDefinition) {
final SubstitutionFilterDataDefinition substitutionFilterDataDefinition1 = Objects
.requireNonNullElseGet(substitutionFilterDataDefinition, SubstitutionFilterDataDefinition::new);
- final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties = Objects
+ final ListDataDefinition<SubstitutionFilterPropertyDataDefinition> properties = Objects
.requireNonNullElseGet(substitutionFilterDataDefinition1.getProperties(), ListDataDefinition::new);
properties.getListToscaDataDefinition().add(substitutionFilterPropertyDataDefinition);
substitutionFilterDataDefinition1.setProperties(properties);
return addOrUpdateSubstitutionFilter(true, componentId, substitutionFilterDataDefinition1);
}
- public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> updateProperties(final String componentId,
- final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
- final List<RequirementSubstitutionFilterPropertyDataDefinition> requirementSubstitutionFilterPropertyDataDefinition) {
- final ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> properties = substitutionFilterDataDefinition.getProperties();
+ public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> updatePropertyFilters(final String componentId,
+ final SubstitutionFilterDataDefinition substitutionFilterDataDefinition,
+ final List<SubstitutionFilterPropertyDataDefinition> substitutionFilterPropertyDataDefinition) {
+ final ListDataDefinition<SubstitutionFilterPropertyDataDefinition> properties = substitutionFilterDataDefinition.getProperties();
properties.getListToscaDataDefinition().clear();
- properties.getListToscaDataDefinition().addAll(requirementSubstitutionFilterPropertyDataDefinition);
+ properties.getListToscaDataDefinition().addAll(substitutionFilterPropertyDataDefinition);
substitutionFilterDataDefinition.setProperties(properties);
return addOrUpdateSubstitutionFilter(true, componentId, substitutionFilterDataDefinition);
}
+ public Either<SubstitutionFilterDataDefinition, StorageOperationStatus> updatePropertyFilter(final String componentId,
+ final SubstitutionFilterDataDefinition substitutionFilter,
+ final SubstitutionFilterPropertyDataDefinition substitutionFilterProperty,
+ final int index) {
+ substitutionFilter.getProperties().getListToscaDataDefinition().set(index, substitutionFilterProperty);
+ return addOrUpdateSubstitutionFilter(true, componentId, substitutionFilter);
+ }
+
private Either<SubstitutionFilterDataDefinition, StorageOperationStatus> addOrUpdateSubstitutionFilter(final boolean isUpdateAction,
final String componentId,
final SubstitutionFilterDataDefinition substitutionFilterDataDefinition) {
@@ -92,7 +99,7 @@ public class SubstitutionFilterOperation extends BaseOperation {
final GraphVertex serviceVertex = toscaElementEither.left().value();
substitutionFilterDataDefinition.setID(componentId);
final StorageOperationStatus operationStatus = performUpdateToscaAction(isUpdateAction, serviceVertex,
- ImmutableList.of(substitutionFilterDataDefinition));
+ List.of(substitutionFilterDataDefinition));
if (!StorageOperationStatus.OK.equals(operationStatus)) {
janusGraphDao.rollback();
LOGGER.error(EcompErrorSeverity.ERROR, EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR,
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 b5215dc848..6b580527c4 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
@@ -82,12 +82,11 @@ import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.IComplexDefaultValue;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.validation.ToscaFunctionValidator;
import org.openecomp.sdc.be.model.operations.api.DerivedFromOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
-import org.openecomp.sdc.be.model.tosca.constraints.ConstraintType;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint;
@@ -96,6 +95,7 @@ import org.openecomp.sdc.be.model.tosca.constraints.LessThanConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.MinLengthConstraint;
import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
+import org.openecomp.sdc.be.model.validation.ToscaFunctionValidator;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.openecomp.sdc.be.resources.data.ModelData;
@@ -2145,7 +2145,7 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
Entry<String, JsonElement> element = set.iterator().next();
String key = element.getKey();
JsonElement value = element.getValue();
- ConstraintType constraintType = ConstraintType.getByType(key);
+ ConstraintType constraintType = ConstraintType.findByType(key).orElse(null);
if (constraintType == null) {
log.warn("ConstraintType was not found for constraint name:{}", key);
} else {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java
index ec7ca43155..364dfd33fb 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java
@@ -71,10 +71,10 @@ public enum ToscaPropertyType {
JSON("json", JsonValidator.getInstance(), JsonConverter.getInstance(), ToscaJsonValueConverter.getInstance());
// @formatter:on
- private String type;
- private PropertyTypeValidator validator;
- private PropertyValueConverter converter;
- private ToscaValueConverter valueConverter;
+ private final String type;
+ private final PropertyTypeValidator validator;
+ private final PropertyValueConverter converter;
+ private final ToscaValueConverter valueConverter;
private boolean isAbstract = false;
ToscaPropertyType(String type, PropertyTypeValidator validator, PropertyValueConverter converter, ToscaValueConverter valueConverter) {
@@ -111,10 +111,7 @@ public enum ToscaPropertyType {
if (ToscaPropertyType.MAP.getType().equals(dataTypeName) || ToscaPropertyType.LIST.getType().equals(dataTypeName)) {
return false;
}
- if (isScalarType(dataTypeName)) {
- return true;
- }
- return false;
+ return isScalarType(dataTypeName);
}
public static ToscaPropertyType getTypeIfScalar(String dataTypeName) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java
deleted file mode 100644
index 3647bd67d0..0000000000
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintType.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.model.tosca.constraints;
-
-import java.util.Arrays;
-import java.util.List;
-
-public enum ConstraintType {
- // @formatter:off
- EQUAL("equal", "equal"),
- IN_RANGE("inRange", "in_range"),
- GREATER_THAN("greaterThan", "greater_than"),
- GREATER_OR_EQUAL("greaterOrEqual", "greater_or_equal"),
- LESS_OR_EQUAL("lessOrEqual", "less_or_equal"),
- LENGTH("length", "length"),
- MIN_LENGTH("minLength", "min_length"),
- MAX_LENGTH("maxLength", "max_length"),
- VALID_VALUES("validValues", "valid_values"),
- LESS_THAN("lessThan", "less_than"),
- SCHEMA("schema", "schema");
- // @formatter:on
-
- List<String> types;
-
- private ConstraintType(String... types) {
- this.types = Arrays.asList(types);
- }
-
- public static ConstraintType getByType(String type) {
- for (ConstraintType inst : ConstraintType.values()) {
- if (inst.getTypes().contains(type)) {
- return inst;
- }
- }
- return null;
- }
-
- public List<String> getTypes() {
- return types;
- }
-}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
index 4b62b12897..c4b26f3077 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/EqualConstraint.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
index dc50d7d549..d32ab721fc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterOrEqualConstraint.java
@@ -23,6 +23,7 @@ import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
index 0b76e97967..e50c8fe3d0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/GreaterThanConstraint.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.model.tosca.constraints;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
index bfb1b75a5c..d574816c5f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/InRangeConstraint.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import com.google.common.collect.Lists;
import java.util.List;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
index 3c89ed1b07..457c824ac6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LengthConstraint.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
index 653c93bf29..62cec05a73 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessOrEqualConstraint.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.model.tosca.constraints;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
index 59c091f224..c721c5cd63 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/LessThanConstraint.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
index 2535d972ca..004e431485 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MaxLengthConstraint.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java
index 98fda80604..a2ff95512a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/MinLengthConstraint.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
index e3f4d3e7e3..e519f1b7e4 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/PatternConstraint.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.tosca.constraints;
import java.util.regex.Pattern;
import javax.validation.constraints.NotNull;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
index fb4685d716..1cafc213bb 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ValidValuesConstraint.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Set;
import javax.validation.constraints.NotNull;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/DataTypeValidatorConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/DataTypeValidatorConverter.java
index 0a537a5445..4a5cda2fdd 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/DataTypeValidatorConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/DataTypeValidatorConverter.java
@@ -29,6 +29,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -36,18 +38,13 @@ import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
import org.openecomp.sdc.common.log.wrappers.Logger;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DataTypeValidatorConverter {
private static final Logger log = Logger.getLogger(DataTypeValidatorConverter.class.getName());
- private static DataTypeValidatorConverter dataTypeValidatorConverter = new DataTypeValidatorConverter();
- JsonParser jsonParser = new JsonParser();
- ImmutablePair<JsonElement, Boolean> falseResult = new ImmutablePair<>(null, false);
- ImmutablePair<JsonElement, Boolean> trueEmptyResult = new ImmutablePair<>(null, true);
- ImmutablePair<String, Boolean> trueStringEmptyResult = new ImmutablePair<>(null, true);
- ImmutablePair<String, Boolean> falseStringEmptyResult = new ImmutablePair<>(null, true);
-
- private DataTypeValidatorConverter() {
- }
+ private static final DataTypeValidatorConverter dataTypeValidatorConverter = new DataTypeValidatorConverter();
+ private static final ImmutablePair<JsonElement, Boolean> falseResult = new ImmutablePair<>(null, false);
+ private static final ImmutablePair<JsonElement, Boolean> trueEmptyResult = new ImmutablePair<>(null, true);
public static DataTypeValidatorConverter getInstance() {
return dataTypeValidatorConverter;
@@ -101,7 +98,7 @@ public class DataTypeValidatorConverter {
String convertedValue = converter.convert(value, null, allDataTypes);
JsonElement element = null;
try {
- element = jsonParser.parse(convertedValue);
+ element = JsonParser.parseString(convertedValue);
} catch (JsonSyntaxException e) {
log.debug("Failed to parse value {} of property {} {}", convertedValue, dataTypeDefinition.getName(), e);
return falseResult;
@@ -174,7 +171,7 @@ public class DataTypeValidatorConverter {
element = new JsonPrimitive("");
} else {
try {
- element = jsonParser.parse(convertedValue);
+ element = JsonParser.parseString(convertedValue);
} catch (JsonSyntaxException e) {
log.debug("Failed to parse value {} of type {}", convertedValue, propertyType, e);
return falseResult;
@@ -237,9 +234,9 @@ public class DataTypeValidatorConverter {
if (value == null || value.isEmpty()) {
return true;
}
- JsonElement jsonElement = null;
+ JsonElement jsonElement;
try {
- jsonElement = jsonParser.parse(value);
+ jsonElement = JsonParser.parseString(value);
} catch (JsonSyntaxException e) {
log.debug("Failed to parse the value {} from type {}", value, dataTypeDefinition, e);
return false;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/MapValidator.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/MapValidator.java
index 2635647467..d3424b8612 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/MapValidator.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/MapValidator.java
@@ -52,9 +52,8 @@ Keys always need " " around them.
public class MapValidator implements PropertyTypeValidator {
private static final Logger log = Logger.getLogger(MapValidator.class.getName());
- private static MapValidator mapValidator = new MapValidator();
- private static DataTypeValidatorConverter dataTypeValidatorConverter = DataTypeValidatorConverter.getInstance();
- private static JsonParser jsonParser = new JsonParser();
+ private static final MapValidator mapValidator = new MapValidator();
+ private static final DataTypeValidatorConverter dataTypeValidatorConverter = DataTypeValidatorConverter.getInstance();
public static MapValidator getInstance() {
return mapValidator;
@@ -99,7 +98,7 @@ public class MapValidator implements PropertyTypeValidator {
return isValid;
}
try {
- JsonElement jsonObject = jsonParser.parse(value);
+ JsonElement jsonObject = JsonParser.parseString(value);
if (!jsonObject.isJsonObject()) {
return false;
}
@@ -134,7 +133,7 @@ public class MapValidator implements PropertyTypeValidator {
return false;
}
try {
- JsonElement jsonObject = jsonParser.parse(value);
+ JsonElement jsonObject = JsonParser.parseString(value);
JsonObject asJsonObject = jsonObject.getAsJsonObject();
Set<Entry<String, JsonElement>> entrySet = asJsonObject.entrySet();
for (Entry<String, JsonElement> entry : entrySet) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/validation/FilterConstraintValidator.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/validation/FilterConstraintValidator.java
new file mode 100644
index 0000000000..634b1efe85
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/validation/FilterConstraintValidator.java
@@ -0,0 +1,39 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.validation;
+
+import org.openecomp.sdc.be.model.dto.FilterConstraintDto;
+
+/**
+ * Handle validation for a node/substitution filter constraint
+ */
+public interface FilterConstraintValidator {
+
+ /**
+ * Validates a node/substitution filter constraint
+ *
+ * @param filterConstraint the filter constraint
+ * @throws RuntimeException when the filter constraint is invalid
+ */
+ void validate(final FilterConstraintDto filterConstraint);
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java
new file mode 100644
index 0000000000..da486e47f5
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java
@@ -0,0 +1,124 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.ui.mapper;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import java.util.Map;
+import java.util.Optional;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.be.datatypes.elements.PropertyFilterConstraintDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
+import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
+import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
+import org.openecomp.sdc.be.model.dto.FilterConstraintDto;
+import org.openecomp.sdc.be.ui.model.UIConstraint;
+
+public class FilterConstraintMapper {
+
+ public FilterConstraintDto mapFrom(final UIConstraint uiConstraint) {
+ final var filterConstraint = new FilterConstraintDto();
+ ConstraintType.findByType(uiConstraint.getConstraintOperator()).ifPresent(filterConstraint::setOperator);
+ filterConstraint.setCapabilityName(uiConstraint.getCapabilityName());
+ filterConstraint.setPropertyName(uiConstraint.getServicePropertyName());
+ filterConstraint.setTargetType(StringUtils.isEmpty(uiConstraint.getCapabilityName()) ? PropertyFilterTargetType.PROPERTY : PropertyFilterTargetType.CAPABILITY);
+ FilterValueType.findByName(uiConstraint.getSourceType()).ifPresent(filterConstraint::setValueType);
+ filterConstraint.setValue(parseValueFromUiConstraint(uiConstraint.getValue()));
+ return filterConstraint;
+ }
+
+ public FilterConstraintDto mapFrom(final PropertyFilterConstraintDataDefinition propertyFilterConstraint) {
+ var filterConstraintDto = new FilterConstraintDto();
+ filterConstraintDto.setTargetType(propertyFilterConstraint.getTargetType());
+ filterConstraintDto.setPropertyName(propertyFilterConstraint.getPropertyName());
+ filterConstraintDto.setCapabilityName(propertyFilterConstraint.getCapabilityName());
+ filterConstraintDto.setOperator(propertyFilterConstraint.getOperator());
+ filterConstraintDto.setValueType(propertyFilterConstraint.getValueType());
+ filterConstraintDto.setValue(propertyFilterConstraint.getValue());
+ return filterConstraintDto;
+ }
+
+ public PropertyFilterConstraintDataDefinition mapTo(final FilterConstraintDto filterConstraintDto) {
+ var propertyFilterConstraint = new PropertyFilterConstraintDataDefinition();
+ propertyFilterConstraint.setTargetType(filterConstraintDto.getTargetType());
+ propertyFilterConstraint.setPropertyName(filterConstraintDto.getPropertyName());
+ propertyFilterConstraint.setCapabilityName(filterConstraintDto.getCapabilityName());
+ propertyFilterConstraint.setOperator(filterConstraintDto.getOperator());
+ propertyFilterConstraint.setValueType(filterConstraintDto.getValueType());
+ propertyFilterConstraint.setValue(filterConstraintDto.getValue());
+ return propertyFilterConstraint;
+ }
+
+ public UIConstraint mapToUiConstraint(final FilterConstraintDto filterConstraintDto) {
+ final var uiConstraint = new UIConstraint();
+ uiConstraint.setConstraintOperator(filterConstraintDto.getOperator().getType());
+ uiConstraint.setValue(filterConstraintDto.getValue());
+ uiConstraint.setCapabilityName(filterConstraintDto.getCapabilityName());
+ uiConstraint.setServicePropertyName(filterConstraintDto.getPropertyName());
+ uiConstraint.setSourceType(filterConstraintDto.getValueType().getName());
+ return uiConstraint;
+ }
+
+ private Object parseValueFromUiConstraint(final Object value) {
+ if (!(value instanceof Map || value instanceof String)) {
+ return value;
+ }
+ final Map<?, ?> valueAsMap;
+ if (value instanceof String) {
+ try {
+ valueAsMap = new Gson().fromJson((String) value, Map.class);
+ } catch (final Exception ignored) {
+ return value;
+ }
+ } else {
+ valueAsMap = (Map<?, ?>) value;
+ }
+
+ final Optional<ToscaFunction> toscaFunction = parseValueToToscaFunction(valueAsMap);
+ if (toscaFunction.isPresent()) {
+ return toscaFunction.get();
+ }
+
+ return valueAsMap;
+ }
+
+ public Optional<ToscaFunction> parseValueToToscaFunction(final Object value) {
+ if (value instanceof ToscaFunction) {
+ return Optional.of((ToscaFunction) value);
+ }
+ return readToscaFunctionType(value).map(toscaFunctionType -> new ObjectMapper().convertValue(value, ToscaFunction.class));
+ }
+
+ private Optional<ToscaFunctionType> readToscaFunctionType(final Object toscaFunction) {
+ if (!(toscaFunction instanceof Map)) {
+ return Optional.empty();
+ }
+ final Object type = ((Map<?, ?>) toscaFunction).get("type");
+ if (type instanceof String) {
+ return ToscaFunctionType.findType((String) type);
+ }
+ return Optional.empty();
+ }
+
+}