public R2RMLReader(File file) throws Exception { manager = new R2RMLManager(file); m = manager.getModel(); }
/** * method to read the mappings from the graph * @return list of obdaMappingAxioms */ public ArrayList<OBDAMappingAxiom> readMappings(){ return manager.getMappings(m); }
mapping = getMapping(tm); List<OBDAMappingAxiom> joinMappings = getJoinMappings(tripleMaps, tm); if (joinMappings != null) { mappings.addAll(joinMappings);
public R2RMLReader(Model m) { manager = new R2RMLManager(m); this.m = m; }
/** * Get OBDA mapping axiom from R2RML TriplesMap * @param tm * @return * @throws Exception */ private OBDAMappingAxiom getMapping(TriplesMap tm) throws Exception { String sourceQuery = r2rmlParser.getSQLQuery(tm).trim(); List<Function> body = getMappingTripleAtoms(tm); //Function head = getHeadAtom(body); //CQIE targetQuery = fac.getCQIE(head, body); OBDAMappingAxiom mapping = fac.getRDBMSMappingAxiom("mapping-"+tm.hashCode(), fac.getSQLQuery(sourceQuery), body); if (body.isEmpty()){ //we do not have a target query System.out.println("WARNING a mapping without target query will not be introduced : "+ mapping.toString()); return null; } return mapping; }
/** * the method that gives the obda model based on the given graph * @param sourceUri - the uri of the datasource of the model * @return the read obda model */ public OBDAModel readModel(URI sourceUri){ try { //add to the model the mappings retrieved from the manager obdaModel.addMappings(sourceUri, manager.getMappings(m)); } catch (DuplicateMappingException e) { e.printStackTrace(); } return obdaModel; }
/** * the method that gives the obda model based on the given graph * @param dataSource - the datasource of the model * @return the read obda model */ public OBDAModel readModel(OBDADataSource dataSource){ try { obdaModel.addSource(dataSource); URI sourceUri = dataSource.getSourceID(); //add to the model the mappings retrieved from the manager obdaModel.addMappings(sourceUri, manager.getMappings(m)); } catch (DuplicateMappingException e) { e.printStackTrace(); } return obdaModel; }