<artifactId>security-util-lib</artifactId>
<version>${security.util.lib.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-tosca-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
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;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.tosca.PropertyConvertor;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.validators.PropertyTypeValidator;
import org.openecomp.sdc.be.types.ServiceConsumptionData;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.tosca.InterfacesOperationsConverter;
import java.util.ArrayList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.model.tosca.constraints.ConstraintType;
import org.openecomp.sdc.be.ui.model.UIConstraint;
import org.slf4j.Logger;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.OperationInput;
import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.types.ServiceConsumptionData;
import org.openecomp.sdc.be.types.ServiceConsumptionSource;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Product;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.tosca.model.ToscaInterfaceDefinition;
import org.openecomp.sdc.be.tosca.model.ToscaInterfaceNodeType;
import org.openecomp.sdc.be.tosca.model.ToscaLifecycleOperationDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.converters.DataTypePropertyConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaMapValueConverter;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.ServiceMetadataDefinition;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.tosca.InterfacesOperationsConverter;
import org.openecomp.sdc.be.tosca.PropertyConvertor;
import org.openecomp.sdc.be.tosca.ToscaExportHandler;
import java.util.Objects;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.SELF;
import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
@RunWith(MockitoJUnitRunner.class)
<artifactId>joda-time</artifactId>
<version>${joda.time.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-tosca-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.model.tosca;
-
-/**
- * tosca functions supported by sdc
- */
-public enum ToscaFunctions {
-
- GET_INPUT("get_input"),
- GET_PROPERTY("get_property"),
- GET_OPERATION_OUTPUT("get_operation_output"),
- GET_POLICY("get_policy");
-
- private String functionName;
-
- ToscaFunctions(String functionName) {
- this.functionName = functionName;
- }
-
- public String getFunctionName() {
- return functionName;
- }
-}
package org.openecomp.sdc.be.model.tosca.converters;
import com.google.gson.JsonObject;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
public class ToscaConverterUtils {
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.tosca.ToscaFunctions;
+import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.common.log.wrappers.Logger;
if (toscaPropertyValue instanceof List && ((List) toscaPropertyValue).get(0) instanceof Map) {
Resource subInterfaceResource = subInterfaceTo.getResource();
Map<String, String> toscaPropertyValueMap = (Map) ((List) toscaPropertyValue).get(0);
- String parentPortPropertyInput = toscaPropertyValueMap.get(ToscaFunctions.GET_INPUT.getDisplayName());
+ String parentPortPropertyInput = toscaPropertyValueMap.get(ToscaFunctions.GET_INPUT.getFunctionName());
Map<String, Object> resourceDefPropertiesMap;
if (!isYamlFile(subInterfaceResource.getType())) {
resourceDefPropertiesMap =
for (String propertyName : exposedVfcInstanceGroupingProperties) {
Map<String, Object> getInputMap = new HashMap<>();
String vfcGroupPropertyInputName = subInterfaceNetworkRole + "_" + propertyName;
- getInputMap.put(GET_INPUT.getDisplayName(), vfcGroupPropertyInputName);
+ getInputMap.put(GET_INPUT.getFunctionName(), vfcGroupPropertyInputName);
properties.put(propertyName, getInputMap);
addInputParameter(vfcGroupPropertyInputName, PropertyType.STRING.getDisplayName(), null,
List<List<Object>> getAttrValueList = new ArrayList<>();
if (valueObject instanceof Map) {
- if (((Map) valueObject).containsKey(ToscaFunctions.GET_ATTRIBUTE.getDisplayName())) {
+ if (((Map) valueObject).containsKey(ToscaFunctions.GET_ATTRIBUTE.getFunctionName())) {
getAttrValueList.add(
- (List<Object>) ((Map) valueObject).get(ToscaFunctions.GET_ATTRIBUTE.getDisplayName()));
+ (List<Object>) ((Map) valueObject).get(ToscaFunctions.GET_ATTRIBUTE.getFunctionName()));
}
for (Object key : ((Map) valueObject).keySet()) {
private boolean isIncludeToscaFunc(Object valueObject, ToscaFunctions toscaFunction) {
if (valueObject instanceof Map) {
- if (((Map) valueObject).containsKey(toscaFunction.getDisplayName())) {
+ if (((Map) valueObject).containsKey(toscaFunction.getFunctionName())) {
return true;
}
List<Object> valueList = new ArrayList<>();
valueList.add(newNodeTemplateId);
valueList.add(getAttrFuncData.getAttributeName());
- parameterValue.put(ToscaFunctions.GET_ATTRIBUTE.getDisplayName(), valueList);
+ parameterValue.put(ToscaFunctions.GET_ATTRIBUTE.getFunctionName(), valueList);
ParameterDefinition outputParameter = new ParameterDefinition();
outputParameter.setValue(parameterValue);
setOutputParameterType(substitutionServiceTemplate, newNodeTemplateId, getAttrFuncData
Map<String, Object> indexPropertyValue = new HashMap<>();
Map<String, Object> properties = nodeTemplate.getProperties();
- indexPropertyValue.put(ToscaFunctions.GET_PROPERTY.getDisplayName(),
+ indexPropertyValue.put(ToscaFunctions.GET_PROPERTY.getFunctionName(),
indexValueGetPropertyValue);
properties.put(ToscaConstants.INDEX_VALUE_PROPERTY_NAME,
indexPropertyValue);
if (nodeTemplateProperties.containsKey(enrichPropertyName)) {
handleExistingEnrichedProperty(enrichPropertyName, nodeTemplateProperties, inputParamId);
} else {
- propertyValMap.put(ToscaFunctions.GET_INPUT.getDisplayName(), inputParamId);
+ propertyValMap.put(GET_INPUT.getFunctionName(), inputParamId);
nodeTemplate.getProperties().put(enrichPropertyName, propertyValMap);
}
propertyType =
Object enrichedProperty = nodeTemplateProperties.get(enrichPropertyName);
if (!isPropertyContainsToscaFunction(enrichedProperty)) {
Map<String, Object> propertyWithGetInput = new HashMap<>();
- propertyWithGetInput.put(ToscaFunctions.GET_INPUT.getDisplayName(), inputParamId);
+ propertyWithGetInput.put(ToscaFunctions.GET_INPUT.getFunctionName(), inputParamId);
nodeTemplateProperties.put(enrichPropertyName, propertyWithGetInput);
}
}
case COMPUTE:
inputParamId = COMPUTE_IDENTICAL_VALUE_PROPERTY_PREFIX + propertyId
+ COMPUTE_IDENTICAL_VALUE_PROPERTY_SUFFIX;
- propertyVal.put(ToscaFunctions.GET_INPUT.getDisplayName(), inputParamId);
+ propertyVal.put(ToscaFunctions.GET_INPUT.getFunctionName(), inputParamId);
nodeTemplate.getProperties().put(propertyId, propertyVal);
break;
case PORT:
ComputeTemplateConsolidationData computeTemplateConsolidationData =
getConnectedComputeConsolidationData(unifiedCompositionDataList, nodeTemplateId);
inputParamId = getInputParamIdForPort(nodeTemplateId, propertyId, portType, computeTemplateConsolidationData);
- propertyVal.put(ToscaFunctions.GET_INPUT.getDisplayName(), inputParamId);
+ propertyVal.put(ToscaFunctions.GET_INPUT.getFunctionName(), inputParamId);
nodeTemplate.getProperties().put(propertyId, propertyVal);
break;
default:
List<String> getInputFuncParams = new ArrayList<>();
getInputFuncParams.add(inputParamId);
getInputFuncParams.add(ToscaConstants.INDEX_VALUE_PROPERTY_NAME);
- propertyVal.put(ToscaFunctions.GET_INPUT.getDisplayName(), getInputFuncParams);
+ propertyVal.put(ToscaFunctions.GET_INPUT.getFunctionName(), getInputFuncParams);
return propertyVal;
}
if (refParameter instanceof Map && ((Map) refParameter).get("Ref") != null) {
Map<String, String> stringWithToken = new HashMap<>();
((Map) stringWithToken)
- .put(ToscaFunctions.GET_INPUT.getDisplayName(), ((Map) refParameter).get("Ref"));
+ .put(ToscaFunctions.GET_INPUT.getFunctionName(), ((Map) refParameter).get("Ref"));
tokenPropertyValue.get("token").add(stringWithToken);
} else if (refParameter instanceof String) {
if (includeBooleanValue) {
if (functionTranslator.isResourceSupported(attributeFunctionExpression.get(0).toString())
&& functionTranslator.isAttributeSupported(attributeFunctionExpression.get(0).toString())) {
Map<String, Object> getAttrValue = new HashMap<>();
- getAttrValue.put(ToscaFunctions.GET_ATTRIBUTE.getDisplayName(), attributeFunctionExpression);
+ getAttrValue.put(ToscaFunctions.GET_ATTRIBUTE.getFunctionName(), attributeFunctionExpression);
returnValue = getAttrValue;
} else {
returnValue = attributeFunctionExpression;
Map<String, Object> returnValue = new HashMap<>();
List<String> artifactParameters = new ArrayList<>();
artifactParameters.add(ToscaConstants.MODELABLE_ENTITY_NAME_SELF);
- returnValue.put(ToscaFunctions.GET_ARTIFACT.getDisplayName(), artifactParameters);
+ returnValue.put(ToscaFunctions.GET_ARTIFACT.getFunctionName(), artifactParameters);
artifactParameters.add(artifactId);
ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl();
@Override
public Object translateFunction(FunctionTranslator functionTranslator) {
Map<String, Object> returnValue = new HashMap<>();
- returnValue.put(ToscaFunctions.GET_INPUT.getDisplayName(),
+ returnValue.put(ToscaFunctions.GET_INPUT.getFunctionName(),
translateGetParamFunctionExpression(functionTranslator));
return returnValue;
}
for (String propertyName : nestedPropertyNames) {
Object propertyValue = mappedNodeTemplate.getProperties().get(propertyName);
if (propertyValue instanceof Map
- && ((Map) propertyValue).containsKey(ToscaFunctions.GET_INPUT.getDisplayName())) {
- Object paramName = ((Map) propertyValue).get(ToscaFunctions.GET_INPUT.getDisplayName());
+ && ((Map) propertyValue).containsKey(ToscaFunctions.GET_INPUT.getFunctionName())) {
+ Object paramName = ((Map) propertyValue).get(ToscaFunctions.GET_INPUT.getFunctionName());
if (paramName instanceof String) {
connectionParameterNameList.add((String) paramName);
}
List<String> outputGetAttributeList = new ArrayList<>();
outputGetAttributeList.add(nodeTemplateId);
outputGetAttributeList.add(attributeDefinitionEntry.getKey());
- outputValue.put(ToscaFunctions.GET_ATTRIBUTE.getDisplayName(), outputGetAttributeList);
+ outputValue.put(ToscaFunctions.GET_ATTRIBUTE.getFunctionName(), outputGetAttributeList);
nestedSubstitutionServiceTemplateOutputs.put(attributeDefinitionEntry.getKey(),
DataModelUtil.convertAttributeDefToParameterDef(abstractAttributeDef, outputValue));
}
if (contrailComputeProperties != null) {
for (String computePropertyKey : contrailComputeProperties.keySet()) {
Map<String, Object> getInputProperty = new HashMap<>();
- getInputProperty.put(ToscaFunctions.GET_INPUT.getDisplayName(), computePropertyKey);
+ getInputProperty.put(ToscaFunctions.GET_INPUT.getFunctionName(), computePropertyKey);
computeNodeTemplateProperties.put(computePropertyKey, getInputProperty);
}
}
if (!(dhcpEnabled instanceof Map)) {
return;
}
- Object dhcpEnabledParameterName = ((Map) dhcpEnabled).get(ToscaFunctions.GET_INPUT.getDisplayName());
+ Object dhcpEnabledParameterName = ((Map) dhcpEnabled).get(ToscaFunctions.GET_INPUT.getFunctionName());
if (dhcpEnabledParameterName == null) {
return;
}
indexVarValList.add(ToscaConstants.MODELABLE_ENTITY_NAME_SELF);
indexVarValList.add(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME);
indexVarValList.add(ToscaConstants.INDEX_VALUE_PROPERTY_NAME);
- newIndexVarValue.put(ToscaFunctions.GET_PROPERTY.getDisplayName(), indexVarValList);
+ newIndexVarValue.put(ToscaFunctions.GET_PROPERTY.getFunctionName(), indexVarValList);
return newIndexVarValue;
}
concatList.add(value);
}
- concatMap.put(ToscaFunctions.CONCAT.getDisplayName(), concatList);
+ concatMap.put(ToscaFunctions.CONCAT.getFunctionName(), concatList);
return concatMap;
}
return propertyValue; //no update is needed
return Optional.of((Boolean) dhcp);
} else if (dhcp instanceof Map) {
String inputParameterName =
- (String) ((Map) dhcp).get(ToscaFunctions.GET_INPUT.getDisplayName());
+ (String) ((Map) dhcp).get(ToscaFunctions.GET_INPUT.getFunctionName());
if (inputParameterName != null) {
ParameterDefinition inputParameterDefinition =
serviceTemplate.getTopology_template().getInputs().get(inputParameterName);
NODE_TYPE,
ARTIFACT_TYPE,
DATA_TYPE,
- INTERFCAE_TYPE,
+ INTERFACE_TYPE,
RELATIONSHIP_TYPE,
GROUP_TYPE,
POLICY_TYPE
import lombok.AllArgsConstructor;
import lombok.Getter;
+/**
+ * TOSCA Simple Profile in YAML Version 1.3.
+ * <p>
+ * OASIS Standard (26 February 2020).
+ * <p>
+ * https://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.3/TOSCA-Simple-Profile-YAML-v1.3.html
+ */
@Getter
@AllArgsConstructor
public enum ToscaFunctions {
+ // Intrinsic functions, section 4.3 in TOSCA 1.3
+ CONCAT("concat"),
+ JOIN("join"), // since 1.2
TOKEN("token"),
+
+ // Property functions, section 4.4 in TOSCA 1.3
+ GET_INPUT("get_input"),
GET_PROPERTY("get_property"),
+
+ // Attribute functions, section 4.5 in TOSCA 1.3
GET_ATTRIBUTE("get_attribute"),
+
+ // Operation functions, section 4.6 in TOSCA 1.3
+ GET_OPERATION_OUTPUT("get_operation_output"),
+
+ // Navigation functions, section 4.7 in TOSCA 1.3
+ GET_NODES_OF_TYPE("get_nodes_of_type"),
+
+ // Artifact functions, section 4.8 in TOSCA 1.3
GET_ARTIFACT("get_artifact"),
- GET_INPUT("get_input"),
- CONCAT("concat");
- private String displayName;
+ // non TOSCA-compliant function
+ GET_POLICY("get_policy");
+
+ private String functionName;
}
Collections.addAll(propertyList, nestedPropertyName);
}
Map<String, Object> getInputProperty = new HashMap<>();
- getInputProperty.put(ToscaFunctions.GET_INPUT.getDisplayName(), propertyList);
+ getInputProperty.put(ToscaFunctions.GET_INPUT.getFunctionName(), propertyList);
return getInputProperty;
}
Map inputPropertyMap = DataModelUtil.createGetInputPropertyValueFromListParameter("inputPropertyList", 1,
"nestedPropertyName");
- assertNotNull(inputPropertyMap.get(ToscaFunctions.GET_INPUT.getDisplayName()));
+ assertNotNull(inputPropertyMap.get(ToscaFunctions.GET_INPUT.getFunctionName()));
}
@Test