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<String, String> edgeProperties = null;
34 private final String IS_PARENT = "isParent";
35 private final String USES_RESOURCE = "usesResource";
36 private final String HAS_DEL_TARGET = "hasDelTarget";
37 private final String SVC_INFRA = "SVC-INFRA";
40 * Instantiates a new edge rule.
43 edgeProperties = new HashMap<>();
51 public String getLabel() {
58 * @param label the new label
60 public void setLabel(String label) {
65 * Gets the multiplicity rule.
67 * @return the multiplicity rule
69 public MultiplicityRule getMultiplicityRule() {
70 return multiplicityRule;
73 public void setMultiplicityRule(String multiplicity){
74 if ("Many2Many".equalsIgnoreCase(multiplicity)) {
75 this.multiplicityRule = MultiplicityRule.MANY2MANY;
76 } else if ("One2Many".equalsIgnoreCase(multiplicity)) {
77 this.multiplicityRule = MultiplicityRule.ONE2MANY;
78 } else if ("One2One".equalsIgnoreCase(multiplicity)) {
79 this.multiplicityRule = MultiplicityRule.ONE2ONE;
80 } else { //should be "Many2One"
81 this.multiplicityRule = MultiplicityRule.MANY2ONE;
86 * Sets the multiplicity rule.
88 * @param multiplicityRule the new multiplicity rule
90 public void setMultiplicityRule(MultiplicityRule multiplicityRule) {
91 this.multiplicityRule = multiplicityRule;
97 * @return the direction
99 public Direction getDirection() {
103 public void setDirection(String direction){
104 if ("OUT".equalsIgnoreCase(direction)) {
105 this.direction = Direction.OUT;
106 } else if ("IN".equalsIgnoreCase(direction)) {
107 this.direction = Direction.IN;
109 this.direction = Direction.BOTH;
114 * Sets the direction.
116 * @param direction the new direction
118 public void setDirection(Direction direction) {
119 this.direction = direction;
123 * Gets the checks if is parent.
125 * @return the checks if is parent
127 public String getIsParent() {
128 return this.getProp(this.IS_PARENT);
132 * Sets the checks if is parent.
134 * @param isParent the new checks if is parent
136 public void setIsParent(String isParent) {
137 this.setProp(this.IS_PARENT, isParent);
141 * Gets the uses resource.
143 * @return the uses resource
145 public String getUsesResource() {
146 return this.getProp(this.USES_RESOURCE);
150 * Sets the uses resource.
152 * @param usesResource the new uses resource
154 public void setUsesResource(String usesResource) {
155 this.setProp(this.USES_RESOURCE, usesResource);
159 * Gets the checks for del target.
161 * @return the checks for del target
163 public String getHasDelTarget() {
164 return this.getProp(this.HAS_DEL_TARGET);
168 * Sets the checks for del target.
170 * @param hasDelTarget the new checks for del target
172 public void setHasDelTarget(String hasDelTarget) {
173 this.setProp(this.HAS_DEL_TARGET, hasDelTarget);
177 * Gets the service infrastructure.
179 * @return the service infrastructure
181 public String getServiceInfrastructure() {
182 return this.getProp(this.SVC_INFRA);
186 * Sets the service infrastructure.
188 * @param serviceInfrastructure the new service infrastructure
190 public void setServiceInfrastructure(String serviceInfrastructure) {
191 this.setProp(this.SVC_INFRA, serviceInfrastructure);
195 * Gets the edge properties.
197 * @return the edge properties
199 public Map<String, String> getEdgeProperties() {
200 return this.edgeProperties;
207 * @param value the value
209 private void setProp(String key, String value) {
210 this.edgeProperties.put(key, value);
219 private String getProp(String key) {
220 return this.edgeProperties.get(key);