b610ecd9d6e71d2d2f0488976e878615b972b200
[vfc/nfvo/catalog.git] /
1 /**
2  * Copyright 2016 [ZTE] and others.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openo.commontosca.catalog.model.parser.yaml.aria.entity;
18
19 import java.util.HashMap;
20 import java.util.Map;
21 import java.util.Map.Entry;
22
23 import lombok.AllArgsConstructor;
24 import lombok.Data;
25 import lombok.NoArgsConstructor;
26
27 import com.google.gson.JsonObject;
28
29 @Data
30 @NoArgsConstructor
31 @AllArgsConstructor
32 public class AriaParserResult {
33   private String description;
34   private Map<String, String> metadata;
35   private Node[] nodes;
36   private JsonObject groups;
37   private JsonObject policies;
38   private Substitution substitution;
39   private Map<String, Input> inputs;
40   private Map<String, Output> outpus;
41   
42   @Data
43   public class Substitution {
44     private String node_type_name;
45     private Mapping[] requirement;
46     private Mapping[] capabilities;
47     
48     @Data
49     public class Mapping {
50       private String mapped_name;
51       private String node_id;
52       private String name;
53       
54     }
55   }
56
57   @Data
58   public class Input {
59     private String type_name;
60     private Object value;
61     private String description;
62   }
63   
64   @Data
65   public class Output {
66     private String type_name;
67     private Object value;
68     private String description;
69   }
70
71   @Data
72   public class Node {
73     private String id;
74     private String name;
75     private String type_name;
76     private Map<String, Property> properties;
77     private JsonObject[] interfaces;
78     private JsonObject[] artifacts;
79     private JsonObject[] capabilities;
80     private Relationship[] relationships;
81     
82     @Data
83     public class Property {
84       private String type_name;
85       private Object value;
86       private String description;
87     }
88
89     @Data
90     public class Relationship {
91       private String target_node_id;
92       private String target_capability_name;
93       private String type_name;
94       private String template_name;
95       private Map<String, Property> properties;
96       private JsonObject[] source_interfaces;
97       private JsonObject[] target_interfaces;
98       
99       @Data
100       public class Property {
101         private String type_name;
102         private Object value;
103         private String description;
104       }
105     }
106
107     /**
108      * @return
109      */
110     public Map<String, Object> getPropertyAssignments() {
111       if (this.properties == null || this.properties.isEmpty()) {
112         return new HashMap<String, Object>();
113       }
114       
115       Map<String, Object> ret = new HashMap<String, Object>();
116       for (Entry<String, Property> e : this.properties.entrySet()) {
117         ret.put(e.getKey(), e.getValue().getValue());
118       }
119
120       return ret;
121     }
122   }
123 }