re base code
[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 org.yaml.snakeyaml.TypeDescription;
24
25 import java.util.HashMap;
26 import java.util.Map;
27 import java.util.stream.Collectors;
28
29 //      spec page 104   
30 public class ToscaTopologyTemplateDefinition {
31
32         String description;
33 //      Map<String, Map<String, ToscaInputsDefinition>> inputs;
34         Map<String,ToscaNodeTemplatesTopologyTemplateDefinition> node_templates = new HashMap<>();
35 //      Map<String,ToscaRelationshipTemplatesTopologyTemplateDefinition> relationship_templates;
36         Map<String,ToscaGroupsTopologyTemplateDefinition> groups = new HashMap<>();
37         Map<String, ToscaInputsTopologyTemplateDefinition> inputs = new HashMap<>();
38 //      Map<String,ToscaPoliciesTopologyTemplateDefinition> policies;
39 //      Map<String,ToscaOutputsTopologyTemplateDefinition> outputs;
40         ToscaSubstitutionMappingsDefinition substitution_mappings;
41         
42         public ToscaTopologyTemplateDefinition() {
43                 super();
44         }
45         
46         public ToscaTopologyTemplateDefinition(ToscaTopologyTemplateDefinition definition) {
47                 this.description = definition.description;
48                 this.node_templates = new HashMap<>(definition.node_templates);
49                 this.groups = new HashMap<String,ToscaGroupsTopologyTemplateDefinition>(definition.groups);
50                 this.inputs = definition.inputs.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> new ToscaInputsTopologyTemplateDefinition(e.getValue())));
51                 this.substitution_mappings = definition.substitution_mappings;
52         }
53         
54         public ToscaTopologyTemplateDefinition(String description, Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> node_templates, Map<String, ToscaGroupsTopologyTemplateDefinition> groups,
55                 Map<String, ToscaInputsTopologyTemplateDefinition> inputs, ToscaSubstitutionMappingsDefinition substitution_mappings) {
56         super();
57         this.description = description;
58         this.node_templates = node_templates;
59         this.groups = groups;
60         this.inputs = inputs;
61         this.substitution_mappings = substitution_mappings;
62 }
63
64         public Map<String, ToscaInputsTopologyTemplateDefinition> getInputs() {
65                 return inputs;
66         }
67
68         public void setInputs(Map<String, ToscaInputsTopologyTemplateDefinition> inputs) {
69                 this.inputs = inputs;
70         }
71
72         public void addInputs(Map<String, ToscaInputsTopologyTemplateDefinition> inputs) {
73                 this.inputs.putAll(inputs);
74         }
75         
76         public ToscaSubstitutionMappingsDefinition getSubstitution_mappings() {
77                 return substitution_mappings;
78         }
79         public void setSubstitution_mappings(ToscaSubstitutionMappingsDefinition substitution_mappings) {
80                 this.substitution_mappings = substitution_mappings;
81         }
82
83         public String getDescription() {
84                 return description;
85         }
86
87         public void setDescription(String description) {
88                 this.description = description;
89         }
90
91
92         public Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> getNode_templates() {
93                 return node_templates;
94         }
95
96         public void setNode_templates(Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> node_templates) {
97                 this.node_templates = node_templates;
98         }
99
100         public Map<String, ToscaGroupsTopologyTemplateDefinition> getGroups() {
101                 return groups;
102         }
103
104         public void setGroups(Map<String, ToscaGroupsTopologyTemplateDefinition> groups) {
105                 this.groups = groups;
106         }
107
108         
109         //gets Type description for Yaml snake
110         public static TypeDescription getTypeDescription(){
111         TypeDescription typeDescription = new TypeDescription(ToscaTopologyTemplateDefinition.class);
112         typeDescription.putMapPropertyType("inputs", String.class, ToscaInputsTopologyTemplateDefinition.class);
113         typeDescription.putMapPropertyType("node_templates", String.class, ToscaNodeTemplatesTopologyTemplateDefinition.class);
114         typeDescription.putMapPropertyType("groups", String.class, ToscaGroupsTopologyTemplateDefinition.class);
115         return typeDescription;
116         }
117         
118         
119 }