diff --git a/sparql-anything-html/src/main/java/com/github/sparqlanything/html/MetadataWriter.java b/sparql-anything-html/src/main/java/com/github/sparqlanything/html/MetadataWriter.java index 667bbeab..45734335 100644 --- a/sparql-anything-html/src/main/java/com/github/sparqlanything/html/MetadataWriter.java +++ b/sparql-anything-html/src/main/java/com/github/sparqlanything/html/MetadataWriter.java @@ -20,6 +20,7 @@ */ package com.github.sparqlanything.html; +import org.apache.any23.extractor.ExtractionContext; import org.apache.any23.writer.TripleHandlerException; import org.apache.any23.writer.TripleWriterHandler; import org.apache.jena.graph.BlankNodeId; @@ -31,10 +32,13 @@ import org.eclipse.rdf4j.model.Value; import com.github.sparqlanything.model.FacadeXGraphBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MetadataWriter extends TripleWriterHandler { - + private static final Logger log = LoggerFactory.getLogger(MetadataWriter.class); private FacadeXGraphBuilder facadeXGraphBuilder; + private String runningExtractor = null; public MetadataWriter(FacadeXGraphBuilder facadeXGraphBuilder) { this.facadeXGraphBuilder = facadeXGraphBuilder; @@ -45,8 +49,22 @@ public void close() throws TripleHandlerException { } + @Override + public void openContext(ExtractionContext context) throws TripleHandlerException { + super.openContext(context); + runningExtractor = context.getExtractorName(); + log.debug("Run extractor: {}", runningExtractor); + } + + @Override + public void closeContext(ExtractionContext context) throws TripleHandlerException { + super.closeContext(context); + runningExtractor = null; + } + @Override public void writeTriple(Resource s, IRI p, Value o, Resource g) throws TripleHandlerException { + log.debug("Graph: {} ({})", g, runningExtractor, g); facadeXGraphBuilder.add(resolveValue(g), resolveValue(s), NodeFactory.createURI(p.stringValue()), resolveValue(o)); }