diff options
Diffstat (limited to 'common-be')
50 files changed, 917 insertions, 302 deletions
diff --git a/common-be/pom.xml b/common-be/pom.xml index 970f533ae5..6a10d8476a 100644 --- a/common-be/pom.xml +++ b/common-be/pom.xml @@ -28,27 +28,6 @@ </dependency> <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <version>${logback.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j-api.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-core-asl</artifactId> - <version>${codehaus.jackson.core}</version> - <scope>provided</scope> - </dependency> - - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> @@ -61,7 +40,13 @@ <scope>provided</scope> </dependency> - <!-- TEST --> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -74,33 +59,6 @@ <build> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId>fr.fastconnect</groupId> - <artifactId>plantuml-maven-plugin</artifactId> - <versionRange>[1.0.0,)</versionRange> - <goals> - <goal>plant</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java index 5fecac429a..9499529f03 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ComponentMetadataDataDefinition.java @@ -557,4 +557,9 @@ public abstract class ComponentMetadataDataDefinition extends ToscaDataDefinitio return true; } + /** + * Return the type of the actual component - e.g. for a Resource, return the actual VF/CR + * @return + */ + public abstract String getActualComponentType(); } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ResourceMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ResourceMetadataDataDefinition.java index 8dac7ea4c4..da432ca971 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ResourceMetadataDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ResourceMetadataDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.components; -import java.io.Serializable; - import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import java.io.Serializable; + public class ResourceMetadataDataDefinition extends ComponentMetadataDataDefinition implements Serializable { /** @@ -192,4 +192,9 @@ public class ResourceMetadataDataDefinition extends ComponentMetadataDataDefinit return super.equals(obj); } + @Override + public String getActualComponentType() { + return getResourceType().getValue(); + } + } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java index 7a85a763f6..c36c7f053d 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/components/ServiceMetadataDataDefinition.java @@ -169,4 +169,10 @@ public class ServiceMetadataDataDefinition extends ComponentMetadataDataDefiniti return super.equals(obj); } + @Override + public String getActualComponentType() { + + return componentType.getValue(); + } + } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterDataDefinition.java index f618458edf..ea47342ce3 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterDataDefinition.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.List; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class AdditionalInfoParameterDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterInfo.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterInfo.java index cdfe75d156..94aea6d321 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterInfo.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AdditionalInfoParameterInfo.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; - import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import java.io.Serializable; + public class AdditionalInfoParameterInfo extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ArtifactDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ArtifactDataDefinition.java index 49c13a09cd..b42ceab945 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ArtifactDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ArtifactDataDefinition.java @@ -20,15 +20,15 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; -import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; - //import com.google.gson.reflect.TypeToken; public class ArtifactDataDefinition extends ToscaDataDefinition implements Serializable { @@ -86,6 +86,7 @@ public class ArtifactDataDefinition extends ToscaDataDefinition implements Seria if (a.getHeatParameters() != null) this.setHeatParameters(new ArrayList<>(a.getHeatParameters())); this.setGeneratedFromId( a.getGeneratedFromId()); + this.setIsFromCsar(a.getIsFromCsar()); } @@ -350,6 +351,13 @@ public class ArtifactDataDefinition extends ToscaDataDefinition implements Seria public String getGeneratedFromId() { return (String) getToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID); } + public boolean getIsFromCsar(){ + Boolean isFromCsar = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR); + return isFromCsar == null ? Boolean.FALSE: isFromCsar; + } + public void setIsFromCsar(Boolean isFromCsar) { + setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, isFromCsar); + } public void setGeneratedFromId(String generatedFromId) { setToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID, generatedFromId); diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java index 5baed964c7..9327499981 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityDataDefinition.java @@ -20,14 +20,13 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - +import com.google.common.collect.Lists; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; -import com.google.common.collect.Lists; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * Represents the capability of the component or component instance diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityTypeDataDefinition.java index 110e08852b..cecb4f1bf9 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityTypeDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CapabilityTypeDataDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; -import java.util.List; - import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import java.io.Serializable; +import java.util.List; + public class CapabilityTypeDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java index be21a70bbc..57270f6eaa 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; - import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import org.openecomp.sdc.common.util.ValidationUtils; +import java.io.Serializable; + public class ComponentInstanceDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CompositionDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CompositionDataDefinition.java index 853e7cf261..590cdb8a5a 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CompositionDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/CompositionDataDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import java.util.HashMap; +import java.util.Map; + public class CompositionDataDefinition extends ToscaDataDefinition { public Map<String, ComponentInstanceDataDefinition> getComponentInstances() { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java index a048ceb096..923c47de58 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/DataTypeDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; - import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import java.io.Serializable; + public class DataTypeDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ForwardingPathDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ForwardingPathDataDefinition.java new file mode 100644 index 0000000000..bf63e20d38 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ForwardingPathDataDefinition.java @@ -0,0 +1,94 @@ +package org.openecomp.sdc.be.datatypes.elements; + +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.DESCRIPTION; +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.PATH_DESTINATION_PORT_NUMBER; +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.PATH_ELEMENT_LIST; +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.PATH_NAME; +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.PATH_PROTOCOL; +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.TOSCA_RESOURCE_NAME; +import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.UNIQUE_ID; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.io.Serializable; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +public class ForwardingPathDataDefinition extends ToscaDataDefinition implements Serializable { + + @JsonCreator + public ForwardingPathDataDefinition() { + super(); + } + + public ForwardingPathDataDefinition(String name) { + super(); + setName(name); + + } + + public ForwardingPathDataDefinition(ForwardingPathDataDefinition path) { + super(); + setName(path.getName()); + setDestinationPortNumber(path.getDestinationPortNumber()); + setUniqueId(path.getUniqueId()); + setPathElements(path.getPathElements()); + setProtocol(path.getProtocol()); + setDescription(path.getDescription()); + setToscaResourceName(path.getToscaResourceName()); + } + + public String getName() { + return (String) getToscaPresentationValue(PATH_NAME); + } + + public void setName(String name) { + setToscaPresentationValue(PATH_NAME, name); + } + + public ListDataDefinition<ForwardingPathElementDataDefinition> getPathElements() { + return (ListDataDefinition<ForwardingPathElementDataDefinition>) getToscaPresentationValue(PATH_ELEMENT_LIST); + } + + public void setPathElements(ListDataDefinition<ForwardingPathElementDataDefinition> pathElements) { + setToscaPresentationValue(PATH_ELEMENT_LIST, pathElements); + } + + public String getUniqueId() { + return (String) getToscaPresentationValue(UNIQUE_ID); + } + + public void setUniqueId(String uid) { + setToscaPresentationValue(UNIQUE_ID, uid); + } + + public String getProtocol() { + return (String) getToscaPresentationValue(PATH_PROTOCOL); + } + + public void setProtocol(String protocol) { + setToscaPresentationValue(PATH_PROTOCOL, protocol); + } + + public String getDestinationPortNumber() { + return (String) getToscaPresentationValue(PATH_DESTINATION_PORT_NUMBER); + } + + public void setDestinationPortNumber(String destinationPortNumber) { + setToscaPresentationValue(PATH_DESTINATION_PORT_NUMBER, destinationPortNumber); + } + + public String getDescription() { + return (String) getToscaPresentationValue(DESCRIPTION); + } + + public void setDescription(String description) { + setToscaPresentationValue(DESCRIPTION, description); + } + + public String getToscaResourceName() { + return (String) getToscaPresentationValue(TOSCA_RESOURCE_NAME); + } + + public void setToscaResourceName(String toscaResourceName) { + setToscaPresentationValue(TOSCA_RESOURCE_NAME, toscaResourceName); + } +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ForwardingPathElementDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ForwardingPathElementDataDefinition.java new file mode 100644 index 0000000000..3bbe9cae70 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ForwardingPathElementDataDefinition.java @@ -0,0 +1,107 @@ +package org.openecomp.sdc.be.datatypes.elements; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.google.common.base.MoreObjects; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +import java.io.Serializable; +import java.util.Objects; + +public class ForwardingPathElementDataDefinition extends ToscaDataDefinition implements Serializable { + @JsonCreator + public ForwardingPathElementDataDefinition() { + super(); + } + + public ForwardingPathElementDataDefinition(String fromNode, String toNode, String fromCPName, String toCPName , String fromCPOriginId, String toCPOriginId) { + super(); + setFromNode(fromNode); + setToNode(toNode); + setFromCP(fromCPName); + setToCP(toCPName); + setFromCPOriginId(fromCPOriginId); + setToCPOriginId(toCPOriginId); + + } + + public ForwardingPathElementDataDefinition(ForwardingPathElementDataDefinition pathElement) { + super(); + setFromNode(pathElement.getFromNode()); + setToNode(pathElement.getToNode()); + setFromCP(pathElement.getFromCP()); + setToCP(pathElement.getToCP()); + setFromCPOriginId(pathElement.getFromCPOriginId()); + setToCPOriginId(pathElement.getToCPOriginId()); + } + + public String getFromNode() { + return (String) getToscaPresentationValue(JsonPresentationFields.FROM_NODE); + } + + public void setFromNode(String fromNode) { + setToscaPresentationValue(JsonPresentationFields.FROM_NODE, fromNode); + } + + public String getToNode() { + return (String) getToscaPresentationValue(JsonPresentationFields.TO_NODE); + } + + public void setToNode(String toNode) { + setToscaPresentationValue(JsonPresentationFields.TO_NODE, toNode); + } + + public String getFromCP() { + return (String) getToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP); + } + + public void setFromCP(String fromCP) { + setToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP, fromCP); + } + + public String getToCP() { + return (String) getToscaPresentationValue(JsonPresentationFields.PATH_TO_CP); + } + + public void setToCP(String toCP) { + setToscaPresentationValue(JsonPresentationFields.PATH_TO_CP, toCP); + } + + public String getToCPOriginId() { + return (String) getToscaPresentationValue(JsonPresentationFields.PATH_TO_CP_ORIGIN); + } + + public void setToCPOriginId(String toCPOriginId) { + setToscaPresentationValue(JsonPresentationFields.PATH_TO_CP_ORIGIN, toCPOriginId); + } + + public String getFromCPOriginId() { + return (String) getToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP_ORIGIN); + } + + public void setFromCPOriginId(String fromCPOriginId) { + setToscaPresentationValue(JsonPresentationFields.PATH_FROM_CP_ORIGIN, fromCPOriginId); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ForwardingPathElementDataDefinition that = (ForwardingPathElementDataDefinition) o; + return Objects.equals(getFromNode(), that.getFromNode()) && Objects.equals(getToNode(), that.getToNode()) + && Objects.equals(getFromCPOriginId(), that.getFromCPOriginId()) && Objects.equals(getToCPOriginId(), that.getToCPOriginId()); + } + + @Override + public int hashCode() { + return Objects.hash(getFromNode(), getToNode(), getFromCP(),getToCP(), getFromCPOriginId(), getToCPOriginId()); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("fromNode", getFromNode()).add("toNode", getToNode()) + .add("fromCPOriginId", getFromCPOriginId()).add("toCPOriginId", getToCPOriginId()) + .add("fromCPName", getFromCP()).add("toCPName", getToCP()).toString(); + } +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetInputValueDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetInputValueDataDefinition.java index c913eaf0cb..131d41a06a 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetInputValueDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GetInputValueDataDefinition.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.Map; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class GetInputValueDataDefinition extends ToscaDataDefinition implements Serializable{ /** * diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupDataDefinition.java index d4981a72ae..c46e21166c 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupDataDefinition.java @@ -20,15 +20,15 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class GroupDataDefinition extends ToscaDataDefinition implements Serializable { @@ -188,8 +188,8 @@ public class GroupDataDefinition extends ToscaDataDefinition implements Serializ + super.toString() + "]"; } - - - + public boolean containsInstanceAsMember(String instanceId) { + return getMembers() != null && getMembers().values().contains(instanceId); + } } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupInstanceDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupInstanceDataDefinition.java index 03e8cc34bb..04cac38e47 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupInstanceDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupInstanceDataDefinition.java @@ -20,14 +20,14 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class GroupInstanceDataDefinition extends ToscaDataDefinition implements Serializable { private static final long serialVersionUID = -4231181556686542208L; diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java index a250ac4308..18e594e0ce 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/GroupTypeDataDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class GroupTypeDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/HeatParameterDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/HeatParameterDataDefinition.java index 33091473cf..a2440610ae 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/HeatParameterDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/HeatParameterDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; - import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import java.io.Serializable; + public class HeatParameterDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java index 301d888bd2..7afae8a799 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class InterfaceDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java index 0ea3e64f28..b705be49e0 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListCapabilityDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; +import java.util.List; public class ListCapabilityDataDefinition extends ListDataDefinition<CapabilityDataDefinition> { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java index e9969d73de..ab886fa41f 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListDataDefinition.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.be.datatypes.elements; +import com.fasterxml.jackson.annotation.JsonCreator; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -27,11 +32,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import org.codehaus.jackson.annotate.JsonCreator; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - -public class ListDataDefinition<T extends ToscaDataDefinition> extends ToscaDataDefinition { +public class ListDataDefinition<T extends ToscaDataDefinition> extends ToscaDataDefinition implements Serializable { protected List<T> listToscaDataDefinition; @@ -41,14 +42,15 @@ public class ListDataDefinition<T extends ToscaDataDefinition> extends ToscaData } - @JsonCreator public ListDataDefinition(List<T> listToscaDataDefinition) { super(); this.listToscaDataDefinition = listToscaDataDefinition; } + @JsonCreator public ListDataDefinition() { super(); + this.listToscaDataDefinition = new ArrayList<>(); } public List<T> getListToscaDataDefinition() { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListMapPropertiesDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListMapPropertiesDataDefinition.java index f6c0c491f5..368ed1bdc4 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListMapPropertiesDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListMapPropertiesDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; +import java.util.List; public class ListMapPropertiesDataDefinition extends ListDataDefinition<MapPropertiesDataDefinition> { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java index dee3a8a1f3..652ab335c6 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ListRequirementDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; +import java.util.List; public class ListRequirementDataDefinition extends ListDataDefinition<RequirementDataDefinition> { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapArtifactDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapArtifactDataDefinition.java index db32d56c3a..6629d10802 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapArtifactDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapArtifactDataDefinition.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; +import java.util.Map; public class MapArtifactDataDefinition extends MapDataDefinition<ArtifactDataDefinition>{ diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapCapabiltyProperty.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapCapabiltyProperty.java index 6814d41914..5f22e6b401 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapCapabiltyProperty.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapCapabiltyProperty.java @@ -20,10 +20,11 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.Map; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Map; public class MapCapabiltyProperty extends MapDataDefinition<MapPropertiesDataDefinition> { @JsonCreator diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapComponentInstanceExternalRefs.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapComponentInstanceExternalRefs.java new file mode 100644 index 0000000000..0900f44cea --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapComponentInstanceExternalRefs.java @@ -0,0 +1,83 @@ +package org.openecomp.sdc.be.datatypes.elements; + +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +import java.io.Serializable; +import java.util.*; + +/** + * Maps an object type (e.g. "monitoring", "workflows" etc) to a list of external references. + * + * "monitoring" -> { "ref1", "ref2" }, + * "workflows" -> { "ref1", "ref2" } + * + */ +public class MapComponentInstanceExternalRefs extends ToscaDataDefinition implements Serializable { + + private static final long serialVersionUID = 7788408255736272985L; + + //Constructor + public MapComponentInstanceExternalRefs() { + this.setComponentInstanceExternalRefs(new HashMap<String, List<String>>()); + } + + public Map<String, List<String>> getComponentInstanceExternalRefs() { + return (Map<String, List<String>>) getToscaPresentationValue(JsonPresentationFields.EXTERNAL_REF); + } + + public List<String> getExternalRefsByObjectType(String objectType) { + List<String> externalRefsByObjectType = ((Map<String, List<String>>) getToscaPresentationValue(JsonPresentationFields.EXTERNAL_REF)).get(objectType); + return externalRefsByObjectType; + } + + public void setComponentInstanceExternalRefs(Map<String, List<String>> componentInstanceExternalRefs) { + setToscaPresentationValue(JsonPresentationFields.EXTERNAL_REF, componentInstanceExternalRefs); + } + + /** + * Adds a reference to the given object type. Will do nothing if already exist. + * + * @param objectType object type to associate reference to + * @param ref to add + */ + public boolean addExternalRef(String objectType, String ref){ + + List<String> refList = this.getExternalRefsByObjectType(objectType); + + if (refList == null) { + //Create list if does not exist and add it to map + refList = new ArrayList<String>(); + this.getComponentInstanceExternalRefs().put(objectType, refList); + } + + //Add reference to list if does not exist + if (!refList.contains(ref)){ + return refList.add(ref); + } + + return false; + + } + + public boolean deleteExternalRef(String objectType, String ref){ + List<String> refList = this.getExternalRefsByObjectType(objectType); + + if (refList != null) { + return refList.remove(ref); + } else { + return false; + } + } + + public boolean replaceExternalRef(String objectType, String oldRef, String newRef) { + List<String> refList = this.getExternalRefsByObjectType(objectType); + + if (refList != null && !refList.contains(newRef)) { + return Collections.replaceAll(refList, oldRef, newRef); + } else { + return false; + } + } + +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapDataDefinition.java index 597e640165..1ca067e047 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapDataDefinition.java @@ -20,15 +20,17 @@ package org.openecomp.sdc.be.datatypes.elements; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class MapDataDefinition <T extends ToscaDataDefinition> extends ToscaDataDefinition { protected Map<String, T > mapToscaDataDefinition; diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapGroupsDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapGroupsDataDefinition.java index 983f1434c5..cdb48336a7 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapGroupsDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapGroupsDataDefinition.java @@ -20,10 +20,13 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.util.Map; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import java.util.Map; public class MapGroupsDataDefinition extends MapDataDefinition<GroupInstanceDataDefinition>{ diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListCapabiltyDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListCapabiltyDataDefinition.java index 37703df631..f56b59934a 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListCapabiltyDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListCapabiltyDataDefinition.java @@ -20,12 +20,15 @@ package org.openecomp.sdc.be.datatypes.elements; + + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + import java.util.HashMap; import java.util.Map; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - public class MapListCapabiltyDataDefinition extends MapDataDefinition<ListCapabilityDataDefinition> { public MapListCapabiltyDataDefinition(MapListCapabiltyDataDefinition cdt) { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinition.java index 2144dcac69..d4fecb70e3 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapListRequirementDataDefinition.java @@ -20,12 +20,15 @@ package org.openecomp.sdc.be.datatypes.elements; + + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + import java.util.HashMap; import java.util.Map; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - public class MapListRequirementDataDefinition extends MapDataDefinition<ListRequirementDataDefinition> { public MapListRequirementDataDefinition(MapListRequirementDataDefinition cdt) { diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapPropertiesDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapPropertiesDataDefinition.java index 87a7c60d92..eec5bc1fb8 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapPropertiesDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapPropertiesDataDefinition.java @@ -20,12 +20,15 @@ package org.openecomp.sdc.be.datatypes.elements; + + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + import java.util.HashMap; import java.util.Map; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - public class MapPropertiesDataDefinition extends MapDataDefinition<PropertyDataDefinition>{ private String parentName; diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java index 09370f8311..cb09411337 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/OperationDataDefinition.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.Map; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class OperationDataDefinition extends ToscaDataDefinition implements Serializable { /** 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 new file mode 100644 index 0000000000..fd34428855 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyDataDefinition.java @@ -0,0 +1,204 @@ +package org.openecomp.sdc.be.datatypes.elements; + +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * public class representing the component policy, + * described by the next properties: + * + * name + * uniqueId + * type (policy type name) + * typeUid (policy type uniqueId) + * version (version) + * derivedFrom (policy type derivedFrom) + * description + * policyUUID + * invariantUUID + * members + * metadata + * properties + * targets + * isFromCsar + */ +public class PolicyDataDefinition extends ToscaDataDefinition implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -4705371580363581255L; + + /** + * public constructor by default + */ + public PolicyDataDefinition() { + super(); + } + + /** + * public constructor from superclass + * @param policy + */ + public PolicyDataDefinition(Map<String, Object> policy) { + super(policy); + } + + /** + * public copy constructor + * @param other + */ + public PolicyDataDefinition(PolicyDataDefinition other){ + this.setName(other.getName()); + this.setUniqueId(other.getUniqueId()); + this.setPolicyTypeName(other.getPolicyTypeName()); + this.setPolicyTypeUid(other.getPolicyTypeUid()); + this.setVersion(other.getVersion()); + this.setDerivedFrom(other.getDerivedFrom()); + this.setDescription(other.getDescription()); + this.setPolicyUUID(other.getPolicyUUID()); + this.setInvariantUUID(other.getInvariantUUID()); + this.setInvariantName(other.getInvariantName()); + this.setComponentName(other.getComponentName()); + this.setIsFromCsar(other.getIsFromCsar()); + if (other.getProperties() != null) { + this.setProperties(other.getProperties()); + } + if (other.getTargets() != null) { + this.setTargets(other.getTargets()); + } + } + + private void setIsFromCsar(Boolean isFromCsar) { + if(isFromCsar == null){ + setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, false); + } else { + setToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR, isFromCsar); + } + } + + public Boolean getIsFromCsar() { + Boolean isFromCsar = (Boolean) getToscaPresentationValue(JsonPresentationFields.IS_FROM_CSAR); + return ( isFromCsar != null ) ? isFromCsar : false; + } + + public String getComponentName() { + return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME); + } + + public void setComponentName(String componentName) { + setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME, componentName); + } + + public String getInvariantName() { + return (String) getToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME); + } + + public void setInvariantName(Object invariantName) { + 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); + } + + public void setPolicyTypeName(String policyTypeName) { + setToscaPresentationValue(JsonPresentationFields.TYPE, policyTypeName); + } + + public String getPolicyTypeUid() { + return (String) getToscaPresentationValue(JsonPresentationFields.TYPE_UNIQUE_ID); + } + + public void setPolicyTypeUid(String policyTypeUid) { + setToscaPresentationValue(JsonPresentationFields.TYPE_UNIQUE_ID, policyTypeUid); + } + + public String getVersion() { + return (String) getToscaPresentationValue(JsonPresentationFields.VERSION); + } + + public void setVersion(String version) { + setToscaPresentationValue(JsonPresentationFields.VERSION, version); + } + + public String getDerivedFrom() { + return (String) getToscaPresentationValue(JsonPresentationFields.DERIVED_FROM); + } + + public void setDerivedFrom(String derivedFrom) { + setToscaPresentationValue(JsonPresentationFields.DERIVED_FROM, derivedFrom); + } + + public String getDescription() { + return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION); + } + + public void setDescription(String description) { + setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description); + } + + public String getPolicyUUID() { + return (String) getToscaPresentationValue(JsonPresentationFields.UUID); + } + + public void setPolicyUUID(String policyUUID) { + setToscaPresentationValue(JsonPresentationFields.UUID, policyUUID); + } + public String getInvariantUUID() { + return (String) getToscaPresentationValue(JsonPresentationFields.INVARIANT_UUID); + } + + public void setInvariantUUID(String invariantUUID) { + setToscaPresentationValue(JsonPresentationFields.INVARIANT_UUID, invariantUUID); + } + + @SuppressWarnings("unchecked") + public List<PropertyDataDefinition> getProperties() { + return (List<PropertyDataDefinition> ) getToscaPresentationValue(JsonPresentationFields.PROPERTIES); + } + + public void setProperties(List<PropertyDataDefinition> properties) { + setToscaPresentationValue(JsonPresentationFields.PROPERTIES, properties); + } + + @SuppressWarnings("unchecked") + public Map<PolicyTargetType, List<String>> getTargets() { + return (Map<PolicyTargetType, List<String>>) getToscaPresentationValue(JsonPresentationFields.TARGETS); + } + + public void setTargets(Map<PolicyTargetType, List<String>> metadata) { + setToscaPresentationValue(JsonPresentationFields.TARGETS, metadata); + } + + public List<String> resolveComponentInstanceTargets() { + Map<PolicyTargetType, List<String>> targets = getTargets(); + return targets == null ? null: targets.get(PolicyTargetType.COMPONENT_INSTANCES); + } + + public boolean containsCmptInstanceAsTarget(String cmptInstId) { + List<String> componentInstanceTargets = resolveComponentInstanceTargets(); + return componentInstanceTargets != null && componentInstanceTargets.contains(cmptInstId); + } + +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTargetType.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTargetType.java new file mode 100644 index 0000000000..3cf8ce1266 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTargetType.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.be.datatypes.elements; + +import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; + +public enum PolicyTargetType { + + GROUPS("GROUPS"), + COMPONENT_INSTANCES("COMPONENT_INSTANCES"), + TYPE_DOES_NOT_EXIST("TYPE_DOES_NOT_EXIST"); + + private String name; + + PolicyTargetType(String name) { + this.name = name; + } + + public String getName() { + return name; + } + public static PolicyTargetType getByNameIgnoreCase(String name) { + for (PolicyTargetType inst : PolicyTargetType.values()) { + if (inst.getName().equalsIgnoreCase(name)) { + return inst; + } + } + return null; + } +} + diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTypeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTypeDataDefinition.java index 8f73764234..38cb4da1ca 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTypeDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PolicyTypeDataDefinition.java @@ -7,9 +7,9 @@ * 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. @@ -20,146 +20,147 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class PolicyTypeDataDefinition extends ToscaDataDefinition implements Serializable { - /** - * - */ - private static final long serialVersionUID = -3783390539788578388L; + /** + * + */ + private static final long serialVersionUID = -3783390539788578388L; - private String uniqueId; + private String uniqueId; - private String type; + private String type; - private String version; + private String version; - private String derivedFrom; + private String derivedFrom; - private List<String> targets; + private List<String> targets; - private Map<String, String> metadata; + private Map<String, String> metadata; - private String description; + private String description; - /** - * Timestamp of data type creation - */ - private Long creationTime; + /** + * Timestamp of data type creation + */ + private Long creationTime; - /** - * Timestamp of the data type last update - */ - private Long modificationTime; + /** + * Timestamp of the data type last update + */ + private Long modificationTime; - private boolean highestVersion; + private boolean highestVersion; - public PolicyTypeDataDefinition() { + public PolicyTypeDataDefinition() { - } + } - public PolicyTypeDataDefinition(PolicyTypeDataDefinition p) { - this.uniqueId = p.uniqueId; - this.type = p.type; - this.version = p.version; - this.targets = p.targets; - this.metadata = p.metadata; - // this.derivedFromName = p.derivedFromName; - this.description = p.description; - this.creationTime = p.creationTime; - this.modificationTime = p.modificationTime; - } + public PolicyTypeDataDefinition(PolicyTypeDataDefinition p) { + this.uniqueId = p.uniqueId; + this.type = p.type; + this.version = p.version; + this.targets = p.targets; + this.metadata = p.metadata; + this.derivedFrom = p.derivedFrom; + this.description = p.description; + this.creationTime = p.creationTime; + this.modificationTime = p.modificationTime; + this.highestVersion = p.highestVersion; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } - public String getVersion() { - return version; - } + public String getVersion() { + return version; + } - public void setVersion(String version) { - this.version = version; - } + public void setVersion(String version) { + this.version = version; + } - public List<String> getTargets() { - return targets; - } + public List<String> getTargets() { + return targets; + } - public void setTargets(List<String> members) { - this.targets = members; - } + public void setTargets(List<String> members) { + this.targets = members; + } - public Map<String, String> getMetadata() { - return metadata; - } + public Map<String, String> getMetadata() { + return metadata; + } - public void setMetadata(Map<String, String> metadata) { - this.metadata = metadata; - } + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public String getUniqueId() { - return uniqueId; - } + public String getUniqueId() { + return uniqueId; + } - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; - } + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } - public Long getCreationTime() { - return creationTime; - } + public Long getCreationTime() { + return creationTime; + } - public void setCreationTime(Long creationTime) { - this.creationTime = creationTime; - } + public void setCreationTime(Long creationTime) { + this.creationTime = creationTime; + } - public Long getModificationTime() { - return modificationTime; - } + public Long getModificationTime() { + return modificationTime; + } - public void setModificationTime(Long modificationTime) { - this.modificationTime = modificationTime; - } + public void setModificationTime(Long modificationTime) { + this.modificationTime = modificationTime; + } - @Override - public String toString() { - return "PolicyTypeDataDefinition [uniqueId=" + uniqueId + ", type=" + type + ", version=" + version - + ", targets=" + targets + ", metadata=" + metadata + ", description=" + description + ", creationTime=" - + creationTime + ", modificationTime=" + modificationTime + "]"; - } - - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public boolean isHighestVersion() { - return highestVersion; - } - - public void setHighestVersion(boolean isLatestVersion) { - this.highestVersion = isLatestVersion; - } + @Override + public String toString() { + return "PolicyTypeDataDefinition [uniqueId=" + uniqueId + ", type=" + type + ", version=" + version + + ", targets=" + targets + ", metadata=" + metadata + ", description=" + description + ", creationTime=" + + creationTime + ", modificationTime=" + modificationTime + "]"; + } + + public String getDerivedFrom() { + return derivedFrom; + } + + public void setDerivedFrom(String derivedFrom) { + this.derivedFrom = derivedFrom; + } + + public boolean isHighestVersion() { + return highestVersion; + } + + public void setHighestVersion(boolean isLatestVersion) { + this.highestVersion = isLatestVersion; + } } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ProductMetadataDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ProductMetadataDataDefinition.java index 3f044c1d46..d3855b5b1d 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ProductMetadataDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ProductMetadataDataDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition; - public class ProductMetadataDataDefinition extends ComponentMetadataDataDefinition implements Serializable { /** @@ -123,4 +123,9 @@ public class ProductMetadataDataDefinition extends ComponentMetadataDataDefiniti return false; return super.equals(obj); } + + @Override + public String getActualComponentType() { + return getComponentType().getValue(); + } } diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertiesOwner.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertiesOwner.java new file mode 100644 index 0000000000..cee3384a13 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertiesOwner.java @@ -0,0 +1,11 @@ +package org.openecomp.sdc.be.datatypes.elements; + +public interface PropertiesOwner { + + String getUniqueId(); + + String getName(); + + String getNormalizedName(); + +} 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 c338597f40..1092b8f24e 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,13 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class PropertyDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyRule.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyRule.java index 639c6dd118..a23ecfee05 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyRule.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/PropertyRule.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonIgnore; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - public class PropertyRule extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RelationshipInstDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RelationshipInstDataDefinition.java index 0017567031..f1fe93f6ba 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RelationshipInstDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RelationshipInstDataDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; -import java.util.List; - import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; +import java.io.Serializable; +import java.util.List; + public class RelationshipInstDataDefinition extends ToscaDataDefinition implements Serializable { /** diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java index 75f4b857c5..42b828634d 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/RequirementDataDefinition.java @@ -20,14 +20,13 @@ package org.openecomp.sdc.be.datatypes.elements; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - +import com.google.common.collect.Lists; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; -import com.google.common.collect.Lists; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * Represents the requirement of the component or component instance */ diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java index 8d8e518049..e8bd775e78 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/SchemaDefinition.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.be.datatypes.elements; +import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; + import java.io.Serializable; import java.util.List; import java.util.Map; -import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; - /** * Schema allows to create new types that can be used along TOSCA definitions. */ diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java index 9bef5ce887..dfbb7a7c37 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentFieldsEnum.java @@ -44,7 +44,9 @@ public enum ComponentFieldsEnum { SERVICE_API_ARTIFACTS("serviceApiArtifacts"), METADATA("metadata"), CATEGORIES("categories"), - INSTANCE_CAPABILTY_PROPERTIES("instanceCapabiltyProperties"); + INSTANCE_CAPABILTY_PROPERTIES("instanceCapabiltyProperties"), + FORWARDING_PATHS("forwardingPaths"), + POLICIES("policies"); private String value; diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConnectionPointEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConnectionPointEnum.java new file mode 100644 index 0000000000..fd49e29822 --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ConnectionPointEnum.java @@ -0,0 +1,25 @@ +package org.openecomp.sdc.be.datatypes.enums; + +import java.util.Arrays; +import java.util.List; + +public enum ConnectionPointEnum { + + CAPABILITY("capability"), REQUIREMENT("requirement"); + + private String data; + private static List<ConnectionPointEnum> connectionPointEnums = Arrays.asList(values()); + + ConnectionPointEnum(String inData) { + this.data = inData; + } + + @Override + public String toString() { + return data; + } + + public static ConnectionPointEnum getConnectionPointEnum(String data) { + return connectionPointEnums.stream().filter(cp -> cp.toString().equals(data)).findAny().orElse(null); + } +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/EnvironmentStatusEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/EnvironmentStatusEnum.java new file mode 100644 index 0000000000..ef78ea8fdc --- /dev/null +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/EnvironmentStatusEnum.java @@ -0,0 +1,27 @@ +package org.openecomp.sdc.be.datatypes.enums; + +public enum EnvironmentStatusEnum { + UNKNOWN("unknown"), + IN_PROGRESS("in_progress"), + FAILED("failed"), + COMPLETED("completed"); + + private final String name; + + private EnvironmentStatusEnum(String name){ + this.name = name; + } + + public String getName() { + return name; + } + public static EnvironmentStatusEnum getByName(final String name){ + switch(name){ + case ("in_progress") : return IN_PROGRESS; + case ("failed") : return FAILED; + case ("completed") : return COMPLETED; + default: return UNKNOWN; + } + } + +} diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java index bb65e7e7a9..083f8dd544 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java @@ -19,12 +19,8 @@ */ package org.openecomp.sdc.be.datatypes.enums; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; - - -//@JsonDeserialize(using = MyDeserializer.class) +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; public enum JsonPresentationFields { UNIQUE_ID ("uniqueId", GraphPropertyEnum.UNIQUE_ID), @@ -75,6 +71,7 @@ public enum JsonPresentationFields { USER_ID_LAST_UPDATER ("userIdLastUpdater", null), CREATOR_FULL_NAME ("creatorFullName", null), UPDATER_FULL_NAME ("updaterFullName", null), + IS_FROM_CSAR ("isFromCsar", null), ES_ID ("esId", null), ARTIFACT_LABEL ("artifactLabel", null), @@ -136,6 +133,7 @@ public enum JsonPresentationFields { VALID_SOURCE_TYPES ("validSourceTypes", null), REQUIREMENT_ID ("requirementId", null), PARENT_NAME ("parentName", null), + //Relation CAPABILTY_OWNER_ID ("capabilityOwnerId", null), REQUIREMENT_OWNER_ID ("requirementOwnerId", null), @@ -144,7 +142,6 @@ public enum JsonPresentationFields { REQUIREMENT ("requirement", null), //Groups - GROUP_INVARIANT_UUID ("invariantUUID", null), GROUP_UUID ("groupUUID", null), GROUP_MEMBER ("members", null), @@ -162,7 +159,6 @@ public enum JsonPresentationFields { GROUP_INSTANCE_PROPERTIES ("groupInstancesProperties", null), //Component instance - CI_COMPONENT_UID ("componentUid", null), CI_POS_X ("posX", null), CI_POS_Y ("posY", null), @@ -180,7 +176,27 @@ public enum JsonPresentationFields { CI_SOURCE_MODEL_INVARIANT ("sourceModelInvariant", null), CI_SOURCE_MODEL_NAME ("sourceModelName", null), CI_IS_PROXY ("isProxy", null), + + //path + FORWARDING_PATH ("forwardingPath", null), + FROM_NODE ("fromNode", null), + TO_NODE ("toNode", null), + PATH_FROM_CP ("fromCP", null), + PATH_TO_CP ("toCP", null), + PATH_TO_CP_ORIGIN ("toCPOrigin", null), + PATH_FROM_CP_ORIGIN ("fromCPOrigin", null), + PATH_NAME ("pathName", null), + PATH_PROTOCOL ("pathProtocol", null), + PATH_DESTINATION_PORT_NUMBER ("destinationPortNumber", null), + PATH_ELEMENT_LIST ("pathElementList", null), + + TYPE_UNIQUE_ID ("typeUniqueId", null), + METADATA ("metadata", null), + TARGETS ("targets", null), + //External Refs + EXTERNAL_REF ("externalRef", null), + //Workflow Operation WO_TYPE ("operationType",null), WO_INPUT_PARAMETERS ("inputParams",null), diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java index 714e3c6c0a..b295ef7a82 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java @@ -21,17 +21,18 @@ package org.openecomp.sdc.be.datatypes.enums; public enum OriginTypeEnum { - PRODUCT("Product", "Product", "product instance", ComponentTypeEnum.PRODUCT), - SERVICE("Service", "Service", "service instance", ComponentTypeEnum.SERVICE), - VF("VF", "VF (Virtual Function)", "resource instance", ComponentTypeEnum.RESOURCE), - VFC("VFC", "VFC (Virtual Function Component)", "resource instance", ComponentTypeEnum.RESOURCE), - CP("CP", "CP (Connection Point)", "resource instance", ComponentTypeEnum.RESOURCE), - VL("VL", "VL (Virtual Link)", "resource instance", ComponentTypeEnum.RESOURCE), - Configuration("Configuration", "Configuration ()", "resource instance", ComponentTypeEnum.RESOURCE), - VFCMT("VFCMT", "VFCMT (VFC Monitoring Template)", "resource instance", ComponentTypeEnum.RESOURCE), - CVFC("CVFC", "CVFC (Complex Virtual Function Component)", "resource instance", ComponentTypeEnum.RESOURCE), - PNF("PNF", "PNF (Physical Network Function)", "resource instance", ComponentTypeEnum.RESOURCE), - ServiceProxy("Service Proxy", "Service Proxy", "service proxy", ComponentTypeEnum.RESOURCE) + PRODUCT("Product", "Product", "product instance", ComponentTypeEnum.PRODUCT, false), + SERVICE("Service", "Service", "service instance", ComponentTypeEnum.SERVICE, false), + VF("VF", "VF (Virtual Function)", "resource instance", ComponentTypeEnum.RESOURCE, false), + VFC("VFC", "VFC (Virtual Function Component)", "resource instance", ComponentTypeEnum.RESOURCE, true), + CP("CP", "CP (Connection Point)", "resource instance", ComponentTypeEnum.RESOURCE, true), + VL("VL", "VL (Virtual Link)", "resource instance", ComponentTypeEnum.RESOURCE, true), + Configuration("Configuration", "Configuration ()", "resource instance", ComponentTypeEnum.RESOURCE, true), + VFCMT("VFCMT", "VFCMT (VFC Monitoring Template)", "resource instance", ComponentTypeEnum.RESOURCE, true), + CVFC("CVFC", "CVFC (Complex Virtual Function Component)", "resource instance", ComponentTypeEnum.RESOURCE, false), + PNF("PNF", "PNF (Physical Network Function)", "resource instance", ComponentTypeEnum.RESOURCE, false), + CR("CR", "CR (Complex Resource)", "resource instance", ComponentTypeEnum.RESOURCE, false), + ServiceProxy("Service Proxy", "Service Proxy", "service proxy", ComponentTypeEnum.RESOURCE, false) ; private String value; @@ -39,7 +40,7 @@ public enum OriginTypeEnum { private String instanceType; private ComponentTypeEnum componentType; - private OriginTypeEnum(String value, String displayValue, String instanceType, ComponentTypeEnum componentType) { + private OriginTypeEnum(String value, String displayValue, String instanceType, ComponentTypeEnum componentType, boolean isAtomicType) { this.value = value; this.displayValue = displayValue; this.instanceType = instanceType; diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java index a4efafbf75..8e026b146e 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java @@ -27,27 +27,34 @@ package org.openecomp.sdc.be.datatypes.enums; */ public enum ResourceTypeEnum { - VFC("VFC (Virtual Function Component)"), - VF("VF"/* (Virtual Function)" */), - CP("CP (Connection Point)"), - PNF("PNF"/* (Physical Network Function)" */), - CVFC("CVFC"/*Complex Virtual Function Component*/), - VL( "VL (Virtual Link)"), - VFCMT("VFCMT (VFC Monitoring Template)"), - Configuration("Configuration ()"), - ServiceProxy("ServiceProxy ()"), - ABSTRACT("Abstract (Generic VFC/VF/PNF/Service Type)"); + VFC("VFC"/* (Virtual Function Component)"*/, true), + VF("VF"/* (Virtual Function)" */, false), + CR("CR"/* (Complex Resource"*/, false), + CP("CP"/* (Connection Point)"*/, true), + PNF("PNF"/* (Physical Network Function)" */, false), + CVFC("CVFC"/* Complex Virtual Function Component*/, false), + VL("VL"/* (Virtual Link)"*/, true), + VFCMT("VFCMT"/* (VFC Monitoring Template)"*/, true), + Configuration("Configuration ()", true), + ServiceProxy("ServiceProxy ()", true), + ABSTRACT("Abstract (Generic VFC/VF/PNF/Service Type)", true); private String value; + private boolean isAtomicType; - private ResourceTypeEnum(String value) { + private ResourceTypeEnum(String value, boolean isAtomicType) { this.value = value; + this.isAtomicType = isAtomicType; } public String getValue() { return value; } - + + public boolean isAtomicType() { + return isAtomicType; + } + public static ResourceTypeEnum getType(String type) { for (ResourceTypeEnum e : ResourceTypeEnum.values()) { if (e.name().equals(type)) { @@ -56,7 +63,7 @@ public enum ResourceTypeEnum { } return null; } - + public static ResourceTypeEnum getTypeByName(String type) { for (ResourceTypeEnum e : ResourceTypeEnum.values()) { if (e.name().equalsIgnoreCase(type)) { @@ -65,11 +72,13 @@ public enum ResourceTypeEnum { } return null; } -/** - * Returns ResourceTypeEnum matching to received String ignore case - * @param type - * @return - */ + + /** + * Returns ResourceTypeEnum matching to received String ignore case + * + * @param type + * @return + */ public static ResourceTypeEnum getTypeIgnoreCase(String type) { for (ResourceTypeEnum e : ResourceTypeEnum.values()) { if (e.name().toLowerCase().equals(type.toLowerCase())) { @@ -78,8 +87,10 @@ public enum ResourceTypeEnum { } return null; } + /** * Checks if enum exist with given type + * * @param type * @return */ @@ -92,8 +103,10 @@ public enum ResourceTypeEnum { } return false; } + /** * Checks if enum exist with given type ignore case + * * @param type * @return */ @@ -106,4 +119,5 @@ public enum ResourceTypeEnum { } return false; } -} + +}
\ No newline at end of file diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java index 31ca6bb1cd..8be36e526a 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.be.datatypes.tosca; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import fj.data.Either; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,18 +32,12 @@ import java.util.Map.Entry; import java.util.Set; import java.util.stream.Collectors; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonValue; -import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; - -import fj.data.Either; - public abstract class ToscaDataDefinition { protected Map<String, Object> toscaPresentation; public ToscaDataDefinition() { - toscaPresentation = new HashMap<String, Object>(); + toscaPresentation = new HashMap<>(); } @JsonCreator |