diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib')
90 files changed, 2281 insertions, 3938 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/pom.xml b/openecomp-be/lib/openecomp-tosca-lib/pom.xml index bcca8e70c2..52a4061c2f 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/pom.xml +++ b/openecomp-be/lib/openecomp-tosca-lib/pom.xml @@ -1,23 +1,22 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" 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.core</groupId> + <name>openecomp-tosca-lib</name> + <artifactId>openecomp-tosca-lib</artifactId> <parent> <artifactId>openecomp-sdc-lib</artifactId> <groupId>org.openecomp.sdc</groupId> <version>1.1.0-SNAPSHOT</version> + <relativePath>..</relativePath> </parent> - - <artifactId>openecomp-tosca-lib</artifactId> - <name>openecomp-tosca-lib</name> - - <dependencies> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-utilities-lib</artifactId> <version>${project.version}</version> </dependency> @@ -27,37 +26,61 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-common-lib</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> - <version>1.1.2</version> + <version>${logback.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>RELEASE</version> + <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>1.10.19</version> - <scope>test</scope> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-core</artifactId> + <version>${project.version}</version> </dependency> <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>19.0</version> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-core</artifactId> + <version>${openecomp.sdc.common.version}</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-api</artifactId> + <version>${openecomp.sdc.common.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-tosca-datatype</artifactId> + <version>${openecomp.sdc.common.version}</version> </dependency> - </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${mvn.surefire.version}</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> - - - - -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/lib/openecomp-tosca-lib/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-tosca-lib/pom.xml.versionsBackup new file mode 100644 index 0000000000..be3c3509ad --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/pom.xml.versionsBackup @@ -0,0 +1,87 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + 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.core</groupId> + <name>openecomp-tosca-lib</name> + <dependencies> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-utilities-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-datatypes-lib</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-common-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-core</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-core</artifactId> + <version>1707.0.0-SNAPSHOT</version> + <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-configuration-management-api</artifactId> + <version>1707.0.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.common</groupId> + <artifactId>openecomp-tosca-datatype</artifactId> + <version>1707.0.0-SNAPSHOT</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <useSystemClassLoader>false</useSystemClassLoader> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> + + + <artifactId>openecomp-tosca-lib</artifactId> + + <parent> + <artifactId>openecomp-sdc-lib</artifactId> + <groupId>org.openecomp.sdc</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java index 2da60c0b79..9e353a25df 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java @@ -21,19 +21,17 @@ package org.openecomp.sdc.tosca.datatypes; -public enum ToscaArtifactType { +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; - DEPLOYMENT("tosca.artifacts.Deployment"),; +public class ToscaArtifactType { - private String displayName; + private static Configuration config = ConfigurationManager.lookup(); - ToscaArtifactType(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } + public static String ARTIFACT_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_ARTIFACT_TYPE); + public static String NATIVE_DEPLOYMENT = "tosca.artifacts.Deployment"; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java index d26eb3a83a..b3a0e69c88 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java @@ -21,32 +21,34 @@ package org.openecomp.sdc.tosca.datatypes; -public enum ToscaCapabilityType { - - ROOT("tosca.capabilities.Root"), - NODE("tosca.capabilities.Node"), - CONTAINER("tosca.capabilities.Container"), - NETWORK_BINDABLE("tosca.capabilities.network.Bindable"), - SCALABLE("tosca.capabilities.Scalable"), - OPERATING_SYSTEM("tosca.capabilities.OperatingSystem"), - ENDPOINT_ADMIN("tosca.capabilities.Endpoint.Admin"), - ATTACHMENT("tosca.capabilities.Attachment"), - NETWORK_LINKABLE("tosca.capabilities.network.Linkable"), - METRIC("org.openecomp.capabilities.Metric"), - NFV_METRIC("tosca.capabilities.nfv.Metric"), - METRIC_CEILOMETER("org.openecomp.capabilities.metric.Ceilometer"), - METRIC_SNMP_TRAP("org.openecomp.capabilities.metric.SnmpTrap"), - METRIC_SNMP_POLLING("org.openecomp.capabilities.metric.SnmpPolling"),; - - private String displayName; - - ToscaCapabilityType(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } - +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; + +public class ToscaCapabilityType { + + private static Configuration config = ConfigurationManager.lookup(); + + public static String CAPABILITY_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_CAPABILITY_TYPE); + + //TOSCA native types + public static String NATIVE_ROOT = "tosca.capabilities.Root"; + public static String NATIVE_NODE = "tosca.capabilities.Node"; + public static String NATIVE_CONTAINER = "tosca.capabilities.Container"; + public static String NATIVE_COMPUTE = "tosca.capabilities.Compute"; + public static String NATIVE_NETWORK_BINDABLE = "tosca.capabilities.network.Bindable"; + public static String NATIVE_SCALABLE = "tosca.capabilities.Scalable"; + public static String NATIVE_OPERATING_SYSTEM = "tosca.capabilities.OperatingSystem"; + public static String NATIVE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"; + public static String NATIVE_ATTACHMENT = "tosca.capabilities.Attachment"; + public static String NATIVE_NETWORK_LINKABLE = "tosca.capabilities.network.Linkable"; + public static String NATIVE_NFV_METRIC = "tosca.capabilities.nfv.Metric"; + + //Additional types + public static String METRIC = CAPABILITY_PREFIX + "Metric"; + public static String METRIC_CEILOMETER = CAPABILITY_PREFIX + "metric.Ceilometer"; + public static String METRIC_SNMP_TRAP = CAPABILITY_PREFIX + "metric.SnmpTrap"; + public static String METRIC_SNMP_POLLING = CAPABILITY_PREFIX + "metric.SnmpPolling"; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java index 2a9df65b17..37d1d2c4ba 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java @@ -21,64 +21,83 @@ package org.openecomp.sdc.tosca.datatypes; -public enum ToscaDataType { +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; - ROOT("tosca.datatypes.Root"), - NETWORK_NETWORK_INFO("tosca.datatypes.network.NetworkInfo"), - NETWORK_PORT_INFO("tosca.datatypes.network.PortInfo"), - NOVA_SERVER_PORT_EXTRA_PROPERTIES( - "org.openecomp.datatypes.heat.novaServer.network.PortExtraProperties"), - NETWORK_ADDRESS_PAIR("org.openecomp.datatypes.heat.network.AddressPair"), - NEUTRON_PORT_FIXED_IPS("org.openecomp.datatypes.heat.neutron.port.FixedIps"), - CONTRAIL_NETWORK_RULE("org.openecomp.datatypes.heat.contrail.network.rule.Rule"), - CONTRAIL_NETWORK_RULE_LIST("org.openecomp.datatypes.heat.contrail.network.rule.RuleList"), - CONTRAIL_NETWORK_RULE_PORT_PAIRS("org.openecomp.datatypes.heat.contrail.network.rule.PortPairs"), - CONTRAIL_NETWORK_RULE_VIRTUAL_NETWORK( - "org.openecomp.datatypes.heat.contrail.network.rule.VirtualNetwork"), - CONTRAILV2_NETWORK_RULE("org.openecomp.datatypes.heat.contrailV2.network.rule.Rule"), - CONTRAILV2_NETWORK_RULE_LIST("org.openecomp.datatypes.heat.contrailV2.network.rule.RuleList"), - CONTRAILV2_NETWORK_RULE_SRC_PORT_PAIRS( - "org.openecomp.datatypes.heat.contrailV2.network.rule.SrcPortPairs"), - CONTRAILV2_NETWORK_RULE_DST_PORT_PAIRS( - "org.openecomp.datatypes.heat.contrailV2.network.rule.DstPortPairs"), - CONTRAILV2_NETWORK_RULE_DST_VIRTUAL_NETWORK( - "org.openecomp.datatypes.heat.contrailV2.network.rule.DstVirtualNetwork"), - CONTRAILV2_NETWORK_RULE_SRC_VIRTUAL_NETWORK( - "org.openecomp.datatypes.heat.contrailV2.network.rule.SrcVirtualNetwork"), - CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES( - "org.openecomp.datatypes.heat.contrailV2.virtual.machine.interface.Properties"), - CONTRAILV2_NETWORK_RULE_ACTION_LIST( - "org.openecomp.datatypes.heat.contrailV2.network.rule.ActionList"), - CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA( - "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.IpamRefData"), - CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST( - "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.ref.data.IpamSubnetList"), - CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET( - "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.ref.data.IpamSubnet"), - CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA( - "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.RefData"), - CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE( - "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.RefDataSequence"), - NOVA_SERVER_NETWORK_ADDRESS_INFO("org.openecomp.datatypes.heat.novaServer.network.AddressInfo"), - NEUTRON_SUBNET("org.openecomp.datatypes.heat.network.neutron.Subnet"), - NETWORK_ALLOCATION_POOL("org.openecomp.datatypes.heat.network.AllocationPool"), - NETWORK_HOST_ROUTE("org.openecomp.datatypes.heat.network.subnet.HostRoute"), - SUBSTITUTION_FILTER("org.openecomp.datatypes.heat.substitution.SubstitutionFilter"), - SUBSTITUTION_FILTERING("org.openecomp.datatypes.heat.substitution.SubstitutionFiltering"), - NEUTRON_SECURITY_RULES_RULE("org.openecomp.datatypes.heat.network.neutron.SecurityRules.Rule"), - CONTRAIL_STATIC_ROUTE("org.openecomp.datatypes.heat.network.contrail.port.StaticRoute"), - CONTRAIL_ADDRESS_PAIR("org.openecomp.datatypes.heat.network.contrail.AddressPair"), - CONTRAIL_INTERFACE_DATA("org.openecomp.datatypes.heat.network.contrail.InterfaceData"); +public class ToscaDataType { - private String displayName; + private static Configuration config = ConfigurationManager.lookup(); - ToscaDataType(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } + public static String DATA_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_DATA_TYPE); + //TOSCA native types + public static String NATIVE_ROOT = "tosca.datatypes.Root"; + public static String NATIVE_NETWORK_NETWORK_INFO = "tosca.datatypes.network.NetworkInfo"; + public static String NATIVE_NETWORK_PORT_INFO = "tosca.datatypes.network.PortInfo"; + //Additional types + public static String NOVA_SERVER_PORT_EXTRA_PROPERTIES = + DATA_TYPE_PREFIX + "heat.novaServer.network.PortExtraProperties"; + public static String NETWORK_ADDRESS_PAIR = DATA_TYPE_PREFIX + "heat.network.AddressPair"; + public static String NEUTRON_PORT_FIXED_IPS = DATA_TYPE_PREFIX + "heat.neutron.port.FixedIps"; + public static String CONTRAIL_NETWORK_RULE = DATA_TYPE_PREFIX + "heat.contrail.network.rule.Rule"; + public static String CONTRAIL_NETWORK_RULE_LIST = + DATA_TYPE_PREFIX + "heat.contrail.network.rule.RuleList"; + public static String CONTRAIL_NETWORK_RULE_PORT_PAIRS = + DATA_TYPE_PREFIX + "heat.contrail.network.rule.PortPairs"; + public static String CONTRAIL_NETWORK_RULE_VIRTUAL_NETWORK = + DATA_TYPE_PREFIX + "heat.contrail.network.rule.VirtualNetwork"; + public static String CONTRAILV2_NETWORK_RULE = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.Rule"; + public static String CONTRAILV2_NETWORK_RULE_LIST = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.RuleList"; + public static String CONTRAILV2_NETWORK_RULE_SRC_PORT_PAIRS = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.SrcPortPairs"; + public static String CONTRAILV2_NETWORK_RULE_DST_PORT_PAIRS = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.DstPortPairs"; + public static String CONTRAILV2_NETWORK_RULE_DST_VIRTUAL_NETWORK = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.DstVirtualNetwork"; + public static String CONTRAILV2_NETWORK_RULE_SRC_VIRTUAL_NETWORK = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.SrcVirtualNetwork"; + public static String CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.machine.interface.Properties"; + public static String CONTRAILV2_NETWORK_RULE_ACTION_LIST = + DATA_TYPE_PREFIX + "heat.contrailV2.network.rule.ActionList"; + public static String CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.network.rule.IpamRefData"; + public static String CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.network.rule.ref.data.IpamSubnetList"; + public static String CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.network.rule.ref.data.IpamSubnet"; + public static String CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.network.rule.RefData"; + public static String CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.network.rule.RefDataSequence"; + public static String NOVA_SERVER_NETWORK_ADDRESS_INFO = + DATA_TYPE_PREFIX + "heat.novaServer.network.AddressInfo"; + public static String NEUTRON_SUBNET = DATA_TYPE_PREFIX + "heat.network.neutron.Subnet"; + public static String NETWORK_ALLOCATION_POOL = DATA_TYPE_PREFIX + "heat.network.AllocationPool"; + public static String NETWORK_HOST_ROUTE = DATA_TYPE_PREFIX + "heat.network.subnet.HostRoute"; + public static String SUBSTITUTION_FILTERING = + DATA_TYPE_PREFIX + "heat.substitution.SubstitutionFiltering"; + public static String NEUTRON_SECURITY_RULES_RULE = + DATA_TYPE_PREFIX + "heat.network.neutron.SecurityRules.Rule"; + public static String CONTRAIL_STATIC_ROUTE = + DATA_TYPE_PREFIX + "heat.network.contrail.port.StaticRoute"; + public static String CONTRAIL_ADDRESS_PAIR = + DATA_TYPE_PREFIX + "heat.network.contrail.AddressPair"; + public static String CONTRAIL_INTERFACE_DATA = + DATA_TYPE_PREFIX + "heat.network.contrail.InterfaceData"; + public static String CONTRAILV2_VIRTUAL_MACHINE_SUB_INTERFACE_PROPERTIES = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.machine.subInterface.Properties"; + public static String CONTRAILV2_VIRTUAL_MACHINE_SUB_INTERFACE_MAC_ADDRESS = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.machine.subInterface.MacAddress"; + public static String CONTRAILV2_VIRTUAL_MACHINE_SUB_INTERFACE_ADDRESS_PAIRS = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.machine.subInterface.AddressPairs"; + public static String CONTRAILV2_VIRTUAL_MACHINE_SUB_INTERFACE_ADDRESS_PAIR = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.machine.subInterface.AddressPair"; + public static String CONTRAILV2_VIRTUAL_MACHINE_SUB_INTERFACE_ADDRESS_PAIR_IP = + DATA_TYPE_PREFIX + "heat.contrailV2.virtual.machine.subInterface.AddressPairIp"; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java index 97fec7ae7d..584bf3036f 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java @@ -21,5 +21,12 @@ package org.openecomp.sdc.tosca.datatypes; public enum ToscaElementTypes { - CAPABILITY_TYPE + CAPABILITY_TYPE, + NODE_TYPE, + ARTIFACT_TYPE, + DATA_TYPE, + INTERFCAE_TYPE, + RELATIONSHIP_TYPE, + GROUP_TYPE, + POLICY_TYPE } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java index 5422fa6dc9..c2070c34f4 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java @@ -20,21 +20,22 @@ package org.openecomp.sdc.tosca.datatypes; +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; -public enum ToscaGroupType { +public class ToscaGroupType { - ROOT("tosca.groups.Root"), - HEAT_STACK("org.openecomp.groups.heat.HeatStack"),; + private static Configuration config = ConfigurationManager.lookup(); - private String displayName; + public static String GROUP_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_GROUP_TYPE); - ToscaGroupType(String displayName) { - this.displayName = displayName; - } + //TOSCA native types + public static String NATIVE_ROOT = "tosca.groups.Root"; - public String getDisplayName() { - return displayName; - } + //Additional types + public static String HEAT_STACK = GROUP_TYPE_PREFIX + "heat.HeatStack"; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java index c7c5a6e64e..22658c8b1c 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java @@ -20,143 +20,66 @@ package org.openecomp.sdc.tosca.datatypes; -import org.openecomp.sdc.tosca.services.ToscaConstants; +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +public class ToscaNodeType { -/** - * The enum Tosca node type. - */ -public enum ToscaNodeType { + private static Configuration config = ConfigurationManager.lookup(); - /** - * Compute tosca node type. - */ - COMPUTE("tosca.nodes.Compute"), - /** - * Root tosca node type. - */ - ROOT("tosca.nodes.Root"), - /** - * Block storage tosca node type. - */ - BLOCK_STORAGE("tosca.nodes.BlockStorage"), - /** - * Network tosca node type. - */ - NETWORK("tosca.nodes.network.Network"), - /** - * Network port tosca node type. - */ - NETWORK_PORT("tosca.nodes.network.Port"), - /** - * Nova server tosca node type. - */ - NOVA_SERVER(ToscaConstants.NODES_PREFIX + "nova.Server"), - /** - * Cinder volume tosca node type. - */ - CINDER_VOLUME(ToscaConstants.NODES_PREFIX + "cinder.Volume"), - /** - * Neutron net tosca node type. - */ - NEUTRON_NET("org.openecomp.resource.vl.nodes.heat.network.neutron.Net"), - /** - * Neutron port tosca node type. - */ - NEUTRON_PORT("org.openecomp.resource.cp.nodes.heat.network.neutron.Port"), - /** - * Neutron security rules tosca node type. - */ - NEUTRON_SECURITY_RULES("org.openecomp.resource.vfc.rules.nodes" - + ".heat.network.neutron.SecurityRules"), - /** - * Contrail virtual network tosca node type. - */ - CONTRAIL_VIRTUAL_NETWORK("org.openecomp.resource.vl.nodes.heat.network.contrail.VirtualNetwork"), - /** - * Contrail network rule tosca node type. - */ - CONTRAIL_NETWORK_RULE("org.openecomp.resource.vfc." - + "rules.nodes.heat.network.contrail.NetworkRules"), - /** - * Contrailv 2 virtual network tosca node type. - */ - CONTRAILV2_VIRTUAL_NETWORK("org.openecomp.resource.vl.nodes." - + "heat.network.contrailV2.VirtualNetwork"), - /** - * Contrailv 2 network rule tosca node type. - */ - CONTRAILV2_NETWORK_RULE( - "org.openecomp.resource.vfc.rules.nodes.heat.network.contrailV2.NetworkRules"), - /** - * Contrailv 2 virtual machine interface tosca node type. - */ - CONTRAILV2_VIRTUAL_MACHINE_INTERFACE( - "org.openecomp.resource.cp.nodes.heat.contrailV2.VirtualMachineInterface"), - /** - * Abstract substitute tosca node type. - */ - ABSTRACT_SUBSTITUTE("org.openecomp.resource.abstract.nodes.AbstractSubstitute"), - /** - * Contrail compute tosca node type. - */ - CONTRAIL_COMPUTE(ToscaConstants.NODES_PREFIX + "contrail.Compute"), - /** - * Contrail port tosca node type. - */ - CONTRAIL_PORT("org.openecomp.resource.cp.nodes.heat.network.contrail.Port"), - /** - * Contrail abstract substitute tosca node type. - */ - CONTRAIL_ABSTRACT_SUBSTITUTE("org.openecomp.resource.abstract." - + "nodes.contrail.AbstractSubstitute"),; + public static String VFC_NODE_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_NODE_TYPE_VFC); + public static String CP_NODE_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_NODE_TYPE_CP); + public static String NETWORK_NODE_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_NODE_TYPE_NETWORK); + public static String ABSTRACT_NODE_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_NODE_TYPE_ABSTARCT); + public static String RULE_NODE_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_NODE_TYPE_RULE); - private static final Map<String, ToscaNodeType> mMap = - Collections.unmodifiableMap(initializeMapping()); - private String displayName; + //TOSCA native types + public static String NATIVE_COMPUTE = "tosca.nodes.Compute"; + public static String NATIVE_ROOT = "tosca.nodes.Root"; + public static String NATIVE_BLOCK_STORAGE = "tosca.nodes.BlockStorage"; + public static String NATIVE_NETWORK = "tosca.nodes.network.Network"; + public static String NATIVE_NETWORK_PORT = "tosca.nodes.network.Port"; - ToscaNodeType(String displayName) { - this.displayName = displayName; - } + //Additional types + public static String NOVA_SERVER = VFC_NODE_TYPE_PREFIX + "heat.nova.Server"; + public static String CINDER_VOLUME = VFC_NODE_TYPE_PREFIX + "heat.cinder.Volume"; + public static String COMPUTE = VFC_NODE_TYPE_PREFIX + "Compute"; + public static String CONTRAIL_COMPUTE = VFC_NODE_TYPE_PREFIX + "heat.contrail.Compute"; - /** - * Initialize mapping map. - * - * @return the map - */ - public static Map<String, ToscaNodeType> initializeMapping() { - Map<String, ToscaNodeType> toscaMap = new HashMap<>(); - for (ToscaNodeType v : ToscaNodeType.values()) { - toscaMap.put(v.displayName, v); - } - return toscaMap; - } + public static String NEUTRON_SECURITY_RULES = + RULE_NODE_TYPE_PREFIX + "heat.network.neutron.SecurityRules"; + public static String CONTRAILV2_NETWORK_RULE = + RULE_NODE_TYPE_PREFIX + "heat.network.contrailV2.NetworkRules"; + public static String CONTRAIL_NETWORK_RULE = + RULE_NODE_TYPE_PREFIX + "heat.network.contrail.NetworkRules"; - /** - * Gets tosca node type by display name. - * - * @param displayName the display name - * @return the tosca node type by display name - */ - public static ToscaNodeType getToscaNodeTypeByDisplayName(String displayName) { - if (mMap.containsKey(displayName)) { - return mMap.get(displayName); - } - return null; - } + public static String NEUTRON_NET = NETWORK_NODE_TYPE_PREFIX + "heat.network.neutron.Net"; + public static String CONTRAILV2_VIRTUAL_NETWORK = + NETWORK_NODE_TYPE_PREFIX + "heat.network.contrailV2.VirtualNetwork"; + public static String CONTRAIL_VIRTUAL_NETWORK = + NETWORK_NODE_TYPE_PREFIX + "heat.network.contrail.VirtualNetwork"; + public static String NETWORK = NETWORK_NODE_TYPE_PREFIX + "network.Network"; - /** - * Gets display name. - * - * @return the display name - */ - public String getDisplayName() { - return displayName; - } + public static String NEUTRON_PORT = CP_NODE_TYPE_PREFIX + "heat.network.neutron.Port"; + public static String CONTRAILV2_VIRTUAL_MACHINE_INTERFACE = + CP_NODE_TYPE_PREFIX + "heat.contrailV2.VirtualMachineInterface"; + public static String CONTRAIL_PORT = CP_NODE_TYPE_PREFIX + "heat.network.contrail.Port"; + public static String NETWORK_PORT = CP_NODE_TYPE_PREFIX + "network.Port"; + public static String NETWORK_SUB_INTERFACE = CP_NODE_TYPE_PREFIX + "network.SubInterface"; + public static String CONTRAILV2_VLAN_SUB_INTERFACE = CP_NODE_TYPE_PREFIX + + "heat.network.contrailV2.VLANSubInterface"; + public static String ABSTRACT_SUBSTITUTE = ABSTRACT_NODE_TYPE_PREFIX + "AbstractSubstitute"; + public static String VFC_ABSTRACT_SUBSTITUTE = ABSTRACT_NODE_TYPE_PREFIX + "VFC"; + public static String CONTRAIL_ABSTRACT_SUBSTITUTE = + ABSTRACT_NODE_TYPE_PREFIX + "contrail.AbstractSubstitute"; } + diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java index 38195782d2..ed0232929b 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java @@ -20,24 +20,21 @@ package org.openecomp.sdc.tosca.datatypes; -public enum ToscaPolicyType { +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; - PLACEMENT("tosca.policy.placement"), - PLACEMENT_ANTILOCATE("org.openecomp.policies.placement.Antilocate"), - PLACEMENT_COLOCATE("org.openecomp.policies.placement.Colocate"), - PLACEMENT_VALET_AFFINITY("org.openecomp.policies.placement.valet.Affinity"), - PLACEMENT_VALET_EXCLUSIVITY("org.openecomp.policies.placement.valet.Exclusivity"), - PLACEMENT_VALET_DIVERSITY("org.openecomp.policies.placement.valet.Diversity"); +public class ToscaPolicyType { - private String displayName; + private static Configuration config = ConfigurationManager.lookup(); - ToscaPolicyType(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } + public static String POLICY_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_POLICY_TYPE); + //TOSCA native types + public static String NATIVE_PLACEMENT = "tosca.policy.placement"; + //Additional types + public static String PLACEMENT_ANTILOCATE = POLICY_TYPE_PREFIX + "placement.Antilocate"; + public static String PLACEMENT_COLOCATE = POLICY_TYPE_PREFIX + "placement.Colocate"; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java index 03a35bd4d0..f1ef5ab234 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java @@ -20,25 +20,24 @@ package org.openecomp.sdc.tosca.datatypes; -public enum ToscaRelationshipType { +import org.openecomp.config.api.Configuration; +import org.openecomp.config.api.ConfigurationManager; +import org.openecomp.sdc.tosca.services.ConfigConstants; - ROOT("tosca.relationships.Root"), - NATIVE_ATTACHES_TO("tosca.relationships.AttachesTo"), - DEPENDS_ON("tosca.relationships.DependsOn"), - NETWORK_LINK_TO("tosca.relationships.network.LinksTo"), - NETWORK_BINDS_TO("tosca.relationships.network.BindsTo"), - CINDER_VOLUME_ATTACHES_TO("org.openecomp.relationships.heat.cinder.VolumeAttachesTo"), - ATTACHES_TO("org.openecomp.relationships.AttachesTo"),; +public class ToscaRelationshipType { - private String displayName; + private static Configuration config = ConfigurationManager.lookup(); - ToscaRelationshipType(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } + public static String RELATIONSHIP_TYPE_PREFIX = + config.getAsString(ConfigConstants.NAMESPACE, ConfigConstants.PREFIX_RELATIONSHIP_TYPE); + public static String NATIVE_ROOT = "tosca.relationships.Root"; + public static String NATIVE_ATTACHES_TO = "tosca.relationships.AttachesTo"; + public static String NATIVE_DEPENDS_ON = "tosca.relationships.DependsOn"; + public static String NATIVE_NETWORK_LINK_TO = "tosca.relationships.network.LinksTo"; + public static String NATIVE_NETWORK_BINDS_TO = "tosca.relationships.network.BindsTo"; + public static String CINDER_VOLUME_ATTACHES_TO = + RELATIONSHIP_TYPE_PREFIX + "VolumeAttachesTo"; + public static String ATTACHES_TO = RELATIONSHIP_TYPE_PREFIX + "AttachesTo"; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java index 70b23ae3f6..573ce395d5 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java @@ -27,6 +27,9 @@ import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import java.util.Collections; import java.util.Map; +/** + * Tosca service model. + */ public class ToscaServiceModel implements AsdcModel { private FileContentHandler artifactFiles; private Map<String, ServiceTemplate> serviceTemplates; @@ -48,24 +51,48 @@ public class ToscaServiceModel implements AsdcModel { } + /** + * Gets artifact files. + * + * @return the artifact files + */ public FileContentHandler getArtifactFiles() { - return artifactFiles;//MapUtils.isEmpty(artifactFiles) ? Collections.EMPTY_MAP - // : Collections.unmodifiableMap(artifactFiles); + return artifactFiles; } + /** + * Gets service templates. + * + * @return the service templates + */ public Map<String, ServiceTemplate> getServiceTemplates() { return Collections.unmodifiableMap(serviceTemplates); } + /** + * Sets service templates. + * + * @param serviceTemplates the service templates + */ public void setServiceTemplates(Map<String, ServiceTemplate> serviceTemplates) { this.serviceTemplates = serviceTemplates; } + /** + * Gets entry definition service template. + * + * @return the entry definition service template + */ public String getEntryDefinitionServiceTemplate() { return entryDefinitionServiceTemplate; } + /** + * Sets entry definition service template. + * + * @param entryDefinitionServiceTemplate the entry definition service template + */ public void setEntryDefinitionServiceTemplate(String entryDefinitionServiceTemplate) { this.entryDefinitionServiceTemplate = entryDefinitionServiceTemplate; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaTopologyTemplateElements.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaTopologyTemplateElements.java new file mode 100644 index 0000000000..576bab5df1 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaTopologyTemplateElements.java @@ -0,0 +1,10 @@ +package org.openecomp.sdc.tosca.datatypes; + +public enum ToscaTopologyTemplateElements { + NODE_TEMPLATE, + RELATIONSHIP_TEMPLATE, + GROUP, + POLICY, + WORKFLOW +} + diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java deleted file mode 100644 index 8461fef85f..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class ArtifactDefinition { - private String type; - private String file; - private String repository; - private String description; - private String deploy_path; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getFile() { - return file; - } - - public void setFile(String file) { - this.file = file; - } - - public String getRepository() { - return repository; - } - - public void setRepository(String repository) { - this.repository = repository; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDeploy_path() { - return deploy_path; - } - - public void setDeploy_path(String deployPath) { - this.deploy_path = deployPath; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java deleted file mode 100644 index 80580e97f3..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class ArtifactType { - - private String derived_from; - private String version; - private String description; - private String mime_type; - private List<String> file_ext; - private Map<String, PropertyDefinition> properties; - - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getMime_type() { - return mime_type; - } - - public void setMime_type(String mimeType) { - this.mime_type = mimeType; - } - - public List<String> getFile_ext() { - return file_ext; - } - - public void setFile_ext(List<String> fileExt) { - this.file_ext = fileExt; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java deleted file mode 100644 index 13c93a283d..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class AttributeDefinition { - - private String type; - private String description; - private Object _default; - private Status status; - private EntrySchema entry_schema; - - public AttributeDefinition() { - status = Status.SUPPORTED; - } - - public EntrySchema getEntry_schema() { - return entry_schema; - } - - public void setEntry_schema(EntrySchema entrySchema) { - this.entry_schema = entrySchema; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public Object get_default() { - return _default; - } - - public void set_default(Object defaultValue) { - this._default = defaultValue; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public AttributeDefinition clone() { - AttributeDefinition attributeDefinition = new AttributeDefinition(); - attributeDefinition.setType(this.getType()); - attributeDefinition.setDescription(this.getDescription()); - attributeDefinition.set_default(this.get_default()); - attributeDefinition.setStatus(this.getStatus()); - attributeDefinition.setEntry_schema(this.getEntry_schema().clone()); - return attributeDefinition; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java deleted file mode 100644 index b548f7855c..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.Map; - -public class CapabilityAssignment { - - private Map<String, Object> properties; - private Map<String, Object> attributes; - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public Map<String, Object> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, Object> attributes) { - this.attributes = attributes; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java deleted file mode 100644 index 36dccad6eb..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import org.openecomp.sdc.tosca.services.DataModelUtil; -import org.openecomp.sdc.tosca.services.ToscaConstants; - -import java.util.List; -import java.util.Map; - -public class CapabilityDefinition { - - private String type; - private String description; - private Map<String, PropertyDefinition> properties; - private Map<String, AttributeDefinition> attributes; - private List<String> valid_source_types; - private Object[] occurrences; - - - /** - * Instantiates a new Capability definition. - */ - public CapabilityDefinition() { - occurrences = new Object[2]; - occurrences[0] = 1; - occurrences[1] = ToscaConstants.UNBOUNDED; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public Map<String, AttributeDefinition> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, AttributeDefinition> attributes) { - this.attributes = attributes; - } - - public List<String> getValid_source_types() { - return valid_source_types; - } - - public void setValid_source_types(List<String> validSourceTypes) { - this.valid_source_types = validSourceTypes; - } - - public Object[] getOccurrences() { - return occurrences; - } - - public void setOccurrences(Object[] occurrences) { - this.occurrences = occurrences; - } - - @Override - public CapabilityDefinition clone() { - CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); - capabilityDefinition - .setOccurrences(new Object[]{this.getOccurrences()[0], this.getOccurrences()[1]}); - capabilityDefinition - .setProperties(DataModelUtil.clonePropertyDefinitions(this.getProperties())); - capabilityDefinition.setType(this.getType()); - capabilityDefinition - .setAttributes(DataModelUtil.cloneAttributeDefinitions(this.getAttributes())); - capabilityDefinition.setDescription(this.getDescription()); - capabilityDefinition - .setValid_source_types(DataModelUtil.cloneValidSourceTypes(this.getValid_source_types())); - return capabilityDefinition; - - } - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java deleted file mode 100644 index 3678583384..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; - -public class CapabilityFilterDefinition { - List<Constraint> properties; - - public List<Constraint> getProperties() { - return properties; - } - - public void setProperties(List<Constraint> properties) { - this.properties = properties; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java deleted file mode 100644 index b0281b4ca0..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class CapabilityType { - - private String derived_from; - private String version; - private String description; - private Map<String, PropertyDefinition> properties; - private Map<String, AttributeDefinition> attributes; - private List<String> valid_source_types; - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public Map<String, AttributeDefinition> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, AttributeDefinition> attributes) { - this.attributes = attributes; - } - - public List<String> getValid_source_types() { - return valid_source_types; - } - - public void setValid_source_types(List<String> validSourceTypes) { - this.valid_source_types = validSourceTypes; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java deleted file mode 100644 index 2c39ce3902..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.ArrayList; -import java.util.List; - -public class Constraint { - private Object equal; - private Object greater_or_equal; - private Object greater_than; - private Object less_than; - private Object less_or_equal; - private Object[] in_range; - private List<Object> valid_values; - private Integer length; - private Integer min_length; - private Integer max_length; - private Object pattern; - - public Constraint() { - } - - public Object getGreater_or_equal() { - return greater_or_equal; - } - - public void setGreater_or_equal(Object greaterOrEqual) { - this.greater_or_equal = greaterOrEqual; - } - - public Object getEqual() { - return equal; - } - - public void setEqual(Object equal) { - this.equal = equal; - } - - public Object getGreater_than() { - return greater_than; - } - - public void setGreater_than(Object greaterThan) { - this.greater_than = greaterThan; - } - - public Object getLess_than() { - return less_than; - } - - public void setLess_than(Object lessThan) { - this.less_than = lessThan; - } - - public Object getLess_or_equal() { - return less_or_equal; - } - - public void setLess_or_equal(Object lessOrEqual) { - this.less_or_equal = lessOrEqual; - } - - public Object[] getIn_range() { - return in_range; - } - - /** - * Sets in range. - * - * @param inRange the in range - */ - public void setIn_range(Object[] inRange) { - this.in_range = new Object[2]; - this.in_range[0] = inRange[0]; - this.in_range[1] = inRange[1]; - } - - public List<Object> getValid_values() { - return valid_values; - } - - public void setValid_values(List<Object> validValues) { - this.valid_values = validValues; - } - - /** - * Add valid value. - * - * @param validValue the valid value - */ - public void addValidValue(Object validValue) { - if (this.valid_values == null) { - this.valid_values = new ArrayList<>(); - } - valid_values.add(validValue); - } - - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length = length; - } - - public Integer getMin_length() { - return min_length; - } - - public void setMin_length(Integer minLength) { - this.min_length = minLength; - } - - public Integer getMax_length() { - return max_length; - } - - public void setMax_length(Integer maxLength) { - this.max_length = maxLength; - } - - public Object getPattern() { - return pattern; - } - - public void setPattern(Object pattern) { - this.pattern = pattern; - } - - @Override - public Constraint clone() { - Constraint constraint = new Constraint(); - constraint.setEqual(this.getEqual()); - constraint.setGreater_or_equal(this.getGreater_or_equal()); - constraint.setGreater_than(this.getGreater_than()); - cloneInRange(constraint); - constraint.setLength(this.getLength()); - constraint.setLess_or_equal(this.getLess_or_equal()); - constraint.setLess_than(this.getLess_than()); - constraint.setMax_length(this.getMax_length()); - constraint.setMin_length(this.getMin_length()); - constraint.setPattern(this.getPattern()); - cloneValidValues(constraint); - - return constraint; - } - - private void cloneInRange(Constraint constraint) { - if (this.getIn_range() != null) { - constraint.setIn_range(new Object[]{this.getIn_range()[0], this.getIn_range()[1]}); - } - } - - private void cloneValidValues(Constraint constraint) { - if (this.getValid_values() != null) { - constraint.setValid_values(new ArrayList<>()); - for (Object entry : this.getValid_values()) { - constraint.getValid_values().add(entry); - } - } - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java deleted file mode 100644 index 866c5774d8..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class DataType { - - private String derived_from; - private String version; - private String description; - private List<Constraint> constraints; - private Map<String, PropertyDefinition> properties; - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public List<Constraint> getConstraints() { - return constraints; - } - - public void setConstraints(List<Constraint> constraints) { - this.constraints = constraints; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java deleted file mode 100644 index 078a6449ea..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public enum Directive { - - - SELECTABLE("selectable"), - SUBSTITUTABLE("substitutable"); - - private String displayName; - - Directive(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } - - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java deleted file mode 100644 index 8b08e54c01..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import org.openecomp.sdc.tosca.services.DataModelUtil; - -import java.util.List; - -public class EntrySchema { - - private String description; - private String type; - private List<Constraint> constraints; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public List<Constraint> getConstraints() { - return constraints; - } - - public void setConstraints(List<Constraint> constraints) { - this.constraints = constraints; - } - - @Override - public EntrySchema clone() { - EntrySchema entrySchema = new EntrySchema(); - entrySchema.setDescription(this.getDescription()); - entrySchema.setType(this.getType()); - entrySchema.setConstraints(DataModelUtil.cloneConstraints(this.getConstraints())); - return entrySchema; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java deleted file mode 100644 index 807bf260c3..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class GroupDefinition { - - private String type; - private String description; - private Map<String, Object> properties; - private List<String> members; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public List<String> getMembers() { - return members; - } - - public void setMembers(List<String> members) { - this.members = members; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java deleted file mode 100644 index 4bbb861286..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class GroupType { - - private String derived_from; - private String version; - private String description; - private Map<String, PropertyDefinition> properties; - private List<String> members; - private Map<String, InterfaceDefinition> interfaces; - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public List<String> getMembers() { - return members; - } - - public void setMembers(List<String> members) { - this.members = members; - } - - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java deleted file mode 100644 index 207a1b520a..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class Import { - - private String file; - private String repository; - private String namespace_uri; - private String namespace_prefix; - - public String getFile() { - return file; - } - - public void setFile(String file) { - this.file = file; - } - - public String getRepository() { - return repository; - } - - public void setRepository(String repository) { - this.repository = repository; - } - - public String getNamespace_uri() { - return namespace_uri; - } - - public void setNamespace_uri(String namespaceUri) { - this.namespace_uri = namespaceUri; - } - - public String getNamespace_prefix() { - return namespace_prefix; - } - - public void setNamespace_prefix(String namespacePrefix) { - this.namespace_prefix = namespacePrefix; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java deleted file mode 100644 index cf09510083..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class InterfaceDefinition { -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java deleted file mode 100644 index b177b0660a..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class InterfaceType { -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java deleted file mode 100644 index 162e693dba..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.Map; - -public class Metadata { - - private String template_name; - private String template_author; - private String template_version; - - - public String getTemplate_name() { - return template_name; - } - - public void setTemplate_name(String templateName) { - this.template_name = templateName; - } - - public String getTemplate_author() { - return template_author; - } - - public void setTemplate_author(String templateAuthor) { - this.template_author = templateAuthor; - } - - public String getTemplate_version() { - return template_version; - } - - public void setTemplate_version(String templateVersion) { - this.template_version = templateVersion; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java deleted file mode 100644 index d87dcd7b1d..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class NodeFilter { - - Map<String, List<Constraint>> properties; - Map<String, CapabilityFilterDefinition> capabilities; - - public Map<String, List<Constraint>> getProperties() { - - return properties; - } - - public void setProperties(Map<String, List<Constraint>> properties) { - this.properties = properties; - } - - public Map<String, CapabilityFilterDefinition> getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map<String, CapabilityFilterDefinition> capabilities) { - this.capabilities = capabilities; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java deleted file mode 100644 index 41ac232605..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class NodeTemplate implements Template { - - private String type; - private String description; - private List<String> directives; - private Map<String, Object> properties; - private Map<String, Object> attributes; - private List<Map<String, RequirementAssignment>> requirements; - private List<Map<String, CapabilityAssignment>> capabilities; - private Map<String, InterfaceDefinition> interfaces; - private Map<String, ArtifactDefinition> artifacts; - private NodeFilter node_filter; - private String copy; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public List<String> getDirectives() { - return directives; - } - - public void setDirectives(List<String> directives) { - this.directives = directives; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public Map<String, Object> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, Object> attributes) { - this.attributes = attributes; - } - - public List<Map<String, RequirementAssignment>> getRequirements() { - return requirements; - } - - public void setRequirements(List<Map<String, RequirementAssignment>> requirements) { - this.requirements = requirements; - } - - public List<Map<String, CapabilityAssignment>> getCapabilities() { - return capabilities; - } - - public void setCapabilities(List<Map<String, CapabilityAssignment>> capabilities) { - this.capabilities = capabilities; - } - - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } - - public Map<String, ArtifactDefinition> getArtifacts() { - return artifacts; - } - - public void setArtifacts(Map<String, ArtifactDefinition> artifacts) { - this.artifacts = artifacts; - } - - public NodeFilter getNode_filter() { - return node_filter; - } - - public void setNode_filter(NodeFilter nodeFilter) { - this.node_filter = nodeFilter; - } - - public String getCopy() { - return copy; - } - - public void setCopy(String copy) { - this.copy = copy; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java deleted file mode 100644 index d477f286ee..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class NodeType { - - private String derived_from; - private String version; - private String description; - private Map<String, PropertyDefinition> properties; - private Map<String, AttributeDefinition> attributes; - private List<Map<String, RequirementDefinition>> requirements; - private Map<String, CapabilityDefinition> capabilities; - private Map<String, InterfaceDefinition> interfaces; - private Map<String, ArtifactDefinition> artifacts; - - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public Map<String, AttributeDefinition> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, AttributeDefinition> attributes) { - this.attributes = attributes; - } - - public List<Map<String, RequirementDefinition>> getRequirements() { - return requirements; - } - - public void setRequirements(List<Map<String, RequirementDefinition>> requirements) { - this.requirements = requirements; - } - - public Map<String, CapabilityDefinition> getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map<String, CapabilityDefinition> capabilities) { - this.capabilities = capabilities; - } - - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } - - public Map<String, ArtifactDefinition> getArtifacts() { - return artifacts; - } - - public void setArtifacts(Map<String, ArtifactDefinition> artifacts) { - this.artifacts = artifacts; - } - - @Override - public NodeType clone() { - NodeType clone = new NodeType(); - clone.setCapabilities(this.getCapabilities()); - clone.setDerived_from(this.getDerived_from()); - clone.setProperties(this.getProperties()); - clone.setRequirements(this.getRequirements()); - clone.setDescription(this.getDescription()); - clone.setAttributes(this.getAttributes()); - clone.setInterfaces(this.getInterfaces()); - clone.setVersion(this.getVersion()); - clone.setArtifacts(this.getArtifacts()); - return clone; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Old1610ServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Old1610ServiceTemplate.java new file mode 100644 index 0000000000..2ee7bca5bc --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Old1610ServiceTemplate.java @@ -0,0 +1,152 @@ +package org.openecomp.sdc.tosca.datatypes.model; + +import org.openecomp.sdc.tosca.datatypes.model.ArtifactType; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; +import org.openecomp.sdc.tosca.datatypes.model.DataType; +import org.openecomp.sdc.tosca.datatypes.model.GroupType; +import org.openecomp.sdc.tosca.datatypes.model.Import; +import org.openecomp.sdc.tosca.datatypes.model.InterfaceType; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.PolicyType; +import org.openecomp.sdc.tosca.datatypes.model.RelationshipType; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.datatypes.model.Template; +import org.openecomp.sdc.tosca.datatypes.model.TopologyTemplate; + +import java.util.List; +import java.util.Map; + +/** + * Created by Talio on 3/30/2017. + */ +public class Old1610ServiceTemplate { + + private String tosca_definitions_version; + private Map<String, String> metadata; + private String description; + private Map<String, Import> imports; + private Map<String, ArtifactType> artifact_types; + private Map<String, DataType> data_types; + private Map<String, CapabilityType> capability_types; + private Map<String, Object> interface_types; + private Map<String, RelationshipType> relationship_types; + private Map<String, NodeType> node_types; + private Map<String, GroupType> group_types; + private Map<String, PolicyType> policy_types; + private TopologyTemplate topology_template; + + public String getTosca_definitions_version() { + return tosca_definitions_version; + } + + public void setTosca_definitions_version(String tosca_definitions_version) { + this.tosca_definitions_version = tosca_definitions_version; + } + + public Map<String, String> getMetadata() { + return metadata; + } + + public void setMetadata(Map<String, String> metadata) { + this.metadata = metadata; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public Map<String, Import> getImports() { + return this.imports; + } + + public void setImports( + Map<String, Import> imports) { + this.imports = imports; + } + + public Map<String, ArtifactType> getArtifact_types() { + return artifact_types; + } + + public void setArtifact_types( + Map<String, ArtifactType> artifact_types) { + this.artifact_types = artifact_types; + } + + public Map<String, DataType> getData_types() { + return data_types; + } + + public void setData_types( + Map<String, DataType> data_types) { + this.data_types = data_types; + } + + public Map<String, CapabilityType> getCapability_types() { + return capability_types; + } + + public void setCapability_types( + Map<String, CapabilityType> capability_types) { + this.capability_types = capability_types; + } + + public Map<String, Object> getInterface_types() { + return interface_types; + } + + public void setInterface_types(Map<String, Object> interface_types) { + this.interface_types = interface_types; + } + + public Map<String, RelationshipType> getRelationship_types() { + return relationship_types; + } + + public void setRelationship_types( + Map<String, RelationshipType> relationship_types) { + this.relationship_types = relationship_types; + } + + public Map<String, NodeType> getNode_types() { + return node_types; + } + + public void setNode_types( + Map<String, NodeType> node_types) { + this.node_types = node_types; + } + + public Map<String, GroupType> getGroup_types() { + return group_types; + } + + public void setGroup_types( + Map<String, GroupType> group_types) { + this.group_types = group_types; + } + + public Map<String, PolicyType> getPolicy_types() { + return policy_types; + } + + public void setPolicy_types( + Map<String, PolicyType> policy_types) { + this.policy_types = policy_types; + } + + public TopologyTemplate getTopology_template() { + return topology_template; + } + + public void setTopology_template( + TopologyTemplate topology_template) { + this.topology_template = topology_template; + } +} + diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java deleted file mode 100644 index 6ef4c782f5..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; - -public class ParameterDefinition { - - private String type; - private String description; - private Object value; - private Boolean required; - private Object _default; - private Status status; - private List<Constraint> constraints; - private EntrySchema entry_schema; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public Boolean getRequired() { - return required; - } - - public void setRequired(Boolean required) { - this.required = required; - } - - public Object get_default() { - return _default; - } - - public void set_default(Object defaultValue) { - this._default = defaultValue; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public List<Constraint> getConstraints() { - return constraints; - } - - public void setConstraints(List<Constraint> constraints) { - this.constraints = constraints; - } - - public EntrySchema getEntry_schema() { - return entry_schema; - } - - public void setEntry_schema(EntrySchema entrySchema) { - this.entry_schema = entrySchema; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java deleted file mode 100644 index 90f44ae36a..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class PolicyDefinition implements Template { - private String type; - private String description; - private Map<String, Object> properties; - private List<String> targets; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public List<String> getTargets() { - return targets; - } - - public void setTargets(List<String> targets) { - this.targets = targets; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java deleted file mode 100644 index 07412cda59..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class PolicyType { - - private String derived_from; - private String version; - private String description; - private Map<String, PropertyDefinition> properties; - private List<String> targets; - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public List<String> getTargets() { - return targets; - } - - public void setTargets(List<String> targets) { - this.targets = targets; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java deleted file mode 100644 index cf47d0b113..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import org.openecomp.sdc.tosca.services.DataModelUtil; - -import java.util.List; - -public class PropertyDefinition { - - private String type; - private String description; - private Boolean required; - private Object _default; - private Status status; - private List<Constraint> constraints; - private EntrySchema entry_schema; - - public PropertyDefinition() { - status = Status.SUPPORTED; - required = true; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Boolean getRequired() { - return required; - } - - public void setRequired(Boolean required) { - this.required = required; - } - - public Object get_default() { - return _default; - } - - public void set_default(Object defaultValue) { - this._default = defaultValue; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public List<Constraint> getConstraints() { - return constraints; - } - - public void setConstraints(List<Constraint> constraints) { - this.constraints = constraints; - } - - public EntrySchema getEntry_schema() { - return entry_schema; - } - - public void setEntry_schema(EntrySchema entrySchema) { - this.entry_schema = entrySchema; - } - - @Override - public PropertyDefinition clone() { - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(this.getType()); - propertyDefinition.setDescription(this.getDescription()); - propertyDefinition.setRequired(this.getRequired()); - propertyDefinition.set_default(this.get_default()); - propertyDefinition.setStatus(this.getStatus()); - propertyDefinition.setEntry_schema(this.getEntry_schema().clone()); - propertyDefinition.setConstraints(DataModelUtil.cloneConstraints(this.getConstraints())); - return propertyDefinition; - } - - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java deleted file mode 100644 index 3fdd9bba0e..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * The enum Property type. - */ -public enum PropertyType { - - /** - * String property type. - */ - STRING("string"), - /** - * Integer property type. - */ - INTEGER("integer"), - /** - * Float property type. - */ - FLOAT("float"), - /** - * Boolean property type. - */ - BOOLEAN("boolean"), - /** - * Timestamp property type. - */ - TIMESTAMP("timestamp"), - /** - * Null property type. - */ - NULL("null"), - /** - * Map property type. - */ - MAP("map"), - /** - * List property type. - */ - LIST("list"), - /** - * Scalar unit size property type. - */ - SCALAR_UNIT_SIZE("scalar-unit.size"); - - private static final Map<String, PropertyType> mMap = - Collections.unmodifiableMap(initializeMapping()); - private String displayName; - - PropertyType(String displayName) { - - this.displayName = displayName; - } - - /** - * Initialize mapping map. - * - * @return the map - */ - public static Map<String, PropertyType> initializeMapping() { - Map<String, PropertyType> typeMap = new HashMap<String, PropertyType>(); - for (PropertyType v : PropertyType.values()) { - typeMap.put(v.displayName, v); - } - return typeMap; - } - - /** - * Gets property type by display name. - * - * @param displayName the display name - * @return the property type by display name - */ - public static PropertyType getPropertyTypeByDisplayName(String displayName) { - if (mMap == null) { - initializeMapping(); - } - if (mMap.containsKey(displayName)) { - return mMap.get(displayName); - } - return null; - } - - /** - * Gets display name. - * - * @return the display name - */ - public String getDisplayName() { - return displayName; - } - - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java deleted file mode 100644 index c3a1195565..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.Map; - -public class RelationshipTemplate implements Template { - - private String type; - private String description; - private Map<String, Object> properties; - private Map<String, Object> attributes; - private Map<String, RequirementAssignment> requirements; - private Map<String, CapabilityAssignment> capabilities; - private Map<String, InterfaceDefinition> interfaces; - private String copy; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } - - public Map<String, Object> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, Object> attributes) { - this.attributes = attributes; - } - - public Map<String, RequirementAssignment> getRequirements() { - return requirements; - } - - public void setRequirements(Map<String, RequirementAssignment> requirements) { - this.requirements = requirements; - } - - public Map<String, CapabilityAssignment> getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map<String, CapabilityAssignment> capabilities) { - this.capabilities = capabilities; - } - - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } - - public String getCopy() { - return copy; - } - - public void setCopy(String copy) { - this.copy = copy; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java deleted file mode 100644 index 173a8a0f64..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class RelationshipType { - - private String derived_from; - private String version; - private String description; - private Map<String, PropertyDefinition> properties; - private Map<String, AttributeDefinition> attributes; - private Map<String, InterfaceDefinition> interfaces; - private List<String> valid_target_types; - //An optional list of one or more names of Capability Types that are valid targets - //for this relationship - - public String getDerived_from() { - return derived_from; - } - - public void setDerived_from(String derivedFrom) { - this.derived_from = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(Map<String, PropertyDefinition> properties) { - this.properties = properties; - } - - public Map<String, AttributeDefinition> getAttributes() { - return attributes; - } - - public void setAttributes(Map<String, AttributeDefinition> attributes) { - this.attributes = attributes; - } - - public Map<String, InterfaceDefinition> getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map<String, InterfaceDefinition> interfaces) { - this.interfaces = interfaces; - } - - public List<String> getValid_target_types() { - return valid_target_types; - } - - public void setValid_target_types(List<String> validTargetTypes) { - this.valid_target_types = validTargetTypes; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java deleted file mode 100644 index 445063a3ed..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class RequirementAssignment { - - private String capability; - private String node; - private String relationship; - private NodeFilter node_filter; - private Object[] occurrences; - - public String getCapability() { - return capability; - } - - public void setCapability(String capability) { - this.capability = capability; - } - - public String getNode() { - return node; - } - - public void setNode(String node) { - this.node = node; - } - - public String getRelationship() { - return relationship; - } - - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public NodeFilter getNode_filter() { - return node_filter; - } - - public void setNode_filter(NodeFilter nodeFilter) { - this.node_filter = nodeFilter; - } - - public Object[] getOccurrences() { - return occurrences; - } - - public void setOccurrences(Object[] occurrences) { - this.occurrences = occurrences; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java deleted file mode 100644 index fe3238f1b5..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class RequirementDefinition { - - private String capability; - private String node; - private String relationship; - private Object[] occurrences; - - /** - * Instantiates a new Requirement definition. - */ - public RequirementDefinition() { - occurrences = new Object[2]; - occurrences[0] = 1; - occurrences[1] = 1; - } - - public String getCapability() { - return capability; - } - - public void setCapability(String capability) { - this.capability = capability; - } - - public String getNode() { - return node; - } - - public void setNode(String node) { - this.node = node; - } - - public String getRelationship() { - return relationship; - } - - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public Object[] getOccurrences() { - return occurrences; - } - - public void setOccurrences(Object[] occurrences) { - this.occurrences = occurrences; - } - - @Override - public RequirementDefinition clone() { - RequirementDefinition requirementDefinition = new RequirementDefinition(); - requirementDefinition.setNode(this.getNode()); - requirementDefinition.setRelationship(this.getRelationship()); - requirementDefinition.setCapability(this.getCapability()); - requirementDefinition - .setOccurrences(new Object[]{this.getOccurrences()[0], this.getOccurrences()[1]}); - return requirementDefinition; - } - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java deleted file mode 100644 index 619ac510b0..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public class Scalar { - - private Float value; - - public Float getValue() { - return value; - } - - public void setValue(Float value) { - this.value = value; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java deleted file mode 100644 index 98da0104b8..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.Map; - -public class ServiceTemplate implements Template { - - private String tosca_definitions_version; - private Metadata metadata; - private String description; - private Map<String, Import> imports; - private Map<String, ArtifactType> artifact_types; - private Map<String, DataType> data_types; - private Map<String, CapabilityType> capability_types; - private Map<String, InterfaceType> interface_types; - private Map<String, RelationshipType> relationship_types; - private Map<String, NodeType> node_types; - private Map<String, GroupType> group_types; - private Map<String, PolicyType> policy_types; - private TopologyTemplate topology_template; - - public String getTosca_definitions_version() { - return tosca_definitions_version; - } - - public void setTosca_definitions_version(String toscaDefinitionsVersion) { - this.tosca_definitions_version = toscaDefinitionsVersion; - } - - public Metadata getMetadata() { - return metadata; - } - - public void setMetadata(Metadata metadata) { - this.metadata = metadata; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, Import> getImports() { - return imports; - } - - public void setImports(Map<String, Import> imports) { - this.imports = imports; - } - - public Map<String, ArtifactType> getArtifact_types() { - return artifact_types; - } - - public void setArtifact_types(Map<String, ArtifactType> artifactTypes) { - this.artifact_types = artifactTypes; - } - - public Map<String, DataType> getData_types() { - return data_types; - } - - public void setData_types(Map<String, DataType> dataTypes) { - this.data_types = dataTypes; - } - - public Map<String, CapabilityType> getCapability_types() { - return capability_types; - } - - public void setCapability_types(Map<String, CapabilityType> capabilityTypes) { - this.capability_types = capabilityTypes; - } - - public Map<String, RelationshipType> getRelationship_types() { - return relationship_types; - } - - public void setRelationship_types(Map<String, RelationshipType> relationshipTypes) { - this.relationship_types = relationshipTypes; - } - - public Map<String, NodeType> getNode_types() { - return node_types; - } - - public void setNode_types(Map<String, NodeType> nodeTypes) { - this.node_types = nodeTypes; - } - - public Map<String, GroupType> getGroup_types() { - return group_types; - } - - public void setGroup_types(Map<String, GroupType> groupTypes) { - this.group_types = groupTypes; - } - - public Map<String, InterfaceType> getInterface_types() { - return interface_types; - } - - public void setInterface_types(Map<String, InterfaceType> interfaceTypes) { - this.interface_types = interfaceTypes; - } - - public Map<String, PolicyType> getPolicy_types() { - return policy_types; - } - - public void setPolicy_types(Map<String, PolicyType> policyTypes) { - this.policy_types = policyTypes; - } - - public TopologyTemplate getTopology_template() { - return topology_template; - } - - public void setTopology_template(TopologyTemplate topologyTemplate) { - this.topology_template = topologyTemplate; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java deleted file mode 100644 index 0805982a54..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.Map; - -public enum Status { - - SUPPORTED("supported"), - UNSUPPORTED("unsupported"), - EXPERIMENTAL("experimental"), - DEPRECATED("deprecated"),; - private String displayName; - - Status(String displayName) { - this.displayName = displayName; - } - - public String getDisplayName() { - return displayName; - } - - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java deleted file mode 100644 index 50c262dc42..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.List; -import java.util.Map; - -public class SubstitutionMapping { - private String node_type; - private Map<String, List<String>> capabilities; - private Map<String, List<String>> requirements; - - public String getNode_type() { - return node_type; - } - - public void setNode_type(String nodeType) { - this.node_type = nodeType; - } - - public Map<String, List<String>> getRequirements() { - return requirements; - } - - public void setRequirements(Map<String, List<String>> requirements) { - this.requirements = requirements; - } - - public Map<String, List<String>> getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map<String, List<String>> capabilities) { - this.capabilities = capabilities; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java deleted file mode 100644 index 128bb3c0a9..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -public interface Template { -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java deleted file mode 100644 index 288242946a..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -public class TopologyTemplate { - - private String description; - private Map<String, ParameterDefinition> inputs; - private Map<String, NodeTemplate> node_templates; - private Map<String, RelationshipTemplate> relationship_templates; - private Map<String, GroupDefinition> groups; - private Map<String, ParameterDefinition> outputs; - private SubstitutionMapping substitution_mappings; - private Map<String, PolicyDefinition> policies; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map<String, ParameterDefinition> getInputs() { - return inputs; - } - - public void setInputs(Map<String, ParameterDefinition> inputs) { - this.inputs = inputs; - } - - public Map<String, NodeTemplate> getNode_templates() { - return node_templates; - } - - public void setNode_templates(Map<String, NodeTemplate> nodeTemplates) { - this.node_templates = nodeTemplates; - } - - public Map<String, RelationshipTemplate> getRelationship_templates() { - return relationship_templates; - } - - public void setRelationship_templates(Map<String, RelationshipTemplate> relationshipTemplates) { - this.relationship_templates = relationshipTemplates; - } - - public Map<String, GroupDefinition> getGroups() { - return groups; - } - - public void setGroups(Map<String, GroupDefinition> groups) { - this.groups = groups; - } - - /** - * Add group. - * - * @param groupKey the group key - * @param groupDefinition the group definition - */ - public void addGroup(String groupKey, GroupDefinition groupDefinition) { - if (Objects.isNull(this.groups)) { - this.groups = new HashMap<>(); - } - this.groups.put(groupKey, groupDefinition); - } - - public Map<String, ParameterDefinition> getOutputs() { - return outputs; - } - - public void setOutputs(Map<String, ParameterDefinition> outputs) { - this.outputs = outputs; - } - - public SubstitutionMapping getSubstitution_mappings() { - return substitution_mappings; - } - - public void setSubstitution_mappings(SubstitutionMapping substitutionMapping) { - this.substitution_mappings = substitutionMapping; - } - - public Map<String, PolicyDefinition> getPolicies() { - return policies; - } - - public void setPolicies(Map<String, PolicyDefinition> policies) { - this.policies = policies; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java deleted file mode 100644 index bde81108de..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model.heatextend; - - -import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; - -public class ParameterDefinitionExt extends ParameterDefinition { - - String label; - Boolean hidden; - Boolean immutable; - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Boolean getHidden() { - return hidden; - } - - public void setHidden(Boolean hidden) { - this.hidden = hidden; - } - - public Boolean getImmutable() { - return immutable; - } - - public void setImmutable(Boolean immutable) { - this.immutable = immutable; - } -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java deleted file mode 100644 index f92d674070..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.datatypes.model.heatextend; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * The enum Property type ext. - */ -public enum PropertyTypeExt { - - /** - * Json property type ext. - */ - JSON("json"); - - private static final Map<String, PropertyTypeExt> mMap = - Collections.unmodifiableMap(initializeMapping()); - private String displayName; - - PropertyTypeExt(String displayName) { - - this.displayName = displayName; - } - - /** - * Initialize mapping map. - * - * @return the map - */ - public static Map<String, PropertyTypeExt> initializeMapping() { - Map<String, PropertyTypeExt> typeMap = new HashMap<String, PropertyTypeExt>(); - for (PropertyTypeExt v : PropertyTypeExt.values()) { - typeMap.put(v.displayName, v); - } - return typeMap; - } - - /** - * Gets property type by display name. - * - * @param displayName the display name - * @return the property type by display name - */ - public static PropertyTypeExt getPropertyTypeByDisplayName(String displayName) { - if (mMap == null) { - initializeMapping(); - } - if (mMap.containsKey(displayName)) { - return mMap.get(displayName); - } - return null; - } - - /** - * Gets display name. - * - * @return the display name - */ - public String getDisplayName() { - return displayName; - } - - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java index 02bee69251..68d7da1b36 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java @@ -23,9 +23,6 @@ package org.openecomp.sdc.tosca.errors; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -/** - * The type Invalid add action null entity error builder. - */ public class InvalidAddActionNullEntityErrorBuilder { private static final String INVALID_ACTION_NULL_ENTITY_ERR_MSG = @@ -34,10 +31,9 @@ public class InvalidAddActionNullEntityErrorBuilder { private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); /** - * Instantiates a new Invalid add action null entity error builder. - * - * @param addedData the added data - * @param updatedEntity the updated entity + * Invalid Action Error builder. + * @param addedData Added data + * @param updatedEntity Updated Entity */ public InvalidAddActionNullEntityErrorBuilder(String addedData, String updatedEntity) { builder.withId(ToscaErrorCodes.TOSCA_INVALID_ADD_ACTION_NULL_ENTITY); @@ -46,11 +42,6 @@ public class InvalidAddActionNullEntityErrorBuilder { String.format(INVALID_ACTION_NULL_ENTITY_ERR_MSG, addedData, updatedEntity, updatedEntity)); } - /** - * Build error code. - * - * @return the error code - */ public ErrorCode build() { return builder.build(); } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java index cc0b821748..1947ce950b 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java @@ -23,9 +23,6 @@ package org.openecomp.sdc.tosca.errors; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -/** - * The type Invalid requirement assignment error builder. - */ public class InvalidRequirementAssignmentErrorBuilder { private static final String INVALID_REQ_ASSIGNMENT_ERR_ID = "INVALID_REQ_ASSIGNMENT_ERR_ID"; @@ -35,9 +32,8 @@ public class InvalidRequirementAssignmentErrorBuilder { private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); /** - * Instantiates a new Invalid requirement assignment error builder. - * - * @param requirementId the requirement id + * Invalid Requirement Assignment Error Builder. + * @param requirementId. */ public InvalidRequirementAssignmentErrorBuilder(String requirementId) { builder.withId(INVALID_REQ_ASSIGNMENT_ERR_ID); @@ -45,11 +41,6 @@ public class InvalidRequirementAssignmentErrorBuilder { builder.withMessage(String.format(INVALID_REQ_ASSIGNMENT_ERR_MSG, requirementId)); } - /** - * Build error code. - * - * @return the error code - */ public ErrorCode build() { return builder.build(); } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java index 5913e5ffba..bab2e77c75 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java @@ -29,8 +29,8 @@ import org.openecomp.sdc.common.errors.ErrorCode; */ public class ToscaInvalidSubstituteNodeTemplateErrorBuilder { private static final String INVALID_SUBSTITUTE_NODE_TEMPLATE_MSG = - "Invalid substitute node template, directives with substitutable value must be defined. " - + "node template id %s"; + "Invalid substitute node template, directives with substitutable value must be defined." + + " node template id %s"; private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); /** diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java index 74392cdcdb..c41e2fa137 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java @@ -60,13 +60,7 @@ public class ToscaMissingSubstitutionMappingForReqCapErrorBuilder { */ public enum MappingExposedEntry { - /** - * Capability mapping exposed entry. - */ CAPABILITY("Capability"), - /** - * Requirement mapping exposed entry. - */ REQUIREMENT("Requirement"),; private String displayName; @@ -75,11 +69,6 @@ public class ToscaMissingSubstitutionMappingForReqCapErrorBuilder { this.displayName = displayName; } - /** - * Gets display name. - * - * @return the display name - */ public String getDisplayName() { return displayName; } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java index 3d51970d50..1a2c124f4f 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java @@ -23,6 +23,9 @@ package org.openecomp.sdc.tosca.errors; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; +/** + * The type Tosca node type not found error builder. + */ public class ToscaNodeTypeNotFoundErrorBuilder { private static final String ENTRY_NOT_FOUND_MSG = "NodeType '%s' or one of its derivedFrom node type hierarchy, " @@ -40,6 +43,11 @@ public class ToscaNodeTypeNotFoundErrorBuilder { builder.withMessage(String.format(ENTRY_NOT_FOUND_MSG, nodeType)); } + /** + * Build error code. + * + * @return the error code + */ public ErrorCode build() { return builder.build(); } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java index c7b9bc2da4..42e38a854a 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java @@ -23,9 +23,6 @@ package org.openecomp.sdc.tosca.exceptions; import org.openecomp.sdc.common.errors.BaseErrorBuilder; import org.openecomp.sdc.common.errors.ErrorCategory; -/** - * The type Csar creation error builder. - */ public class CsarCreationErrorBuilder extends BaseErrorBuilder { private static final String MANDATORY_PROPERTY_IS_MISSING_MSG = @@ -33,7 +30,7 @@ public class CsarCreationErrorBuilder extends BaseErrorBuilder { private static final String ZIP_FILE_CREATION = "ZIP_FILE_CREATION"; /** - * Instantiates a new Csar creation error builder. + * Constructor. */ public CsarCreationErrorBuilder() { getErrorCodeBuilder().withId(ZIP_FILE_CREATION); diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java index 9b9257ad33..94dd138d03 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java @@ -23,18 +23,15 @@ package org.openecomp.sdc.tosca.exceptions; import org.openecomp.sdc.common.errors.BaseErrorBuilder; import org.openecomp.sdc.common.errors.ErrorCategory; -/** - * The type Csar missing entry point error builder. - */ public class CsarMissingEntryPointErrorBuilder extends BaseErrorBuilder { private static final String MANDATORY_PROPERTY_IS_MISSING_MSG = "Failed to create CSAR file from ToscaServiceModel,missing mandatory " - + "EntryDefinitionServiceTemplate "; + + "EntryDefinitionServiceTemplate "; private static final String ZIP_FILE_CREATION = "ZIP_FILE_CREATION__MISSING_ENTRY_DEFINITION"; /** - * Instantiates a new Csar missing entry point error builder. + * Constructor. */ public CsarMissingEntryPointErrorBuilder() { getErrorCodeBuilder().withId(ZIP_FILE_CREATION); diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ConfigConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ConfigConstants.java new file mode 100644 index 0000000000..df6eb195d8 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ConfigConstants.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + +public class ConfigConstants { + //namespaces + public static final String NAMESPACE = "ToscaModel"; + + //keys + public static final String PREFIX_CAPABILITY_TYPE = + "tosca.entity.namespace.prefix.capabilityType"; + public static final String PREFIX_DATA_TYPE = "tosca.entity.namespace.prefix.dataType"; + public static final String PREFIX_GROUP_TYPE = "tosca.entity.namespace.prefix.groupType"; + public static final String PREFIX_POLICY_TYPE = "tosca.entity.namespace.prefix.policyType"; + public static final String PREFIX_ARTIFACT_TYPE = "tosca.entity.namespace.prefix.artifactType"; + public static final String PREFIX_RELATIONSHIP_TYPE = + "tosca.entity.namespace.prefix.relationshipType"; + + public static final String PREFIX_NODE_TYPE_VFC = "tosca.entity.namespace.prefix.nodeType.vfc"; + public static final String PREFIX_NODE_TYPE_NETWORK = + "tosca.entity.namespace.prefix.nodeType.network"; + public static final String PREFIX_NODE_TYPE_CP = + "tosca.entity.namespace.prefix.nodeType.connectionPoint"; + public static final String PREFIX_NODE_TYPE_ABSTARCT = + "tosca.entity.namespace.prefix.nodeType.abstract"; + public static final String PREFIX_NODE_TYPE_RULE = "tosca.entity.namespace.prefix.nodeType.rule"; + + + private ConfigConstants() { + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java index d0d7ccf621..63080641e3 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java @@ -20,15 +20,29 @@ package org.openecomp.sdc.tosca.services; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.core.utilities.yaml.YamlUtil; import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerErrorDescription; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; import org.openecomp.sdc.tosca.datatypes.model.Constraint; import org.openecomp.sdc.tosca.datatypes.model.EntrySchema; import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition; -import org.openecomp.sdc.tosca.datatypes.model.Metadata; +import org.openecomp.sdc.tosca.datatypes.model.Import; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; import org.openecomp.sdc.tosca.datatypes.model.PolicyDefinition; import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition; import org.openecomp.sdc.tosca.datatypes.model.RelationshipTemplate; @@ -41,15 +55,18 @@ import org.openecomp.sdc.tosca.datatypes.model.TopologyTemplate; import org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt; import org.openecomp.sdc.tosca.errors.InvalidAddActionNullEntityErrorBuilder; import org.openecomp.sdc.tosca.errors.InvalidRequirementAssignmentErrorBuilder; +import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl; +import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; +import java.util.Optional; /** * The type Data model util. @@ -58,13 +75,24 @@ public class DataModelUtil { /** * Add substitution mapping. + */ + + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + + /** + * Add substitution mapping. * * @param serviceTemplate the service template * @param substitutionMapping the substitution mapping */ public static void addSubstitutionMapping(ServiceTemplate serviceTemplate, SubstitutionMapping substitutionMapping) { + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping", "Service Template") .build()); @@ -74,6 +102,8 @@ public class DataModelUtil { serviceTemplate.setTopology_template(new TopologyTemplate()); } serviceTemplate.getTopology_template().setSubstitution_mappings(substitutionMapping); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -86,7 +116,14 @@ public class DataModelUtil { public static void addSubstitutionMappingReq(ServiceTemplate serviceTemplate, String substitutionMappingRequirementId, List<String> substitutionMappingRequirementList) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Requirements", "Service Template").build()); @@ -106,6 +143,8 @@ public class DataModelUtil { serviceTemplate.getTopology_template().getSubstitution_mappings().getRequirements() .put(substitutionMappingRequirementId, substitutionMappingRequirementList); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -117,7 +156,14 @@ public class DataModelUtil { */ public static void addNodeTemplate(ServiceTemplate serviceTemplate, String nodeTemplateId, NodeTemplate nodeTemplate) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Node Template", "Service Template").build()); } @@ -130,6 +176,66 @@ public class DataModelUtil { topologyTemplate.setNode_templates(new HashMap<>()); } topologyTemplate.getNode_templates().put(nodeTemplateId, nodeTemplate); + + mdcDataDebugMessage.debugExitMessage(null, null); + + } + + /** + * Add capability def. + * + * @param nodeType the node type + * @param capabilityId the capability id + * @param capabilityDefinition the capability definition + */ + public static void addCapabilityDef(NodeType nodeType, String capabilityId, + CapabilityDefinition capabilityDefinition) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (nodeType == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Capability Definition", "Node Type").build()); + } + if (Objects.isNull(nodeType.getCapabilities())) { + nodeType.setCapabilities(new HashMap<>()); + } + nodeType.getCapabilities().put(capabilityId, capabilityDefinition); + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + /** + * Add capabilities def to node type. + * + * @param nodeType the node type + * @param capabilities the capability definitions + */ + public static void addNodeTypeCapabilitiesDef(NodeType nodeType, + Map<String, CapabilityDefinition> capabilities) { + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (capabilities == null || capabilities.entrySet().size() == 0) { + return; + } + + if (nodeType == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Capability Definition", "Node Type").build()); + } + + if (MapUtils.isEmpty(nodeType.getCapabilities())) { + nodeType.setCapabilities(new HashMap<>()); + } + if (capabilities.size() > 0) { + nodeType.setCapabilities(new HashMap<>()); + } + for (Map.Entry<String, CapabilityDefinition> entry : capabilities.entrySet()) { + nodeType.getCapabilities().put(entry.getKey(), entry.getValue()); + } + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -141,7 +247,14 @@ public class DataModelUtil { */ public static void addPolicyDefinition(ServiceTemplate serviceTemplate, String policyId, PolicyDefinition policyDefinition) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Policy Definition", "Service Template") .build()); @@ -155,6 +268,8 @@ public class DataModelUtil { topologyTemplate.setPolicies(new HashMap<>()); } topologyTemplate.getPolicies().put(policyId, policyDefinition); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -166,7 +281,14 @@ public class DataModelUtil { */ public static void addNodeType(ServiceTemplate serviceTemplate, String nodeTypeId, NodeType nodeType) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Node Type", "Service Template").build()); } @@ -174,6 +296,8 @@ public class DataModelUtil { serviceTemplate.setNode_types(new HashMap<>()); } serviceTemplate.getNode_types().put(nodeTypeId, nodeType); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -186,7 +310,14 @@ public class DataModelUtil { public static void addRelationshipTemplate(ServiceTemplate serviceTemplate, String relationshipTemplateId, RelationshipTemplate relationshipTemplate) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Relationship Template", "Service Template") .build()); @@ -199,6 +330,8 @@ public class DataModelUtil { } serviceTemplate.getTopology_template().getRelationship_templates() .put(relationshipTemplateId, relationshipTemplate); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -210,12 +343,22 @@ public class DataModelUtil { */ public static void addRequirementAssignment(NodeTemplate nodeTemplate, String requirementId, RequirementAssignment requirementAssignment) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (nodeTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Requirement Assignment", "Node Template") .build()); } if (requirementAssignment.getNode() == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException(new InvalidRequirementAssignmentErrorBuilder(requirementId).build()); } @@ -225,6 +368,8 @@ public class DataModelUtil { Map<String, RequirementAssignment> requirement = new HashMap<>(); requirement.put(requirementId, requirementAssignment); nodeTemplate.getRequirements().add(requirement); + + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -236,11 +381,16 @@ public class DataModelUtil { */ public static NodeTemplate getNodeTemplate(ServiceTemplate serviceTemplate, String nodeTemplateId) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null || serviceTemplate.getTopology_template() == null || serviceTemplate.getTopology_template().getNode_templates() == null) { return null; } + + mdcDataDebugMessage.debugExitMessage(null, null); return serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId); } @@ -252,13 +402,92 @@ public class DataModelUtil { * @return the node type */ public static NodeType getNodeType(ServiceTemplate serviceTemplate, String nodeTypeId) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); if (serviceTemplate == null || serviceTemplate.getNode_types() == null) { return null; } + + mdcDataDebugMessage.debugExitMessage(null, null); return serviceTemplate.getNode_types().get(nodeTypeId); } /** + * Gets requirement definition. + * + * @param nodeType the node type + * @param requirementDefinitionId the requirement definition id + * @return the requirement definition + */ + public static Optional<RequirementDefinition> getRequirementDefinition( + NodeType nodeType, + String requirementDefinitionId) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (nodeType == null || nodeType.getRequirements() == null || requirementDefinitionId == null) { + return Optional.empty(); + } + for (Map<String, RequirementDefinition> reqMap : nodeType.getRequirements()) { + if (reqMap.containsKey(requirementDefinitionId)) { + return Optional.of(reqMap.get(requirementDefinitionId)); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return Optional.empty(); + } + + /** + * get requirement defenition from requirement defenition list by req key. + * + * @param requirementsDefinitionList requirement defenition list + * @param requirementKey requirement key + */ + public static Optional<RequirementDefinition> getRequirementDefinition( + List<Map<String, RequirementDefinition>> requirementsDefinitionList, + String requirementKey) { + mdcDataDebugMessage.debugEntryMessage(null, null); + if (CollectionUtils.isEmpty(requirementsDefinitionList)) { + return Optional.empty(); + } + + for (Map<String, RequirementDefinition> requirementMap : requirementsDefinitionList) { + if (requirementMap.containsKey(requirementKey)) { + mdcDataDebugMessage.debugExitMessage(null, null); + return Optional.of(requirementMap.get(requirementKey)); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return Optional.empty(); + } + + /** + * Gets capability definition. + * + * @param nodeType the node type + * @param capabilityDefinitionId the capability definition id + * @return the capability definition + */ + public static Optional<CapabilityDefinition> getCapabilityDefinition( + NodeType nodeType, + String capabilityDefinitionId) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (nodeType == null || nodeType.getCapabilities() == null || capabilityDefinitionId == null) { + return Optional.empty(); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return Optional.ofNullable(nodeType.getCapabilities().get(capabilityDefinitionId)); + } + + /** * Add group definition to topology template. * * @param serviceTemplate the service template @@ -267,7 +496,14 @@ public class DataModelUtil { */ public static void addGroupDefinitionToTopologyTemplate(ServiceTemplate serviceTemplate, String groupName, GroupDefinition group) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (serviceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); throw new CoreException( new InvalidAddActionNullEntityErrorBuilder("Group Definition", "Service Template") .build()); @@ -285,7 +521,9 @@ public class DataModelUtil { Map<String, GroupDefinition> groups = new HashMap<>(); serviceTemplate.getTopology_template().setGroups(groups); } + serviceTemplate.getTopology_template().getGroups().put(groupName, group); + mdcDataDebugMessage.debugExitMessage(null, null); } /** @@ -306,6 +544,10 @@ public class DataModelUtil { Status status, EntrySchema entrySchema, Object defaultVal) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + PropertyDefinition propDef = new PropertyDefinition(); propDef.setType(type); propDef.setDescription(description); @@ -317,10 +559,50 @@ public class DataModelUtil { propDef.setEntry_schema(entrySchema); propDef.set_default(defaultVal); + mdcDataDebugMessage.debugExitMessage(null, null); return propDef; } /** + * Create parameter definition property definition. + * + * @param type the type + * @param description the description + * @param value the value + * @param required the required + * @param constraints the constraints + * @param status the status + * @param entrySchema the entry schema + * @param defaultVal the default val + * @return the property definition + */ + public static ParameterDefinition createParameterDefinition(String type, String description, + Object value, boolean required, + List<Constraint> constraints, + Status status, + EntrySchema entrySchema, + Object defaultVal) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + ParameterDefinition paramDef = new ParameterDefinition(); + paramDef.setType(type); + paramDef.setDescription(description); + paramDef.setValue(value); + paramDef.setRequired(required); + paramDef.setConstraints(constraints); + if (status != null) { + paramDef.setStatus(status); + } + paramDef.setEntry_schema(entrySchema); + paramDef.set_default(defaultVal); + + mdcDataDebugMessage.debugExitMessage(null, null); + return paramDef; + } + + /** * Create requirement requirement definition. * * @param capability the capability @@ -331,6 +613,10 @@ public class DataModelUtil { */ public static RequirementDefinition createRequirement(String capability, String node, String relationship, Object[] occurrences) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + RequirementDefinition requirementDefinition = new RequirementDefinition(); requirementDefinition.setCapability(capability); requirementDefinition.setNode(node); @@ -338,6 +624,8 @@ public class DataModelUtil { if (occurrences != null) { requirementDefinition.setOccurrences(occurrences); } + + mdcDataDebugMessage.debugExitMessage(null, null); return requirementDefinition; } @@ -355,6 +643,10 @@ public class DataModelUtil { Status status, EntrySchema entrySchema, Object defaultVal) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + AttributeDefinition attributeDef = new AttributeDefinition(); attributeDef.setType(type); @@ -367,6 +659,7 @@ public class DataModelUtil { attributeDef.setEntry_schema(entrySchema); attributeDef.set_default(defaultVal); + mdcDataDebugMessage.debugExitMessage(null, null); return attributeDef; } @@ -377,10 +670,16 @@ public class DataModelUtil { * @return the constraint */ public static Constraint createValidValuesConstraint(Object... values) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + Constraint validValues = new Constraint(); for (Object value : values) { validValues.addValidValue(value); } + + mdcDataDebugMessage.debugExitMessage(null, null); return validValues; } @@ -392,13 +691,17 @@ public class DataModelUtil { * @param templateAuthor the template author * @return the metadata */ - public static Metadata createMetadata(String templateName, String templateVersion, + public static Map<String, String> createMetadata(String templateName, String templateVersion, String templateAuthor) { - Metadata metadata = new Metadata(); - metadata.setTemplate_name(templateName); - metadata.setTemplate_version(templateVersion); - metadata.setTemplate_author(templateAuthor); + + mdcDataDebugMessage.debugEntryMessage(null, null); + Map<String, String> metadata = new HashMap<>(); + metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, templateName); + metadata.put("template_version", templateVersion); + metadata.put("template_author", templateAuthor); + + mdcDataDebugMessage.debugExitMessage(null, null); return metadata; } @@ -412,10 +715,16 @@ public class DataModelUtil { */ public static EntrySchema createEntrySchema(String type, String description, List<Constraint> constraints) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + EntrySchema entrySchema = new EntrySchema(); entrySchema.setType(type); entrySchema.setDescription(description); entrySchema.setConstraints(constraints); + + mdcDataDebugMessage.debugExitMessage(null, null); return entrySchema; } @@ -426,11 +735,17 @@ public class DataModelUtil { * @return the list */ public static List<Constraint> createValidValuesConstraintsList(String... values) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + List<Constraint> constraints; Constraint validValues; constraints = new ArrayList<>(); validValues = DataModelUtil.createValidValuesConstraint(values); constraints.add(validValues); + + mdcDataDebugMessage.debugExitMessage(null, null); return constraints; } @@ -441,9 +756,12 @@ public class DataModelUtil { * @return the constraint */ public static Constraint createGreaterOrEqualConstrain(Object value) { + mdcDataDebugMessage.debugEntryMessage(null, null); Constraint constraint = new Constraint(); constraint.setGreater_or_equal(value); + + mdcDataDebugMessage.debugExitMessage(null, null); return constraint; } @@ -469,6 +787,10 @@ public class DataModelUtil { public static Map createGetInputPropertyValueFromListParameter(String inputPropertyListName, int indexInTheList, String... nestedPropertyName) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + List propertyList = new ArrayList<>(); propertyList.add(inputPropertyListName); propertyList.add(indexInTheList); @@ -477,6 +799,8 @@ public class DataModelUtil { } Map getInputProperty = new HashMap<>(); getInputProperty.put(ToscaFunctions.GET_INPUT.getDisplayName(), propertyList); + + mdcDataDebugMessage.debugExitMessage(null, null); return getInputProperty; } @@ -488,6 +812,10 @@ public class DataModelUtil { */ public static ParameterDefinitionExt convertPropertyDefToParameterDef( PropertyDefinition propertyDefinition) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (propertyDefinition == null) { return null; } @@ -499,10 +827,12 @@ public class DataModelUtil { parameterDefinition.set_default(propertyDefinition.get_default()); parameterDefinition.setStatus(propertyDefinition.getStatus()); parameterDefinition.setConstraints(propertyDefinition.getConstraints()); - parameterDefinition.setEntry_schema(propertyDefinition.getEntry_schema()); + parameterDefinition.setEntry_schema(Objects.isNull(propertyDefinition.getEntry_schema()) ? null + : propertyDefinition.getEntry_schema().clone()); parameterDefinition.setHidden(false); parameterDefinition.setImmutable(false); + mdcDataDebugMessage.debugExitMessage(null, null); return parameterDefinition; } @@ -515,74 +845,535 @@ public class DataModelUtil { */ public static ParameterDefinitionExt convertAttributeDefToParameterDef( AttributeDefinition attributeDefinition, Map<String, List> outputValue) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (attributeDefinition == null) { return null; } ParameterDefinitionExt parameterDefinition = new ParameterDefinitionExt(); parameterDefinition.setDescription(attributeDefinition.getDescription()); parameterDefinition.setValue(outputValue); + + mdcDataDebugMessage.debugExitMessage(null, null); return parameterDefinition; } /** - * Clone constraints list. + * Convert capability type to capability definition capability definition. * - * @param constraints the constraints - * @return the list + * @param capabilityTypeId the capability type id + * @param capabilityType the capability type + * @param properties the properties + * @return the capability definition */ - public static List<Constraint> cloneConstraints(List<Constraint> constraints) { - if (constraints == null) { + public static CapabilityDefinition convertCapabilityTypeToCapabilityDefinition( + String capabilityTypeId, CapabilityType capabilityType, Map<String, Object> properties) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setAttributes(cloneAttributeDefinitionMap(capabilityType.getAttributes())); + capabilityDefinition.setProperties(clonePropertyDefinitionMap(capabilityType.getProperties())); + capabilityDefinition.setDescription(capabilityType.getDescription()); + capabilityDefinition.setType(capabilityTypeId); + + capabilityDefinition.getProperties() + .entrySet() + .stream() + .filter(entry -> properties.containsKey(entry.getKey())) + .forEach(entry -> entry.getValue() + .set_default(properties.get(entry.getKey()))); + + mdcDataDebugMessage.debugExitMessage(null, null); + return capabilityDefinition; + } + + /** + * Clone property definition map map. + * + * @param propertyDefinitionMap the property definition map + * @return the map + */ + public static Map clonePropertyDefinitionMap( + Map<String, PropertyDefinition> propertyDefinitionMap) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + Map outMap = new HashMap<>(); + for (String propertyDefKey : propertyDefinitionMap.keySet()) { + PropertyDefinition propertyDefValue = propertyDefinitionMap.get(propertyDefKey); + outMap.put(new String(propertyDefKey), propertyDefValue.clone()); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return outMap; + } + + /** + * Clone attribute definition map map. + * + * @param attributeDefinitionMap the attribute definition map + * @return the map + */ + public static Map cloneAttributeDefinitionMap( + Map<String, AttributeDefinition> attributeDefinitionMap) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + Map outMap = new HashMap<>(); + for (String attributeDefKey : attributeDefinitionMap.keySet()) { + AttributeDefinition attributeDefinition = attributeDefinitionMap.get(attributeDefKey); + outMap.put(new String(attributeDefKey), attributeDefinition.clone()); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return outMap; + } + + public static boolean isNodeTemplate(String entryId, ServiceTemplate serviceTemplate) { + return serviceTemplate.getTopology_template().getNode_templates() != null + && serviceTemplate.getTopology_template().getNode_templates().get(entryId) != null; + } + + /** + * Add Input parameter. + * + * @param serviceTemplate the service template + * @param parameterDefinitionId the parameter definition id + * @param parameterDefinition the parameter definition + */ + public static void addInputParameterToTopologyTemplate(ServiceTemplate serviceTemplate, + String parameterDefinitionId, + ParameterDefinition parameterDefinition) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (Objects.isNull(serviceTemplate)) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Topology Template Input Parameter", + "Service Template").build()); + } + TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template(); + if (Objects.isNull(topologyTemplate)) { + topologyTemplate = new TopologyTemplate(); + serviceTemplate.setTopology_template(topologyTemplate); + } + if (topologyTemplate.getInputs() == null) { + topologyTemplate.setInputs(new HashMap<>()); + } + topologyTemplate.getInputs().put(parameterDefinitionId, parameterDefinition); + + mdcDataDebugMessage.debugExitMessage(null, null); + + } + + /** + * Add Output parameter. + * + * @param serviceTemplate the service template + * @param parameterDefinitionId the parameter definition id + * @param parameterDefinition the parameter definition + */ + public static void addOutputParameterToTopologyTemplate(ServiceTemplate serviceTemplate, + String parameterDefinitionId, + ParameterDefinition parameterDefinition) { + + + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (Objects.isNull(serviceTemplate)) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ADD_ACTION); + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Topology Template Ouput Parameter", + "Service Template").build()); + } + TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template(); + if (Objects.isNull(topologyTemplate)) { + topologyTemplate = new TopologyTemplate(); + serviceTemplate.setTopology_template(topologyTemplate); + } + if (topologyTemplate.getOutputs() == null) { + topologyTemplate.setOutputs(new HashMap<>()); + } + topologyTemplate.getOutputs().put(parameterDefinitionId, parameterDefinition); + + mdcDataDebugMessage.debugExitMessage(null, null); + + } + + /** + * Add requirement def to requirement def list. + * + * @param requirementList requirement list + * @param requirementDef added requirement def + */ + public static void addRequirementToList(List<Map<String, RequirementDefinition>> requirementList, + Map<String, RequirementDefinition> requirementDef) { + if (requirementDef == null) { + return; + } + if (requirementList == null) { + requirementList = new ArrayList<Map<String, RequirementDefinition>>(); + } + + for (Map.Entry<String, RequirementDefinition> entry : requirementDef.entrySet()) { + CommonMethods.mergeEntryInList(entry.getKey(), entry.getValue(), requirementList); + } + } + + /** + * get node template requirement. + * + * @param nodeTemplate node template + */ + public static Map<String, RequirementAssignment> getNodeTemplateRequirements( + NodeTemplate nodeTemplate) { + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (Objects.isNull(nodeTemplate)) { return null; } - return constraints.stream().map(Constraint::clone).collect(Collectors.toList()); + List<Map<String, RequirementAssignment>> templateRequirements = nodeTemplate.getRequirements(); + + Map<String, RequirementAssignment> nodeTemplateRequirementsAssignment = new HashMap<>(); + if (CollectionUtils.isEmpty(templateRequirements)) { + return nodeTemplateRequirementsAssignment; + } + YamlUtil yamlUtil = new YamlUtil(); + for (Map<String, RequirementAssignment> requirementAssignmentMap : templateRequirements) { + for (Map.Entry<String, RequirementAssignment> requirementEntry : requirementAssignmentMap + .entrySet()) { + RequirementAssignment requirementAssignment = (yamlUtil + .yamlToObject(yamlUtil.objectToYaml(requirementEntry.getValue()), + RequirementAssignment.class)); + nodeTemplateRequirementsAssignment + .put(requirementEntry.getKey(), requirementAssignment); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return nodeTemplateRequirementsAssignment; } /** - * Clone valid source types list. + * Gets the list of requirements for the node template. * - * @param validSourceTypes the valid source types - * @return the list + * @param nodeTemplate the node template + * @return the node template requirement list and null if the node has no requirements */ - public static List<String> cloneValidSourceTypes(List<String> validSourceTypes) { - if (validSourceTypes == null) { + public static List<Map<String, RequirementAssignment>> getNodeTemplateRequirementList( + NodeTemplate nodeTemplate) { + mdcDataDebugMessage.debugEntryMessage(null, null); + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + //Creating concrete objects + List<Map<String, RequirementAssignment>> requirements = nodeTemplate.getRequirements(); + List<Map<String, RequirementAssignment>> concreteRequirementList = null; + if (requirements != null) { + concreteRequirementList = new ArrayList<>(); + ListIterator<Map<String, RequirementAssignment>> reqListIterator = requirements + .listIterator(); + while (reqListIterator.hasNext()) { + Map<String, RequirementAssignment> requirement = reqListIterator.next(); + Map<String, RequirementAssignment> concreteRequirement = new HashMap<>(); + for (Map.Entry<String, RequirementAssignment> reqEntry : requirement.entrySet()) { + RequirementAssignment requirementAssignment = (toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(reqEntry.getValue()), + RequirementAssignment.class)); + concreteRequirement.put(reqEntry.getKey(), requirementAssignment); + concreteRequirementList.add(concreteRequirement); + reqListIterator.remove(); + } + } + requirements.clear(); + requirements.addAll(concreteRequirementList); + nodeTemplate.setRequirements(requirements); + } + mdcDataDebugMessage.debugExitMessage(null, null); + return concreteRequirementList; + } + + /** + * get requirement assignment from requirement assignment list by req key. + * + * @param requirementsAssignmentList requirement defenition list + * @param requirementKey requirement key + */ + public static Optional<List<RequirementAssignment>> getRequirementAssignment( + List<Map<String, RequirementAssignment>> requirementsAssignmentList, + String requirementKey) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + if (CollectionUtils.isEmpty(requirementsAssignmentList)) { + return Optional.empty(); + } + + List<RequirementAssignment> matchRequirementAssignmentList = new ArrayList<>(); + for (Map<String, RequirementAssignment> requirementMap : requirementsAssignmentList) { + if (requirementMap.containsKey(requirementKey)) { + YamlUtil yamlUtil = new YamlUtil(); + RequirementAssignment requirementAssignment = (yamlUtil + .yamlToObject(yamlUtil.objectToYaml(requirementMap.get(requirementKey)), + RequirementAssignment.class)); + matchRequirementAssignmentList.add(requirementAssignment); + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return Optional.ofNullable(matchRequirementAssignmentList); + } + + /** + * remove requirement defenition from requirement defenition list by req key. + * + * @param requirementsDefinitionList requirement defenition list + * @param requirementKey requirement key + */ + public static void removeRequirementsDefinition( + List<Map<String, RequirementDefinition>> requirementsDefinitionList, + String requirementKey) { + mdcDataDebugMessage.debugEntryMessage(null, null); + if (requirementsDefinitionList == null) { + return; + } + + List<Map<String, RequirementDefinition>> mapToBeRemoved = new ArrayList<>(); + for (Map<String, RequirementDefinition> reqMap : requirementsDefinitionList) { + reqMap.remove(requirementKey); + if (reqMap.isEmpty()) { + mapToBeRemoved.add(reqMap); + } + } + for (Map<String, RequirementDefinition> removeMap : mapToBeRemoved) { + requirementsDefinitionList.remove(removeMap); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + /** + * remove requirement assignment from requirement defenition list by req key. + * + * @param requirementsAssignmentList requirement Assignment list + * @param requirementKey requirement key + */ + public static void removeRequirementsAssignment( + List<Map<String, RequirementAssignment>> requirementsAssignmentList, + String requirementKey) { + mdcDataDebugMessage.debugEntryMessage(null, null); + if (requirementsAssignmentList == null) { + return; + } + + List<Map<String, RequirementAssignment>> mapToBeRemoved = new ArrayList<>(); + for (Map<String, RequirementAssignment> reqMap : requirementsAssignmentList) { + reqMap.remove(requirementKey); + if (reqMap.isEmpty()) { + mapToBeRemoved.add(reqMap); + } + } + for (Map<String, RequirementAssignment> removeMap : mapToBeRemoved) { + requirementsAssignmentList.remove(removeMap); + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + + /** + * Remove requirement assignment. + * + * @param nodeTemplate the node template + * @param requirementKey the requirement key + * @param requirementAssignmentToBeDeleted the requirement assignment to be deleted + */ + public static void removeRequirementAssignment( + NodeTemplate nodeTemplate, + String requirementKey, + RequirementAssignment requirementAssignmentToBeDeleted) { + mdcDataDebugMessage.debugEntryMessage(null, null); + ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl(); + List<Map<String, RequirementAssignment>> nodeTemplateRequirements = nodeTemplate + .getRequirements(); + if (nodeTemplateRequirements == null) { + return; + } + + Map<String, RequirementAssignment> mapToBeRemoved = new HashMap<>(); + ListIterator<Map<String, RequirementAssignment>> iter = nodeTemplateRequirements.listIterator(); + while (iter.hasNext()) { + Map<String, RequirementAssignment> reqMap = iter.next(); + RequirementAssignment requirementAssignment = reqMap.get(requirementKey); + if (requirementAssignment != null) { + boolean isDesiredRequirementAssignment = toscaAnalyzerService + .isDesiredRequirementAssignment(requirementAssignment, + requirementAssignmentToBeDeleted.getCapability(), + requirementAssignmentToBeDeleted.getNode(), + requirementAssignmentToBeDeleted.getRelationship()); + if (isDesiredRequirementAssignment) { + iter.remove(); + } + } + } + + mdcDataDebugMessage.debugExitMessage(null, null); + } + + /** + * Return the suffix of the input namespace + * For an exmpale - for abc.sdf.vsrx, retrun vsrx + * + * @param namespace namespace + * @return String namespace suffix + */ + public static String getNamespaceSuffix(String namespace) { + if (namespace == null) { return null; } - return validSourceTypes.stream().collect(Collectors.toList()); + String delimiterChar = "."; + if (namespace.contains(delimiterChar)) { + return namespace.substring(namespace.lastIndexOf(delimiterChar) + 1); + } + return namespace; } /** - * Clone property definitions map. + * Return true if the input import exist in the input imports list. * - * @param propertyDefinitions the property definitions - * @return the map + * @param imports namespace + * @param importId namespace + * @return true if exist, flase if not exist + */ + public static boolean isImportAddedToServiceTemplate(List<Map<String, Import>> imports, + String importId) { + for (Map<String, Import> anImport : imports) { + if (anImport.containsKey(importId)) { + return true; + } + } + return false; + } + + /** + * Get output parameter according to the input outputParameterId. + * + * @param serviceTemplate service template + * @param outputParameterId output parameter id + * @return ParameterDefinition - output parameter */ - public static Map<String, PropertyDefinition> clonePropertyDefinitions( - Map<String, PropertyDefinition> propertyDefinitions) { - if (propertyDefinitions == null) { + public static ParameterDefinition getOuputParameter(ServiceTemplate serviceTemplate, + String outputParameterId) { + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (serviceTemplate == null + || serviceTemplate.getTopology_template() == null + || serviceTemplate.getTopology_template().getOutputs() == null) { return null; } - Map<String, PropertyDefinition> clonedProperties = new HashMap<>(); - for (String propertyKey : propertyDefinitions.keySet()) { - clonedProperties.put(propertyKey, propertyDefinitions.get(propertyKey).clone()); + + mdcDataDebugMessage.debugExitMessage(null, null); + return serviceTemplate.getTopology_template().getOutputs().get(outputParameterId); + } + + /** + * Gets input parameters in a service template. + * + * @param serviceTemplate the service template + * @return the input parameters + */ + public static Map<String, ParameterDefinition> getInputParameters(ServiceTemplate + serviceTemplate) { + if (serviceTemplate == null + || serviceTemplate.getTopology_template() == null + || serviceTemplate.getTopology_template().getInputs() == null) { + return null; } - return clonedProperties; + return serviceTemplate.getTopology_template().getInputs(); } /** - * Clone attribute definitions map. + * Gets relationship templates in a service template. * - * @param attributeDefinitions the attribute definitions - * @return the map + * @param serviceTemplate the service template + * @return the relationship template + */ + public static Map<String, RelationshipTemplate> getRelationshipTemplates(ServiceTemplate + serviceTemplate) { + if (serviceTemplate == null + || serviceTemplate.getTopology_template() == null + || serviceTemplate.getTopology_template().getRelationship_templates() == null) { + return null; + } + return serviceTemplate.getTopology_template().getRelationship_templates(); + } + + /** + * Get property value according to the input propertyId. + * + * @param nodeTemplate node template + * @param propertyId property id + * @return Object property Value */ - public static Map<String, AttributeDefinition> cloneAttributeDefinitions( - Map<String, AttributeDefinition> attributeDefinitions) { - if (attributeDefinitions == null) { + public static Object getPropertyValue(NodeTemplate nodeTemplate, + String propertyId) { + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (nodeTemplate == null + || nodeTemplate.getProperties() == null) { return null; } - Map<String, AttributeDefinition> clonedAttributeDefinitions = new HashMap<>(); - for (String attributeKey : attributeDefinitions.keySet()) { - clonedAttributeDefinitions.put(attributeKey, attributeDefinitions.get(attributeKey).clone()); + + mdcDataDebugMessage.debugExitMessage(null, null); + return nodeTemplate.getProperties().get(propertyId); + } + + /** + * Get node template properties according to the input node template id. + * + * @param serviceTemplate service template + * @param nodeTemplateId node template id + * @return node template properties + */ + public static Map<String, Object> getNodeTemplateProperties(ServiceTemplate serviceTemplate, + String nodeTemplateId) { + mdcDataDebugMessage.debugEntryMessage(null, null); + + if (serviceTemplate == null + || serviceTemplate.getTopology_template() == null + || serviceTemplate.getTopology_template().getNode_templates() == null + || serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId) == null) { + return null; + } + + mdcDataDebugMessage.debugExitMessage(null, null); + return serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId) + .getProperties(); + } + + /** + * Compare two requirement assignment objects for equality. + * + * @param first the first requirement assignement object + * @param second the second requirement assignement object + * @return true if objects are equal and false otherwise + */ + public static boolean compareRequirementAssignment(RequirementAssignment first, + RequirementAssignment second) { + if (first.getCapability().equals(second.getCapability()) + && first.getNode().equals(second.getNode()) + && first.getRelationship().equals(second.getRelationship())) { + return true; } - return clonedAttributeDefinitions; + return false; } } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java index 271c471922..7d408ab82e 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java @@ -23,9 +23,11 @@ package org.openecomp.sdc.tosca.services; import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; @@ -38,6 +40,8 @@ public interface ToscaAnalyzerService { Map<String, NodeTemplate> getNodeTemplatesByType(ServiceTemplate serviceTemplate, String nodeType, ToscaServiceModel toscaServiceModel); + Optional<NodeType> fetchNodeType(String nodeTypeKey, Collection<ServiceTemplate> serviceTemplates); + boolean isTypeOf(NodeTemplate nodeTemplate, String nodeType, ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel); @@ -63,4 +67,13 @@ public interface ToscaAnalyzerService { Object getFlatEntity(ToscaElementTypes elementType, String type, ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel); + + boolean isSubstitutableNodeTemplate(NodeTemplate nodeTemplate); + + NodeType createInitSubstitutionNodeType(ServiceTemplate substitutionServiceTemplate, + String nodeTypeDerivedFromValue); + + boolean isRequirementExistInNodeTemplate(NodeTemplate nodeTemplate, + String requirementId, + RequirementAssignment requirementAssignment); } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java index 27cf07e166..cf0c763846 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java @@ -23,11 +23,6 @@ package org.openecomp.sdc.tosca.services; public class ToscaConstants { - //TOSCA Node Types prefix - public static final String NODES_PREFIX = "org.openecomp.resource.vfc.nodes.heat."; - public static final String NODES_SUBSTITUTION_PREFIX - = "org.openecomp.resource.abstract.nodes.heat."; - //TOSCA Requirement Ids public static final String DEPENDS_ON_REQUIREMENT_ID = "dependency"; public static final String BINDING_REQUIREMENT_ID = "binding"; @@ -43,6 +38,8 @@ public class ToscaConstants { public static final String ENDPOINT_CAPABILITY_ID = "endpoint"; public static final String OS_CAPABILITY_ID = "os"; public static final String SCALABLE_CAPABILITY_ID = "scalable"; + public static final String ATTACHMENT_CAPABILITY_ID = "attachment"; + public static final String FEATURE_CAPABILITY_ID = "feature"; //General public static final String TOSCA_DEFINITIONS_VERSION = "tosca_simple_yaml_1_0_0"; @@ -50,6 +47,8 @@ public class ToscaConstants { public static final String NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE = "substitutable"; public static final String NATIVE_TYPES_SERVICE_TEMPLATE_NAME = "NativeTypesServiceTemplate"; public static final String UNBOUNDED = "UNBOUNDED"; + public static final String ST_METADATA_FILE_NAME = "filename"; + public static final String ST_METADATA_TEMPLATE_NAME = "template_name"; //properties public static final String SERVICE_TEMPLATE_FILTER_PROPERTY_NAME = "service_template_filter"; @@ -61,5 +60,12 @@ public class ToscaConstants { public static final String DHCP_ENABLED_PROPERTY_NAME = "dhcp_enabled"; + public static final String PORT_FIXED_IPS = "fixed_ips"; + public static final String PORT_ALLOWED_ADDRESS_PAIRS = "allowed_address_pairs"; + public static final String MAC_ADDRESS = "mac_address"; + + public static final String COMPUTE_IMAGE = "image"; + public static final String COMPUTE_FLAVOR = "flavor"; + } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java deleted file mode 100644 index 013d761168..0000000000 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java +++ /dev/null @@ -1,309 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.tosca.services; - -import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; -import org.openecomp.sdc.tosca.datatypes.ToscaDataType; -import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; -import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; - -import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; -import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; -import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition; -import org.openecomp.sdc.tosca.datatypes.model.NodeType; -import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition; -import org.openecomp.sdc.tosca.datatypes.model.PropertyType; -import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition; -import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * The type Tosca native types service template. - */ -public class ToscaNativeTypesServiceTemplate { - /** - * Create service template service template. - * - * @return the service template - */ - public static ServiceTemplate createServiceTemplate() { - ServiceTemplate nativeNodeTypesServiceTemplate = new ServiceTemplate(); - nativeNodeTypesServiceTemplate - .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION); - nativeNodeTypesServiceTemplate.setMetadata(DataModelUtil - .createMetadata(ToscaConstants.NATIVE_TYPES_SERVICE_TEMPLATE_NAME, "1.0.0", null)); - nativeNodeTypesServiceTemplate.setDescription("TOSCA Native Node Types"); - nativeNodeTypesServiceTemplate.setNode_types(createNativeNodeTypes()); - return nativeNodeTypesServiceTemplate; - } - - private static Map<String, NodeType> createNativeNodeTypes() { - Map<String, NodeType> nativeNodeTypes = new HashMap<>(); - nativeNodeTypes.put(ToscaNodeType.COMPUTE.getDisplayName(), createToscaNodesComputeNodeType()); - nativeNodeTypes.put(ToscaNodeType.ROOT.getDisplayName(), createToscaNodesRootNodeType()); - nativeNodeTypes - .put(ToscaNodeType.NETWORK_PORT.getDisplayName(), createToscaNodesPortsNodeType()); - nativeNodeTypes - .put(ToscaNodeType.BLOCK_STORAGE.getDisplayName(), createToscaNodesBlockStorageNodeType()); - nativeNodeTypes.put(ToscaNodeType.NETWORK.getDisplayName(), createToscaNodesNetworkNodeType()); - return nativeNodeTypes; - } - - private static NodeType createToscaNodesComputeNodeType() { - NodeType computeNodeType = new NodeType(); - computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); - computeNodeType.setAttributes(createComputeAttributes()); - computeNodeType.setRequirements(createComputeRequirements()); - computeNodeType.setCapabilities(createComputeCapabilities()); - return computeNodeType; - } - - private static NodeType createToscaNodesRootNodeType() { - NodeType computeNodeType = new NodeType(); - computeNodeType.setAttributes(createRootAttributes()); - computeNodeType.setInterfaces(createRootInterfaces()); - return computeNodeType; - } - - private static NodeType createToscaNodesPortsNodeType() { - NodeType computeNodeType = new NodeType(); - computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); - computeNodeType.setProperties(createToscaNodesPortProperties()); - computeNodeType.setRequirements(createToscaNodesPortRequirements()); - return computeNodeType; - } - - private static NodeType createToscaNodesBlockStorageNodeType() { - NodeType computeNodeType = new NodeType(); - computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); - computeNodeType.setProperties(createToscaNodesBlockStorageProperties()); - computeNodeType.setCapabilities(createToscaNodesBlockStorageCapabilities()); - return computeNodeType; - } - - private static NodeType createToscaNodesNetworkNodeType() { - NodeType computeNodeType = new NodeType(); - computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); - computeNodeType.setProperties(createToscaNodesNetworkProperties()); - computeNodeType.setCapabilities(createToscaNodesNetworkCapabilities()); - return computeNodeType; - } - - private static Map<String, PropertyDefinition> createToscaNodesPortProperties() { - Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>(); - propertyDefinitionMap.put("ip_address", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("order", DataModelUtil - .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(), null, true, - DataModelUtil.getConstrainList(DataModelUtil.createGreaterOrEqualConstrain(0)), null, - null, 0)); - propertyDefinitionMap.put("is_default", DataModelUtil - .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), null, false, null, null, - null, false)); - propertyDefinitionMap.put("ip_range_start", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("ip_range_end", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - return propertyDefinitionMap; - } - - private static Map<String, PropertyDefinition> createToscaNodesBlockStorageProperties() { - Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>(); - propertyDefinitionMap.put("size", DataModelUtil - .createPropertyDefinition(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(), null, false, - DataModelUtil.getConstrainList(DataModelUtil.createGreaterOrEqualConstrain("1 MB")), - null, null, null)); - propertyDefinitionMap.put("volume_id", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("snapshot_id", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - return propertyDefinitionMap; - } - - private static Map<String, PropertyDefinition> createToscaNodesNetworkProperties() { - Map<String, PropertyDefinition> propertyDefinitionMap = new HashMap<>(); - propertyDefinitionMap.put("ip_version", DataModelUtil - .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(), null, false, - DataModelUtil.getConstrainList(DataModelUtil.createValidValuesConstraint(4, 6)), null, - null, 4)); - propertyDefinitionMap.put("cidr", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("start_ip", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("end_ip", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("gateway_ip", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("network_name", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("network_id", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("segmentation_id", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("network_type", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("physical_network", DataModelUtil - .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, - null, null)); - propertyDefinitionMap.put("dhcp_enabled", DataModelUtil - .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), null, false, null, null, - null, true)); - - return propertyDefinitionMap; - } - - private static Map<String, InterfaceDefinition> createRootInterfaces() { - return new HashMap<>(); - } - - private static Map<String, CapabilityDefinition> createComputeCapabilities() { - Map<String, CapabilityDefinition> computeCapabilities = new HashMap<>(); - computeCapabilities.put(ToscaConstants.HOST_CAPABILITY_ID, - createCapabilityDefinition(ToscaCapabilityType.CONTAINER.getDisplayName(), - createValidSourceTypes("tosca.nodes.SoftwareComponent"))); - computeCapabilities.put(ToscaConstants.ENDPOINT_CAPABILITY_ID, - createCapabilityDefinition(ToscaCapabilityType.ENDPOINT_ADMIN.getDisplayName(), null)); - computeCapabilities.put(ToscaConstants.OS_CAPABILITY_ID, - createCapabilityDefinition(ToscaCapabilityType.OPERATING_SYSTEM.getDisplayName(), null)); - computeCapabilities.put(ToscaConstants.SCALABLE_CAPABILITY_ID, - createCapabilityDefinition(ToscaCapabilityType.SCALABLE.getDisplayName(), null)); - computeCapabilities.put(ToscaConstants.BINDING_CAPABILITY_ID, - createCapabilityDefinition(ToscaCapabilityType.NETWORK_BINDABLE.getDisplayName(), null)); - return computeCapabilities; - } - - private static Map<String, CapabilityDefinition> createToscaNodesBlockStorageCapabilities() { - Map<String, CapabilityDefinition> computeCapabilities = new HashMap<>(); - computeCapabilities.put("attachment", - createCapabilityDefinition(ToscaCapabilityType.ATTACHMENT.getDisplayName(), null)); - return computeCapabilities; - } - - private static Map<String, CapabilityDefinition> createToscaNodesNetworkCapabilities() { - Map<String, CapabilityDefinition> computeCapabilities = new HashMap<>(); - computeCapabilities.put(ToscaConstants.LINK_CAPABILITY_ID, - createCapabilityDefinition(ToscaCapabilityType.NETWORK_LINKABLE.getDisplayName(), null)); - return computeCapabilities; - } - - private static List<String> createValidSourceTypes(String... validSourceTypes) { - return Arrays.asList(validSourceTypes); - } - - private static CapabilityDefinition createCapabilityDefinition(String type, - List<String> validSourceTypes) { - CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); - capabilityDefinition.setType(type); - capabilityDefinition.setValid_source_types(validSourceTypes); - return capabilityDefinition; - } - - private static List<Map<String, RequirementDefinition>> createComputeRequirements() { - List<Map<String, RequirementDefinition>> computeRequirementList = new ArrayList<>(); - Map<String, RequirementDefinition> localStorageRequirement = new HashMap<>(); - localStorageRequirement.put("local_storage", DataModelUtil - .createRequirement(ToscaCapabilityType.ATTACHMENT.getDisplayName(), - ToscaNodeType.BLOCK_STORAGE.getDisplayName(), - ToscaRelationshipType.NATIVE_ATTACHES_TO.getDisplayName(), - createOccurrences(0, ToscaConstants.UNBOUNDED))); - computeRequirementList.add(localStorageRequirement); - return computeRequirementList; - } - - private static List<Map<String, RequirementDefinition>> createToscaNodesPortRequirements() { - List<Map<String, RequirementDefinition>> requirements = new ArrayList<>(); - - Map<String, RequirementDefinition> linkRequirement = new HashMap<>(); - linkRequirement.put(ToscaConstants.LINK_REQUIREMENT_ID, DataModelUtil - .createRequirement(ToscaCapabilityType.NETWORK_LINKABLE.getDisplayName(), - ToscaNodeType.ROOT.getDisplayName(), - ToscaRelationshipType.NETWORK_LINK_TO.getDisplayName(), null)); - requirements.add(linkRequirement); - - Map<String, RequirementDefinition> bindingRequirement = new HashMap<>(); - bindingRequirement.put(ToscaConstants.BINDING_REQUIREMENT_ID, DataModelUtil - .createRequirement(ToscaCapabilityType.NETWORK_BINDABLE.getDisplayName(), - ToscaNodeType.ROOT.getDisplayName(), - ToscaRelationshipType.NETWORK_BINDS_TO.getDisplayName(), null)); - requirements.add(bindingRequirement); - - return requirements; - } - - - private static Object[] createOccurrences(Object min, Object max) { - return new Object[]{min, max}; - - } - - private static Map<String, AttributeDefinition> createComputeAttributes() { - Map<String, AttributeDefinition> computeAttributesDefMap = new HashMap<>(); - computeAttributesDefMap.put("private_address", DataModelUtil - .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "private address", null, - null, null)); - computeAttributesDefMap.put("public_address", DataModelUtil - .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "public_address", null, - null, null)); - computeAttributesDefMap.put("networks", DataModelUtil - .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "networks", null, - DataModelUtil - .createEntrySchema(ToscaDataType.NETWORK_NETWORK_INFO.getDisplayName(), null, null), - null)); - computeAttributesDefMap.put("ports", DataModelUtil - .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "ports", null, DataModelUtil - .createEntrySchema(ToscaDataType.NETWORK_PORT_INFO.getDisplayName(), null, null), - null)); - return computeAttributesDefMap; - } - - private static Map<String, AttributeDefinition> createRootAttributes() { - Map<String, AttributeDefinition> attributesDefMap = new HashMap<>(); - attributesDefMap.put("tosca_id", DataModelUtil - .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "tosca id", null, null, - null)); - attributesDefMap.put("tosca_name", DataModelUtil - .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "tosca name", null, null, - null)); - attributesDefMap.put("state", DataModelUtil - .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "state", null, null, - null)); - return attributesDefMap; - } - -} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java index 4f9c70267d..f3bf3280dc 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java @@ -20,18 +20,10 @@ package org.openecomp.sdc.tosca.services; -import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; -import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; -import org.openecomp.sdc.tosca.datatypes.model.NodeType; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.Set; import java.util.UUID; /** @@ -52,100 +44,40 @@ public class ToscaUtil { if (serviceTemplate.getMetadata() == null) { return UUID.randomUUID().toString() + "ServiceTemplate.yaml"; } - return getServiceTemplateFileName(serviceTemplate.getMetadata().getTemplate_name()); + return getServiceTemplateFileName(serviceTemplate.getMetadata()); } /** * Gets service template file name. * - * @param templateName the template name + * @param metaData the file name * @return the service template file name */ - public static String getServiceTemplateFileName(String templateName) { - return (Objects.isNull(templateName) ? UUID.randomUUID().toString() : templateName) - + "ServiceTemplate.yaml"; - } - - /** - * Add service template to map with key file name. - * - * @param serviceTemplates the service templates - * @param commonServiceTemplate the common service template - */ - public static void addServiceTemplateToMapWithKeyFileName( - Map<String, ServiceTemplate> serviceTemplates, ServiceTemplate commonServiceTemplate) { - serviceTemplates - .put(ToscaUtil.getServiceTemplateFileName(commonServiceTemplate), commonServiceTemplate); - } - - /** - * Convert type to definition capability definition. - * - * @param type the type - * @param capabilityType the capability type - * @param properties the properties - * @param description the description - * @return the capability definition - */ - public static CapabilityDefinition convertTypeToDefinition(String type, - CapabilityType capabilityType, - Map<String, Object> properties, - String description) { - CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); - capabilityDefinition.setAttributes(capabilityType.getAttributes()); - capabilityDefinition.setProperties(capabilityType.getProperties()); - if (description == null) { - capabilityDefinition.setDescription(capabilityType.getDescription()); - } else { - capabilityDefinition.setDescription(description); + public static String getServiceTemplateFileName(Map<String, String> metadata) { + if (metadata.get(ToscaConstants.ST_METADATA_FILE_NAME) != null) { + return metadata.get(ToscaConstants.ST_METADATA_FILE_NAME); + } else if (metadata.get(ToscaConstants.ST_METADATA_TEMPLATE_NAME) != null) { + return metadata.get(ToscaConstants.ST_METADATA_TEMPLATE_NAME) + "ServiceTemplate.yaml"; } - capabilityDefinition.setType(type); - - capabilityDefinition.getProperties() - .entrySet() - .stream() - .filter(entry -> properties.containsKey(entry.getKey())) - .forEach(entry -> entry.getValue() - .set_default(properties.get(entry.getKey()))); - - - return capabilityDefinition; + return UUID.randomUUID().toString() + "ServiceTemplate.yaml"; } + /** - * Normalize component name node type map. + * Add service template to map with key file name. * - * @param toscaModel the tosca model - * @param components the components - * @return the map + * @param serviceTemplateMap the service template map + * @param serviceTemplate the service template */ - public static Map<String, List<NodeType>> normalizeComponentNameNodeType( - ToscaServiceModel toscaModel, Set<String> components) { - - Map<String, List<NodeType>> normalizedData = new HashMap<>(); - toscaModel - .getServiceTemplates() - .entrySet().stream().filter(entry -> entry - .getValue() - .getNode_types() != null) - .forEach(entry -> entry - .getValue() - .getNode_types() - .entrySet().stream() - .filter(nodeTypeEntry -> components - .contains(nodeTypeEntry - .getKey())) - .forEach(nodeTypeEntry -> addNodeType(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(), - normalizedData))); - return normalizedData; + public static void addServiceTemplateToMapWithKeyFileName( + Map<String, ServiceTemplate> serviceTemplateMap, ServiceTemplate serviceTemplate) { + serviceTemplateMap.put(ToscaUtil.getServiceTemplateFileName(serviceTemplate), serviceTemplate); } - private static void addNodeType(String key, NodeType value, - Map<String, List<NodeType>> normalizedData) { - if (!normalizedData.containsKey(key)) { - normalizedData.put(key, new ArrayList<>()); - } - normalizedData.get(key).add(value); + public static String getServiceTemplateFileName(String templateName) { + Map<String, String> metadata = new HashMap<>(); + metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, templateName); + return getServiceTemplateFileName(metadata); } } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java index a11bff4b6a..e7aacb96cf 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java @@ -24,25 +24,37 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerErrorDescription; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes; import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; import org.openecomp.sdc.tosca.datatypes.model.Import; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; +import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition; +import org.openecomp.sdc.tosca.datatypes.model.PropertyType; import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.errors.ToscaInvalidEntryNotFoundErrorBuilder; import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder; import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstitutionServiceTemplateErrorBuilder; import org.openecomp.sdc.tosca.errors.ToscaNodeTypeNotFoundErrorBuilder; +import org.openecomp.sdc.tosca.services.DataModelUtil; import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; import org.openecomp.sdc.tosca.services.ToscaConstants; +import org.openecomp.sdc.tosca.services.ToscaUtil; import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +65,7 @@ import java.util.Set; public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { /* - node template with type equal to node type or derived from node type. + node template with type equal to node type or derived from node type */ @Override public Map<String, NodeTemplate> getNodeTemplatesByType(ServiceTemplate serviceTemplate, @@ -75,6 +87,19 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { } @Override + public Optional<NodeType> fetchNodeType(String nodeTypeKey, Collection<ServiceTemplate> + serviceTemplates) { + Optional<Map<String, NodeType>> nodeTypeMap = serviceTemplates.stream() + .map(st -> st.getNode_types()) + .filter(nodeTypes -> Objects.nonNull(nodeTypes) && nodeTypes.containsKey(nodeTypeKey)) + .findFirst(); + if (nodeTypeMap.isPresent()) { + return Optional.ofNullable(nodeTypeMap.get().values().iterator().next()); + } + return Optional.empty(); + } + + @Override public boolean isTypeOf(NodeTemplate nodeTemplate, String nodeType, ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) { if (nodeTemplate == null) { @@ -92,88 +117,6 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { new ToscaNodeTypeNotFoundErrorBuilder(nodeTemplate.getType()).build())); } - - private Optional<Boolean> isNodeTypeExistInServiceTemplateHierarchy(String nodeTypeToMatch, - String nodeTypeToSearch, - ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel, - Set<String> analyzedImportFiles) { - Map<String, NodeType> searchableNodeTypes = serviceTemplate.getNode_types(); - if (!MapUtils.isEmpty(searchableNodeTypes)) { - NodeType nodeType = searchableNodeTypes.get(nodeTypeToSearch); - if (Objects.nonNull(nodeType)) { - if (Objects.equals(nodeType.getDerived_from(), nodeTypeToMatch)) { - return Optional.of(true); - } else if (isNodeTypeIsToscaRoot(nodeType)) { - return Optional.of(false); - } else { - return isNodeTypeExistInServiceTemplateHierarchy(nodeTypeToMatch, - nodeType.getDerived_from(), serviceTemplate, toscaServiceModel, null); - } - } else { - return isNodeTypeExistInImports(nodeTypeToMatch, nodeTypeToSearch, serviceTemplate, - toscaServiceModel, analyzedImportFiles); - } - } - return isNodeTypeExistInImports(nodeTypeToMatch, nodeTypeToSearch, serviceTemplate, - toscaServiceModel, analyzedImportFiles); - - } - - private Optional<Boolean> isNodeTypeExistInImports(String nodeTypeToMatch, - String nodeTypeToSearch, - ServiceTemplate serviceTemplate, - ToscaServiceModel toscaServiceModel, - Set<String> analyzedImportFiles) { - Map<String, Import> imports = serviceTemplate.getImports(); - if (imports == null) { - return Optional.empty(); - } - - analyzedImportFiles = createAnalyzedImportFilesSet(analyzedImportFiles); - for (Import anImport : imports.values()) { - if (Objects.isNull(anImport) || Objects.isNull(anImport.getFile())) { - throw new RuntimeException("import without file entry"); - } - String importFile = anImport.getFile(); - if (analyzedImportFiles.contains(importFile)) { - continue; - } - addImportFileToAnalyzedImportFilesSet(analyzedImportFiles, importFile); - ServiceTemplate template = toscaServiceModel.getServiceTemplates().get(importFile); - Optional<Boolean> nodeTypeExistInServiceTemplateHierarchy = - isNodeTypeExistInServiceTemplateHierarchy(nodeTypeToMatch, nodeTypeToSearch, template, - toscaServiceModel, analyzedImportFiles); - if (nodeTypeExistInServiceTemplateHierarchy.isPresent()) { - if (nodeTypeExistInServiceTemplateHierarchy.get()) { - return Optional.of(true); - } - } - } - return Optional.of(false); - } - - private Set<String> addImportFileToAnalyzedImportFilesSet(Set<String> analyzedImportFiles, - String importFile) { - analyzedImportFiles.add(importFile); - return analyzedImportFiles; - } - - private Set<String> createAnalyzedImportFilesSet(Set<String> analyzedImportFiles) { - if (Objects.isNull(analyzedImportFiles)) { - analyzedImportFiles = new HashSet<>(); - } - return analyzedImportFiles; - } - - private boolean isNodeTypeIsToscaRoot(NodeType stNodeType) { - return Objects.equals(stNodeType.getDerived_from(), ToscaNodeType.ROOT.getDisplayName()); - } - - private boolean isNodeTemplateOfTypeNodeType(NodeTemplate nodeTemplate, String nodeType) { - return Objects.equals(nodeTemplate.getType(), nodeType); - } - @Override public List<RequirementAssignment> getRequirements(NodeTemplate nodeTemplate, String requirementId) { @@ -197,8 +140,8 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { String nodeTemplateId) { if ((serviceTemplate.getTopology_template() != null) && (serviceTemplate.getTopology_template().getNode_templates() != null) - && (serviceTemplate.getTopology_template().getNode_templates() - .get(nodeTemplateId) != null)) { + && (serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId) + != null)) { return Optional .of(serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId)); } @@ -214,13 +157,16 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { if (substitutableNodeTemplate.getProperties() != null && substitutableNodeTemplate.getProperties() - .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME) != null) { + .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME) != null) { Object serviceTemplateFilter = substitutableNodeTemplate.getProperties() .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME); if (serviceTemplateFilter != null && serviceTemplateFilter instanceof Map) { Object substituteServiceTemplate = ((Map) serviceTemplateFilter) .get(ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME); if (substituteServiceTemplate == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_PROPERTY); throw new CoreException( new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId) .build()); @@ -228,6 +174,9 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { return Optional.of(substituteServiceTemplate.toString()); } } + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_PROPERTY); throw new CoreException( new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId) .build()); @@ -255,28 +204,6 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { return substitutableNodeTemplates; } - private boolean isSubstitutableNodeTemplate(NodeTemplate nodeTemplate) { - return nodeTemplate.getDirectives() != null - && nodeTemplate.getDirectives().contains(ToscaConstants - .NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE); - } - - private boolean isSubstitutionServiceTemplate(String substituteServiceTemplateFileName, - ServiceTemplate substituteServiceTemplate) { - if (substituteServiceTemplate != null - && substituteServiceTemplate.getTopology_template() != null - && substituteServiceTemplate.getTopology_template().getSubstitution_mappings() != null) { - if (substituteServiceTemplate.getTopology_template().getSubstitution_mappings() - .getNode_type() == null) { - throw new CoreException(new ToscaInvalidSubstitutionServiceTemplateErrorBuilder( - substituteServiceTemplateFileName).build()); - } - return true; - } - return false; - - } - @Override public Optional<Map.Entry<String, NodeTemplate>> getSubstitutionMappedNodeTemplateByExposedReq( String substituteServiceTemplateFileName, ServiceTemplate substituteServiceTemplate, @@ -319,7 +246,6 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { return Optional.empty(); } - /* match only for the input which is not null */ @@ -361,62 +287,245 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { case CAPABILITY_TYPE: returnEntity = new CapabilityType(); break; + case NODE_TYPE: + returnEntity = new NodeType(); + break; default: + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_ENTITY); throw new RuntimeException( "Entity[" + elementType + "] id[" + typeId + "] flat not supported"); } - scanAnFlatEntity(elementType, typeId, returnEntity, serviceTemplate, toscaModel); + scanAnFlatEntity(elementType, typeId, returnEntity, serviceTemplate, toscaModel, + new ArrayList<String>(), 0); return returnEntity; } - private void scanAnFlatEntity(ToscaElementTypes elementType, String typeId, Object entity, - ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel) { + @Override + public boolean isSubstitutableNodeTemplate(NodeTemplate nodeTemplate) { + return nodeTemplate.getDirectives() != null + && nodeTemplate.getDirectives().contains(ToscaConstants + .NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE); + } + + private Optional<Boolean> isNodeTypeExistInServiceTemplateHierarchy( + String nodeTypeToMatch, + String nodeTypeToSearch, + ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + Set<String> analyzedImportFiles) { + Map<String, NodeType> searchableNodeTypes = serviceTemplate.getNode_types(); + if (!MapUtils.isEmpty(searchableNodeTypes)) { + NodeType nodeType = searchableNodeTypes.get(nodeTypeToSearch); + if (Objects.nonNull(nodeType)) { + if (Objects.equals(nodeType.getDerived_from(), nodeTypeToMatch)) { + return Optional.of(true); + } else if (isNodeTypeIsToscaRoot(nodeType)) { + return Optional.of(false); + } else { + return isNodeTypeExistInServiceTemplateHierarchy(nodeTypeToMatch, + nodeType.getDerived_from(), serviceTemplate, toscaServiceModel, null); + } + } else { + return isNodeTypeExistInImports(nodeTypeToMatch, nodeTypeToSearch, serviceTemplate, + toscaServiceModel, analyzedImportFiles); + } + } + return isNodeTypeExistInImports(nodeTypeToMatch, nodeTypeToSearch, serviceTemplate, + toscaServiceModel, analyzedImportFiles); + + } + + private Optional<Boolean> isNodeTypeExistInImports(String nodeTypeToMatch, + String nodeTypeToSearch, + ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + Set<String> filesScanned) { + List<Map<String, Import>> imports = serviceTemplate.getImports(); + if (CollectionUtils.isEmpty(imports)) { + return Optional.empty(); + } + + filesScanned = createFilesScannedSet(filesScanned); + + for (Map<String, Import> map : imports) { + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + Import anImport = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(map.values().iterator().next()), + Import.class); + if (Objects.isNull(anImport) || Objects.isNull(anImport.getFile())) { + throw new RuntimeException("import without file entry"); + } + String importFile = anImport.getFile(); + ServiceTemplate template = + toscaServiceModel.getServiceTemplates().get(fetchFileNameForImport(importFile, + serviceTemplate.getMetadata() == null ? null + : serviceTemplate.getMetadata().get("filename"))); + if (filesScanned.contains(ToscaUtil.getServiceTemplateFileName(template))) { + continue; + } else { + filesScanned.add(ToscaUtil.getServiceTemplateFileName(template)); + } + Optional<Boolean> nodeTypeExistInServiceTemplateHierarchy = + isNodeTypeExistInServiceTemplateHierarchy(nodeTypeToMatch, nodeTypeToSearch, template, + toscaServiceModel, filesScanned); + if (nodeTypeExistInServiceTemplateHierarchy.isPresent()) { + if (nodeTypeExistInServiceTemplateHierarchy.get()) { + filesScanned.clear(); + return Optional.of(true); + } + } + + } + return Optional.of(false); + } + + private Set<String> addImportFileToAnalyzedImportFilesSet(Set<String> analyzedImportFiles, + String importFile) { + analyzedImportFiles.add(importFile); + return analyzedImportFiles; + } + + private Set<String> createFilesScannedSet(Set<String> filesScanned) { + if (Objects.isNull(filesScanned)) { + filesScanned = new HashSet<>(); + } + return filesScanned; + } + + private boolean isNodeTypeIsToscaRoot(NodeType stNodeType) { + return Objects.equals(stNodeType.getDerived_from(), ToscaNodeType.NATIVE_ROOT); + } + + private boolean isNodeTemplateOfTypeNodeType(NodeTemplate nodeTemplate, String nodeType) { + return Objects.equals(nodeTemplate.getType(), nodeType); + } + + private boolean isSubstitutionServiceTemplate(String substituteServiceTemplateFileName, + ServiceTemplate substituteServiceTemplate) { + if (substituteServiceTemplate != null + && substituteServiceTemplate.getTopology_template() != null + && substituteServiceTemplate.getTopology_template().getSubstitution_mappings() != null) { + if (substituteServiceTemplate.getTopology_template().getSubstitution_mappings() + .getNode_type() == null) { + throw new CoreException(new ToscaInvalidSubstitutionServiceTemplateErrorBuilder( + substituteServiceTemplateFileName).build()); + } + return true; + } + return false; + + } + + private boolean scanAnFlatEntity(ToscaElementTypes elementType, String typeId, Object entity, + ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel, + List<String> filesScanned, int rootScanStartInx) { boolean entityFound = enrichEntityFromCurrentServiceTemplate(elementType, typeId, entity, serviceTemplate, - toscaModel); + toscaModel, filesScanned, rootScanStartInx); if (!entityFound) { - Map<String, Import> imports = serviceTemplate.getImports(); - if (MapUtils.isEmpty(imports)) { - return; + List<Map<String, Import>> imports = serviceTemplate.getImports(); + if (CollectionUtils.isEmpty(imports)) { + return false; } - for (Import importServiceTemplate : imports.values()) { - ServiceTemplate template = - toscaModel.getServiceTemplates().get(importServiceTemplate.getFile()); - scanAnFlatEntity(elementType, typeId, entity, template, toscaModel); + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + boolean found = false; + for (Map<String, Import> importMap : imports) { + if (found) { + return true; + } + String filename = ""; + for (Object importObject : importMap.values()) { + Import importServiceTemplate = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(importObject), Import.class); + filename = fetchFileNameForImport(importServiceTemplate.getFile(), + serviceTemplate.getMetadata() == null ? null : serviceTemplate.getMetadata().get + ("filename")); + if (filesScanned.contains(filename)) { + return false; + } else { + filesScanned.add(filename); + } + ServiceTemplate template = + toscaModel.getServiceTemplates() + .get(filename); + found = + scanAnFlatEntity(elementType, typeId, entity, template, toscaModel, filesScanned, + filesScanned.size()); + } } + return found; } + return true; + } + private String fetchFileNameForImport(String importServiceTemplateFile, + String currentMetadatafileName) { + if (importServiceTemplateFile.contains("../")) { + return importServiceTemplateFile.replace("../", ""); + } else if (importServiceTemplateFile.contains("/")) { + return importServiceTemplateFile; + } else if (currentMetadatafileName != null) { + return currentMetadatafileName.substring(0, currentMetadatafileName.indexOf("/")) + "/" + + importServiceTemplateFile; + } else { + return importServiceTemplateFile; + } } private boolean enrichEntityFromCurrentServiceTemplate(ToscaElementTypes elementType, String typeId, Object entity, ServiceTemplate serviceTemplate, - ToscaServiceModel toscaModel) { + ToscaServiceModel toscaModel, + List<String> filesScanned, + int rootScanStartInx) { String derivedFrom; switch (elementType) { case CAPABILITY_TYPE: if (serviceTemplate.getCapability_types() != null && serviceTemplate.getCapability_types().containsKey(typeId)) { + filesScanned.clear(); CapabilityType targetCapabilityType = ((CapabilityType) entity); CapabilityType sourceCapabilityType = serviceTemplate.getCapability_types().get(typeId); derivedFrom = sourceCapabilityType.getDerived_from(); - if (derivedFrom != null - && !ToscaCapabilityType.NFV_METRIC.getDisplayName().equals(derivedFrom)) { - scanAnFlatEntity(elementType, derivedFrom, entity, serviceTemplate, toscaModel); + if (derivedFrom != null) { + scanAnFlatEntity(elementType, derivedFrom, entity, serviceTemplate, toscaModel, + filesScanned, rootScanStartInx); } combineCapabilityTypeInfo(sourceCapabilityType, targetCapabilityType); } else { return false; } break; + case NODE_TYPE: + if (serviceTemplate.getNode_types() != null + && serviceTemplate.getNode_types().containsKey(typeId)) { + + filesScanned.clear(); + NodeType targetNodeType = ((NodeType) entity); + NodeType sourceNodeType = serviceTemplate.getNode_types().get(typeId); + derivedFrom = sourceNodeType.getDerived_from(); + if (derivedFrom != null) { + scanAnFlatEntity(elementType, derivedFrom, entity, serviceTemplate, toscaModel, + filesScanned, rootScanStartInx); + } + combineNodeTypeInfo(sourceNodeType, targetNodeType); + } else { + return false; + } + break; default: + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.ADD_ENTITIES_TO_TOSCA, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_ENTITY); throw new RuntimeException( "Entity[" + elementType + "] id[" + typeId + "] flat not supported"); } @@ -426,37 +535,44 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { } + private void combineNodeTypeInfo(NodeType sourceNodeType, NodeType targetNodeType) { + targetNodeType.setDerived_from(sourceNodeType.getDerived_from()); + targetNodeType.setDescription(sourceNodeType.getDescription()); + targetNodeType.setVersion(sourceNodeType.getVersion()); + targetNodeType.setProperties( + CommonMethods.mergeMaps(targetNodeType.getProperties(), sourceNodeType.getProperties())); + targetNodeType.setInterfaces( + CommonMethods.mergeMaps(targetNodeType.getInterfaces(), sourceNodeType.getInterfaces())); + targetNodeType.setArtifacts( + CommonMethods.mergeMaps(targetNodeType.getArtifacts(), sourceNodeType.getArtifacts())); + targetNodeType.setAttributes( + CommonMethods.mergeMaps(targetNodeType.getAttributes(), sourceNodeType.getAttributes())); + targetNodeType.setCapabilities(CommonMethods + .mergeMaps(targetNodeType.getCapabilities(), sourceNodeType.getCapabilities())); + targetNodeType.setRequirements(CommonMethods + .mergeListsOfMap(targetNodeType.getRequirements(), sourceNodeType.getRequirements())); + + } + + private void combineCapabilityTypeInfo(CapabilityType sourceCapabilityType, CapabilityType targetCapabilityType) { - if (MapUtils.isNotEmpty(sourceCapabilityType.getAttributes())) { - if (targetCapabilityType.getAttributes() == null) { - targetCapabilityType.setAttributes(new HashMap<>()); - } - targetCapabilityType.getAttributes().putAll(sourceCapabilityType.getAttributes()); - } - if (MapUtils.isNotEmpty(sourceCapabilityType.getProperties())) { - if (targetCapabilityType.getProperties() == null) { - targetCapabilityType.setProperties(new HashMap<>()); - } - targetCapabilityType.getProperties().putAll(sourceCapabilityType.getProperties()); - } + targetCapabilityType.setAttributes(CommonMethods + .mergeMaps(targetCapabilityType.getAttributes(), sourceCapabilityType.getAttributes())); + targetCapabilityType.setProperties(CommonMethods + .mergeMaps(targetCapabilityType.getProperties(), sourceCapabilityType.getProperties())); + targetCapabilityType.setValid_source_types(CommonMethods + .mergeLists(targetCapabilityType.getValid_source_types(), + sourceCapabilityType.getValid_source_types())); - if (CollectionUtils.isNotEmpty(sourceCapabilityType.getValid_source_types())) { - if (targetCapabilityType.getValid_source_types() == null) { - targetCapabilityType.setValid_source_types(new ArrayList<>()); - } - targetCapabilityType.getValid_source_types() - .addAll(sourceCapabilityType.getValid_source_types()); - } - - if (CommonMethods.isEmpty(sourceCapabilityType.getDerived_from())) { + if (!CommonMethods.isEmpty(sourceCapabilityType.getDerived_from())) { targetCapabilityType.setDerived_from(sourceCapabilityType.getDerived_from()); } - if (CommonMethods.isEmpty(sourceCapabilityType.getDescription())) { + if (!CommonMethods.isEmpty(sourceCapabilityType.getDescription())) { targetCapabilityType.setDescription(sourceCapabilityType.getDescription()); } - if (CommonMethods.isEmpty(sourceCapabilityType.getVersion())) { + if (!CommonMethods.isEmpty(sourceCapabilityType.getVersion())) { targetCapabilityType.setVersion(sourceCapabilityType.getVersion()); } @@ -464,4 +580,121 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { } + /* + * Create node type according to the input substitution service template, while the substitution + * service template can be mappted to this node type, for substitution mapping. + * + * @param substitutionServiceTemplate substitution serivce template + * @param nodeTypeDerivedFromValue derived from value for the created node type + * @return the node type + */ + @Override + public NodeType createInitSubstitutionNodeType(ServiceTemplate substitutionServiceTemplate, + String nodeTypeDerivedFromValue) { + NodeType substitutionNodeType = new NodeType(); + substitutionNodeType.setDerived_from(nodeTypeDerivedFromValue); + substitutionNodeType.setDescription(substitutionServiceTemplate.getDescription()); + substitutionNodeType + .setProperties(manageSubstitutionNodeTypeProperties(substitutionServiceTemplate)); + substitutionNodeType + .setAttributes(manageSubstitutionNodeTypeAttributes(substitutionServiceTemplate)); + return substitutionNodeType; + } + + private Map<String, PropertyDefinition> manageSubstitutionNodeTypeProperties( + ServiceTemplate substitutionServiceTemplate) { + Map<String, PropertyDefinition> substitutionNodeTypeProperties = new HashMap<>(); + Map<String, ParameterDefinition> properties = + substitutionServiceTemplate.getTopology_template().getInputs(); + if (properties == null) { + return null; + } + + PropertyDefinition propertyDefinition; + String toscaPropertyName; + for (Map.Entry<String, ParameterDefinition> entry : properties.entrySet()) { + toscaPropertyName = entry.getKey(); + propertyDefinition = new PropertyDefinition(); + ParameterDefinition parameterDefinition = + substitutionServiceTemplate.getTopology_template().getInputs().get(toscaPropertyName); + propertyDefinition.setType(parameterDefinition.getType()); + propertyDefinition.setDescription(parameterDefinition.getDescription()); + propertyDefinition.set_default(parameterDefinition.get_default()); + if (parameterDefinition.getRequired() != null) { + propertyDefinition.setRequired(parameterDefinition.getRequired()); + } + if (propertyDefinition.get_default() != null) { + propertyDefinition.setRequired(false); + } + if (!CollectionUtils.isEmpty(parameterDefinition.getConstraints())) { + propertyDefinition.setConstraints(parameterDefinition.getConstraints()); + } + propertyDefinition.setEntry_schema(parameterDefinition.getEntry_schema()); + if (parameterDefinition.getStatus() != null) { + propertyDefinition.setStatus(parameterDefinition.getStatus()); + } + substitutionNodeTypeProperties.put(toscaPropertyName, propertyDefinition); + } + return substitutionNodeTypeProperties; + } + + private Map<String, AttributeDefinition> manageSubstitutionNodeTypeAttributes( + ServiceTemplate substitutionServiceTemplate) { + Map<String, AttributeDefinition> substitutionNodeTypeAttributes = new HashMap<>(); + Map<String, ParameterDefinition> attributes = + substitutionServiceTemplate.getTopology_template().getOutputs(); + if (attributes == null) { + return null; + } + AttributeDefinition attributeDefinition; + String toscaAttributeName; + + for (Map.Entry<String, ParameterDefinition> entry : attributes.entrySet()) { + attributeDefinition = new AttributeDefinition(); + toscaAttributeName = entry.getKey(); + ParameterDefinition parameterDefinition = + substitutionServiceTemplate.getTopology_template().getOutputs().get(toscaAttributeName); + if (parameterDefinition.getType() != null && !parameterDefinition.getType().isEmpty()) { + attributeDefinition.setType(parameterDefinition.getType()); + } else { + attributeDefinition.setType(PropertyType.STRING.getDisplayName()); + } + attributeDefinition.setDescription(parameterDefinition.getDescription()); + attributeDefinition.set_default(parameterDefinition.get_default()); + attributeDefinition.setEntry_schema(parameterDefinition.getEntry_schema()); + if (Objects.nonNull(parameterDefinition.getStatus())) { + attributeDefinition.setStatus(parameterDefinition.getStatus()); + } + substitutionNodeTypeAttributes.put(toscaAttributeName, attributeDefinition); + } + return substitutionNodeTypeAttributes; + } + + /** + * Checks if the requirement exists in the node template. + * + * @param nodeTemplate the node template + * @param requirementId the requirement id + * @param requirementAssignment the requirement assignment + * @return true if the requirement already exists and false otherwise + */ + public boolean isRequirementExistInNodeTemplate(NodeTemplate nodeTemplate, + String requirementId, + RequirementAssignment requirementAssignment) { + boolean result = false; + List<Map<String, RequirementAssignment>> nodeTemplateRequirements = nodeTemplate + .getRequirements(); + if (nodeTemplateRequirements != null) { + for (Map<String, RequirementAssignment> requirement : nodeTemplateRequirements) { + if (requirement.containsKey(requirementId)) { + result = DataModelUtil.compareRequirementAssignment(requirementAssignment, + requirement.get(requirementId)); + if (result) { + break; + } + } + } + } + return result; + } } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java index d4c22f105f..b518057e35 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java @@ -23,6 +23,12 @@ package org.openecomp.sdc.tosca.services.impl; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerErrorDescription; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.exceptions.CsarCreationErrorBuilder; @@ -39,6 +45,7 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; + public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { static final String EXTERNAL_ARTIFACTS_FOLDER_NAME = "Artifacts"; private static final String DEFINITIONS_FOLDER_NAME = "Definitions"; @@ -57,6 +64,7 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { private static final String SPACE = " "; private static final String FILE_SEPARATOR = File.separator; + @Override public byte[] createOutputFile(ToscaServiceModel toscaServiceModel, FileContentHandler externalArtifacts) { @@ -68,18 +76,25 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { packArtifacts(zos, artifactFiles); } if (toscaServiceModel.getEntryDefinitionServiceTemplate() == null) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.CREATE_CSAR, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CREATE_CSAR); throw new CoreException(new CsarMissingEntryPointErrorBuilder().build()); } createAndPackToscaMetaFile(zos, toscaServiceModel.getEntryDefinitionServiceTemplate()); if (externalArtifacts != null) { packExternalArtifacts(zos, externalArtifacts); } - } catch (IOException exc) { - throw new CoreException(new CsarCreationErrorBuilder().build(), exc); + } catch (IOException ex) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.CREATE_CSAR, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CREATE_CSAR); + throw new CoreException(new CsarCreationErrorBuilder().build(), ex); } return baos.toByteArray(); } + @Override public String createMetaFile(String entryDefinitionsFileName) { return TOSCA_META_FILE_VERSION + META_FILE_DELIMITER + SPACE + TOSCA_META_FILE_VERSION_VALUE @@ -87,7 +102,8 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { + CSAR_VERSION + META_FILE_DELIMITER + SPACE + CSAR_VERSION_VALUE + System.lineSeparator() + CREATED_BY + META_FILE_DELIMITER + SPACE + CREATED_BY_VALUE + System.lineSeparator() + ENTRY_DEFINITIONS + META_FILE_DELIMITER + SPACE + DEFINITIONS_FOLDER_NAME - + FILE_SEPARATOR + entryDefinitionsFileName; + + FILE_SEPARATOR + + entryDefinitionsFileName; } @Override @@ -120,8 +136,11 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { zos.putNextEntry(new ZipEntry(filenameIncludingPath)); writeBytesToZip(zos, externalArtifacts.getFileContent(filenameIncludingPath)); - } catch (IOException exc) { - throw new RuntimeException(exc); + } catch (IOException ex) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.PACK_ARTIFACTS, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.PACK_ARTIFACTS); + throw new RuntimeException(ex); } finally { try { zos.closeEntry(); @@ -140,8 +159,11 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { zos.putNextEntry(new ZipEntry((ARTIFACTS_FOLDER_NAME + FILE_SEPARATOR + fileName))); writeBytesToZip(zos, artifacts.getFileContent(fileName)); - } catch (IOException exc) { - throw new RuntimeException(exc); + } catch (IOException ex) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.PACK_ARTIFACTS, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.PACK_ARTIFACTS); + throw new RuntimeException(ex); } finally { try { zos.closeEntry(); @@ -150,6 +172,7 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { } } } + } private void writeBytesToZip(ZipOutputStream zos, InputStream is) throws IOException { diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java index a1c11c2483..2b806fbea0 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java @@ -46,13 +46,13 @@ public class ToscaExtensionYamlUtil extends YamlUtil { public Property getProperty(Class<? extends Object> type, String name) throws IntrospectionException { try { - if (type.equals( - Class.forName("org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition"))) { - type = Class.forName( - "org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt"); + if (type + .equals(Class.forName("org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition"))) { + type = Class + .forName("org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt"); } - } catch (ClassNotFoundException exception) { - throw new RuntimeException(exception); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex); } return super.getProperty(type, name); } @@ -80,9 +80,8 @@ public class ToscaExtensionYamlUtil extends YamlUtil { // create JavaBean return super.constructJavaBean2ndStep(node, object); } - } catch (ClassNotFoundException | InstantiationException - | IllegalAccessException exception) { - throw new RuntimeException(exception); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { + throw new RuntimeException(ex); } } } diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/resources/config.properties b/openecomp-be/lib/openecomp-tosca-lib/src/main/resources/config.properties new file mode 100644 index 0000000000..cf7596c176 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/resources/config.properties @@ -0,0 +1,17 @@ +tosca.entity.namespace.prefix=org.openecomp. +tosca.entity.namespace.prefix.capabilityType=${tosca.entity.namespace.prefix}capabilities. +tosca.entity.namespace.prefix.dataType=${tosca.entity.namespace.prefix}datatypes. +tosca.entity.namespace.prefix.groupType=${tosca.entity.namespace.prefix}groups. +tosca.entity.namespace.prefix.policyType=${tosca.entity.namespace.prefix}policies. +tosca.entity.namespace.prefix.relationshipType=${tosca.entity.namespace.prefix}relationships. +tosca.entity.namespace.prefix.artifactType=${tosca.entity.namespace.prefix}artifacts. + +tosca.entity.namespace.prefix.nodeType.vfc=${tosca.entity.namespace.prefix}resource.vfc.nodes. +tosca.entity.namespace.prefix.nodeType.network=${tosca.entity.namespace.prefix}resource.vl.nodes. +tosca.entity.namespace.prefix.nodeType.connectionPoint=${tosca.entity.namespace.prefix}resource.cp.nodes. +tosca.entity.namespace.prefix.nodeType.abstract=${tosca.entity.namespace.prefix}resource.abstract.nodes. +tosca.entity.namespace.prefix.nodeType.rule=${tosca.entity.namespace.prefix}resource.vfc.rules.nodes. + + + +_config.namespace=ToscaModel
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java index da3ae76f27..773b902182 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/TestUtil.java @@ -1,10 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.nio.file.NotDirectoryException; import java.util.HashMap; diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java index 470dd9784a..820d79184e 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/PropertyTypeTest.java @@ -1,8 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.datatypes; -import org.openecomp.sdc.tosca.datatypes.model.PropertyType; import org.junit.Assert; import org.junit.Test; +import org.openecomp.sdc.tosca.datatypes.model.PropertyType; public class PropertyTypeTest { @Test @@ -17,4 +37,4 @@ public class PropertyTypeTest { Assert .assertEquals(PropertyType.getPropertyTypeByDisplayName(s), PropertyType.SCALAR_UNIT_SIZE); } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java index 13b05543fb..c7b0659c21 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/ToscaModelTest.java @@ -1,5 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.datatypes; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.core.utilities.yaml.YamlUtil; import org.openecomp.sdc.tosca.datatypes.model.ArtifactType; import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; import org.openecomp.sdc.tosca.datatypes.model.CapabilityAssignment; @@ -7,7 +30,6 @@ import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; import org.openecomp.sdc.tosca.datatypes.model.Constraint; import org.openecomp.sdc.tosca.datatypes.model.Directive; import org.openecomp.sdc.tosca.datatypes.model.Import; -import org.openecomp.sdc.tosca.datatypes.model.Metadata; import org.openecomp.sdc.tosca.datatypes.model.NodeFilter; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; @@ -23,10 +45,6 @@ import org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt import org.openecomp.sdc.tosca.services.DataModelUtil; import org.openecomp.sdc.tosca.services.ToscaConstants; import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; -import org.openecomp.core.utilities.yaml.YamlUtil; -import org.junit.Assert; -import org.junit.Test; - import java.io.InputStream; import java.util.ArrayList; @@ -41,21 +59,24 @@ public class ToscaModelTest { public void testServiceTemplateJavaToYaml() { ServiceTemplate serviceTemplate = new ServiceTemplate(); - Metadata metadata = new Metadata(); - metadata.setTemplate_author("OPENECOMP"); - metadata.setTemplate_name("Test"); - metadata.setTemplate_version("1.0.0"); + Map<String, String> metadata = new HashMap<>(); + metadata.put("Template_author", "OPENECOMP"); + metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "Test"); + metadata.put("Template_version", "1.0.0"); serviceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0"); serviceTemplate.setDescription("testing desc tosca service template"); - serviceTemplate.setMetadata(metadata); Import fileImport1 = new Import(); fileImport1.setFile("path1/path2/file1.yaml"); Import fileImport2 = new Import(); fileImport2.setFile("path1/path2/file2.yaml"); - Map<String, Import> imports = new HashMap<>(); - imports.put("myfile1", fileImport1); - imports.put("myfile2", fileImport2); + List<Map<String, Import>> imports = new ArrayList<>(); + Map<String, Import> importsMap = new HashMap<>(); + importsMap.put("myfile1", fileImport1); + imports.add(importsMap); + importsMap = new HashMap<>(); + importsMap.put("myfile2", fileImport2); + imports.add(importsMap); serviceTemplate.setImports(imports); ArtifactType artifact = new ArtifactType(); diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java index 2b0f88fdea..4cd76ce6ec 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinitionTest.java @@ -1,15 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.datatypes.model; -import org.openecomp.sdc.tosca.services.ToscaConstants; -import org.openecomp.core.utilities.yaml.YamlUtil; import org.junit.Assert; import org.junit.Test; +import org.openecomp.core.utilities.yaml.YamlUtil; +import org.openecomp.sdc.tosca.services.ToscaConstants; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * @author shiria + * @since September 06, 2016. + */ public class CapabilityDefinitionTest { @Test @@ -64,7 +88,7 @@ public class CapabilityDefinitionTest { private ArtifactDefinition getMockArtifactDefinition() { ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setType("type1"); - artifactDefinition.setDescription("description of OPENECOMP def"); + artifactDefinition.setDescription("description of openecomp def"); artifactDefinition.setDeploy_path("my deployment path"); artifactDefinition.setFile("my file"); artifactDefinition.setRepository("my repository"); @@ -98,4 +122,4 @@ public class CapabilityDefinitionTest { return constraints; } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java index 3109a8abff..38d8aba3ec 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinitionTest.java @@ -1,14 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.datatypes.model; -import org.openecomp.core.utilities.yaml.YamlUtil; import org.junit.Assert; import org.junit.Test; +import org.openecomp.core.utilities.yaml.YamlUtil; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * @author shiria + * @since September 07, 2016. + */ public class RequirementDefinitionTest { @Test @@ -37,4 +61,4 @@ public class RequirementDefinitionTest { } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java index 893f7a1a5e..e15f59dac4 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/DataModelUtilTest.java @@ -1,11 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.services; -import org.openecomp.sdc.common.errors.CoreException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; +import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; @@ -16,6 +36,10 @@ import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping; import java.util.ArrayList; +/** + * @author shiria + * @since September 15, 2016. + */ @RunWith(MockitoJUnitRunner.class) public class DataModelUtilTest { @@ -101,4 +125,4 @@ public class DataModelUtilTest { "Invalid action, can't add 'Group Definition' to 'Service Template', 'Service Template' entity is NULL."); DataModelUtil.addGroupDefinitionToTopologyTemplate(null, "123", new GroupDefinition()); } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java index 47f0bd9aef..2afe6033b5 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java @@ -1,12 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.services.impl; -import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.tosca.TestUtil; -import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; -import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; -import org.openecomp.sdc.tosca.services.ToscaConstants; -import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; @@ -16,6 +35,10 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.runners.MockitoJUnitRunner; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.tosca.TestUtil; +import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.Import; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; @@ -23,17 +46,23 @@ import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping; import org.openecomp.sdc.tosca.datatypes.model.TopologyTemplate; +import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; +import org.openecomp.sdc.tosca.services.ToscaConstants; +import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; +/** + * @author Avrahamg + * @since July 14, 2016 + */ @RunWith(MockitoJUnitRunner.class) public class ToscaAnalyzerServiceImplTest { /* @@ -70,7 +99,8 @@ public class ToscaAnalyzerServiceImplTest { ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); InputStream yamlFile = toscaExtensionYamlUtil .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml"); - ServiceTemplate serviceTemplateFromYaml = + ServiceTemplate + serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class); NodeTemplate port_0 = @@ -112,35 +142,44 @@ public class ToscaAnalyzerServiceImplTest { thrown.expectMessage( "Invalid Substitute Node Template invalid2, mandatory map property service_template_filter with mandatory key substitute_service_template must be defined."); + Optional<String> substituteServiceTemplateName; + ServiceTemplate mainServiceTemplate = toscaServiceModel.getServiceTemplates() .get(toscaServiceModel.getEntryDefinitionServiceTemplate()); Optional<NodeTemplate> notSubstitutableNodeTemplate = toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_net"); - Optional<String> substituteServiceTemplateName = toscaAnalyzerService - .getSubstituteServiceTemplateName("test_net", notSubstitutableNodeTemplate.get()); - assertEquals(false, substituteServiceTemplateName.isPresent()); + assertEquals(true, notSubstitutableNodeTemplate.isPresent()); + + if (notSubstitutableNodeTemplate.isPresent()) { + substituteServiceTemplateName = toscaAnalyzerService + .getSubstituteServiceTemplateName("test_net", notSubstitutableNodeTemplate.get()); + assertEquals(false, substituteServiceTemplateName.isPresent()); + } Optional<NodeTemplate> substitutableNodeTemplate = toscaAnalyzerService.getNodeTemplateById(mainServiceTemplate, "test_nested"); - substituteServiceTemplateName = toscaAnalyzerService - .getSubstituteServiceTemplateName("test_nested", substitutableNodeTemplate.get()); - assertEquals(true, substituteServiceTemplateName.isPresent()); - assertEquals("nestedServiceTemplate.yaml", substituteServiceTemplateName.get()); + assertEquals(true, substitutableNodeTemplate.isPresent()); + if (substitutableNodeTemplate.isPresent()) { + substituteServiceTemplateName = toscaAnalyzerService + .getSubstituteServiceTemplateName("test_nested", substitutableNodeTemplate.get()); + assertEquals(true, substituteServiceTemplateName.isPresent()); + assertEquals("nestedServiceTemplate.yaml", substituteServiceTemplateName.get()); + } NodeTemplate invalidSubstitutableNodeTemplate1 = new NodeTemplate(); substituteServiceTemplateName = toscaAnalyzerService .getSubstituteServiceTemplateName("invalid1", invalidSubstitutableNodeTemplate1); assertEquals(false, substituteServiceTemplateName.isPresent()); + if (substitutableNodeTemplate.isPresent()) { + NodeTemplate invalidSubstitutableNodeTemplate2 = substitutableNodeTemplate.get(); + Object serviceTemplateFilter = invalidSubstitutableNodeTemplate2.getProperties() + .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME); + ((Map) serviceTemplateFilter).clear(); + toscaAnalyzerService + .getSubstituteServiceTemplateName("invalid2", invalidSubstitutableNodeTemplate2); - NodeTemplate invalidSubstitutableNodeTemplate2 = substitutableNodeTemplate.get(); - Object serviceTemplateFilter = invalidSubstitutableNodeTemplate2.getProperties() - .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME); - ((Map) serviceTemplateFilter).clear(); - toscaAnalyzerService - .getSubstituteServiceTemplateName("invalid2", invalidSubstitutableNodeTemplate2); - - + } } @@ -186,14 +225,20 @@ public class ToscaAnalyzerServiceImplTest { Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml", nestedServiceTemplateFromYaml, "local_storage_server_cmaui"); - assertEquals("server_cmaui", mappedNodeTemplate.get().getKey()); - assertNotNull(mappedNodeTemplate.get().getValue()); + assertEquals(true, mappedNodeTemplate.isPresent()); + if (mappedNodeTemplate.isPresent()) { + assertEquals("server_cmaui", mappedNodeTemplate.get().getKey()); + assertNotNull(mappedNodeTemplate.get().getValue()); + } mappedNodeTemplate = toscaAnalyzerService .getSubstitutionMappedNodeTemplateByExposedReq("NestedServiceTemplateSubstituteTest.yaml", nestedServiceTemplateFromYaml, "link_cmaui_port_invalid"); - assertEquals("server_cmaui", mappedNodeTemplate.get().getKey()); - assertNotNull(mappedNodeTemplate.get().getValue()); + assertEquals(true, mappedNodeTemplate.isPresent()); + if (mappedNodeTemplate.isPresent()) { + assertEquals("server_cmaui", mappedNodeTemplate.get().getKey()); + assertNotNull(mappedNodeTemplate.get().getValue()); + } ServiceTemplate mainServiceTemplate = toscaServiceModel.getServiceTemplates() .get(toscaServiceModel.getEntryDefinitionServiceTemplate()); @@ -310,33 +355,33 @@ public class ToscaAnalyzerServiceImplTest { @Test public void shouldReturnFalseIfNdTmpIsNull() { assertFalse(toscaAnalyzerService - .isTypeOf(null, ToscaNodeType.NETWORK.getDisplayName(), new ServiceTemplate(), + .isTypeOf(null, ToscaNodeType.NATIVE_NETWORK, new ServiceTemplate(), toscaServiceModelMock)); } @Test public void shouldReturnTrueIfNdTmpTypeIsOfRequestedType() { NodeTemplate nodeTemplate = new NodeTemplate(); - ToscaNodeType nodeTypeToSearch = ToscaNodeType.BLOCK_STORAGE; - nodeTemplate.setType(nodeTypeToSearch.getDisplayName()); + String nodeTypeToSearch = ToscaNodeType.NATIVE_BLOCK_STORAGE; + nodeTemplate.setType(nodeTypeToSearch); assertTrue(toscaAnalyzerService - .isTypeOf(nodeTemplate, nodeTypeToSearch.getDisplayName(), new ServiceTemplate(), + .isTypeOf(nodeTemplate, nodeTypeToSearch, new ServiceTemplate(), toscaServiceModelMock)); } @Test public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyAndNdTyDerivedFromRequestedType() { - String typeToMatch = ToscaNodeType.CINDER_VOLUME.getDisplayName(); + String typeToMatch = ToscaNodeType.CINDER_VOLUME; when(nodeTemplateMock.getType()).thenReturn(typeToMatch); Map<String, NodeType> stNodeTypes = new HashMap<>(); - addNodeType(stNodeTypes, ToscaNodeType.COMPUTE.getDisplayName(), new NodeType()); - NodeType nodeType = createNodeType(ToscaNodeType.BLOCK_STORAGE.getDisplayName()); + addNodeType(stNodeTypes, ToscaNodeType.NATIVE_COMPUTE, new NodeType()); + NodeType nodeType = createNodeType(ToscaNodeType.NATIVE_BLOCK_STORAGE); addNodeType(stNodeTypes, typeToMatch, nodeType); ServiceTemplate serviceTemplate = new ServiceTemplate(); serviceTemplate.setNode_types(stNodeTypes); assertTrue(toscaAnalyzerService - .isTypeOf(nodeTemplateMock, ToscaNodeType.BLOCK_STORAGE.getDisplayName(), serviceTemplate, - toscaServiceModelMock)); + .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, + serviceTemplate, toscaServiceModelMock)); } @@ -351,7 +396,7 @@ public class ToscaAnalyzerServiceImplTest { ServiceTemplate serviceTemplate = new ServiceTemplate(); serviceTemplate.setNode_types(stNodeTypes); toscaAnalyzerService - .isTypeOf(nodeTemplateMock, ToscaNodeType.COMPUTE.getDisplayName(), serviceTemplate, + .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_COMPUTE, serviceTemplate, toscaServiceModelMock); } @@ -398,19 +443,21 @@ public class ToscaAnalyzerServiceImplTest { @Test public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyButRequestedTypeNotMatchButFoundIn1stLevelImports() { - String typeToMatch = ToscaNodeType.CINDER_VOLUME.getDisplayName(); + String typeToMatch = ToscaNodeType.CINDER_VOLUME; when(nodeTemplateMock.getType()).thenReturn(typeToMatch); ServiceTemplate mainST = new ServiceTemplate(); - Map<String, Import> imports = new HashMap<>(); + List<Map<String, Import>> imports = new ArrayList<>(); + Map<String, Import> importMap = new HashMap<>(); Import anImport = new Import(); anImport.setFile("mainImport"); - imports.put("bla bla", anImport); + importMap.put("bla bla", anImport); + imports.add(importMap); mainST.setImports(imports); //create searchable service template Map<String, NodeType> stNodeTypes = new HashMap<>(); - addNodeType(stNodeTypes, ToscaNodeType.COMPUTE.getDisplayName(), new NodeType()); - NodeType nodeType = createNodeType(ToscaNodeType.BLOCK_STORAGE.getDisplayName()); + addNodeType(stNodeTypes, ToscaNodeType.NATIVE_COMPUTE, new NodeType()); + NodeType nodeType = createNodeType(ToscaNodeType.NATIVE_BLOCK_STORAGE); addNodeType(stNodeTypes, typeToMatch, nodeType); ServiceTemplate serviceTemplate = new ServiceTemplate(); serviceTemplate.setNode_types(stNodeTypes); @@ -422,36 +469,39 @@ public class ToscaAnalyzerServiceImplTest { when(toscaServiceModelMock.getServiceTemplates()).thenReturn(serviceTemplates); assertTrue(toscaAnalyzerService - .isTypeOf(nodeTemplateMock, ToscaNodeType.BLOCK_STORAGE.getDisplayName(), mainST, + .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainST, toscaServiceModelMock)); } @Test public void shouldReturnTrueIfNdTmpTypeIsFoundInSrvTmpNdTyButRequestedTypeNotMatchButFoundIn2ndLevelImports() { - String typeToMatch = ToscaNodeType.CINDER_VOLUME.getDisplayName(); + String typeToMatch = ToscaNodeType.CINDER_VOLUME; when(nodeTemplateMock.getType()).thenReturn(typeToMatch); ServiceTemplate mainST = new ServiceTemplate(); - Map<String, Import> imports = new HashMap<>(); + List<Map<String, Import>> imports = new ArrayList<>(); + Map<String, Import> importMap = new HashMap<>(); Import anImport = new Import(); anImport.setFile("refToMainImport"); - imports.put("bla bla", anImport); + importMap.put("bla bla", anImport); + imports.add(importMap); mainST.setImports(imports); //create searchable service template Map<String, NodeType> stNodeTypes = new HashMap<>(); - addNodeType(stNodeTypes, ToscaNodeType.COMPUTE.getDisplayName(), new NodeType()); - NodeType nodeType = createNodeType(ToscaNodeType.BLOCK_STORAGE.getDisplayName()); + addNodeType(stNodeTypes, ToscaNodeType.NATIVE_COMPUTE, new NodeType()); + NodeType nodeType = createNodeType(ToscaNodeType.NATIVE_BLOCK_STORAGE); addNodeType(stNodeTypes, typeToMatch, nodeType); ServiceTemplate serviceTemplate = new ServiceTemplate(); serviceTemplate.setNode_types(stNodeTypes); // create 1st level service template with import only ServiceTemplate firstLevelST = new ServiceTemplate(); - Map<String, Import> firstLevelImports = new HashMap<>(); + List<Map<String, Import>> firstLevelImports = new ArrayList<>(); + Map<String, Import> firstLevelImportsMap = new HashMap<>(); Import firstLevelImport = new Import(); firstLevelImport.setFile("mainImport"); - firstLevelImports.put("bla bla 2", firstLevelImport); - + firstLevelImportsMap.put("bla bla 2", firstLevelImport); + firstLevelImports.add(firstLevelImportsMap); firstLevelST.setImports(firstLevelImports); // add service templates to tosca service model @@ -462,11 +512,11 @@ public class ToscaAnalyzerServiceImplTest { when(toscaServiceModelMock.getServiceTemplates()).thenReturn(serviceTemplates); assertTrue(toscaAnalyzerService - .isTypeOf(nodeTemplateMock, ToscaNodeType.BLOCK_STORAGE.getDisplayName(), mainST, + .isTypeOf(nodeTemplateMock, ToscaNodeType.NATIVE_BLOCK_STORAGE, mainST, toscaServiceModelMock)); } // not found at all should throw core exception -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java index 963b8a6f57..4d025e1540 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java @@ -1,12 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.tosca.services.impl; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import org.openecomp.sdc.tosca.datatypes.model.Metadata; import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.services.ToscaConstants; import org.openecomp.sdc.tosca.services.ToscaUtil; -import org.openecomp.core.utilities.file.FileContentHandler; -import org.junit.Assert; -import org.junit.Test; import java.io.File; import java.io.FileOutputStream; @@ -21,12 +41,12 @@ import java.util.zip.ZipFile; public class ToscaFileOutputServiceCsarImplTest { - private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCsarImpl = + private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl = new ToscaFileOutputServiceCsarImpl(); @Test public void testCreationMetaFile() { - String createdMeta = toscaFileOutputServiceCsarImpl.createMetaFile("entryFile.yaml"); + String createdMeta = toscaFileOutputServiceCSARImpl.createMetaFile("entryFile.yaml"); String expectedMeta = "TOSCA-Meta-File-Version: 1.0\n" + "CSAR-Version: 1.1\n" + @@ -38,19 +58,19 @@ public class ToscaFileOutputServiceCsarImplTest { @Test public void testCSARFileCreationWithExternalArtifacts() throws IOException { ServiceTemplate mainServiceTemplate = new ServiceTemplate(); - Metadata metadata1 = new Metadata(); - metadata1.setTemplate_author("OPENECOMP"); - metadata1.setTemplate_name("ST1"); - metadata1.setTemplate_version("1.0.0"); + Map<String, String> metadata1 = new HashMap<>(); + metadata1.put("Template_author", "OPENECOMP"); + metadata1.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME,"ST1"); + metadata1.put("Template_version", "1.0.0"); + mainServiceTemplate.setMetadata(metadata1); mainServiceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0"); mainServiceTemplate.setDescription("testing desc tosca service template"); - mainServiceTemplate.setMetadata(metadata1); ServiceTemplate additionalServiceTemplate = new ServiceTemplate(); - Metadata metadata2 = new Metadata(); - metadata2.setTemplate_author("OPENECOMP"); - metadata2.setTemplate_name("ST2"); - metadata2.setTemplate_version("1.0.0"); + Map<String, String> metadata2 = new HashMap<>(); + metadata2.put("Template_author", "OPENECOMP"); + metadata2.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "ST2"); + metadata2.put("Template_version", "1.0.0"); additionalServiceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0"); additionalServiceTemplate.setDescription("testing desc tosca service template"); additionalServiceTemplate.setMetadata(metadata2); @@ -86,7 +106,7 @@ public class ToscaFileOutputServiceCsarImplTest { licenseArtifactsFiles.putAll(licenseArtifacts); - byte[] csarFile = toscaFileOutputServiceCsarImpl.createOutputFile( + byte[] csarFile = toscaFileOutputServiceCSARImpl.createOutputFile( new ToscaServiceModel(heatFiles, definitionsInput, ToscaUtil.getServiceTemplateFileName(mainServiceTemplate)), licenseArtifactsFiles); @@ -113,17 +133,17 @@ public class ToscaFileOutputServiceCsarImplTest { @Test public void testCSARFileCreation_noArtifacts() throws IOException { ServiceTemplate serviceTemplate = new ServiceTemplate(); - Metadata metadata = new Metadata(); - metadata.setTemplate_author("OPENECOMP"); - metadata.setTemplate_name("Test"); - metadata.setTemplate_version("1.0.0"); + Map<String, String> metadata = new HashMap<>(); + metadata.put("Template_author", "OPENECOMP"); + metadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "Test"); + metadata.put("Template_version", "1.0.0"); serviceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0"); serviceTemplate.setDescription("testing desc tosca service template"); serviceTemplate.setMetadata(metadata); Map<String, ServiceTemplate> definitionsInput = new HashMap<>(); String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate); definitionsInput.put(serviceTemplateFileName, serviceTemplate); - byte[] csarFile = toscaFileOutputServiceCsarImpl + byte[] csarFile = toscaFileOutputServiceCSARImpl .createOutputFile(new ToscaServiceModel(null, definitionsInput, serviceTemplateFileName), null); @@ -147,4 +167,4 @@ public class ToscaFileOutputServiceCsarImplTest { zipFile.close(); Files.delete(Paths.get(file.getPath())); } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml index f64cb709f0..ce02d0c034 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml @@ -2,25 +2,25 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 metadata: template_name: nested imports: - NeutronPortGlobalTypes: +- NeutronPortGlobalTypes: file: NeutronPortGlobalTypesServiceTemplate.yaml - NeutronNetGlobalTypes: +- NeutronNetGlobalTypes: file: NeutronNetGlobalTypesServiceTemplate.yaml - CommonGlobalTypes: +- CommonGlobalTypes: file: CommonGlobalTypesServiceTemplate.yaml - CinderVolumeGlobalTypes: +- CinderVolumeGlobalTypes: file: CinderVolumeGlobalTypesServiceTemplate.yaml - ContrailNetworkRuleGlobalType: +- ContrailNetworkRuleGlobalType: file: ContrailNetworkRuleGlobalTypeServiceTemplate.yaml - NeutronSecurityRulesGlobalTypes: +- NeutronSecurityRulesGlobalTypes: file: NeutronSecurityRulesGlobalTypesServiceTemplate.yaml - NovaServerGlobalTypes: +- NovaServerGlobalTypes: file: NovaServerGlobalTypesServiceTemplate.yaml - ContrailVirtualNetworkGlobalType: +- ContrailVirtualNetworkGlobalType: file: ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml - AbstractSubstituteGlobalTypes: +- AbstractSubstituteGlobalTypes: file: AbstractSubstituteGlobalTypesServiceTemplate.yaml - nested: +- nested: file: GlobalSubstitutionTypesServiceTemplate.yaml node_types: org.openecomp.resource.vfc.nodes.heat.cmaui_image: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateSubstituteTest.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateSubstituteTest.yaml index c4df76a1aa..8d63ac21ae 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateSubstituteTest.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateSubstituteTest.yaml @@ -2,23 +2,23 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 metadata: template_name: Main imports: - NeutronPortGlobalTypes: +- NeutronPortGlobalTypes: file: NeutronPortGlobalTypesServiceTemplate.yaml - NeutronNetGlobalTypes: +- NeutronNetGlobalTypes: file: NeutronNetGlobalTypesServiceTemplate.yaml - CommonGlobalTypes: +- CommonGlobalTypes: file: CommonGlobalTypesServiceTemplate.yaml - CinderVolumeGlobalTypes: +- CinderVolumeGlobalTypes: file: CinderVolumeGlobalTypesServiceTemplate.yaml - ContrailNetworkRuleGlobalType: +- ContrailNetworkRuleGlobalType: file: ContrailNetworkRuleGlobalTypeServiceTemplate.yaml - NeutronSecurityRulesGlobalTypes: +- NeutronSecurityRulesGlobalTypes: file: NeutronSecurityRulesGlobalTypesServiceTemplate.yaml - NovaServerGlobalTypes: +- NovaServerGlobalTypes: file: NovaServerGlobalTypesServiceTemplate.yaml - ContrailVirtualNetworkGlobalType: +- ContrailVirtualNetworkGlobalType: file: ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml - AbstractSubstituteGlobalTypes: +- AbstractSubstituteGlobalTypes: file: AbstractSubstituteGlobalTypesServiceTemplate.yaml topology_template: inputs: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/MainServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/MainServiceTemplate.yaml index 65b90ef5b1..c9affb7442 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/MainServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/MainServiceTemplate.yaml @@ -2,23 +2,23 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 metadata: template_name: Main imports: - NeutronPortGlobalTypes: +- NeutronPortGlobalTypes: file: NeutronPortGlobalTypesServiceTemplate.yaml - NeutronNetGlobalTypes: +- NeutronNetGlobalTypes: file: NeutronNetGlobalTypesServiceTemplate.yaml - CommonGlobalTypes: +- CommonGlobalTypes: file: CommonGlobalTypesServiceTemplate.yaml - CinderVolumeGlobalTypes: +- CinderVolumeGlobalTypes: file: CinderVolumeGlobalTypesServiceTemplate.yaml - ContrailNetworkRuleGlobalType: +- ContrailNetworkRuleGlobalType: file: ContrailNetworkRuleGlobalTypeServiceTemplate.yaml - NeutronSecurityRulesGlobalTypes: +- NeutronSecurityRulesGlobalTypes: file: NeutronSecurityRulesGlobalTypesServiceTemplate.yaml - NovaServerGlobalTypes: +- NovaServerGlobalTypes: file: NovaServerGlobalTypesServiceTemplate.yaml - ContrailVirtualNetworkGlobalType: +- ContrailVirtualNetworkGlobalType: file: ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml - AbstractSubstituteGlobalTypes: +- AbstractSubstituteGlobalTypes: file: AbstractSubstituteGlobalTypesServiceTemplate.yaml topology_template: inputs: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/nestedServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/nestedServiceTemplate.yaml index cd27e7ba1a..9c6c7311d0 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/nestedServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/toscasubstitution/nestedServiceTemplate.yaml @@ -2,25 +2,25 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 metadata: template_name: nested imports: - NeutronPortGlobalTypes: +- NeutronPortGlobalTypes: file: NeutronPortGlobalTypesServiceTemplate.yaml - NeutronNetGlobalTypes: +- NeutronNetGlobalTypes: file: NeutronNetGlobalTypesServiceTemplate.yaml - CommonGlobalTypes: +- CommonGlobalTypes: file: CommonGlobalTypesServiceTemplate.yaml - CinderVolumeGlobalTypes: +- CinderVolumeGlobalTypes: file: CinderVolumeGlobalTypesServiceTemplate.yaml - ContrailNetworkRuleGlobalType: +- ContrailNetworkRuleGlobalType: file: ContrailNetworkRuleGlobalTypeServiceTemplate.yaml - NeutronSecurityRulesGlobalTypes: +- NeutronSecurityRulesGlobalTypes: file: NeutronSecurityRulesGlobalTypesServiceTemplate.yaml - NovaServerGlobalTypes: +- NovaServerGlobalTypes: file: NovaServerGlobalTypesServiceTemplate.yaml - ContrailVirtualNetworkGlobalType: +- ContrailVirtualNetworkGlobalType: file: ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml - AbstractSubstituteGlobalTypes: +- AbstractSubstituteGlobalTypes: file: AbstractSubstituteGlobalTypesServiceTemplate.yaml - nested: +- nested: file: GlobalSubstitutionTypesServiceTemplate.yaml node_types: org.openecomp.resource.vfc.nodes.heat.cmaui_image: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/AbstractSubstituteGlobalTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/AbstractSubstituteGlobalTypesServiceTemplate.yaml index 8813b0abf6..449f0939ee 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/AbstractSubstituteGlobalTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/AbstractSubstituteGlobalTypesServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Abstract Substitute Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml data_types: org.openecomp.datatypes.heat.substitution.SubstitutionFilter: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/CinderVolumeGlobalTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/CinderVolumeGlobalTypesServiceTemplate.yaml index 3ef94f22e7..9b0655bf36 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/CinderVolumeGlobalTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/CinderVolumeGlobalTypesServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Cinder Volume TOSCA Global Types relationship_types: - org.openecomp.relationships.heat.cinder.VolumeAttachesTo: + org.openecomp.relationships.VolumeAttachesTo: derived_from: tosca.relationships.AttachesTo description: This type represents an attachment relationship for associating volume properties: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailNetworkRuleGlobalTypeServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailNetworkRuleGlobalTypeServiceTemplate.yaml index 98317310fa..044d759bc0 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailNetworkRuleGlobalTypeServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailNetworkRuleGlobalTypeServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Contrail Network Rule Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml data_types: org.openecomp.datatypes.heat.contrail.network.rule.PortPairs: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml index 0927e3dd0e..cbbb979029 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Contrail Virtual Network Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml node_types: org.openecomp.resource.vl.nodes.heat.network.contrail.VirtualNetwork: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/GlobalSubstitutionTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/GlobalSubstitutionTypesServiceTemplate.yaml index 08c47bc646..1ce3fc54ff 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/GlobalSubstitutionTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/GlobalSubstitutionTypesServiceTemplate.yaml @@ -2,23 +2,23 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 metadata: template_name: GlobalSubstitutionTypes imports: - NeutronPortGlobalTypes: +- NeutronPortGlobalTypes: file: NeutronPortGlobalTypesServiceTemplate.yaml - NeutronNetGlobalTypes: +- NeutronNetGlobalTypes: file: NeutronNetGlobalTypesServiceTemplate.yaml - CommonGlobalTypes: +- CommonGlobalTypes: file: CommonGlobalTypesServiceTemplate.yaml - CinderVolumeGlobalTypes: +- CinderVolumeGlobalTypes: file: CinderVolumeGlobalTypesServiceTemplate.yaml - ContrailNetworkRuleGlobalType: +- ContrailNetworkRuleGlobalType: file: ContrailNetworkRuleGlobalTypeServiceTemplate.yaml - NeutronSecurityRulesGlobalTypes: +- NeutronSecurityRulesGlobalTypes: file: NeutronSecurityRulesGlobalTypesServiceTemplate.yaml - NovaServerGlobalTypes: +- NovaServerGlobalTypes: file: NovaServerGlobalTypesServiceTemplate.yaml - ContrailVirtualNetworkGlobalType: +- ContrailVirtualNetworkGlobalType: file: ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml - AbstractSubstituteGlobalTypes: +- AbstractSubstituteGlobalTypes: file: AbstractSubstituteGlobalTypesServiceTemplate.yaml node_types: org.openecomp.resource.abstract.nodes.heat.nested: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronNetGlobalTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronNetGlobalTypesServiceTemplate.yaml index e80e2727c7..494b44c126 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronNetGlobalTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronNetGlobalTypesServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Neutron Network TOSCA Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml node_types: org.openecomp.resource.vl.nodes.heat.network.neutron.Net: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronPortGlobalTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronPortGlobalTypesServiceTemplate.yaml index a337d6ed18..a561d79b8f 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronPortGlobalTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronPortGlobalTypesServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Neutron Port TOSCA Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml data_types: org.openecomp.datatypes.heat.neutron.port.FixedIps: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronSecurityRulesGlobalTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronSecurityRulesGlobalTypesServiceTemplate.yaml index 49c9a102c8..83fc31520a 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronSecurityRulesGlobalTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NeutronSecurityRulesGlobalTypesServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Neutron Security Rules TOSCA Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml data_types: org.openecomp.datatypes.heat.network.neutron.SecurityRules.Rule: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NovaServerGlobalTypesServiceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NovaServerGlobalTypesServiceTemplate.yaml index 2253a1e4af..d77e378a79 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NovaServerGlobalTypesServiceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/globalServiceTemplates/NovaServerGlobalTypesServiceTemplate.yaml @@ -4,7 +4,7 @@ metadata: template_version: 1.0.0 description: Nova Server TOSCA Global Types imports: - common_definitions: +- common_definitions: file: CommonGlobalTypesServiceTemplate.yaml data_types: org.openecomp.datatypes.heat.novaServer.network.PortExtraProperties: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml index 612bc2d2fa..2fb8042e00 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplate.yaml @@ -5,9 +5,9 @@ metadata: template_version: 1.0.0 description: testing desc tosca service template imports: - myfile1: +- myfile1: file: path1/path2/file1.yaml - myfile2: +- myfile2: file: path1/path2/file2.yaml artifact_types: one_artifact: diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateHeatExtend.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateHeatExtend.yaml index 4515e3dee3..6f34a76ab4 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateHeatExtend.yaml +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/model/serviceTemplateHeatExtend.yaml @@ -5,9 +5,9 @@ metadata: template_version: 1.0.0 description: testing desc tosca service template imports: - myfile1: +- myfile1: file: path1/path2/file1.yaml - myfile2: +- myfile2: file: path1/path2/file2.yaml artifact_types: one_artifact: @@ -57,6 +57,10 @@ node_types: topology_template: description: topologi template descroption inputs: + OS::stack_name: + type: string + description: desc + required: false inParam1: type: string description: desc |