use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class AddElementsExample method addElements.
public void addElements() throws OperationException {
log("#### " + getMethodNameAsSentence(0) + "\n");
printGraph();
final AddElements operation = new AddElements.Builder().elements(new Entity.Builder().group("entity").vertex(6).property("count", 1).build(), new Edge.Builder().group("edge").source(5).dest(6).directed(true).property("count", 1).build()).build();
printJava("new AddElements.Builder()\n" + " .elements(new Entity.Builder()\n" + " .group(\"entity\")\n" + " .vertex(6)\n" + " .property(\"count\", 1)\n" + " .build(),\n" + " new Edge.Builder()\n" + " .group(\"edge\")\n" + " .source(5).dest(6).directed(true)\n" + " .property(\"count\", 1)\n" + " .build())\n" + " .build();");
printAsJson(operation);
printOperationClass(operation);
getGraph().execute(operation, new User("user01"));
log("Updated graph:");
log("```");
log(" --> 4 <--");
log(" / ^ \\");
log(" / | \\");
log("1 --> 2 --> 3");
log(" \\");
log(" --> 5 --> 6");
log("```");
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class OperationExample method runExampleNoResult.
protected void runExampleNoResult(final Operation<?, Void> operation) {
log("#### " + getMethodNameAsSentence(1) + "\n");
printJava(JavaSourceUtil.getRawJavaSnippet(getClass(), "example/example-graph", " " + getMethodName(1) + "() {", String.format("---%n"), "// ----"));
printAsJson(operation);
printOperationClass(operation);
try {
getGraph().execute(operation, new User("user01"));
} catch (OperationException e) {
throw new RuntimeException(e);
}
log(METHOD_DIVIDER);
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class LoadAndQuery6Test method shouldReturnExpectedStringsViaJson.
@Test
public void shouldReturnExpectedStringsViaJson() throws OperationException, SerialisationException {
// Given
final User user01 = new User("user01");
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final OperationChain<CloseableIterable<String>> queryOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), OperationChain.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, user01);
// Execute the query operation on the graph.
final CloseableIterable<String> results = graph.execute(queryOpChain, user01);
// Then
verifyResults(results);
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class LoadAndQuery7Test method shouldReturnExpectedStringsViaJson.
@Test
public void shouldReturnExpectedStringsViaJson() throws OperationException, SerialisationException {
// Given
final User user01 = new User("user01");
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final OperationChain<Iterable<Edge>> queryOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), OperationChain.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, user01);
// Execute the query operation on the graph.
final Iterable<Edge> results = graph.execute(queryOpChain, user01);
// Then
verifyResults(results);
}
use of uk.gov.gchq.gaffer.user.User in project Gaffer by gchq.
the class LoadAndQuery8Test method shouldReturnExpectedStringsViaJson.
@Test
public void shouldReturnExpectedStringsViaJson() throws OperationException, SerialisationException {
// Given
final User publicUser = new User.Builder().userId("public user").dataAuths("public").build();
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final GetAllEdges getAllEdges = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), GetAllEdges.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, publicUser);
// Execute the query operation on the graph.
final Iterable<Edge> results = graph.execute(getAllEdges, publicUser);
// Then
verifyResults(results);
}
Aggregations