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