summaryrefslogtreecommitdiffstats
path: root/aai-schema-abstraction/src
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-abstraction/src')
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java48
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java16
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java17
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java22
4 files changed, 48 insertions, 55 deletions
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java
index 1e798196..5aa8d688 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/SchemaProvider.java
@@ -21,77 +21,75 @@
package org.onap.aai.schemaif;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.onap.aai.schemaif.definitions.EdgeSchema;
import org.onap.aai.schemaif.definitions.VertexSchema;
+import java.util.Map;
+import java.util.Set;
+
public interface SchemaProvider {
-
+
/**
* Load the schema into memory
*/
- public void loadSchema() throws SchemaProviderException;
-
+ void loadSchema() throws SchemaProviderException;
+
/**
* Get the identifier for the more recent version of the schema
*
* @return The schema version identifier
*/
- public String getLatestSchemaVersion() throws SchemaProviderException;
-
+ String getLatestSchemaVersion() throws SchemaProviderException;
+
/**
* Get the schema definition for a vertex
*
* @param vertexName - Name of the vertex
* @param schemaVersion - Version of the schema to use
- *
+ *
* @return The vertex schema definition
*/
- public VertexSchema getVertexSchema(String vertexName, String schemaVersion) throws SchemaProviderException;
-
+ VertexSchema getVertexSchema(String vertexName, String schemaVersion) throws SchemaProviderException;
+
/**
* Get the schema definition for an edge
*
* @param edgeType - Type of the edge
* @param sourceVertex - The source vertex for the edge
* @param targetVertex - The target vertex for the edge
- * @param schemaVersion - Version of the schema to use
- *
+ * @param version - Version of the schema to use
+ *
* @return The edge schema definition
*/
- public EdgeSchema getEdgeSchema(String edgeType, String sourceVertex, String targetVertex, String version) throws SchemaProviderException;
+ EdgeSchema getEdgeSchema(String edgeType, String sourceVertex, String targetVertex, String version) throws SchemaProviderException;
/**
* Get the list of edge definitions which are adjacent to the given vertex
*
* @param vertexType - Type of the vertex
- * @param schemaVersion - Version of the schema to use
- *
+ * @param version - Version of the schema to use
+ *
* @return The list of edge schema definitions
*/
- public Set<EdgeSchema> getAdjacentEdgeSchema(String vertexType, String version) throws SchemaProviderException;
-
+ Set<EdgeSchema> getAdjacentEdgeSchema(String vertexType, String version) throws SchemaProviderException;
+
/**
* Get the list of edge definitions which are valid for the given source and target
*
* @param sourceType - Type of the source vertex
* @param targetType - Type of the target vertex
- * @param schemaVersion - Version of the schema to use
- *
+ * @param version - Version of the schema to use
+ *
* @return The list of edge schema definitions
*/
- public Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version) throws SchemaProviderException;
+ Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version) throws SchemaProviderException;
/**
* Get vertex map for a schema version
*
* @param schemaVersion - Version of the schema to use
- *
+ *
* @return The list of vertex types
*/
- public Map<String, VertexSchema> getVertexMap(String schemaVersion) throws SchemaProviderException;
-
+ Map<String, VertexSchema> getVertexMap(String schemaVersion) throws SchemaProviderException;
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java
index a0586037..2e2884b4 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/definitions/types/DataType.java
@@ -1,4 +1,4 @@
-/**
+/*
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
@@ -21,11 +21,9 @@
package org.onap.aai.schemaif.definitions.types;
-import org.onap.aai.schemaif.SchemaProviderException;
-
public abstract class DataType {
public enum Type {
- STRING,
+ STRING,
BOOL,
INT,
LONG,
@@ -34,9 +32,9 @@ public abstract class DataType {
MAP,
COMPLEX
}
-
- private Type type;
-
+
+ private final Type type;
+
public DataType(Type type) {
this.type = type;
}
@@ -44,9 +42,9 @@ public abstract class DataType {
public Type getType() {
return type;
}
-
+
public abstract Object validateValue(String value);
-
+
public String toString() {
return getType().toString();
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java
index 7fa123a5..0bc1760b 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/SchemaServiceResponse.java
@@ -1,4 +1,4 @@
-/**
+/*
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
@@ -20,26 +20,24 @@
*/
package org.onap.aai.schemaif.json;
-import org.onap.aai.schemaif.SchemaProviderException;
-import org.onap.aai.schemaif.json.definitions.JsonSchema;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
+import org.onap.aai.schemaif.SchemaProviderException;
+import org.onap.aai.schemaif.json.definitions.JsonSchema;
public class SchemaServiceResponse {
public static final String SCHEMA_TYPE_OXM = "oxm";
public static final String SCHEMA_TYPE_JSON = "json";
-
+
private static final Gson gson = new GsonBuilder().create();
@SerializedName("schema-version")
private String version;
-
+
@SerializedName("schema-content")
private JsonSchema data;
-
+
public String getVersion() {
return version;
}
@@ -57,11 +55,10 @@ public class SchemaServiceResponse {
if (json == null || json.isEmpty()) {
throw new SchemaProviderException("Empty schema-service response");
}
-
+
return gson.fromJson(json, SchemaServiceResponse.class);
} catch (Exception ex) {
throw new SchemaProviderException("Invalid response from schema service: " + ex.getMessage());
}
}
-
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java
index 0ad8bf45..bced602c 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
@@ -40,7 +40,7 @@ public class OxmSchemaProvider implements SchemaProvider {
OxmEdgeRulesLoader.loadModels();
OxmSchemaLoader.loadModels();
}
-
+
@Override
public String getLatestSchemaVersion() throws SchemaProviderException {
return OxmSchemaLoader.getLatestVersion();
@@ -72,41 +72,41 @@ public class OxmSchemaProvider implements SchemaProvider {
if (edgeRule == null) {
return null;
}
-
+
FromOxmEdgeSchema es = new FromOxmEdgeSchema();
es.fromEdgeRule(edgeRule);
-
+
return es;
}
@Override
public Set<EdgeSchema> getAdjacentEdgeSchema(String vertexType, String version) throws SchemaProviderException {
RelationshipSchema relSchema = OxmEdgeRulesLoader.getSchemaForVersion(version);
- Set<EdgeSchema> edges = new HashSet<EdgeSchema>();
+ Set<EdgeSchema> edges = new HashSet<>();
List<EdgeRule> rules = relSchema.lookupAdjacentEdges(vertexType);
-
+
for (EdgeRule rule : rules) {
FromOxmEdgeSchema es = new FromOxmEdgeSchema();
es.fromEdgeRule(rule);
edges.add(es);
}
-
+
return edges;
}
-
+
@Override
public Set<EdgeSchema> getEdgeSchemaForSourceTarget(String sourceType, String targetType, String version) throws SchemaProviderException {
RelationshipSchema relSchema = OxmEdgeRulesLoader.getSchemaForVersion(version);
- Set<EdgeSchema> edges = new HashSet<EdgeSchema>();
+ Set<EdgeSchema> edges = new HashSet<>();
Set<String> relTypes = relSchema.getValidRelationTypes(sourceType, targetType);
-
+
for (String type : relTypes) {
EdgeSchema edgeSchema = getEdgeSchema(type, sourceType, targetType, version);
if (edgeSchema != null) {
edges.add(edgeSchema);
}
}
-
+
return edges;
}