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