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.
Schema.Builder
,
ElementDefinitions
Modifier and Type | Class and Description |
---|---|
static class |
Schema.BaseBuilder<CHILD_CLASS extends Schema.BaseBuilder<?>> |
static class |
Schema.Builder |
Constructor and Description |
---|
Schema() |
Modifier and Type | Method and 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.
|
String |
getId()
Deprecated.
the ID should be supplied to the graph library separately
|
String |
getTimestampProperty()
Deprecated.
use a store property specific to your chosen store instead.
|
TypeDefinition |
getType(String typeName) |
Map<String,TypeDefinition> |
getTypes() |
Serialiser |
getVertexSerialiser()
Returns the vertex serialiser for this schema.
|
String |
getVertexSerialiserClass()
Deprecated.
|
String |
getVisibilityProperty() |
boolean |
hasValidation() |
boolean |
isAggregationEnabled()
Checks the schema has aggregators.
|
void |
setId(String id)
Deprecated.
the ID should be supplied to the graph library separately
|
byte[] |
toCompactJson() |
String |
toString() |
uk.gov.gchq.koryphe.ValidationResult |
validate()
Validates the schema to ensure all element definitions are valid.
|
equals, getEdge, getEdgeGroups, getEdges, getEntities, getEntity, getEntityGroups, getGroups, hasEdges, hasEntities, hasGroups, hashCode, isEdge, isEntity, toJson
public static Schema fromJson(InputStream... inputStreams) throws SchemaException
SchemaException
public static Schema fromJson(Path... filePaths) throws SchemaException
SchemaException
public static Schema fromJson(byte[]... jsonBytes) throws SchemaException
SchemaException
@Deprecated public String getId()
@Deprecated public void setId(String id)
id
- the schema idpublic boolean isAggregationEnabled()
true
if the schema contains aggregators, otherwise false
public uk.gov.gchq.koryphe.ValidationResult validate() throws SchemaException
SchemaException
- if validation fails then a SchemaException is thrown.public boolean hasValidation()
public Map<String,TypeDefinition> getTypes()
public TypeDefinition getType(String typeName)
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.
Serialiser
that will be used to serialise all vertices.@Deprecated public String getVertexSerialiserClass()
public SchemaElementDefinition getElement(String group)
ElementDefinitions
getElement
in class ElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>
group
- an groupElementDefinition
for the given grouppublic String getVisibilityProperty()
@Deprecated public String getTimestampProperty()
public String toString()
toString
in class ElementDefinitions<SchemaEntityDefinition,SchemaEdgeDefinition>
public byte[] toCompactJson() throws SchemaException
SchemaException
Copyright © 2022. All rights reserved.