@JsonIgnore public Schema getDeserialisedSchema() { if (null == deserialisedSchema) { if (null == graph) { deserialisedSchema = null != schema ? Schema.fromJson(schema) : null; } else { deserialisedSchema = graph.getSchema(); } } return deserialisedSchema; }
@JsonIgnore public Builder graph(final Graph graph) { schema = graph.getSchema(); properties = graph.getStoreProperties().getProperties(); config = graph.getConfig(); return _self(); }
private void validateSameAsFromCache(final Graph newGraph, final String graphId) { final Graph fromCache = federatedStoreCache.getGraphSerialisableFromCache(graphId).getGraph(graphLibrary); if (!newGraph.getStoreProperties().getProperties().equals(fromCache.getStoreProperties().getProperties())) { throw new RuntimeException(String.format(ERROR_ADDING_GRAPH_TO_CACHE, GraphConfigEnum.PROPERTIES.toString(), graphId)); } else { if (!JsonUtil.equals(newGraph.getSchema().toJson(false), fromCache.getSchema().toJson(false))) { throw new RuntimeException(String.format(ERROR_ADDING_GRAPH_TO_CACHE, GraphConfigEnum.SCHEMA.toString(), graphId)); } else { if (!newGraph.getGraphId().equals(fromCache.getGraphId())) { throw new RuntimeException(String.format(ERROR_ADDING_GRAPH_TO_CACHE, "GraphId", graphId)); } } } }
public Schema getSchema(final Map<String, String> config, final User user) { if (null == user) { // no user then return an empty schema return new Schema(); } final List<String> graphIds = FederatedStoreUtil.getGraphIds(config); final Stream<Graph> graphs = getStream(user, graphIds); final Builder schemaBuilder = new Builder(); try { graphs.forEach(g -> schemaBuilder.merge(g.getSchema())); } catch (final SchemaException e) { final List<String> resultGraphIds = getStream(user, graphIds).map(Graph::getGraphId).collect(Collectors.toList()); throw new SchemaException(String.format(UNABLE_TO_MERGE_THE_SCHEMAS_FOR_ALL_OF_YOUR_FEDERATED_GRAPHS, resultGraphIds, KEY_OPERATION_OPTIONS_GRAPH_IDS), e); } return schemaBuilder.build(); }
@Override public Schema run() throws OperationException { /// [graph] create a graph using our schema and store properties // --------------------------------------------------------- final Graph graph = new Graph.Builder() .graphId("graph1") .addSchemas(StreamUtil.openStreams(getClass(), "SchemaExample/schema")) .storeProperties(StreamUtil.openStream(getClass(), "mockaccumulostore.properties")) .build(); // --------------------------------------------------------- final Schema schema = graph.getSchema(); try { log("SCHEMA", new String(schema.toJson(true), CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } return schema; }
public Schema run() throws OperationException { // [graph] create a graph using our schema and store properties // --------------------------------------------------------- final Graph graph = new Graph.Builder() .addSchemas(getSchemas()) .storeProperties(getStoreProperties()) .build(); // --------------------------------------------------------- final Schema schema = graph.getSchema(); try { log("SCHEMA", new String(schema.toJson(true), CommonConstants.UTF_8)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } return schema; } }
graphs.forEach(g -> schemaBuilder.merge(g.getSchema()));
final View view = ((OperationView) operation).getView(); if (null != view && view.hasGroups()) { final View validView = createValidView(view, graph.getSchema()); if (view != validView) { final Set<String> graphGroups = graph.getSchema().getGroups(); final Iterable<? extends Element> filteredInput = Iterables.filter( addElements.getInput(),
private void updateOperationChainView(final Operations<?> operations) { for (final Operation operation : operations.getOperations()) { if (operation instanceof Operations) { updateOperationChainView((Operations) operation); } else if (operation instanceof OperationView) { View opView = ((OperationView) operation).getView(); if (null == opView) { opView = config.getView(); } else if (!(opView instanceof NamedView) && !opView.hasGroups() && !opView.isAllEdges() && !opView.isAllEntities()) { opView = new View.Builder() .merge(config.getView()) .merge(opView) .build(); } else if (opView.isAllEdges() || opView.isAllEntities()) { View.Builder opViewBuilder = new View.Builder() .merge(opView); if (opView.isAllEdges()) { opViewBuilder.edges(getSchema().getEdgeGroups()); } if (opView.isAllEntities()) { opViewBuilder.entities(getSchema().getEntityGroups()); } opView = opViewBuilder.build(); } opView.expandGlobalDefinitions(); ((OperationView) operation).setView(opView); } } }