public GraphConfig build() { if (null == config.getLibrary()) { config.setLibrary(new NoGraphLibrary()); } return config; }
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; }
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; }
public Graph build() { final GraphConfig config = configBuilder.build(); if (null == config.getLibrary()) { config.setLibrary(new NoGraphLibrary()); if (null != config.getLibrary() && config.getLibrary().exists(config.getGraphId())) { final Pair<Schema, StoreProperties> pair = config.getLibrary().get(config.getGraphId()); properties = (null == properties) ? pair.getSecond() : properties; schema = (null == schema) ? pair.getFirst() : schema; config.getLibrary().checkExisting(config.getGraphId(), schema, properties); config.getLibrary().add(config.getGraphId(), schema, store.getProperties());
library = new NoGraphLibrary(); } else { library = new FileGraphLibrary(getFileGraphLibraryPathString(args)); library.addOrUpdate(getGraphId(args), schema, storeProps);
public void exportToNewGraphBasedOnConfigFromGraphLibrary() { final FileGraphLibrary graphLibrary = new FileGraphLibrary("target/ExportToOtherGraphGraphLibrary"); graphLibrary.addProperties("exportStorePropertiesId", exportStoreProperties); .build()) .build(); graphLibrary.addSchema("exportSchemaId", exportSchema);
public void simpleExportUsingGraphFromGraphLibrary() { final FileGraphLibrary graphLibrary = new FileGraphLibrary("target/ExportToOtherGraphGraphLibrary"); .build(); graphLibrary.addOrUpdate("exportGraphId", exportSchema, exportStoreProperties);
Schema.Builder idFromLibrary = new Schema.Builder(); for (final String parentSchemaId : parentSchemaIds) { Schema tempSchema = graphLibrary.getSchema(parentSchemaId); if (null != tempSchema) { idFromLibrary.merge(tempSchema); if (!fromLibrary.equals(graphLibrary.getProperties(parentStorePropertiesId))) { 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)); if (null != parentSchemaIds) { for (final String exportParentSchemaId : parentSchemaIds) { if (null == graphLibrary.getSchema(exportParentSchemaId)) { result.addError(String.format(SCHEMA_COULD_NOT_BE_FOUND_IN_THE_GRAPH_LIBRARY_WITH_ID_S, parentSchemaIds)); if (null == graphLibrary.getProperties(parentStorePropertiesId)) { result.addError(String.format(STORE_PROPERTIES_COULD_NOT_BE_FOUND_IN_THE_GRAPH_LIBRARY_WITH_ID_S, parentStorePropertiesId));
graphLibrary.checkExisting(graphId, graph.getDeserialisedSchema(), graph.getDeserialisedProperties());
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); }
private void updateStoreProperties(final GraphConfig config) { StoreProperties mergedStoreProperties = null; if (null != parentStorePropertiesId) { mergedStoreProperties = config.getLibrary().getProperties(parentStorePropertiesId); } if (null != properties) { if (null == mergedStoreProperties) { mergedStoreProperties = properties; } else { mergedStoreProperties.merge(properties); } } properties = mergedStoreProperties; }
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));
for (final String parentSchemaId : parentSchemaIds) { if (null != parentSchemaId) { final Schema parentSchema = config.getLibrary().getSchema(parentSchemaId); if (null != parentSchema) { if (null == mergedParentSchema) {
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); }
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(); }