/** * 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 config containing optional graphIds csv. * @param user to match visibility against. * @return the set of {@link StoreTrait} that are common for all visible graphs */ public Set<StoreTrait> getTraits(final Map<String, String> config, final User user) { final List<String> graphIds = FederatedStoreUtil.getGraphIds(config); Collection<Graph> graphs = get(user, graphIds); final Set<StoreTrait> traits = graphs.isEmpty() ? Sets.newHashSet() : Sets.newHashSet(StoreTrait.values()); for (final Graph graph : graphs) { traits.retainAll(graph.getStoreTraits()); } return traits; }
public static Graph createGraph(final String graphId, final String cacheStorePropertiesPath, final Long timeToLive) { if (null == cacheStorePropertiesPath) { throw new IllegalArgumentException("Gaffer result cache Store properties are required"); } final Graph.Builder graphBuilder = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(graphId) .build()) .storeProperties(cacheStorePropertiesPath) .addSchema(createSchema(timeToLive)); final Graph graph = graphBuilder.build(); if (!graph.hasTrait(StoreTrait.STORE_VALIDATION)) { LOGGER.warn("Gaffer JSON export graph does not have {} trait so results may not be aged off.", StoreTrait.STORE_VALIDATION.name()); } return graph; }
/** * 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 */ public Set<StoreTrait> getTraits(final GetTraits op, final Context context) { final Set<StoreTrait> traits = Sets.newHashSet(StoreTrait.values()); if (null != op && op.isCurrentTraits()) { final List<String> graphIds = FederatedStoreUtil.getGraphIds(op.getOptions()); final Stream<Graph> graphs = getStream(context.getUser(), graphIds); final GetTraits getTraits = op.shallowClone(); graphs.forEach(g -> { try { traits.retainAll(g.execute(getTraits, context)); } catch (final OperationException e) { throw new RuntimeException("Unable to fetch traits from graph " + g.getGraphId(), e); } }); } return traits; }