public static void main(String args[]) { String file = "/Users/mindaugas/r2rml/test26.ttl"; R2RMLReader reader = null; try { reader = new R2RMLReader(file); } catch (Exception e) { e.printStackTrace(); } ArrayList<OBDAMappingAxiom> axioms = reader.readMappings(); for (OBDAMappingAxiom ax : axioms) System.out.println(ax); }
public OBDAModel loadRFrom2RMLFile(String r2rmlFile, String jdbcUrl, String username, String password, String driverClass) throws Exception { OBDADataFactory f = OBDADataFactoryImpl.getInstance(); URI obdaURI = new File(r2rmlFile).toURI(); String sourceUrl = obdaURI.toString(); OBDADataSource dataSource = f.getJDBCDataSource(sourceUrl, jdbcUrl, username, password, driverClass); R2RMLReader reader = new R2RMLReader(r2rmlFile); return reader.readModel(dataSource); }
public static void main(String args[]) { String file = "/Users/mindaugas/r2rml/test2.ttl"; try { R2RMLReader reader = new R2RMLReader(file); OWLOntology ontology = null; R2RMLWriter writer = new R2RMLWriter(reader.readModel(URI.create("test")),URI.create("test"), ontology); File out = new File("/Users/mindaugas/r2rml/out.ttl"); // Graph g = writer.getGraph(); // Iterator<Statement> st = g.iterator(); // while (st.hasNext()) // System.out.println(st.next()); writer.write(out); } catch (Exception e) { e.printStackTrace(); } } }
/** * The method generates the OBDAModel from an * obda or ttl (r2rml) file * @param obdaURI - the file URI * @return the generated OBDAModel * @throws IOException * @throws InvalidMappingException */ public OBDAModel getObdaModel(URI obdaURI) throws IOException, InvalidMappingException { //create empty model OBDAModel obdaModel = fac.getOBDAModel(); // System.out.println(obdaURI.toString()); if (obdaURI.toString().endsWith(".obda")) { //read obda file ModelIOManager modelIO = new ModelIOManager(obdaModel); modelIO.load(new File(obdaURI)); } else if (obdaURI.toString().endsWith(".ttl")) { //read R2RML file R2RMLReader reader = null; try { reader = new R2RMLReader(new File(obdaURI)); obdaModel = reader.readModel(obdaURI); } catch (Exception e) { e.printStackTrace(); } } return obdaModel; }
R2RMLReader reader = new R2RMLReader(mapFile);
R2RMLReader reader = new R2RMLReader(mappings); obdaModel = reader.readModel(source.getSourceID());