use of uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition in project Gaffer by gchq.
the class ExamplesService method getEdge.
protected Edge getEdge(final int uniqueId1, final int uniqueId2) {
final String group = getAnEdgeGroup();
final SchemaElementDefinition edgeDef = getSchema().getEdge(group);
final Edge edge = new Edge(group);
edge.setSource(getExampleVertex(edgeDef.getIdentifierClass(IdentifierType.SOURCE), uniqueId1));
edge.setDestination(getExampleVertex(edgeDef.getIdentifierClass(IdentifierType.DESTINATION), uniqueId2));
edge.setDirected(isAnEdgeDirected());
populateProperties(edge, edgeDef, uniqueId1);
return edge;
}
use of uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition in project Gaffer by gchq.
the class ExamplesService method getEntity.
protected Entity getEntity(final int uniqueId) {
final String group = getAnEntityGroup();
final SchemaElementDefinition entityDef = getSchema().getEntity(group);
final Entity entity = new Entity(group);
entity.setVertex(getExampleVertex(entityDef.getIdentifierClass(IdentifierType.VERTEX), uniqueId));
populateProperties(entity, entityDef, uniqueId);
return entity;
}
use of uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition in project Gaffer by gchq.
the class ExamplesService method getAnEdgePropertyName.
protected String getAnEdgePropertyName() {
final SchemaElementDefinition edgeDef = getSchema().getEdge(getAnEdgeGroup());
final String propertyName;
if (null != edgeDef && !edgeDef.getProperties().isEmpty()) {
propertyName = edgeDef.getProperties().iterator().next();
} else {
propertyName = "examplePropertyName";
}
return propertyName;
}
use of uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition in project Gaffer by gchq.
the class ExamplesService method getAnEntityPropertyName.
protected String getAnEntityPropertyName() {
final SchemaElementDefinition entityDef = getSchema().getEntity(getAnEntityGroup());
String propertyName = null;
if (null != entityDef && !entityDef.getProperties().isEmpty()) {
propertyName = entityDef.getProperties().iterator().next();
}
return propertyName;
}
use of uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition in project Gaffer by gchq.
the class Store method validateSchemas.
public void validateSchemas() {
boolean valid = schema.validate();
final HashMap<String, SchemaElementDefinition> schemaElements = new HashMap<>();
schemaElements.putAll(getSchema().getEdges());
schemaElements.putAll(getSchema().getEntities());
for (final Entry<String, SchemaElementDefinition> schemaElementDefinitionEntry : schemaElements.entrySet()) {
for (final String propertyName : schemaElementDefinitionEntry.getValue().getProperties()) {
Class propertyClass = schemaElementDefinitionEntry.getValue().getPropertyClass(propertyName);
Serialisation serialisation = schemaElementDefinitionEntry.getValue().getPropertyTypeDef(propertyName).getSerialiser();
if (null == serialisation) {
valid = false;
LOGGER.error("Could not find a serialiser for property '" + propertyName + "' in the group '" + schemaElementDefinitionEntry.getKey() + "'.");
} else if (!serialisation.canHandle(propertyClass)) {
valid = false;
LOGGER.error("Schema serialiser (" + serialisation.getClass().getName() + ") for property '" + propertyName + "' in the group '" + schemaElementDefinitionEntry.getKey() + "' cannot handle property found in the schema");
}
}
}
if (!valid) {
throw new SchemaException("Schema is not valid. Check the logs for more information.");
}
}
Aggregations