2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.aai.serialization.db;
23 import java.util.HashMap;
26 import org.apache.tinkerpop.gremlin.structure.Direction;
28 public class EdgeRule {
30 private String label = "";
31 private MultiplicityRule multiplicityRule = null;
32 private Direction direction = null;
33 private Map<EdgeProperty, String> edgeProperties = null;
36 * Instantiates a new edge rule.
39 edgeProperties = new HashMap<>();
47 public String getLabel() {
54 * @param label the new label
56 public void setLabel(String label) {
61 * Gets the multiplicity rule.
63 * @return the multiplicity rule
65 public MultiplicityRule getMultiplicityRule() {
66 return multiplicityRule;
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;
82 * Sets the multiplicity rule.
84 * @param multiplicityRule the new multiplicity rule
86 public void setMultiplicityRule(MultiplicityRule multiplicityRule) {
87 this.multiplicityRule = multiplicityRule;
93 * @return the direction
95 public Direction getDirection() {
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;
105 this.direction = Direction.BOTH;
110 * Sets the direction.
112 * @param direction the new direction
114 public void setDirection(Direction direction) {
115 this.direction = direction;
119 * Gets the checks if is parent.
121 * @return the checks if is parent
123 public String getContains() {
124 return this.getProp(EdgeProperty.CONTAINS);
128 * Sets the checks if is parent.
130 * @param isParent the new checks if is parent
132 public void setContains(String isParent) {
133 this.setProp(EdgeProperty.CONTAINS, isParent);
137 * Gets the checks for del target.
139 * @return the checks for del target
141 public String getDeleteOtherV() {
142 return this.getProp(EdgeProperty.DELETE_OTHER_V);
146 * Sets the checks for del target.
148 * @param hasDelTarget the new checks for del target
150 public void setDeleteOtherV(String hasDelTarget) {
151 this.setProp(EdgeProperty.DELETE_OTHER_V, hasDelTarget);
155 * Gets the service infrastructure.
157 * @return the service infrastructure
159 public String getServiceInfrastructure() {
160 return this.getProp(EdgeProperty.SVC_INFRA);
164 * Sets the service infrastructure.
166 * @param serviceInfrastructure the new service infrastructure
168 public void setServiceInfrastructure(String serviceInfrastructure) {
169 this.setProp(EdgeProperty.SVC_INFRA, serviceInfrastructure);
172 public String getPreventDelete() {
173 return this.getProp(EdgeProperty.PREVENT_DELETE);
176 public void setPreventDelete(String preventDelete) {
177 this.setProp(EdgeProperty.PREVENT_DELETE, preventDelete);
181 * Gets the edge properties.
183 * @return the edge properties
185 public Map<EdgeProperty, String> getEdgeProperties() {
186 return this.edgeProperties;
193 * @param value the value
195 private void setProp(EdgeProperty key, String value) {
196 this.edgeProperties.put(key, value);
205 private String getProp(EdgeProperty key) {
206 return this.edgeProperties.get(key);