private Set<IRI> expand(GraphNode node, Set<IRI> alreadyVisited, int recursion) { Set<IRI> rdfSeeAlsoTargets = getSeeAlsoObjectUris(node); Set<IRI> result = new HashSet<IRI>(); result.addAll(rdfSeeAlsoTargets); recursion++; if (recursion > 0) { rdfSeeAlsoTargets.removeAll(alreadyVisited); alreadyVisited.addAll(rdfSeeAlsoTargets); for (IRI target : rdfSeeAlsoTargets) { try { result.addAll(expand(new GraphNode(node.getNode(), tcManager.getGraph(target)), alreadyVisited, recursion)); } catch (NoSuchEntityException e) { //ignore } } } return result; }
/** * expands a node dereferencing its rdfs:seeAlso references using the * tcManager associated to this instance. If the added TripleCollections * also associate rdfs:seeAlso properties to node this are expanded till * the maximum recursion depth specified. * * @param node the node to be expanded * @param recursion the maximum recursion depth * @return a new GraphNode over the union of the original and all expansion graphs */ public GraphNode expand(GraphNode node, int recursion) { Set<IRI> alreadyVisited = new HashSet(); Set<Graph> resultTripleCollections = new HashSet<Graph>(); resultTripleCollections.add(node.getGraph()); for (IRI uriRef : expand(node, alreadyVisited, recursion)) { try { resultTripleCollections.add(tcManager.getGraph(uriRef)); } catch (NoSuchEntityException e) { //ignore } } return new GraphNode(node.getNode(), new UnionGraph(resultTripleCollections.toArray( new Graph[resultTripleCollections.size()]))); }
/** * expands a node dereferencing its rdfs:seeAlso references using the * tcManager associated to this instance. If the added TripleCollections * also associate rdfs:seeAlso properties to node this are expanded till * the maximum recursion depth specified. * * @param node the node to be expanded * @param recursion the maximum recursion depth * @return a new GraphNode over the union of the original and all expansion graphs */ public GraphNode expand(GraphNode node, int recursion) { Set<IRI> alreadyVisited = new HashSet(); Set<Graph> resultTripleCollections = new HashSet<Graph>(); resultTripleCollections.add(node.getGraph()); for (IRI uriRef : expand(node, alreadyVisited, recursion)) { try { resultTripleCollections.add(tcManager.getGraph(uriRef)); } catch (NoSuchEntityException e) { //ignore } } return new GraphNode(node.getNode(), new UnionGraph(resultTripleCollections.toArray( new Graph[resultTripleCollections.size()]))); }
private Set<IRI> expand(GraphNode node, Set<IRI> alreadyVisited, int recursion) { Set<IRI> rdfSeeAlsoTargets = getSeeAlsoObjectUris(node); Set<IRI> result = new HashSet<IRI>(); result.addAll(rdfSeeAlsoTargets); recursion++; if (recursion > 0) { rdfSeeAlsoTargets.removeAll(alreadyVisited); alreadyVisited.addAll(rdfSeeAlsoTargets); for (IRI target : rdfSeeAlsoTargets) { try { result.addAll(expand(new GraphNode(node.getNode(), tcManager.getGraph(target)), alreadyVisited, recursion)); } catch (NoSuchEntityException e) { //ignore } } } return result; }