public GraphTripliser( Queryable input, GraphMapping graphMapping, GraphNodeTripliserFactory graphNodeTripliserFactory, TripliserManager tripliserManager, QueryService queryService, GraphTagger graphTagger) throws InvalidGraphMappingException, IgnoredGraphMappingException { this.input = input; this.graphMapping = graphMapping; this.graphNodeTripliserFactory = graphNodeTripliserFactory; this.tripliserManager = tripliserManager; this.graphTagger = graphTagger; List<Node> graphNodeList = new ArrayList<Node>(); graphNodeList.add(null); if (graphMapping.getQuery() != null) { try { graphNodeList = queryService.getNodes(input, graphMapping, null, tripliserManager.getGraphContext()); } catch (QueryException e) { throw new InvalidGraphMappingException("Invalid graph query", e); } if (graphNodeList.isEmpty()) { if (graphMapping.isRequired()) throw new InvalidGraphMappingException( "A required graph's query must return at least one result"); else throw new IgnoredGraphMappingException( "A non-required graph's query returned no results"); } } graphNodes = graphNodeList.iterator(); }
@Override public Iterator<TripleGraph> nextNestedIterator() { tripliserManager.next(Scope.GRAPH); Node graphNode = graphNodes.next(); try { graphTagger.tagGraph( input, tripliserManager.getTripleGraph(graphMapping, Scope.GRAPH), graphMapping, graphNode); } catch (ScopeException e) { tripliserManager .getReporter(graphMapping, Scope.GRAPH) .addMessage(new ReportEntry(e, Status.WARNING, Scope.GRAPH, graphMapping)); } return tripliserManager.processNestedIterator( graphNodeTripliserFactory.createGraphNodeTripliser( input, graphNode, graphMapping, tripliserManager), graphMapping, Scope.GRAPH); }