public GraphLibrary getGraphLibrary() { return store.getGraphLibrary(); }
public static void validate(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId) { final Pair<Schema, StoreProperties> existingGraphPair; if (null == store.getGraphLibrary()) { existingGraphPair = null; } else { existingGraphPair = store.getGraphLibrary().get(graphId); } validate(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair); }
public void validateGraph(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId) { final Pair<Schema, StoreProperties> existingGraphPair; if (null == store.getGraphLibrary()) { existingGraphPair = null; } else { existingGraphPair = store.getGraphLibrary().get(graphId); } validateGraph(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair); }
protected StoreProperties resolveStorePropertiesForGraph(final Store store, final StoreProperties properties, final String parentStorePropertiesId, final Pair<Schema, StoreProperties> existingGraphPair) { StoreProperties resultProps; if (null != existingGraphPair) { // If there is an existing graph then ignore any user provided properties and just use the existing properties resultProps = existingGraphPair.getSecond(); } else { final GraphLibrary graphLibrary = store.getGraphLibrary(); resultProps = (null == graphLibrary) ? properties : graphLibrary.resolveStoreProperties(properties, parentStorePropertiesId); } return resultProps; }
protected Schema resolveSchemaForGraph(final Store store, final Schema schema, final List<String> parentSchemaIds, final Pair<Schema, StoreProperties> existingGraphPair) { Schema resultSchema; if (null != existingGraphPair) { // If there is an existing graph then ignore any user provided schemas and just use the existing schema resultSchema = existingGraphPair.getFirst(); } else { final GraphLibrary graphLibrary = store.getGraphLibrary(); resultSchema = (null == graphLibrary) ? schema : graphLibrary.resolveSchema(schema, parentSchemaIds); } return resultSchema; }
if (null == store.getGraphLibrary()) { if (store.getGraphLibrary().exists(graphId)) { if (null != parentSchemaIds) { result.addError(String.format(GRAPH_S_ALREADY_EXISTS_SO_YOU_CANNOT_USE_A_DIFFERENT_S_DO_NOT_SET_THE_S_FIELD, graphId, SCHEMA_STRING, PARENT_SCHEMA_IDS)); result.addError(String.format(GRAPH_S_ALREADY_EXISTS_SO_YOU_CANNOT_USE_A_DIFFERENT_S_DO_NOT_SET_THE_S_FIELD, graphId, STORE_PROPERTIES_STRING, PARENT_STORE_PROPERTIES_ID)); } else if (!store.getGraphLibrary().exists(graphId) && null == parentSchemaIds && null == parentStorePropertiesId) { result.addError(String.format(GRAPH_LIBRARY_CANNOT_BE_FOUND_WITH_GRAPHID_S, graphId));
final List<String> parentSchemaIds, final String parentStorePropertiesId, final Pair<Schema, StoreProperties> existingGraphPair, final ValidationResult result) { final GraphLibrary graphLibrary = store.getGraphLibrary();
public GraphSerialisable createGraphSerialisable(final Store store, final String graphId, final Schema schema, final StoreProperties storeProperties, final List<String> parentSchemaIds, final String parentStorePropertiesId, final GraphHook[] hooks) { final GraphLibrary graphLibrary = store.getGraphLibrary(); final Pair<Schema, StoreProperties> existingGraphPair = null != graphLibrary ? graphLibrary.get(graphId) : null; validateGraph(store, graphId, schema, storeProperties, parentSchemaIds, parentStorePropertiesId, existingGraphPair); final Schema resolvedSchema = resolveSchemaForGraph(store, schema, parentSchemaIds, existingGraphPair); final StoreProperties resolvedStoreProperties = resolveStorePropertiesForGraph(store, storeProperties, parentStorePropertiesId, existingGraphPair); return new GraphSerialisable.Builder() .config(new GraphConfig.Builder() .graphId(graphId) .library(graphLibrary) .addHooks(hooks) .build()) .schema(resolvedSchema) .properties(resolvedStoreProperties) .build(); }