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=========================================================
22 package org.onap.aai.schemaif.json;
24 import java.util.HashMap;
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.json.definitions.JsonEdgeSchema;
32 public class FromJsonEdgeSchema extends EdgeSchema {
33 public static final String WILDCARD_CHAR = "*";
35 public FromJsonEdgeSchema() {
38 public FromJsonEdgeSchema(EdgeSchema other) {
39 // A shallow copy should suffice, as edge definitions don't change.
40 name = other.getName();
41 source = other.getSource();
42 target = other.getTarget();
43 multiplicity = other.getMultiplicity();
44 properties = other.getPropertySchemaList();
45 annotations = other.getAnnotations();
48 public void fromJson(JsonEdgeSchema jsonEdge) throws SchemaProviderException {
50 name = jsonEdge.getLabel();
51 source = jsonEdge.getFrom();
52 target = jsonEdge.getTo();
54 // TODO: At present, multiplicity isn't described in the JSON schema. By default, make everything
56 multiplicity = Multiplicity.MANY_2_MANY;
58 // Populate annotation schema
59 annotations = new HashMap<String, String>();
60 if (jsonEdge.getAnnotations() != null) {
61 for (Map.Entry<String, String> entry : jsonEdge.getAnnotations().entrySet()) {
62 annotations.put(entry.getKey().toLowerCase(), entry.getValue());
66 // Currently edge properties are not supported in the json schema
67 properties = new HashMap<String, PropertySchema>();
70 public void replaceWildcard(String vertexName) throws SchemaProviderException {
71 if (source.equals(WILDCARD_CHAR) && target.equals(WILDCARD_CHAR)) {
72 throw new SchemaProviderException("Edge definition with wildcard source and target: " + toString());
75 if (source.equals(WILDCARD_CHAR)) {
79 if (target.equals(WILDCARD_CHAR)) {