Search in sources :

Example 1 with Builder

use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.

the class FederatedStoreGraphVisibilityTest method shouldNotShowHiddenGraphIdWithIDs.

@Test
public void shouldNotShowHiddenGraphIdWithIDs() throws Exception {
    final Schema aSchema = new Schema.Builder().entity("e1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build();
    library.add(TEST_GRAPH_ID, TEST_SCHEMA_ID, aSchema, TEST_STORE_PROPS_ID, PROPERTIES);
    fedGraph = new Builder().config(new GraphConfig.Builder().graphId(TEST_FED_GRAPH_ID).library(library).build()).addStoreProperties(fedProperties).build();
    fedGraph.execute(new AddGraph.Builder().graphId("g1").parentPropertiesId(// <- with ID
    TEST_STORE_PROPS_ID).parentSchemaIds(// <- with ID
    Arrays.asList(TEST_SCHEMA_ID)).build(), addingUser);
    fedGraph.execute(new AddGraph.Builder().graphId("g2").parentPropertiesId(// <- with ID
    TEST_STORE_PROPS_ID).parentSchemaIds(// <- with ID
    Arrays.asList(TEST_SCHEMA_ID)).graphAuths("auth1").build(), addingUser);
    commonAssertions();
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with Builder

use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.

the class SchemaHidingIT method shouldCreateStoreWithFullSchemaAndThenBeAbleUseASubsetOfTheSchema.

@SuppressWarnings("unchecked")
@Test
public void shouldCreateStoreWithFullSchemaAndThenBeAbleUseASubsetOfTheSchema() throws Exception {
    // Add some data to the full graph
    final Store fullStore = createStore(createFullSchema());
    final Graph fullGraph = new Builder().store(fullStore).build();
    final Edge edge1a = new Edge.Builder().source("source1a").dest("dest1a").directed(true).group(TestGroups.EDGE).property(TestPropertyNames.COUNT, 1).property(TestPropertyNames.PROP_1, "1a").property(TestPropertyNames.VISIBILITY, "public").property(TestPropertyNames.TIMESTAMP, 1L).build();
    final Edge edge1b = new Edge.Builder().source("source1b").dest("dest1b").directed(true).group(TestGroups.EDGE).property(TestPropertyNames.COUNT, 1).property(TestPropertyNames.PROP_1, "1b").property(TestPropertyNames.VISIBILITY, "public").property(TestPropertyNames.TIMESTAMP, 1L).build();
    final Edge edge2 = new Edge.Builder().source("source2").dest("dest2").directed(true).group(TestGroups.EDGE_2).property(TestPropertyNames.COUNT, 1).property(TestPropertyNames.PROP_1, "2").property(TestPropertyNames.VISIBILITY, "public").property(TestPropertyNames.TIMESTAMP, 1L).build();
    fullGraph.execute(new AddElements.Builder().input(edge1a, edge1b, edge2).build(), USER);
    // Create a graph with a hidden group backed by the same store
    final Store filteredStore = createStore(createFilteredSchema());
    final Graph filteredGraph = new Builder().store(filteredStore).build();
    final List<Edge> fullExpectedResults = Arrays.asList(edge1a, edge1b, edge2);
    final List<Edge> filteredExpectedResults = Arrays.asList(edge1a, edge1b);
    // Run operations and check the hidden group is hidden when the operation is run on the filtered graph
    testOperations(fullGraph, filteredGraph, fullExpectedResults, filteredExpectedResults);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) Store(uk.gov.gchq.gaffer.store.Store) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 3 with Builder

use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.

the class Queries method createGraph.

private Graph createGraph(final User user) throws IOException, OperationException {
    final Graph graph = new Builder().config(new GraphConfig.Builder().graphId("roadTraffic").build()).addSchemas(StreamUtil.openStreams(ElementGroup.class, "schema")).storeProperties(StreamUtil.openStream(getClass(), "accumulo/store.properties")).build();
    final OperationChain<Void> populateChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().input(IOUtils.readLines(StreamUtil.openStream(getClass(), "roadTrafficSampleData.csv"))).generator(new RoadTrafficStringElementGenerator()).build()).then(new AddElements.Builder().skipInvalidElements(false).build()).build();
    graph.execute(populateChain, user);
    return graph;
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) RoadTrafficStringElementGenerator(uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator)

Example 4 with Builder

use of uk.gov.gchq.gaffer.graph.Graph.Builder in project Gaffer by gchq.

the class FederatedStoreGraphVisibilityTest method shouldNotShowHiddenGraphIdWithoutIDs.

/*
     * Adhoc test to make sure that the naming of props and schemas without ID's
     * is still retrievable via the name of the graph that is was added to the LIBRARY.
     */
@Test
public void shouldNotShowHiddenGraphIdWithoutIDs() throws Exception {
    final Schema aSchema = // <- without ID
    new Schema.Builder().entity("e1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build();
    library.add(TEST_GRAPH_ID, aSchema, PROPERTIES);
    fedGraph = new Builder().config(new GraphConfig.Builder().graphId(TEST_FED_GRAPH_ID).library(library).build()).addStoreProperties(fedProperties).build();
    fedGraph.execute(new AddGraph.Builder().graphId("g1").parentPropertiesId(// <- without ID
    TEST_GRAPH_ID).parentSchemaIds(// <- without ID
    Arrays.asList(TEST_GRAPH_ID)).build(), addingUser);
    fedGraph.execute(new AddGraph.Builder().graphId("g2").parentPropertiesId(// <- without ID
    TEST_GRAPH_ID).parentSchemaIds(// <- without ID
    Arrays.asList(TEST_GRAPH_ID)).graphAuths("auth1").build(), addingUser);
    commonAssertions();
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

Builder (uk.gov.gchq.gaffer.graph.Graph.Builder)4 Test (org.junit.jupiter.api.Test)3 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)2 Graph (uk.gov.gchq.gaffer.graph.Graph)2 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 SchemaEntityDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition)2 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 Store (uk.gov.gchq.gaffer.store.Store)1 RoadTrafficStringElementGenerator (uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator)1