From fe4afd47955705bb377583649cb53e2cf4508493 Mon Sep 17 00:00:00 2001 From: talio Date: Sun, 14 Apr 2019 15:37:20 +0300 Subject: Declare properties as policies Change-Id: I54dc7b444e08117097c314cf5f51bd356ac5287d Issue-ID: SDC-2240 Signed-off-by: talio --- common-be/pom.xml | 12 +++++- .../elements/GetPolicyValueDataDefinition.java | 17 +++++++++ .../datatypes/elements/PolicyDataDefinition.java | 34 +++++++---------- .../datatypes/elements/PropertyDataDefinition.java | 44 ++++++++++++++++------ .../be/datatypes/enums/DeclarationTypeEnum.java | 6 +++ 5 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetPolicyValueDataDefinition.java create mode 100644 common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/DeclarationTypeEnum.java (limited to 'common-be') diff --git a/common-be/pom.xml b/common-be/pom.xml index 3ae7db22ef..c02de892b5 100644 --- a/common-be/pom.xml +++ b/common-be/pom.xml @@ -60,8 +60,18 @@ ${junit.version} test + + org.onap.sdc.common + onap-tosca-datatype + ${tosca.datatype.version} + + + org.projectlombok + lombok + ${lombok.version} + - + diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetPolicyValueDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetPolicyValueDataDefinition.java new file mode 100644 index 0000000000..bf552741a5 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetPolicyValueDataDefinition.java @@ -0,0 +1,17 @@ +package org.openecomp.sdc.be.datatypes.elements; + +import java.util.Objects; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter +@EqualsAndHashCode +public class GetPolicyValueDataDefinition { + private String policyId; + private String propertyName; + private String origPropertyValue; + +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyDataDefinition.java index 1e0d5935da..64efe8fd15 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyDataDefinition.java @@ -1,12 +1,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import static java.util.Collections.emptyList; import java.util.List; import java.util.Map; - -import static java.util.Collections.emptyList; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; /** * public class representing the component policy, @@ -27,7 +25,7 @@ import static java.util.Collections.emptyList; * targets * isFromCsar */ -public class PolicyDataDefinition extends ToscaDataDefinition { +public class PolicyDataDefinition extends PropertyDataDefinition { /** * public constructor by default @@ -36,6 +34,10 @@ public class PolicyDataDefinition extends ToscaDataDefinition { super(); } + public PolicyDataDefinition(PropertyDataDefinition propertyDataDefinition) { + super(propertyDataDefinition); + } + /** * public constructor from superclass * @@ -51,6 +53,7 @@ public class PolicyDataDefinition extends ToscaDataDefinition { * @param other */ public PolicyDataDefinition(PolicyDataDefinition other) { + super(other); this.setName(other.getName()); this.setUniqueId(other.getUniqueId()); this.setPolicyTypeName(other.getPolicyTypeName()); @@ -63,6 +66,11 @@ public class PolicyDataDefinition extends ToscaDataDefinition { this.setInvariantName(other.getInvariantName()); this.setComponentName(other.getComponentName()); this.setIsFromCsar(other.getIsFromCsar()); + this.setValue(other.getValue()); + this.setOwnerId(other.getOwnerId()); + this.setType(other.getType()); + this.setInstanceUniqueId(other.getInstanceUniqueId()); + this.setInputPath(other.getInputPath()); if (other.getProperties() != null) { this.setProperties(other.getProperties()); } @@ -100,22 +108,6 @@ public class PolicyDataDefinition extends ToscaDataDefinition { setToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME, invariantName); } - public String getName() { - return (String) getToscaPresentationValue(JsonPresentationFields.NAME); - } - - public void setName(String name) { - setToscaPresentationValue(JsonPresentationFields.NAME, name); - } - - public String getUniqueId() { - return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID); - } - - public void setUniqueId(String uniqueId) { - setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId); - } - public String getPolicyTypeName() { return (String) getToscaPresentationValue(JsonPresentationFields.TYPE); } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java index 88863b2cf5..fed728dade 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyDataDefinition.java @@ -20,13 +20,18 @@ package org.openecomp.sdc.be.datatypes.elements; +import static org.apache.commons.collections.CollectionUtils.isNotEmpty; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; -import java.util.*; - -import static org.apache.commons.collections.CollectionUtils.isNotEmpty; - public class PropertyDataDefinition extends ToscaDataDefinition { private String uniqueId; @@ -59,8 +64,8 @@ public class PropertyDataDefinition extends ToscaDataDefinition { private String inputId; private String instanceUniqueId; private String propertyId; - private String parentPropertyType; - private String subPropertyInputPath; + private String parentPropertyType; + private String subPropertyInputPath; private List annotations; /** @@ -70,6 +75,8 @@ public class PropertyDataDefinition extends ToscaDataDefinition { private List getInputValues; + private List getPolicyValues; + public PropertyDataDefinition() { super(); } @@ -97,32 +104,33 @@ public class PropertyDataDefinition extends ToscaDataDefinition { this.setParentUniqueId(p.getParentUniqueId()); this.setOwnerId(p.getOwnerId()); this.setGetInputValues(p.getGetInputValues()); + this.setGetPolicyValues(p.getGetPolicyValues()); this.setInputPath(p.getInputPath()); this.setStatus(p.getStatus()); this.setInputId(p.getInputId()); this.setInstanceUniqueId(p.getInstanceUniqueId()); this.setPropertyId(p.getPropertyId()); - this.setParentPropertyType(p.getParentPropertyType()); - this.setSubPropertyInputPath(p.getSubPropertyInputPath()); + this.parentPropertyType = p.getParentPropertyType(); + this.subPropertyInputPath = p.getSubPropertyInputPath(); if(isNotEmpty(p.annotations)){ this.setAnnotations(p.annotations); } } public String getParentPropertyType() { - return parentPropertyType; + return parentPropertyType; } public void setParentPropertyType(String parentPropertyType) { - this.parentPropertyType = parentPropertyType; + this.parentPropertyType = parentPropertyType; } public String getSubPropertyInputPath() { - return subPropertyInputPath; + return subPropertyInputPath; } public void setSubPropertyInputPath(String subPropertyInputPath) { - this.subPropertyInputPath = subPropertyInputPath; + this.subPropertyInputPath = subPropertyInputPath; } public String getInputPath() { @@ -269,6 +277,18 @@ public class PropertyDataDefinition extends ToscaDataDefinition { this.getInputValues = getInputValues; } + public List safeGetGetPolicyValues() { + return CollectionUtils.isEmpty(getPolicyValues) ? new ArrayList<>() : getPolicyValues; + } + + public List getGetPolicyValues() { + return getPolicyValues; + } + + public void setGetPolicyValues(List getPolicyValues) { + this.getPolicyValues = getPolicyValues; + } + public String getStatus() { return status; } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/DeclarationTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/DeclarationTypeEnum.java new file mode 100644 index 0000000000..7b78ff9893 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/DeclarationTypeEnum.java @@ -0,0 +1,6 @@ +package org.openecomp.sdc.be.datatypes.enums; + +public enum DeclarationTypeEnum { + INPUT, + POLICY; +} -- cgit 1.2.3-korg