summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-07-29 20:39:23 +0100
committerMichael Morris <michael.morris@est.tech>2022-08-06 22:43:00 +0000
commit7b0009c2bebe54214f920baf6b2aa4058921777b (patch)
tree1e5a24cea14540b1e6b8777719487aa47497fa42 /catalog-model
parentc2f19bdcf5b5d5647770a5d3435d942fb3dd0efa (diff)
Support for TOSCA functions for Service Import
Reads, interprets and persists property values that uses TOSCA functions during a Service import. Change-Id: I6943c447cc743213cb9807d6433cb25fa5effbc3 Issue-ID: SDC-4120 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadPropInfo.java33
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java134
2 files changed, 6 insertions, 161 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadPropInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadPropInfo.java
index d5221eeef2..da71aeef97 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadPropInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadPropInfo.java
@@ -21,14 +21,20 @@ package org.openecomp.sdc.be.model;
import java.util.ArrayList;
import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
+@Setter
+@Getter
public class UploadPropInfo extends UploadInfo {
private Object value;
private String description;
private boolean password;
private List<GetInputValueDataDefinition> get_input;
+ private ToscaFunction toscaFunction;
public List<GetInputValueDataDefinition> getGet_input() {
if (get_input == null) {
@@ -37,31 +43,4 @@ public class UploadPropInfo extends UploadInfo {
return get_input;
}
- public void setGet_input(List<GetInputValueDataDefinition> get_input) {
- this.get_input = get_input;
- }
-
- public Object getValue() {
- return value;
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isPassword() {
- return password;
- }
-
- public void setPassword(boolean password) {
- this.password = password;
- }
}
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 b66f6c9433..7546e90a82 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
@@ -1701,140 +1701,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
return validateAndUpdatePropertyValue(property.getType(), property.getValue(), true, innerType, dataTypes);
}
-// private <T extends PropertyDefinition> void validateToscaGetFunction(T property, org.openecomp.sdc.be.model.Component parentComponent) {
-// final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) property.getToscaFunction();
-// validateGetToscaFunctionAttributes(toscaGetFunction);
-// validateGetPropertySource(toscaGetFunction.getFunctionType(), toscaGetFunction.getPropertySource());
-// if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_INPUT) {
-// validateGetFunction(property, parentComponent.getInputs(), parentComponent.getModel());
-// return;
-// }
-// if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_PROPERTY) {
-// if (toscaGetFunction.getPropertySource() == PropertySource.SELF) {
-// validateGetFunction(property, parentComponent.getProperties(), parentComponent.getModel());
-// } else if (toscaGetFunction.getPropertySource() == PropertySource.INSTANCE) {
-// final ComponentInstance componentInstance =
-// parentComponent.getComponentInstanceById(toscaGetFunction.getSourceUniqueId())
-// .orElseThrow(ToscaGetFunctionExceptionSupplier.instanceNotFound(toscaGetFunction.getSourceName()));
-// validateGetFunction(property, componentInstance.getProperties(), parentComponent.getModel());
-// }
-//
-// return;
-// }
-// if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_ATTRIBUTE) {
-// if (toscaGetFunction.getPropertySource() == PropertySource.SELF) {
-// validateGetFunction(property, parentComponent.getAttributes(), parentComponent.getModel());
-// } else if (toscaGetFunction.getPropertySource() == PropertySource.INSTANCE) {
-// final ComponentInstance componentInstance =
-// parentComponent.getComponentInstanceById(toscaGetFunction.getSourceUniqueId())
-// .orElseThrow(ToscaGetFunctionExceptionSupplier.instanceNotFound(toscaGetFunction.getSourceName()));
-// validateGetFunction(property, componentInstance.getAttributes(), parentComponent.getModel());
-// }
-//
-// return;
-// }
-//
-// throw ToscaGetFunctionExceptionSupplier.functionNotSupported(toscaGetFunction.getFunctionType()).get();
-// }
-
-// private <T extends PropertyDefinition> void validateGetFunction(final T property,
-// final List<? extends ToscaPropertyData> parentProperties,
-// final String model) {
-// final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) property.getToscaFunction();
-// if (CollectionUtils.isEmpty(parentProperties)) {
-// throw ToscaGetFunctionExceptionSupplier
-// .propertyNotFoundOnTarget(toscaGetFunction.getPropertyName(), toscaGetFunction.getPropertySource(),
-// toscaGetFunction.getFunctionType()
-// ).get();
-// }
-// final String getFunctionPropertyUniqueId = toscaGetFunction.getPropertyUniqueId();
-// ToscaPropertyData referredProperty = parentProperties.stream()
-// .filter(property1 -> getFunctionPropertyUniqueId.equals(property1.getUniqueId()))
-// .findFirst()
-// .orElseThrow(ToscaGetFunctionExceptionSupplier
-// .propertyNotFoundOnTarget(toscaGetFunction.getPropertyName(), toscaGetFunction.getPropertySource()
-// , toscaGetFunction.getFunctionType())
-// );
-// if (toscaGetFunction.isSubProperty()) {
-// referredProperty = findSubProperty(referredProperty, toscaGetFunction, model);
-// }
-//
-// if (!property.getType().equals(referredProperty.getType())) {
-// throw ToscaGetFunctionExceptionSupplier
-// .propertyTypeDiverge(toscaGetFunction.getType(), referredProperty.getType(), property.getType()).get();
-// }
-// if (PropertyType.typeHasSchema(referredProperty.getType()) && !referredProperty.getSchemaType().equals(property.getSchemaType())) {
-// throw ToscaGetFunctionExceptionSupplier
-// .propertySchemaDiverge(toscaGetFunction.getType(), referredProperty.getSchemaType(), property.getSchemaType()).get();
-// }
-// }
-
-// private void validateGetToscaFunctionAttributes(final ToscaGetFunctionDataDefinition toscaGetFunction) {
-// if (toscaGetFunction.getFunctionType() == null) {
-// throw ToscaGetFunctionExceptionSupplier.targetFunctionTypeNotFound().get();
-// }
-// if (toscaGetFunction.getPropertySource() == null) {
-// throw ToscaGetFunctionExceptionSupplier.targetPropertySourceNotFound(toscaGetFunction.getFunctionType()).get();
-// }
-// if (CollectionUtils.isEmpty(toscaGetFunction.getPropertyPathFromSource())) {
-// throw ToscaGetFunctionExceptionSupplier
-// .targetSourcePathNotFound(toscaGetFunction.getFunctionType()).get();
-// }
-// if (StringUtils.isEmpty(toscaGetFunction.getSourceName()) || StringUtils.isBlank(toscaGetFunction.getSourceName())) {
-// throw ToscaGetFunctionExceptionSupplier.sourceNameNotFound(toscaGetFunction.getPropertySource()).get();
-// }
-// if (StringUtils.isEmpty(toscaGetFunction.getSourceUniqueId()) || StringUtils.isBlank(toscaGetFunction.getSourceUniqueId())) {
-// throw ToscaGetFunctionExceptionSupplier.sourceIdNotFound(toscaGetFunction.getPropertySource()).get();
-// }
-// if (StringUtils.isEmpty(toscaGetFunction.getPropertyName()) || StringUtils.isBlank(toscaGetFunction.getPropertyName())) {
-// throw ToscaGetFunctionExceptionSupplier.propertyNameNotFound(toscaGetFunction.getPropertySource()).get();
-// }
-// if (StringUtils.isEmpty(toscaGetFunction.getPropertyUniqueId()) || StringUtils.isBlank(toscaGetFunction.getPropertyUniqueId())) {
-// throw ToscaGetFunctionExceptionSupplier.propertyIdNotFound(toscaGetFunction.getPropertySource()).get();
-// }
-// }
-
-// private void validateGetPropertySource(final ToscaGetFunctionType functionType, final PropertySource propertySource) {
-// if (functionType == ToscaGetFunctionType.GET_INPUT && propertySource != PropertySource.SELF) {
-// throw ToscaGetFunctionExceptionSupplier
-// .targetSourceNotSupported(functionType, propertySource).get();
-// }
-// if (functionType == ToscaGetFunctionType.GET_PROPERTY && !List.of(PropertySource.SELF, PropertySource.INSTANCE).contains(propertySource)) {
-// throw ToscaGetFunctionExceptionSupplier
-// .targetSourceNotSupported(functionType, propertySource).get();
-// }
-// }
-
-// private ToscaPropertyData findSubProperty(final ToscaPropertyData referredProperty,
-// final ToscaGetFunctionDataDefinition toscaGetFunction,
-// final String model) {
-// final Map<String, DataTypeDefinition> dataTypeMap = loadDataTypes(model);
-// final List<String> propertyPathFromSource = toscaGetFunction.getPropertyPathFromSource();
-// DataTypeDefinition dataType = dataTypeMap.get(referredProperty.getType());
-// if (dataType == null) {
-// throw ToscaGetFunctionExceptionSupplier
-// .propertyDataTypeNotFound(propertyPathFromSource.get(0), referredProperty.getType(), toscaGetFunction.getFunctionType()).get();
-// }
-// ToscaPropertyData foundProperty = referredProperty;
-// for (int i = 1; i < propertyPathFromSource.size(); i++) {
-// final String currentPropertyName = propertyPathFromSource.get(i);
-// foundProperty = dataType.getProperties().stream()
-// .filter(propertyDefinition -> currentPropertyName.equals(propertyDefinition.getName())).findFirst()
-// .orElseThrow(
-// ToscaGetFunctionExceptionSupplier
-// .propertyNotFoundOnTarget(propertyPathFromSource.subList(0, i), toscaGetFunction.getPropertySource(),
-// toscaGetFunction.getFunctionType())
-// );
-// dataType = dataTypeMap.get(foundProperty.getType());
-// if (dataType == null) {
-// throw ToscaGetFunctionExceptionSupplier
-// .propertyDataTypeNotFound(propertyPathFromSource.subList(0, i), foundProperty.getType(),
-// toscaGetFunction.getFunctionType()).get();
-// }
-// }
-// return foundProperty;
-// }
-
public <T extends GraphNode> Either<List<PropertyDefinition>, StorageOperationStatus> getAllPropertiesRec(String uniqueId, NodeTypeEnum nodeType,
Class<T> clazz) {
return this.findPropertiesOfNode(nodeType, uniqueId).right().bind(this::handleNotFoundProperties).left()