2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2019 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.schemaif.oxm;
23 import java.util.HashMap;
25 import org.onap.aai.edges.EdgeRule;
26 import org.onap.aai.edges.enums.EdgeProperty;
27 import org.onap.aai.schemaif.SchemaProviderException;
28 import org.onap.aai.schemaif.definitions.EdgeSchema;
29 import org.onap.aai.schemaif.definitions.PropertySchema;
30 import org.onap.aai.schemaif.definitions.types.DataType;
33 public class FromOxmEdgeSchema extends EdgeSchema {
35 public void fromEdgeRule(EdgeRule edgeRule) throws SchemaProviderException {
36 name = edgeRule.getLabel();
37 source = edgeRule.getFrom();
38 target = edgeRule.getTo();
40 switch (edgeRule.getMultiplicityRule()) {
42 multiplicity = Multiplicity.MANY_2_MANY;
45 multiplicity = Multiplicity.MANY_2_ONE;
48 multiplicity = Multiplicity.ONE_2_MANY;
51 multiplicity = Multiplicity.ONE_2_ONE;
55 annotations = new HashMap<String,String>();
56 properties = new HashMap<String,PropertySchema>();
58 // TODO: For now these are hard-coded ... should read them from a config file or something
59 annotations.put(EdgeProperty.CONTAINS.toString().toLowerCase(), edgeRule.getContains());
60 annotations.put(EdgeProperty.DELETE_OTHER_V.toString().toLowerCase(), edgeRule.getDeleteOtherV());
61 annotations.put(EdgeProperty.PREVENT_DELETE.toString().toLowerCase(), edgeRule.getPreventDelete());
63 FromOxmPropertySchema pSchema = new FromOxmPropertySchema();
64 pSchema.fromRelationship(EdgeProperty.CONTAINS.toString(), DataType.Type.STRING);
65 properties.put(EdgeProperty.CONTAINS.toString().toLowerCase(), pSchema);
67 pSchema = new FromOxmPropertySchema();
68 pSchema.fromRelationship(EdgeProperty.DELETE_OTHER_V.toString(), DataType.Type.STRING);
69 properties.put(EdgeProperty.DELETE_OTHER_V.toString().toLowerCase(), pSchema);
71 pSchema = new FromOxmPropertySchema();
72 pSchema.fromRelationship(EdgeProperty.PREVENT_DELETE.toString(), DataType.Type.STRING);
73 properties.put(EdgeProperty.PREVENT_DELETE.toString().toLowerCase(), pSchema);