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