Package de.fuberlin.wiwiss.d2rq.map

Examples of de.fuberlin.wiwiss.d2rq.map.Mapping


    Model model = generateDefaultMappingModel();
    assertFalse(model.isEmpty());
  }
 
  public void testGenerateSomeClassMapsInDefaultMapping() {
    Mapping mapping = generateDefaultMapping();
    assertEquals(1, mapping.classMapResources().size());
  }
View Full Code Here


    GraphD2RQ g = generateDefaultGraphD2RQ();
    assertTrue(g.contains(Node.ANY, Node.ANY, Node.createLiteral("Hello World!")));
  }
 
  public void testGenerateEmptyGraphFromSimpleD2RQMapping() {
    Mapping m = MappingHelper.readFromTestFile("helpers/simple.ttl");
    m.configuration().setServeVocabulary(false);
    GraphD2RQ g = new GraphD2RQ(m);
    assertTrue(g.isEmpty());
  }
View Full Code Here

    GraphD2RQ g = new GraphD2RQ(m);
    assertTrue(g.isEmpty());
  }
 
  public void testGenerateTripleFromSimpleD2RQMapping() {
    Mapping m = MappingHelper.readFromTestFile("helpers/simple.ttl");
    m.configuration().setServeVocabulary(false);
    db.executeSQL("INSERT INTO TEST VALUES (1, 'Hello World!')");
    GraphD2RQ g = new GraphD2RQ(m);
    assertTrue(g.contains(
        Node.createURI(EX + "test/1"), RDF.Nodes.type, Node.createURI(EX + "Test")));
    assertEquals(1, g.size());
View Full Code Here

    }
  }
 
  protected void createMapping(String datatype) {
    this.datatype = datatype;
    Mapping mapping = generateMapping();
    mapping.configuration().setServeVocabulary(false);
    mapping.configuration().setUseAllOptimizations(true);
    mapping.connect();
    graph = getGraph(mapping);
    inspector = mapping.databases().iterator().next().connectedDB().schemaInspector();
  }
View Full Code Here

  private GraphD2RQ getGraph(Mapping mapping) {
    return new GraphD2RQ(mapping);
  }
 
  private Mapping generateMapping() {
    Mapping mapping = new Mapping();
    Database database = new Database(dbURI);
    database.setJDBCDSN(jdbcURL);
    database.setJDBCDriver(driver);
    database.setUsername(user);
    database.setPassword(password);
    database.setStartupSQLScript(ResourceFactory.createResource("file:" + script));
    mapping.addDatabase(database);
    ClassMap classMap = new ClassMap(classMapURI);
    classMap.setDatabase(database);
    classMap.setURIPattern("row/@@T_" + datatype + ".ID@@");
    mapping.addClassMap(classMap);
    PropertyBridge propertyBridge = new PropertyBridge(propertyBridgeURI);
    propertyBridge.setBelongsToClassMap(classMap);
    propertyBridge.addProperty(valueProperty);
    propertyBridge.setColumn("T_" + datatype + ".VALUE");
    classMap.addPropertyBridge(propertyBridge);
View Full Code Here

    response.getOutputStream().println(
        "303 See Other: For a description of this item, see " + location);
  }

  private boolean handleDownload(String resourceURI, HttpServletResponse response, D2RServer server) throws IOException {
    Mapping m = D2RServer.retrieveSystemLoader(getServletContext()).getMapping();
    for (Resource r: m.downloadMapResources()) {
      DownloadMap d = m.downloadMap(r);
      DownloadContentQuery q = new DownloadContentQuery(d, resourceURI);
      if (q.hasContent()) {
        response.setContentType(q.getMediaType() != null ? q.getMediaType() : "application/octet-stream");
        InputStream is = q.getContentStream();
        OutputStream os = response.getOutputStream();
View Full Code Here

    if (cmd.hasArg(baseArg)) {
      loader.setSystemBaseURI(cmd.getArg(baseArg).getValue());
    }

    loader.setResultSizeLimit(Database.NO_LIMIT);
    Mapping mapping = loader.getMapping();
    try {
      // Trigger compilation
      mapping.compiledPropertyBridges();
      // Override the d2rq:resultSizeLimit given in the mapping
      for (Database db: mapping.databases()) {
        db.connectedDB().setDefaultFetchSize(DUMP_DEFAULT_FETCH_SIZE);
     

      Model d2rqModel = loader.getModelD2RQ();

      try {
        RDFWriter writer = d2rqModel.getWriter(format.toUpperCase());
        if (format.equals("RDF/XML") || format.equals("RDF/XML-ABBREV")) {
          writer.setProperty("showXmlDeclaration", "true");
          if (loader.getResourceBaseURI() != null) {
            writer.setProperty("xmlbase", loader.getResourceBaseURI());
          }
        }
        writer.write(d2rqModel, new OutputStreamWriter(out, "utf-8"), loader.getResourceBaseURI());
      } catch (NoWriterForLangException ex) {
        throw new D2RQException("Unknown format '" + format + "'", D2RQException.STARTUP_UNKNOWN_FORMAT);
      } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException("Can't happen -- utf-8 is always supported");
      }
    } finally {
      out.close();
      mapping.close();
    }
  }
View Full Code Here

    // Load mapping file
    Model mapModel = FileManager.get().loadModel("doc/example/mapping-iswc.ttl");
   
    // Parse mapping file
    MapParser parser = new MapParser(mapModel, "http://localhost:2020/");
    Mapping mapping = parser.parse();
   
    // Set up the GraphD2RQ
    GraphD2RQ g = new GraphD2RQ(mapping);

    // Create a find(spo) pattern
View Full Code Here

  public static Collection<TripleRelation> loadPropertyBridges(String mappingFileName) {
    Model m = ModelFactory.createDefaultModel();
    Resource dummyDB = m.getResource(Test.DummyDatabase.getURI());
    dummyDB.addProperty(RDF.type, D2RQ.Database);
    m.read(D2RQTestSuite.class.getResourceAsStream(mappingFileName), null, "TURTLE");
    Mapping mapping = new MapParser(m, null).parse();
    return mapping.compiledPropertyBridges();
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.map.Mapping

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.