[AAI-178 Amsterdam] Make Edge Properties to be
[aai/aai-common.git] / aai-core / src / main / java / org / openecomp / aai / serialization / db / EdgeRule.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.openecomp.aai
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.aai.serialization.db;
22
23 import org.apache.tinkerpop.gremlin.structure.Direction;
24
25 import java.util.HashMap;
26 import java.util.Map;
27
28 public class EdgeRule {
29
30         private String label = "";
31         private MultiplicityRule multiplicityRule = null;
32         private Direction direction = null;
33         private Map<EdgeProperty, String> edgeProperties = null;
34         
35         /**
36          * Instantiates a new edge rule.
37          */
38         public EdgeRule() {
39                 edgeProperties = new HashMap<>();
40         }
41         
42         /**
43          * Gets the label.
44          *
45          * @return the label
46          */
47         public String getLabel() {
48                 return label;
49         }
50         
51         /**
52          * Sets the label.
53          *
54          * @param label the new label
55          */
56         public void setLabel(String label) {
57                 this.label = label;
58         }
59         
60         /**
61          * Gets the multiplicity rule.
62          *
63          * @return the multiplicity rule
64          */
65         public MultiplicityRule getMultiplicityRule() {
66                 return multiplicityRule;
67         }
68         
69         public void setMultiplicityRule(String multiplicity){
70                 if ("Many2Many".equalsIgnoreCase(multiplicity)) {
71                         this.multiplicityRule = MultiplicityRule.MANY2MANY;
72                 } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
73                         this.multiplicityRule = MultiplicityRule.ONE2MANY;
74                 } else if ("One2One".equalsIgnoreCase(multiplicity)) {
75                         this.multiplicityRule = MultiplicityRule.ONE2ONE;
76                 } else { //should be "Many2One"
77                         this.multiplicityRule = MultiplicityRule.MANY2ONE;
78                 }
79         }
80         
81         /**
82          * Sets the multiplicity rule.
83          *
84          * @param multiplicityRule the new multiplicity rule
85          */
86         public void setMultiplicityRule(MultiplicityRule multiplicityRule) {
87                 this.multiplicityRule = multiplicityRule;
88         }
89         
90         /**
91          * Gets the direction.
92          *
93          * @return the direction
94          */
95         public Direction getDirection() {
96                 return direction;
97         }
98         
99         public void setDirection(String direction){
100                 if ("OUT".equalsIgnoreCase(direction)) {
101                         this.direction = Direction.OUT;
102                 } else if ("IN".equalsIgnoreCase(direction)) {
103                         this.direction = Direction.IN;
104                 } else {
105                         this.direction = Direction.BOTH;
106                 }
107         }
108         
109         /**
110          * Sets the direction.
111          *
112          * @param direction the new direction
113          */
114         public void setDirection(Direction direction) {
115                 this.direction = direction;
116         }
117         
118         /**
119          * Gets the checks if is parent.
120          *
121          * @return the checks if is parent
122          */
123         public String getContains() {
124                 return this.getProp(EdgeProperty.CONTAINS);
125         }
126         
127         /**
128          * Sets the checks if is parent.
129          *
130          * @param isParent the new checks if is parent
131          */
132         public void setContains(String isParent) {
133                 this.setProp(EdgeProperty.CONTAINS, isParent);
134         }
135         
136         /**
137          * Gets the checks for del target.
138          *
139          * @return the checks for del target
140          */
141         public String getDeleteOtherV() {
142                 return this.getProp(EdgeProperty.DELETE_OTHER_V);
143         }
144         
145         /**
146          * Sets the checks for del target.
147          *
148          * @param hasDelTarget the new checks for del target
149          */
150         public void setDeleteOtherV(String hasDelTarget) {
151                 this.setProp(EdgeProperty.DELETE_OTHER_V, hasDelTarget);
152         }
153         
154         /**
155          * Gets the service infrastructure.
156          *
157          * @return the service infrastructure
158          */
159         public String getServiceInfrastructure() {
160                 return this.getProp(EdgeProperty.SVC_INFRA);
161         }
162         
163         /**
164          * Sets the service infrastructure.
165          *
166          * @param serviceInfrastructure the new service infrastructure
167          */
168         public void setServiceInfrastructure(String serviceInfrastructure) {
169                 this.setProp(EdgeProperty.SVC_INFRA, serviceInfrastructure);
170         }
171         
172         public String getPreventDelete() {
173                 return this.getProp(EdgeProperty.PREVENT_DELETE);
174         }
175         
176         public void setPreventDelete(String preventDelete) {
177                 this.setProp(EdgeProperty.PREVENT_DELETE, preventDelete);
178         }
179         
180         /**
181          * Gets the edge properties.
182          *
183          * @return the edge properties
184          */
185         public Map<EdgeProperty, String> getEdgeProperties() {
186                 return this.edgeProperties;
187         }
188         
189         /**
190          * Sets the prop.
191          *
192          * @param key the key
193          * @param value the value
194          */
195         private void setProp(EdgeProperty key, String value) {
196                 this.edgeProperties.put(key, value);
197         }
198         
199         /**
200          * Gets the prop.
201          *
202          * @param key the key
203          * @return the prop
204          */
205         private String getProp(EdgeProperty key) {
206                 return this.edgeProperties.get(key);
207         }
208         
209         
210 }