/** * 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; }
/** * 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; }