use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.
the class FederatedGraphStorage method getTraits.
/**
* returns a set of {@link StoreTrait} that are common for all visible graphs.
* traits1 = [a,b,c]
* traits2 = [b,c]
* traits3 = [a,b]
* return [b]
*
* @param op the GetTraits operation
* @param context the user context
* @return the set of {@link StoreTrait} that are common for all visible graphs
* @deprecated use {@link uk.gov.gchq.gaffer.store.Store#execute(uk.gov.gchq.gaffer.operation.Operation, Context)} with GetTraits Operation.
*/
@Deprecated
public Set<StoreTrait> getTraits(final GetTraits op, final Context context) {
boolean firstPass = true;
final Set<StoreTrait> traits = new HashSet<>();
if (null != op) {
final List<String> graphIds = FederatedStoreUtil.getGraphIds(op.getOptions());
final Collection<Graph> graphs = get(context.getUser(), graphIds);
final GetTraits getTraits = op.shallowClone();
for (final Graph graph : graphs) {
try {
Set<StoreTrait> execute = graph.execute(getTraits, context);
if (firstPass) {
traits.addAll(execute);
firstPass = false;
} else {
traits.retainAll(execute);
}
} catch (final OperationException e) {
throw new RuntimeException("Unable to fetch traits from graph " + graph.getGraphId(), e);
}
}
}
return traits;
}
use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.
the class FederatedStoreTest method shouldCombineTraitsToMin.
@Test
public void shouldCombineTraitsToMin() throws Exception {
// Given
final GetTraits getTraits = new GetTraits.Builder().currentTraits(true).build();
// When
final Set<StoreTrait> before = store.getTraits(getTraits, userContext);
store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(ACC_ID_1).storeProperties(PROPERTIES_1).build(), new Context(testUser()));
final Set<StoreTrait> afterAcc = store.getTraits(getTraits, userContext);
StoreProperties TestStoreImp = new StoreProperties();
TestStoreImp.setStoreClass(FederatedGetTraitsHandlerTest.TestStoreImpl.class);
store.execute(new AddGraph.Builder().schema(new Schema()).isPublic(true).graphId(MAP_ID_1).storeProperties(TestStoreImp).build(), new Context(testUser()));
final Set<StoreTrait> afterMap = store.getTraits(getTraits, userContext);
// Then
assertNotEquals(SingleUseAccumuloStore.TRAITS, new HashSet<>(Arrays.asList(StoreTrait.INGEST_AGGREGATION, StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.POST_AGGREGATION_FILTERING, StoreTrait.TRANSFORMATION, StoreTrait.POST_TRANSFORMATION_FILTERING, StoreTrait.MATCHED_VERTEX)));
assertEquals(Collections.emptySet(), before, "No traits should be found for an empty FederatedStore");
assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, ORDERED, MATCHED_VERTEX), afterAcc);
assertEquals(Sets.newHashSet(TRANSFORMATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, MATCHED_VERTEX), afterMap);
}
use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.
the class FederatedGraphStorageTraitsTest method setUp.
@BeforeEach
public void setUp() throws Exception {
graphStorage = new FederatedGraphStorage();
acc = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_ACCUMULO)).properties(ACCUMULO_PROPERTIES).schema(new Schema.Builder().entity("entities", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build()).build();
map = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_MAP)).properties(MAP_PROPERTIES).schema(new Schema.Builder().edge("edges", new SchemaEdgeDefinition.Builder().source("string").destination("string").build()).type("string", String.class).build()).build();
nullUser = nullUser();
testUser = testUser();
authUser = authUser();
blankUser = blankUser();
testUserContext = new Context(testUser);
authUserContext = new Context(authUser);
blankUserContext = new Context(blankUser);
blockingAccessPredicate = new NoAccessPredicate();
permissiveAccessPredicate = new UnrestrictedAccessPredicate();
getTraits = new GetTraits();
}
use of uk.gov.gchq.gaffer.store.operation.GetTraits in project Gaffer by gchq.
the class FederatedStoreGetTraitsTest method setUp.
@Before
public void setUp() throws Exception {
federatedStore = new FederatedStore();
federatedStore.initialise("testFed", new Schema(), new FederatedStoreProperties());
acc = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_ACCUMULO)).properties(ACCUMULO_PROPERTIES).schema(new Schema.Builder().entity("entities", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build()).build();
map = new GraphSerialisable.Builder().config(new GraphConfig(GRAPH_ID_MAP)).properties(MAP_PROPERTIES).schema(new Schema.Builder().edge("edges", new SchemaEdgeDefinition.Builder().source("string").destination("string").build()).type("string", String.class).build()).build();
nullUser = nullUser();
testUser = testUser();
authUser = authUser();
blankUser = blankUser();
testUserContext = new Context(testUser);
authUserContext = new Context(authUser);
blankUserContext = new Context(blankUser);
blockingAccessPredicate = new NoAccessPredicate();
permissiveAccessPredicate = new UnrestrictedAccessPredicate();
getTraits = new GetTraits();
}
Aggregations