-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.openecomp.sdc.jtosca</groupId>
- <artifactId>jtosca</artifactId>
- <version>1.1.1-SNAPSHOT</version>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+\r
+ <groupId>org.openecomp.sdc.jtosca</groupId>\r
+ <artifactId>jtosca</artifactId>\r
+ <version>1.1.3-SNAPSHOT</version>\r
\r
<properties>\r
\r
<releases.path>releases</releases.path>\r
<!--<staging.profile.id>176c31dfe190a</staging.profile.id> -->\r
\r
- </properties>
-
- <dependencies>
- <!-- YAML parser -->
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- <version>1.14</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- </dependency>
-
- <!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId>
- <version>1.1.2</version> <scope>test</scope> </dependency> -->
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- </dependency>
+ </properties>\r
+\r
+ <dependencies>\r
+ <!-- YAML parser -->\r
+ <dependency>\r
+ <groupId>org.yaml</groupId>\r
+ <artifactId>snakeyaml</artifactId>\r
+ <version>1.14</version>\r
+ <scope>compile</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ <version>1.7.25</version>\r
+ </dependency>\r
+\r
+ <!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> \r
+ <version>1.1.2</version> <scope>test</scope> </dependency> -->\r
+\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.12</version>\r
+ </dependency>\r
</dependencies>\r
\r
<reporting>\r
<id>ecomp-site</id>\r
<url>dav:${nexus.proxy}${sitePath}</url>\r
</site>\r
- </distributionManagement>
-
+ </distributionManagement>\r
+\r
</project>
\ No newline at end of file
private String description;
private ToscaGraph graph;
private SubstitutionMappings substitutionMappings;
+ private boolean resolveGetInput;
public TopologyTemplate(
LinkedHashMap<String,Object> _template,
LinkedHashMap<String,Object> _customDefs,
LinkedHashMap<String,Object> _relTypes,//TYPE
LinkedHashMap<String, Object> _parsedParams,
- NodeTemplate _subMappedNodeTemplate) {
+ NodeTemplate _subMappedNodeTemplate,
+ boolean _resolveGetInput) {
tpl = _template;
if(tpl != null) {
customDefs = _customDefs;
relTypes = _relTypes;
parsedParams = _parsedParams;
+ resolveGetInput = _resolveGetInput;
_validateField();
description = _tplDescription();
inputs = _inputs();
if(nodeTemplates != null) {
for(NodeTemplate nt: nodeTemplates) {
for(Property prop: nt.getPropertiesObjects()) {
- prop.setValue(Function.getFunction(this,nt,prop.getValue()));
+ prop.setValue(Function.getFunction(this,nt,prop.getValue(), resolveGetInput));
}
for(InterfacesDef ifd: nt.getInterfaces()) {
LinkedHashMap<String,Object> ifin = ifd.getInputs();
if(ifin != null) {
for(Map.Entry<String,Object> me: ifin.entrySet()) {
String name = me.getKey();
- Object value = Function.getFunction(this,nt,me.getValue());
+ Object value = Function.getFunction(this,nt,me.getValue(), resolveGetInput);
ifd.setInput(name,value);
}
}
(LinkedHashMap<String,Object>)rel.get("properties");
for(String key: relprops.keySet()) {
Object value = relprops.get(key);
- Object func = Function.getFunction(this,req,value);
+ Object func = Function.getFunction(this,req,value, resolveGetInput);
relprops.put(key,func);
}
}
for(Capability cap: nt.getCapabilitiesObjects()) {
if(cap.getPropertiesObjects() != null) {
for(Property prop: cap.getPropertiesObjects()) {
- Object propvalue = Function.getFunction(this,nt,prop.getValue());
+ Object propvalue = Function.getFunction(this,nt,prop.getValue(), resolveGetInput);
if(propvalue instanceof GetInput) {
propvalue = ((GetInput)propvalue).result();
for(String p: cap.getProperties().keySet()) {
Object func = Function.getFunction(
this,
relTpl,
- value);
+ value,
+ resolveGetInput);
iface.setInput(name,func);
}
}
}
}
for(Output output: outputs) {
- Object func = Function.getFunction(this,outputs,output.getValue());
+ Object func = Function.getFunction(this,outputs,output.getValue(), resolveGetInput);
if(func instanceof GetAttribute) {
output.setAttr(Output.VALUE,func);
}
public LinkedHashMap<String,Object> getParsedParams() {
return parsedParams;
}
+
+ public boolean getResolveGetInput() {
+ return resolveGetInput;
+ }
}
/*python
private String path;
private String inputPath;
private LinkedHashMap<String,Object> parsedParams;
+ private boolean resolveGetInput;
private LinkedHashMap<String,Object> tpl;
private String version;
private ArrayList<Object> imports;
private int nestingLoopCounter;
private LinkedHashMap<String, LinkedHashMap<String, Object>> metaProperties;
- @SuppressWarnings("unchecked")
public ToscaTemplate(String _path,
- LinkedHashMap<String,Object> _parsedParams,
+ LinkedHashMap<String,Object> _parsedParams,
+ boolean aFile,
+ LinkedHashMap<String,Object> yamlDictTpl) throws JToscaException {
+ init(_path, _parsedParams, aFile, yamlDictTpl, true);
+ }
+
+ public ToscaTemplate(String _path,
+ LinkedHashMap<String,Object> _parsedParams,
boolean aFile,
- LinkedHashMap<String,Object> yamlDictTpl) throws JToscaException {
+ LinkedHashMap<String,Object> yamlDictTpl, boolean resolveGetInput) throws JToscaException {
+ init(_path, _parsedParams, aFile, yamlDictTpl, resolveGetInput);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void init(String _path,
+ LinkedHashMap<String, Object> _parsedParams,
+ boolean aFile,
+ LinkedHashMap<String, Object> yamlDictTpl, boolean _resolveGetInput) throws JToscaException {
ThreadLocalsHolder.setCollector(new ExceptionCollector(_path));
csarTempDir = null;
nestedToscaTplsWithTopology = new ConcurrentHashMap<>();
nestedToscaTemplatesWithTopology = new ArrayList<TopologyTemplate>();
+ resolveGetInput = _resolveGetInput;
if(_path != null && !_path.isEmpty()) {
// save the original input path
_getAllCustomDefs(imports),
relationshipTypes,
parsedParams,
- null);
+ null,
+ resolveGetInput);
}
private ArrayList<Input> _inputs() {
_getAllCustomDefs(alim),
relationshipTypes,
parsedParams,
- nt);
+ nt,
+ resolveGetInput);
if(topologyWithSubMapping.getSubstitutionMappings() != null) {
// Record nested topology templates in top level template
//nestedToscaTemplatesWithTopology.add(topologyWithSubMapping);
// for all folders in extdir
File extDir = new File(extdir);
File extDirList[] = extDir.listFiles();
- if (extDirList == null) {
- String a = "aaaa";
-
- }
if (extDirList != null) {
for(File f: extDirList) {
if(f.isDirectory()) {
import java.util.*;
import org.openecomp.sdc.toscaparser.api.TopologyTemplate;
+import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
public abstract class Function {
}
@SuppressWarnings("unchecked")
- public static Object getFunction(TopologyTemplate ttpl,Object context,Object rawFunctionObj) {
+ public static Object getFunction(TopologyTemplate ttpl,Object context,Object rawFunctionObj, boolean resolveGetInput) {
// Gets a Function instance representing the provided template function.
// If the format provided raw_function format is not relevant for template
if (rawFunctionObj instanceof LinkedHashMap) { // In map type case
LinkedHashMap rawFunction = ((LinkedHashMap) rawFunctionObj);
if(rawFunction.size() == 1) { // End point
- return getFunctionForObjectItem(ttpl, context, rawFunction);
+ return getFunctionForObjectItem(ttpl, context, rawFunction, resolveGetInput);
} else {
// iterate over map nested properties in recursion, convert leaves to function,
// and collect them in the same hierarchy as the original map.
LinkedHashMap rawFunctionObjMap = new LinkedHashMap();
for (Object rawFunctionObjItem: rawFunction.entrySet()) {
- Object itemValue = getFunction(ttpl, context, ((Map.Entry)rawFunctionObjItem).getValue());
+ Object itemValue = getFunction(ttpl, context, ((Map.Entry)rawFunctionObjItem).getValue(), resolveGetInput);
rawFunctionObjMap.put(((Map.Entry)rawFunctionObjItem).getKey(), itemValue);
}
return rawFunctionObjMap;
// and collect them in the same hierarchy as the original list.
ArrayList<Object> rawFunctionObjList = new ArrayList<>();
for (Object rawFunctionObjItem: (ArrayList) rawFunctionObj) {
- rawFunctionObjList.add(getFunction(ttpl, context, rawFunctionObjItem));
+ rawFunctionObjList.add(getFunction(ttpl, context, rawFunctionObjItem, resolveGetInput));
}
return rawFunctionObjList;
}
return rawFunctionObj;
}
- private static Object getFunctionForObjectItem(TopologyTemplate ttpl, Object context, Object rawFunctionObjItem) {
+ private static Object getFunctionForObjectItem(TopologyTemplate ttpl, Object context, Object rawFunctionObjItem, boolean resolveGetInput) {
if(isFunction(rawFunctionObjItem)) {
LinkedHashMap<String, Object> rawFunction = (LinkedHashMap<String, Object>) rawFunctionObjItem;
String funcName = (new ArrayList<String>(rawFunction.keySet())).get(0);
funcArgs.add(oargs);
}
- if (funcType.equals("GetInput")) {
- return new GetInput(ttpl, context, funcName, funcArgs);
- } else if (funcType.equals("GetAttribute")) {
- return new GetAttribute(ttpl, context, funcName, funcArgs);
- } else if (funcType.equals("GetProperty")) {
- return new GetProperty(ttpl, context, funcName, funcArgs);
- } else if (funcType.equals("GetOperationOutput")) {
- return new GetOperationOutput(ttpl, context, funcName, funcArgs);
- } else if (funcType.equals("Concat")) {
- return new Concat(ttpl, context, funcName, funcArgs);
- } else if (funcType.equals("Token")) {
- return new Token(ttpl, context, funcName, funcArgs);
+ switch (funcType) {
+ case "GetInput":
+ if (resolveGetInput) {
+ GetInput input = new GetInput(ttpl, context, funcName, funcArgs);
+ return input.result();
+ }
+ return new GetInput(ttpl, context, funcName, funcArgs);
+ case "GetAttribute":
+ return new GetAttribute(ttpl, context, funcName, funcArgs);
+ case "GetProperty":
+ return new GetProperty(ttpl, context, funcName, funcArgs);
+ case "GetOperationOutput":
+ return new GetOperationOutput(ttpl, context, funcName, funcArgs);
+ case "Concat":
+ return new Concat(ttpl, context, funcName, funcArgs);
+ case "Token":
+ return new Token(ttpl, context, funcName, funcArgs);
}
}
}
}
Object prop = foundProp.getValue();
if(prop instanceof Function) {
- Function.getFunction(toscaTpl,context, prop);
+ Function.getFunction(toscaTpl,context, prop, toscaTpl.getResolveGetInput());
}
}
else if(args.size() >= 3) {
if(propertyValue instanceof Function) {
return ((Function)propertyValue).result();
}
- return Function.getFunction(toscaTpl,context,propertyValue);
+ return Function.getFunction(toscaTpl,context,propertyValue, toscaTpl.getResolveGetInput());
}
public String getNodeTemplateName() {