2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.ci.tests.tosca.datatypes;
23 import org.yaml.snakeyaml.TypeDescription;
25 import java.util.HashMap;
27 import java.util.stream.Collectors;
30 public class ToscaTopologyTemplateDefinition {
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;
42 public ToscaTopologyTemplateDefinition() {
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;
54 public ToscaTopologyTemplateDefinition(String description, Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> node_templates, Map<String, ToscaGroupsTopologyTemplateDefinition> groups,
55 Map<String, ToscaInputsTopologyTemplateDefinition> inputs, ToscaSubstitutionMappingsDefinition substitution_mappings) {
57 this.description = description;
58 this.node_templates = node_templates;
61 this.substitution_mappings = substitution_mappings;
64 public Map<String, ToscaInputsTopologyTemplateDefinition> getInputs() {
68 public void setInputs(Map<String, ToscaInputsTopologyTemplateDefinition> inputs) {
72 public void addInputs(Map<String, ToscaInputsTopologyTemplateDefinition> inputs) {
73 this.inputs.putAll(inputs);
76 public ToscaSubstitutionMappingsDefinition getSubstitution_mappings() {
77 return substitution_mappings;
79 public void setSubstitution_mappings(ToscaSubstitutionMappingsDefinition substitution_mappings) {
80 this.substitution_mappings = substitution_mappings;
83 public String getDescription() {
87 public void setDescription(String description) {
88 this.description = description;
92 public Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> getNode_templates() {
93 return node_templates;
96 public void setNode_templates(Map<String, ToscaNodeTemplatesTopologyTemplateDefinition> node_templates) {
97 this.node_templates = node_templates;
100 public Map<String, ToscaGroupsTopologyTemplateDefinition> getGroups() {
104 public void setGroups(Map<String, ToscaGroupsTopologyTemplateDefinition> groups) {
105 this.groups = groups;
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;