/** * The save/write operation. * * @param file * The target file object to which the model is saved. * @throws IOException */ public void save(File file) throws IOException { try { BufferedWriter writer = new BufferedWriter(new FileWriter(file)); writePrefixDeclaration(writer); for (OBDADataSource source : model.getSources()) { writeSourceDeclaration(source, writer); writeMappingDeclaration(source, writer); } writer.flush(); writer.close(); } catch (IOException e) { throw new IOException(String.format("Error while saving the OBDA model to file located at %s.\n" + "Make sure you have the write permission at the location specified.", file.getAbsolutePath())); } }
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); } }
e.printStackTrace(); URI srcURI = model.getSources().get(0).getSourceID();
if (obdaModel.getSources().size() == 0) obdaModel.addSource(getMemOBDADataSource("MemH2"));