Fix 'Tosca Function get_input in Properties Assignment error'-bug
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / PropertyDataDefinition.java
index 6b17c41..ee5cd0e 100644 (file)
@@ -22,7 +22,9 @@ package org.openecomp.sdc.be.datatypes.elements;
 
 import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -56,11 +58,17 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
     private Boolean immutable = Boolean.FALSE;
     private Boolean mappedToComponentProperty = Boolean.TRUE;
     /**
-     * @deprecated use {@link #toscaGetFunction#functionType} instead
+     * @deprecated use {@link #toscaFunction} instead
      */
     @Deprecated
     private ToscaGetFunctionType toscaGetFunctionType;
+    /**
+     * @deprecated use {@link #toscaFunction} instead
+     */
+    @Deprecated
     private ToscaGetFunctionDataDefinition toscaGetFunction;
+    private ToscaFunction toscaFunction;
+    private Collection<SubPropertyToscaFunction> subPropertyToscaFunctions;
 
     private String inputPath;
     private String status;
@@ -71,10 +79,6 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
     private String parentPropertyType;
     private String subPropertyInputPath;
     private List<Annotation> annotations;
-    /**
-     * The resource id which this property belongs to
-     */
-    private String parentUniqueId;
     private List<GetInputValueDataDefinition> getInputValues;
     private Boolean isDeclaredListInput = Boolean.FALSE;
     private List<GetPolicyValueDataDefinition> getPolicyValues;
@@ -104,7 +108,6 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
         this.setType(propertyDataDefinition.getType());
         this.setName(propertyDataDefinition.getName());
         this.setValue(propertyDataDefinition.getValue());
-        this.setRequired(propertyDataDefinition.isRequired());
         this.setHidden(propertyDataDefinition.isHidden());
         this.setLabel(propertyDataDefinition.getLabel());
         this.setImmutable(propertyDataDefinition.isImmutable());
@@ -119,10 +122,12 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
         this.setInstanceUniqueId(propertyDataDefinition.getInstanceUniqueId());
         this.setModel(propertyDataDefinition.getModel());
         this.setPropertyId(propertyDataDefinition.getPropertyId());
-        this.setToscaGetFunctionType(propertyDataDefinition.getToscaGetFunctionType());
         this.setToscaGetFunction(propertyDataDefinition.getToscaGetFunction());
+        this.setToscaGetFunctionType(propertyDataDefinition.getToscaGetFunctionType());
+        this.setToscaFunction(propertyDataDefinition.getToscaFunction());
         this.parentPropertyType = propertyDataDefinition.getParentPropertyType();
         this.subPropertyInputPath = propertyDataDefinition.getSubPropertyInputPath();
+        this.subPropertyToscaFunctions = propertyDataDefinition.getSubPropertyToscaFunctions();
         if (isNotEmpty(propertyDataDefinition.annotations)) {
             this.setAnnotations(propertyDataDefinition.annotations);
         }
@@ -136,7 +141,6 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
         this.setUserCreated(propertyDataDefinition.isUserCreated());
     }
 
-    // @Override
     public boolean isDefinition() {
         return true;
     }
@@ -170,10 +174,11 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
     }
 
     public ToscaGetFunctionType getToscaGetFunctionType() {
-        if (toscaGetFunction != null) {
-            return toscaGetFunction.getFunctionType();
+        if (isToscaGetFunction() && toscaFunction != null) {
+            return ((ToscaGetFunctionDataDefinition) toscaFunction).getFunctionType();
         }
-        return toscaGetFunctionType;
+
+        return null;
     }
 
     public Boolean isHidden() {
@@ -188,6 +193,9 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
         return mappedToComponentProperty;
     }
 
+    /**
+     * The resource id which this property belongs to
+     */
     public String getParentUniqueId() {
         return getOwnerId();
     }
@@ -319,12 +327,22 @@ public class PropertyDataDefinition extends ToscaDataDefinition {
         return (List<Annotation>) getToscaPresentationValue(JsonPresentationFields.ANNOTATIONS);
     }
 
-    public boolean isGetFunction() {
-        return this.toscaGetFunctionType != null || this.toscaGetFunction != null;
+    @JsonIgnoreProperties
+    public boolean isToscaFunction() {
+        return this.toscaGetFunctionType != null || this.toscaFunction != null;
+    }
+
+    @JsonIgnoreProperties
+    public boolean isToscaGetFunction() {
+        return this.toscaFunction != null
+            && (this.toscaFunction.getType() == ToscaFunctionType.GET_ATTRIBUTE
+            || this.toscaFunction.getType() == ToscaFunctionType.GET_INPUT
+            || this.toscaFunction.getType() == ToscaFunctionType.GET_PROPERTY);
     }
 
-    public boolean hasGetFunction() {
-        return this.toscaGetFunction != null;
+    @JsonIgnoreProperties
+    public boolean hasToscaFunction() {
+        return this.toscaFunction != null;
     }
 
 }