summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java4
6 files changed, 34 insertions, 6 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index e9d5c025cf..bdb659b259 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -107,10 +107,13 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyFilterConstraintDataDefin
import org.openecomp.sdc.be.datatypes.elements.SubPropertyToscaFunction;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.datatypes.elements.ToscaFunctionType;
import org.openecomp.sdc.be.datatypes.enums.FilterValueType;
import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
+import org.openecomp.sdc.be.datatypes.enums.PropertySource;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -1272,6 +1275,7 @@ public class YamlTemplateParsingHandler {
operationInput.setUniqueId(UUID.randomUUID().toString());
operationInput.setInputId(operationInput.getUniqueId());
operationInput.setName(interfaceInput.getKey());
+
handleInputToscaDefinition(interfaceInput.getKey(), interfaceInput.getValue(), operationInput);
inputs.add(operationInput);
}
@@ -1288,6 +1292,9 @@ public class YamlTemplateParsingHandler {
Type type = new TypeToken<LinkedHashMap<String, Object>>() {
}.getType();
String stringValue = gson.toJson(value, type);
+ if (toscaFunctionYamlParsingHandler.isPropertyValueToscaFunction(value)) {
+ toscaFunctionYamlParsingHandler.buildToscaFunctionBasedOnPropertyValue((Map<String, Object>) value).ifPresent(operationInput::setToscaFunction);
+ }
operationInput.setValue(stringValue);
}
if (value instanceof String) {
@@ -1296,6 +1303,10 @@ public class YamlTemplateParsingHandler {
operationInput.setToscaDefaultValue(stringValue);
operationInput.setValue(stringValue);
}
+ operationInput.setType("string");
+ if (operationInput.getValue() == null) {
+ operationInput.setValue(String.valueOf(value));
+ }
}
private Optional<ArtifactDataDefinition> handleOperationImplementation(
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 60cc6fc7fd..3bfa76dc49 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
@@ -86,6 +86,7 @@ import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SubPropertyToscaFunction;
import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -1847,11 +1848,12 @@ public class ServiceImportBusinessLogic {
log.debug("************* Going to create all nodes {}", yamlName);
handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts,
nodeTypesInfo, csarInfo, nodeName);
+ List<PropertyDefinition> serviceProperties = null != service ? service.getProperties() : Collections.emptyList();
if (MapUtils.isNotEmpty(uploadComponentInstanceInfoMap)) {
log.debug("************* Going to create all resource instances {}", yamlName);
service = createServiceInstances(yamlName, service, uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
log.debug("************* Going to create all relations {}", yamlName);
- service = createServiceInstancesRelations(csarInfo.getModifier(), yamlName, service, uploadComponentInstanceInfoMap);
+ service = createServiceInstancesRelations(csarInfo.getModifier(), yamlName, service, uploadComponentInstanceInfoMap, serviceProperties);
log.debug("************* Going to create positions {}", yamlName);
compositionBusinessLogic.setPositionsForComponentInstances(service, csarInfo.getModifier().getUserId());
log.debug("************* Finished to set positions {}", yamlName);
@@ -1860,7 +1862,8 @@ public class ServiceImportBusinessLogic {
}
protected Service createServiceInstancesRelations(User user, String yamlName, Service service,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ List<PropertyDefinition> serviceProperties) {
log.debug("#createResourceInstancesRelations - Going to create relations ");
List<ComponentInstance> componentInstancesList = service.getComponentInstances();
if (MapUtils.isEmpty(uploadResInstancesMap) || CollectionUtils.isEmpty(componentInstancesList)) { // PNF can have no resource instances
@@ -1888,6 +1891,7 @@ public class ServiceImportBusinessLogic {
final Map<String, DataTypeDefinition> allDataTypesMap =
componentsUtils.getAllDataTypes(applicationDataTypeCache, service.getModel());
final Service service1 = service;
+ service1.setProperties(serviceProperties);
uploadResInstancesMap.values().forEach(
i -> processComponentInstance(yamlName, service1, componentInstancesList,
allDataTypesMap, instProperties,
@@ -2289,6 +2293,13 @@ public class ServiceImportBusinessLogic {
//Inputs
ListDataDefinition<OperationInputDefinition> instanceInputs = instanceOperation.getInputs();
mergeOperationInputDefinitions(templateOperation.getInputs(), instanceInputs);
+ component.getProperties()
+ .forEach(property -> instanceInputs.getListToscaDataDefinition().stream()
+ .filter(instanceInput -> instanceInput.getToscaFunction() instanceof ToscaGetFunctionDataDefinition &&
+ property.getName().equals(instanceInput.getToscaFunction() != null ?
+ ((ToscaGetFunctionDataDefinition) instanceInput.getToscaFunction()).getPropertyName() : null))
+ .forEach(oldInput -> oldInput.setType(property.getType()))
+ );
templateOperation.setInputs(instanceInputs);
//Implementation
templateOperation.setImplementation(instanceOperation.getImplementation());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
index 40d531d788..4a98fa99f4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
@@ -148,7 +148,8 @@ public class AttributeConverter {
return toscaMapValueConverter.handleComplexJsonValue(valueAsJson);
}
//if it is a data type
- return toscaMapValueConverter.convertDataTypeToToscaObject(innerType, dataTypes, null, false, valueAsJson, preserveEmptyValue);
+ return toscaMapValueConverter.convertDataTypeToToscaObject(innerType, dataTypes, null, false, valueAsJson,
+ preserveEmptyValue, false);
} catch (final JsonParseException e) {
final String errorMsg = "Failed to parse json value";
LOGGER.error(EcompLoggerErrorCode.SCHEMA_ERROR, "Attribute Converter", errorMsg, e);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
index 3650422afc..8f5f271407 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
@@ -41,6 +41,7 @@ import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -158,6 +159,9 @@ public class InterfacesOperationsConverter {
}
private static String getInputValue(final OperationInputDefinition input) {
+ if (null != input.getToscaFunction()) {
+ return input.getToscaFunction().getJsonObjectValue().toString();
+ }
String inputValue = input.getValue() == null ? input.getToscaDefaultValue() : input.getValue();
if (inputValue != null && inputValue.contains(ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName())) {
Gson gson = new Gson();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index d1cd495222..bb89d99b2e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -314,7 +314,8 @@ public class PropertyConvertor {
convertedValue = innerConverter.convertToToscaValue(value, innerType, dataTypes);
} else {
convertedValue = mapConverterInst
- .convertDataTypeToToscaObject(innerType, dataTypes, innerConverter, isScalar, jsonElement, preserveEmptyValue);
+ .convertDataTypeToToscaObject(innerType, dataTypes, innerConverter, isScalar, jsonElement, preserveEmptyValue,
+ property.isToscaFunction());
}
return convertedValue;
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 bd61fdbb58..cf40778542 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
@@ -1278,7 +1278,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition);
when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat);
when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(service));
- Assertions.assertNotNull(sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap));
+ Assertions.assertNotNull(sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap, null));
}
@Test
@@ -1289,7 +1289,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
Assertions.assertThrows(ComponentException.class,
- () -> sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap));
+ () -> sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap, null));
}
@Test