/*
 * Copyright 2012  Research Studios Austria Forschungsges.m.b.H.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package won.protocol.util.linkeddata.impl;

import com.hp.hpl.jena.query.Dataset;
import won.protocol.util.linkeddata.CrawlerCallback;

import java.net.URI;

/**
 * Crawler callback implementation that writes crawled data to a predefined sparql endpoint.
 */
public class SparqlUpdateCrawlerCallback implements CrawlerCallback
{
  @Override
  public void onDatasetCrawled(final URI uri, final Dataset dataset) {

  }
}

@@ -744,331 +744,1885 @@
 ort 
-won.protocol.util.linkeddata.CrawlerCallback;%0A%0Aimport java.net.URI;%0A%0A/**%0A * Crawler callback implementation that writes crawled data to a predefined sparql endpoint.%0A */%0Apublic class SparqlUpdateCrawlerCallback implements CrawlerCallback%0A%7B%0A  @Override%0A  public void onDatasetCrawled(final URI uri, final Dataset dataset) %7B%0A
+com.hp.hpl.jena.rdf.model.Model;%0Aimport com.hp.hpl.jena.sparql.modify.UpdateProcessRemote;%0Aimport com.hp.hpl.jena.update.UpdateExecutionFactory;%0Aimport com.hp.hpl.jena.update.UpdateFactory;%0Aimport com.hp.hpl.jena.update.UpdateRequest;%0Aimport org.apache.jena.riot.Lang;%0Aimport org.apache.jena.riot.RDFDataMgr;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport won.protocol.util.linkeddata.CrawlerCallback;%0A%0Aimport java.io.StringWriter;%0Aimport java.net.URI;%0Aimport java.util.Iterator;%0A%0A/**%0A * Crawler callback implementation that writes crawled data to a predefined sparql endpoint.%0A */%0Apublic class SparqlUpdateCrawlerCallback implements CrawlerCallback%0A%7B%0A  private final Logger logger = LoggerFactory.getLogger(getClass());%0A  String sparqlEndpoint = null;%0A%0A  public void setSparqlEndpoint(final String sparqlEndpoint) %7B%0A    this.sparqlEndpoint = sparqlEndpoint;%0A  %7D%0A%0A  @Override%0A  public void onDatasetCrawled(final URI uri, final Dataset dataset) %7B%0A%0A    if (null == sparqlEndpoint) %7B%0A      logger.warn(%22no SPARQL endpoint defined%22);%0A      return;%0A    %7D%0A%0A    Iterator%3CString%3E graphNames = dataset.listNames();%0A    while (graphNames.hasNext()) %7B%0A%0A      StringBuilder quadpatterns = new StringBuilder();%0A      String graphName = graphNames.next();%0A      Model model = dataset.getNamedModel(graphName);%0A      StringWriter sw = new StringWriter();%0A      RDFDataMgr.write(sw, model, Lang.NTRIPLES);%0A      quadpatterns.append(%22%5CnINSERT DATA %7B GRAPH %3C%22)%0A                  .append(graphName)%0A                  .append(%22%3E %7B %22)%0A                  .append(sw)%0A                  .append(%22%7D%7D;%5Cn%22);%0A%0A      logger.info(quadpatterns.toString());%0A      UpdateRequest update = UpdateFactory.create(quadpatterns.toString());%0A      UpdateProcessRemote riStore = (UpdateProcessRemote)%0A        UpdateExecutionFactory.createRemote(update, sparqlEndpoint);%0A      riStore.execute();%0A%0A    %7D
 %0A  %7D

add SPARQL UPDATE test code to crawler callback