public R2RMLWriter(OBDAModel obdamodel, URI sourceURI, OWLOntology ontology) { this.sourceUri = sourceURI; this.mappings = obdamodel.getMappings(sourceUri); this.prefixmng = obdamodel.getPrefixManager(); this.ontology = ontology; }
public void refresh() { final List<OBDADataSource> sourceList = model.getSources(); for (OBDADataSource database : sourceList) { URI sourceUri = database.getSourceID(); List<OBDAMappingAxiom> mappingList = model.getMappings(sourceUri); HashMap<String, Integer> mappingStat = new HashMap<String, Integer>(); for (OBDAMappingAxiom mapping : mappingList) { String mappingId = mapping.getId(); int triplesCount = 0; try { OBDASQLQuery sourceQuery = mapping.getSourceQuery(); int tuples = getTuplesCount(database, sourceQuery); List<Function> targetQuery = mapping.getTargetQuery(); int atoms = targetQuery.size(); triplesCount = tuples * atoms; } catch (Exception e) { triplesCount = -1; // fails to count log.error(e.getMessage()); } mappingStat.put(mappingId, triplesCount); } String sourceId = sourceUri.toString(); statistics.put(sourceId, mappingStat); } }
private void writeMappingDeclaration(OBDADataSource source, BufferedWriter writer) throws IOException { final URI sourceUri = source.getSourceID(); writer.write(MAPPING_DECLARATION_TAG + " " + START_COLLECTION_SYMBOL); writer.write("\n"); boolean needLineBreak = false; for (OBDAMappingAxiom mapping : model.getMappings(sourceUri)) { if (needLineBreak) { writer.write("\n"); } writer.write(Label.mappingId.name() + "\t" + mapping.getId() + "\n"); List<Function> targetQuery = mapping.getTargetQuery(); writer.write(Label.target.name() + "\t\t" + printTargetQuery(targetQuery) + "\n"); OBDASQLQuery sourceQuery = mapping.getSourceQuery(); writer.write(Label.source.name() + "\t\t" + printSourceQuery(sourceQuery) + "\n"); needLineBreak = true; } writer.write(END_COLLECTION_SYMBOL); writer.write("\n\n"); }