2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 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=========================================================
20 package org.onap.aai.serialization.db;
22 import org.apache.tinkerpop.gremlin.structure.Direction;
24 import java.util.EnumMap;
27 public class EdgeRule {
29 private String label = "";
30 private MultiplicityRule multiplicityRule = null;
31 private Direction direction = null;
32 private Map<EdgeProperty, String> edgeProperties = null;
33 private boolean isDefaultEdge = false;
38 * Instantiates a new edge rule.
41 edgeProperties = new EnumMap<>(EdgeProperty.class);
44 public String getFrom() {
48 public void setFrom(String from) {
52 public String getTo() {
56 public void setTo(String to) {
65 public String getLabel() {
72 * @param label the new label
74 public void setLabel(String label) {
79 * Gets the multiplicity rule.
81 * @return the multiplicity rule
83 public MultiplicityRule getMultiplicityRule() {
84 return multiplicityRule;
87 public void setMultiplicityRule(String multiplicity){
88 if ("Many2Many".equalsIgnoreCase(multiplicity)) {
89 this.multiplicityRule = MultiplicityRule.MANY2MANY;
90 } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
91 this.multiplicityRule = MultiplicityRule.ONE2MANY;
92 } else if ("One2One".equalsIgnoreCase(multiplicity)) {
93 this.multiplicityRule = MultiplicityRule.ONE2ONE;
94 } else { //should be "Many2One"
95 this.multiplicityRule = MultiplicityRule.MANY2ONE;
100 * Sets the multiplicity rule.
102 * @param multiplicityRule the new multiplicity rule
104 public void setMultiplicityRule(MultiplicityRule multiplicityRule) {
105 this.multiplicityRule = multiplicityRule;
109 * Gets the direction.
111 * @return the direction
113 public Direction getDirection() {
117 public void setDirection(String direction){
118 if ("OUT".equalsIgnoreCase(direction)) {
119 this.direction = Direction.OUT;
120 } else if ("IN".equalsIgnoreCase(direction)) {
121 this.direction = Direction.IN;
123 this.direction = Direction.BOTH;
128 * Sets the direction.
130 * @param direction the new direction
132 public void setDirection(Direction direction) {
133 this.direction = direction;
137 * Gets the checks if is parent.
139 * @return the checks if is parent
141 public String getContains() {
142 return this.getProp(EdgeProperty.CONTAINS);
146 * Sets the checks if is parent.
148 * @param isParent the new checks if is parent
150 public void setContains(String isParent) {
151 this.setProp(EdgeProperty.CONTAINS, isParent);
155 * Gets the checks for del target.
157 * @return the checks for del target
159 public String getDeleteOtherV() {
160 return this.getProp(EdgeProperty.DELETE_OTHER_V);
164 * Sets the checks for del target.
166 * @param hasDelTarget the new checks for del target
168 public void setDeleteOtherV(String hasDelTarget) {
169 this.setProp(EdgeProperty.DELETE_OTHER_V, hasDelTarget);
173 * Gets the service infrastructure.
175 * @return the service infrastructure
177 public String getServiceInfrastructure() {
178 return this.getProp(EdgeProperty.SVC_INFRA);
182 * Sets the service infrastructure.
184 * @param serviceInfrastructure the new service infrastructure
186 public void setServiceInfrastructure(String serviceInfrastructure) {
187 this.setProp(EdgeProperty.SVC_INFRA, serviceInfrastructure);
190 public String getPreventDelete() {
191 return this.getProp(EdgeProperty.PREVENT_DELETE);
194 public void setPreventDelete(String preventDelete) {
195 this.setProp(EdgeProperty.PREVENT_DELETE, preventDelete);
199 * Gets the edge properties.
201 * @return the edge properties
203 public Map<EdgeProperty, String> getEdgeProperties() {
204 return this.edgeProperties;
211 * @param value the value
213 private void setProp(EdgeProperty key, String value) {
214 this.edgeProperties.put(key, value);
223 private String getProp(EdgeProperty key) {
224 return this.edgeProperties.get(key);
227 public boolean isDefault() {
228 return isDefaultEdge;
231 public void setIsDefault(boolean isDefault) {
232 this.isDefaultEdge = isDefault;
235 public void setIsDefault(String isDefault) {
236 this.isDefaultEdge = "true".equals(isDefault);