Class Schema
- java.lang.Object
-
- uk.gov.gchq.gaffer.data.elementdefinition.ElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>
-
- uk.gov.gchq.gaffer.store.schema.Schema
-
- All Implemented Interfaces:
Cloneable
public class Schema extends ElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition> implements Cloneable
Contains the full list of
Element
types to be stored in the graph.Each type of element should have the identifier type(s) listed and a map of property names and their corresponding types. Each type can either be a full java class name or a custom type. Using custom types then allows you to specify validation and aggregation for the element components.
This class must be JSON serialisable. A schema should normally be written in JSON and then it will be automatically deserialised at runtime. An example of a JSON schemas can be found in the Example module.
- See Also:
Schema.Builder
,ElementDefinitions
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Schema.BaseBuilder<CHILD_CLASS extends Schema.BaseBuilder<?>>
static class
Schema.Builder
-
Field Summary
Fields Modifier and Type Field Description static String
ERROR_MERGING_SCHEMA_DUE_TO
static String
FORMAT_ERROR_WITH_THE_SCHEMA_TYPE_NAMED_S_DUE_TO_S
static String
FORMAT_EXCEPTION
static String
FORMAT_UNABLE_TO_MERGE_SCHEMAS_CONFLICT_WITH_S
-
Constructor Summary
Constructors Constructor Description Schema()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConfig(String key, String value)
Schema
clone()
static Schema
fromJson(byte[]... jsonBytes)
static Schema
fromJson(InputStream... inputStreams)
static Schema
fromJson(Path... filePaths)
List<String>
getAggregatedGroups()
Map<String,String>
getConfig()
String
getConfig(String key)
SchemaElementDefinition
getElement(String group)
Looks the group up in the entity definitions then if it doesn't find a definition it will look it up in the edge definitions.TypeDefinition
getType(String typeName)
Map<String,TypeDefinition>
getTypes()
Serialiser
getVertexSerialiser()
Returns the vertex serialiser for this schema.String
getVisibilityProperty()
boolean
hasValidation()
boolean
isAggregationEnabled()
Checks the schema has aggregators.byte[]
toCompactJson()
String
toString()
uk.gov.gchq.koryphe.ValidationResult
validate()
Validates the schema to ensure all element definitions are valid.-
Methods inherited from class uk.gov.gchq.gaffer.data.elementdefinition.ElementDefinitions
equals, getEdge, getEdgeGroups, getEdges, getEntities, getEntity, getEntityGroups, getGroups, hasEdges, hasEntities, hasGroups, hashCode, isEdge, isEntity, toJson
-
-
-
-
Field Detail
-
FORMAT_EXCEPTION
public static final String FORMAT_EXCEPTION
- See Also:
- Constant Field Values
-
FORMAT_UNABLE_TO_MERGE_SCHEMAS_CONFLICT_WITH_S
public static final String FORMAT_UNABLE_TO_MERGE_SCHEMAS_CONFLICT_WITH_S
- See Also:
- Constant Field Values
-
FORMAT_ERROR_WITH_THE_SCHEMA_TYPE_NAMED_S_DUE_TO_S
public static final String FORMAT_ERROR_WITH_THE_SCHEMA_TYPE_NAMED_S_DUE_TO_S
- See Also:
- Constant Field Values
-
ERROR_MERGING_SCHEMA_DUE_TO
public static final String ERROR_MERGING_SCHEMA_DUE_TO
- See Also:
- Constant Field Values
-
-
Method Detail
-
fromJson
public static Schema fromJson(InputStream... inputStreams) throws SchemaException
- Throws:
SchemaException
-
fromJson
public static Schema fromJson(Path... filePaths) throws SchemaException
- Throws:
SchemaException
-
fromJson
public static Schema fromJson(byte[]... jsonBytes) throws SchemaException
- Throws:
SchemaException
-
clone
public Schema clone()
-
isAggregationEnabled
public boolean isAggregationEnabled()
Checks the schema has aggregators.- Returns:
true
if the schema contains aggregators, otherwisefalse
-
validate
public uk.gov.gchq.koryphe.ValidationResult validate() throws SchemaException
Validates the schema to ensure all element definitions are valid. Throws a SchemaException if it is not valid.- Returns:
- ValidationResult the validation result
- Throws:
SchemaException
- if validation fails then a SchemaException is thrown.
-
hasValidation
public boolean hasValidation()
-
getTypes
public Map<String,TypeDefinition> getTypes()
-
getType
public TypeDefinition getType(String typeName)
-
getVertexSerialiser
public Serialiser getVertexSerialiser()
Returns the vertex serialiser for this schema.
There can be only one vertex serialiser for all elements because in order for searches to work correctly, the byte representation of the search term's (seeds) must match the byte representation stored, i.e you need to know how your results have been serialised which effectively means all vertices must be serialised the same way within a table.
- Returns:
- An implementation of
Serialiser
that will be used to serialise all vertices.
-
getElement
public SchemaElementDefinition getElement(String group)
Description copied from class:ElementDefinitions
Looks the group up in the entity definitions then if it doesn't find a definition it will look it up in the edge definitions. If you know the type of the element (Entity or Edge) then use getEntity or getEdge.- Overrides:
getElement
in classElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>
- Parameters:
group
- an group- Returns:
- the
ElementDefinition
for the given group
-
getVisibilityProperty
public String getVisibilityProperty()
-
toString
public String toString()
- Overrides:
toString
in classElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>
-
toCompactJson
public byte[] toCompactJson() throws SchemaException
- Throws:
SchemaException
-
-