public void save(File file) throws IOException { try { save(new FileWriter(file)); } catch (IOException e) { throw new IOException(String.format("Error while saving the OBDA model to the file located at %s.\n" + "Make sure you have the write permission at the location specified.", file.getAbsolutePath())); } }
private String printSourceQuery(OBDASQLQuery query) { String sourceString = SourceQueryRenderer.encode(query); String toReturn = convertTabToSpaces(sourceString); return toReturn.replaceAll("\n", "\n\t\t\t"); } private String convertTabToSpaces(String input) {
/** * The save/write operation. * * @param writer * The target writer to which the model is saved. * @throws IOException */ public void save(Writer writer) throws IOException { BufferedWriter bufferWriter = new BufferedWriter(writer); writePrefixDeclaration(bufferWriter); writeMappingDeclaration(bufferWriter); bufferWriter.flush(); bufferWriter.close(); }
OntopNativeMappingSerializer writer = new OntopNativeMappingSerializer(ppMapping); writer.save(out);
private void writeMappingDeclaration(BufferedWriter writer) throws IOException { writer.write(OntopNativeMappingParser.MAPPING_DECLARATION_TAG + " " + OntopNativeMappingParser.START_COLLECTION_SYMBOL); writer.write("\n"); boolean needLineBreak = false; for (SQLPPTriplesMap axiom : ppMapping.getTripleMaps()) { if (needLineBreak) { writer.write("\n"); } writer.write(OntopNativeMappingParser.Label.mappingId.name() + "\t" + axiom.getId() + "\n"); ImmutableList<TargetAtom> targetQuery = axiom.getTargetAtoms(); writer.write(OntopNativeMappingParser.Label.target.name() + "\t\t" + printTargetQuery(targetQuery) + "\n"); OBDASQLQuery sourceQuery = axiom.getSourceQuery(); writer.write(OntopNativeMappingParser.Label.source.name() + "\t\t" + printSourceQuery(sourceQuery) + "\n"); needLineBreak = true; } writer.write(OntopNativeMappingParser.END_COLLECTION_SYMBOL); writer.write("\n\n"); }
File obdaFile = new File(mappingFile); OntopNativeMappingSerializer writer = new OntopNativeMappingSerializer(results.getPPMapping()); writer.save(obdaFile);
OntopNativeMappingSerializer writer = new OntopNativeMappingSerializer(ppMapping); writer.save(obdaFile);