f2968fd5421bd0cbb267e46f083a8649d08fc767
[vfc/nfvo/catalog.git] /
1 /**
2  * Copyright 2016 ZTE Corporation.
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 package org.openo.commontosca.catalog.model.parser.yaml.aria.entity;
17
18 import java.util.HashMap;
19 import java.util.Map;
20 import java.util.Map.Entry;
21
22 import lombok.AllArgsConstructor;
23 import lombok.Data;
24 import lombok.NoArgsConstructor;
25
26 @Data
27 @NoArgsConstructor
28 @AllArgsConstructor
29 public class AriaParserResult {
30   private Issue[] issues;
31   private Instance instance = new Instance();
32   
33   private String rawData;
34 //  private Type[] types;
35 //  private Model model;
36
37 //  @Data
38 //  public class Type {
39 //  }
40 //  @Data
41 //  public class Model {
42 //  }
43   @Data
44   public class Issue {
45     private int level;
46     private String message;
47     private String location;
48     private String line;
49     private String column;
50     private String snippet;
51     private String exception;
52   }
53   
54   @Data
55   public class Instance {
56     private String description;
57     private Map<String, String> metadata;
58     private Node[] nodes;
59     private Group[] groups;
60     private Policy[] policies;
61     private Substitution substitution;
62     private Map<String, Input> inputs;
63     private Map<String, Output> outpus;
64     
65     public Map<String, String> getMetadata() {
66       if (this.metadata == null) {
67         return new HashMap<>();
68       }
69       
70       return metadata;
71     }
72
73     @Data
74     public class Node {
75       private String id;
76       private String type_name;
77       private String template_name;
78       private Map<String, Property> properties;
79       private Interface[] interfaces;
80       private Artifact[] artifacts;
81       private Capability[] capabilities;
82       private Relationship[] relationships;
83       
84       @Data
85       public class Artifact {
86         private String name;
87         private String type_name;
88         private String source_path;
89         private String target_path;
90         private String repository_url;
91         private Credential repository_credential;
92         private Map<String, Property> properties;
93         
94         @Data
95         public class Credential {
96           private String protocol;
97           private String token_type;
98           private Map<String, String> keys;
99           private String user;
100         }
101       }
102       
103       @Data
104       public class Capability {
105         private String name;
106         private String type_name;
107         private Map<String, Property> properties;
108       }
109
110       @Data
111       public class Relationship {
112         private String target_node_id;
113         private String target_capability_name;
114         private String type_name;
115         private String template_name;
116         private Map<String, Property> properties;
117         private Interface[] source_interfaces;
118         private Interface[] target_interfaces;
119       }
120
121       /**
122        * @return
123        */
124       public Map<String, Object> getPropertyAssignments() {
125         if (this.properties == null || this.properties.isEmpty()) {
126           return new HashMap<String, Object>();
127         }
128         
129         Map<String, Object> ret = new HashMap<String, Object>();
130         for (Entry<String, Property> e : this.properties.entrySet()) {
131           ret.put(e.getKey(), e.getValue().getValue());
132         }
133
134         return ret;
135       }
136     }
137     
138     @Data
139     public class Group {
140       private String id;
141       private String type_name;
142       private String template_name;
143       private Map<String, Property> properties;
144       private Interface[] interfaces;
145       private GroupPolicy[] policies;
146       private String[] member_node_ids;
147       
148       @Data
149       public class GroupPolicy {
150         private String id;
151         private String type_name;
152         private Map<String, Property> properties;
153         private Trigger[] triggers;
154         
155         @Data
156         public class Trigger {
157           private String name;
158           private String implementation;
159           private Map<String, Property> properties;
160         }
161       }
162       
163     }
164
165     
166     @Data
167     public class Policy {
168       private String name;
169       private String type_name;
170       private Map<String, Property> properties;
171       private String[] target_node_ids;
172       private String[] target_group_ids;
173     }
174     
175     @Data
176     public class Substitution {
177       private String node_type_name;
178       private Mapping[] requirement;
179       private Mapping[] capabilities;
180       
181       @Data
182       public class Mapping {
183         private String mapped_name;
184         private String node_id;
185         private String name;
186         
187       }
188     }
189
190     @Data
191     public class Input {
192       private String type_name;
193       private Object value;
194       private String description;
195     }
196     
197     @Data
198     public class Output {
199       private String type_name;
200       private Object value;
201       private String description;
202     }
203   }
204   
205 }
206
207
208 @Data
209 class Property {
210   private String type_name;
211   private Object value;
212   private String description;
213 }
214
215 @Data
216 class Interface {
217   private String name;
218   private String type_name;
219   private Map<String, Property> inputs;
220   private Operation[] operation;
221   
222   @Data
223   class Operation {
224     private String name;
225     private String implementation;
226     private String[] dependencies;
227     private String executor;
228     private int max_retries;
229     private int retry_interval;
230     private Map<String, Property> inputs;
231   }
232 }
233