Пример #1
0
  @Test
  public void test() throws Exception {
    InputStream fis = getClass().getResourceAsStream("../mappingFiles/test15.ttl");

    R2RMLMappingManager mm = new OWLAPIR2RMLMappingManagerFactory().getR2RMLMappingManager();
    Set<RDFTriple> triples = OWLAPIUtil.readTurtle(fis);
    Collection<TriplesMap> coll = mm.importMappings(triples);

    Assert.assertTrue(coll.size() == 1);

    Iterator<TriplesMap> it = coll.iterator();
    while (it.hasNext()) {
      TriplesMap current = it.next();

      LogicalTable t = current.getLogicalTable();

      if (t instanceof R2RMLViewImpl) {
        R2RMLViewImpl vi = (R2RMLViewImpl) t;

        int cont = 0;
        Iterator<RDFResource> iter = vi.getSQLVersions(RDFResource.class).iterator();
        while (iter.hasNext()) {
          RDFResource s = iter.next();
          Assert.assertTrue(s.toString().contains("SQL2008"));
          cont++;
        }

        Assert.assertTrue(cont == 1);
      }
    }
  }
Пример #2
0
  @Ignore("RDF/XML is not officially supported by W3C R2RML mapping specification")
  @Test
  public void test() throws Exception {

    InputStream fis = getClass().getResourceAsStream("../mappingFiles/test23.ttl");

    R2RMLMappingManager mm = new OWLAPIR2RMLMappingManagerFactory().getR2RMLMappingManager();

    InputSource is = new InputSource(fis);
    is.setSystemId("");
    Set<RDFTriple> triples = OWLAPIUtil.readRDFXML(is);
    Collection<TriplesMap> coll = mm.importMappings(triples);

    Assert.assertTrue(coll.size() == 2);

    Iterator<TriplesMap> it = coll.iterator();
    while (it.hasNext()) {
      TriplesMap current = it.next();

      Iterator<PredicateObjectMap> pomit = current.getPredicateObjectMaps().iterator();
      int cont = 0;
      while (pomit.hasNext()) {
        pomit.next();
        cont++;
      }

      if (cont == 1) {
        SubjectMap s = current.getSubjectMap();
        Template t = s.getTemplate();
        Assert.assertTrue(t.getColumnName(0).contains("Sport"));

      } else if (cont == 4) {

        pomit = current.getPredicateObjectMaps().iterator();

        while (pomit.hasNext()) {
          PredicateObjectMap pom = pomit.next();

          if (pom.getPredicateMaps().iterator().next().getConstant().contains("Sport")) {
            Iterator<RefObjectMap> gmit = pom.getRefObjectMaps().iterator();
            while (gmit.hasNext()) {
              RefObjectMap rom = gmit.next();
              Assert.assertTrue(rom.getParentMap(RDFResource.class) != null);
            }
          }
        }
      } else
        throw new Exception(
            "The number PredicateObjectMaps must be 1 for the TriplesMap2 or 4 for the TriplesMap1!");
    }
  }