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