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
Elementtypes 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 classSchema.BaseBuilder<CHILD_CLASS extends Schema.BaseBuilder<?>>static classSchema.Builder
-
Field Summary
Fields Modifier and Type Field Description static StringERROR_MERGING_SCHEMA_DUE_TOstatic StringFORMAT_ERROR_WITH_THE_SCHEMA_TYPE_NAMED_S_DUE_TO_Sstatic StringFORMAT_EXCEPTIONstatic StringFORMAT_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 voidaddConfig(String key, String value)Schemaclone()static SchemafromJson(byte[]... jsonBytes)static SchemafromJson(InputStream... inputStreams)static SchemafromJson(Path... filePaths)List<String>getAggregatedGroups()Map<String,String>getConfig()StringgetConfig(String key)SchemaElementDefinitiongetElement(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.TypeDefinitiongetType(String typeName)Map<String,TypeDefinition>getTypes()SerialisergetVertexSerialiser()Returns the vertex serialiser for this schema.StringgetVisibilityProperty()booleanhasValidation()booleanisAggregationEnabled()Checks the schema has aggregators.byte[]toCompactJson()StringtoString()uk.gov.gchq.koryphe.ValidationResultvalidate()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:
trueif the schema contains aggregators, otherwisefalse
-
validate
public uk.gov.gchq.koryphe.ValidationResult validate() throws SchemaExceptionValidates 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
Serialiserthat will be used to serialise all vertices.
-
getElement
public SchemaElementDefinition getElement(String group)
Description copied from class:ElementDefinitionsLooks 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:
getElementin classElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>- Parameters:
group- an group- Returns:
- the
ElementDefinitionfor the given group
-
getVisibilityProperty
public String getVisibilityProperty()
-
toString
public String toString()
- Overrides:
toStringin classElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>
-
toCompactJson
public byte[] toCompactJson() throws SchemaException- Throws:
SchemaException
-
-