Sync Integ to Master
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / tosca / datatypes / ToscaTopologyTemplateDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.tosca.datatypes;
22
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.stream.Collectors;
26
27 import org.apache.commons.lang3.tuple.ImmutablePair;
28 import org.yaml.snakeyaml.TypeDescription;
29
30 import com.clearspring.analytics.util.Pair;
31
32 import io.netty.util.collection.IntObjectMap.Entry;
33
34 //      spec page 104   
35 public class ToscaTopologyTemplateDefinition {
36
37         String description;
38 //      Map<String, Map<String, ToscaInputsDefinition>> inputs;
39         Map<String,ToscaNodeTemplatesTopologyTemplateDefinition> node_templates = new HashMap<>();
40 //      Map<String,ToscaRelationshipTemplatesTopologyTemplateDefinition> relationship_templates;
41         Map<String,ToscaGroupsTopologyTemplateDefinition> groups = new HashMap<>();
42         Map<String, ToscaInputsTopologyTemplateDefinition> inputs = new HashMap<>();
43 //      Map<String,ToscaPoliciesTopologyTemplateDefinition> policies;
44 //      Map<String,ToscaOutputsTopologyTemplateDefinition> outputs;
45         ToscaSubstitutionMappingsDefinition substitution_mappings;
46         
47         public ToscaTopologyTemplateDefinition() {
48                 super();
49         }
50         
51         public ToscaTopologyTemplateDefinition(ToscaTopologyTemplateDefinition definition) {
52                 this.description = definition.description;
53                 this.node_templates = new HashMap<>(definition.node_templates);
54                 this.groups = new HashMap<String,ToscaGroupsTopologyTemplateDefinition>(definition.groups);
55                 this.inputs = definition.inputs.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> new ToscaInputsTopologyTemplateDefinition(e.getValue())));
56                 this.substitution_mappings = definition.substitution_mappings;
57         }
58         
59         public ToscaTopologyTemplateDefinition(String description, Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> node_templates, Map<String, ToscaGroupsTopologyTemplateDefinition> groups,
60                 Map<String, ToscaInputsTopologyTemplateDefinition> inputs, ToscaSubstitutionMappingsDefinition substitution_mappings) {
61         super();
62         this.description = description;
63         this.node_templates = node_templates;
64         this.groups = groups;
65         this.inputs = inputs;
66         this.substitution_mappings = substitution_mappings;
67 }
68
69         public Map<String, ToscaInputsTopologyTemplateDefinition> getInputs() {
70                 return inputs;
71         }
72
73         public void setInputs(Map<String, ToscaInputsTopologyTemplateDefinition> inputs) {
74                 this.inputs = inputs;
75         }
76
77         public void addInputs(Map<String, ToscaInputsTopologyTemplateDefinition> inputs) {
78                 this.inputs.putAll(inputs);
79         }
80         
81         public ToscaSubstitutionMappingsDefinition getSubstitution_mappings() {
82                 return substitution_mappings;
83         }
84         public void setSubstitution_mappings(ToscaSubstitutionMappingsDefinition substitution_mappings) {
85                 this.substitution_mappings = substitution_mappings;
86         }
87
88         public String getDescription() {
89                 return description;
90         }
91
92         public void setDescription(String description) {
93                 this.description = description;
94         }
95
96
97         public Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> getNode_templates() {
98                 return node_templates;
99         }
100
101         public void setNode_templates(Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> node_templates) {
102                 this.node_templates = node_templates;
103         }
104
105         public Map<String, ToscaGroupsTopologyTemplateDefinition> getGroups() {
106                 return groups;
107         }
108
109         public void setGroups(Map<String, ToscaGroupsTopologyTemplateDefinition> groups) {
110                 this.groups = groups;
111         }
112
113         
114         //gets Type description for Yaml snake
115         public static TypeDescription getTypeDescription(){
116         TypeDescription typeDescription = new TypeDescription(ToscaTopologyTemplateDefinition.class);
117         typeDescription.putMapPropertyType("inputs", String.class, ToscaInputsTopologyTemplateDefinition.class);
118         typeDescription.putMapPropertyType("node_templates", String.class, ToscaNodeTemplatesTopologyTemplateDefinition.class);
119         typeDescription.putMapPropertyType("groups", String.class, ToscaGroupsTopologyTemplateDefinition.class);
120         return typeDescription;
121         }
122         
123         
124 }