use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class GraphConfigurationServiceTest method setup.
@Before
public void setup() {
final Store store = mock(Store.class);
final Schema schema = mock(Schema.class);
final Set<StoreTrait> traits = new HashSet<>(Arrays.asList(STORE_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, POST_AGGREGATION_FILTERING, TRANSFORMATION, STORE_VALIDATION));
given(store.getSchema()).willReturn(schema);
final Graph graph = new Graph.Builder().store(store).build();
final Set<Class<? extends Operation>> operations = new HashSet<>();
operations.add(AddElements.class);
given(graphFactory.getGraph()).willReturn(graph);
given(graph.getSupportedOperations()).willReturn(operations);
given(graph.isSupported(AddElements.class)).willReturn(true);
given(userFactory.createUser()).willReturn(new User());
given(graph.getStoreTraits()).willReturn(traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class ProxyStore method fetchTraits.
protected Set<StoreTrait> fetchTraits(final ProxyProperties proxyProps) throws StoreException {
final URL url = proxyProps.getGafferUrl("graph/storeTraits");
Set<StoreTrait> newTraits = doGet(url, new TypeReferenceStoreImpl.StoreTraits(), null);
if (null == newTraits) {
newTraits = new HashSet<>(0);
} else {
// This proxy store cannot handle visibility due to the simple rest api using a default user.
newTraits.remove(StoreTrait.VISIBILITY);
}
return newTraits;
}
use of uk.gov.gchq.gaffer.store.StoreTrait in project Gaffer by gchq.
the class GraphConfigurationServiceTest method setup.
@BeforeEach
public void setup() {
final Set<StoreTrait> traits = new HashSet<>(Arrays.asList(INGEST_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, POST_AGGREGATION_FILTERING, TRANSFORMATION, STORE_VALIDATION));
lenient().when(store.getSchema()).thenReturn(new Schema());
lenient().when(store.getProperties()).thenReturn(new StoreProperties());
final Graph graph = new Graph.Builder().config(new GraphConfig.Builder().graphId(GRAPH_ID).build()).store(store).build();
final Set<Class<? extends Operation>> operations = new HashSet<>();
operations.add(AddElements.class);
lenient().when(graphFactory.getGraph()).thenReturn(graph);
lenient().when(graph.getSupportedOperations()).thenReturn(operations);
lenient().when(graph.isSupported(AddElements.class)).thenReturn(true);
lenient().when(userFactory.createContext()).thenReturn(new Context());
lenient().when(graph.getStoreTraits()).thenReturn(traits);
}
use of uk.gov.gchq.gaffer.store.StoreTrait 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.StoreTrait in project Gaffer by gchq.
the class GetTraitsHandler method createCurrentTraits.
private Set<StoreTrait> createCurrentTraits(final Store store) {
final Set<StoreTrait> traits = Sets.newHashSet(store.getTraits());
final Schema schema = store.getSchema();
final boolean hasAggregatedGroups = isNotEmpty(schema.getAggregatedGroups());
final boolean hasVisibility = nonNull(schema.getVisibilityProperty());
boolean hasGroupBy = false;
boolean hasValidation = false;
for (final SchemaElementDefinition def : new ChainedIterable<SchemaElementDefinition>(schema.getEntities().values(), schema.getEdges().values())) {
hasValidation = hasValidation || def.hasValidation();
hasGroupBy = hasGroupBy || isNotEmpty(def.getGroupBy());
if (hasGroupBy && hasValidation) {
break;
}
}
if (!hasAggregatedGroups) {
traits.remove(StoreTrait.INGEST_AGGREGATION);
traits.remove(StoreTrait.QUERY_AGGREGATION);
}
if (!hasGroupBy && traits.contains(StoreTrait.INGEST_AGGREGATION)) {
traits.remove(StoreTrait.QUERY_AGGREGATION);
}
if (!hasValidation) {
traits.remove(StoreTrait.STORE_VALIDATION);
}
if (!hasVisibility) {
traits.remove(StoreTrait.VISIBILITY);
}
return traits;
}
Aggregations