Package de.fuberlin.wiwiss.d2rq

Examples of de.fuberlin.wiwiss.d2rq.SystemLoader


  public void contextInitialized(ServletContextEvent event) {
    ServletContext context = event.getServletContext();

    // Is there already a loader in the servlet context, put there
    // by the JettyLauncher?
    SystemLoader loader = D2RServer.retrieveSystemLoader(context);
    if (loader == null) {
      log.info("Fresh ServletContext; initializing a new SystemLoader");
      // We are running as pure webapp, without JettyLauncher,
      // so initalize the loader from the configFile context parameter.
      loader = new SystemLoader();
      D2RServer.storeSystemLoader(loader, context);
      if (context.getInitParameter("configFile") == null) {
        throw new RuntimeException("No configFile configured in web.xml");
      }
      String configFileName = absolutize(context.getInitParameter("configFile"), context);
      loader.setMappingURL(configFileName);
      loader.setResourceStem("resource/");
    }
    D2RServer server = loader.getD2RServer();
    server.start();
    VelocityWrapper.initEngine(server, context);
  }
View Full Code Here


  public static void main(String[] args) {
    // First, let's set up an in-memory HSQLDB database,
    // load a simple SQL database into it, and generate
    // a default D2RQ mapping for this database using the
    // W3C Direct Mapping
    SystemLoader loader = new SystemLoader();
    loader.setJdbcURL("jdbc:hsqldb:mem:test");
    loader.setStartupSQLScript("doc/example/simple.sql");
    loader.setGenerateW3CDirectMapping(true);
    Mapping mapping = loader.getMapping();

    // Print some internal stuff that shows how D2RQ maps the
    // database to RDF triples
    for (TripleRelation internal: mapping.compiledPropertyBridges()) {
      System.out.println(internal);
    }

    // Write the contents of the virtual RDF model as N-Triples
    Model model = loader.getModelD2RQ();
    model.write(System.out, "N-TRIPLES");

    // Important -- close the model!
    model.close();
   
    // Now let's load an example mapping file that connects to
    // a MySQL database
    loader = new SystemLoader();
    loader.setMappingFileOrJdbcURL("doc/example/mapping-iswc.ttl");
    loader.setFastMode(true);
    loader.setSystemBaseURI("http://example.com/");

    // Get the virtual model and run a SPARQL query
    model = loader.getModelD2RQ();
    ResultSet rs = QueryExecutionFactory.create(
        "SELECT * {?s ?p ?o} LIMIT 10", model).execSelect();
    while (rs.hasNext()) {
      System.out.println(rs.next());
    }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.SystemLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.