@Override public XmlChangeWriter saveData(long sequence) { File changeFile = sequenceFormatter.getFormattedName(sequence, ".osc.gz"); return new XmlChangeWriter(changeFile, CompressionMethod.GZip); } }
@Override public void process(ChangeContainer change) { changeWriter.process(change); }
@Override public void close() { if (changeWriter != null) { changeWriter.close(); changeWriter = null; } stateWriter.close(); } }
/** * Executes the command with the specified options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { checkParameter(refSpec.size() < 3, "Commit list is too long :" + refSpec); GeoGIG geogig = cli.getGeogig(); CreateOSMChangesetOp op = geogig.command(CreateOSMChangesetOp.class); String oldVersion = resolveOldVersion(); String newVersion = resolveNewVersion(); op.setOldVersion(oldVersion).setNewVersion(newVersion).setId(id); try (AutoCloseableIterator<ChangeContainer> entries = op .setProgressListener(cli.getProgressListener()).call()) { if (!entries.hasNext()) { cli.getConsole().println("No differences found"); return; } BufferedWriter bufWriter = new BufferedWriter(new FileWriter(new File(file))); XmlChangeWriter writer = new XmlChangeWriter(bufWriter); while (entries.hasNext()) { ChangeContainer change = entries.next(); writer.process(change); } writer.complete(); bufWriter.flush(); } }
@Override public void complete() { if (state.getSequenceNumber() > 0) { // Complete the writing of the change file. changeWriter.complete(); changeWriter.close(); changeWriter = null; } // Write the sequenced state file. replicationStore.saveState(state); // We must only complete the state writer after we've finished writing // the replication data and sequence numbered state. stateWriter.complete(); }
/** * {@inheritDoc} */ public void process(ChangeContainer changeContainer) { initialize(); osmChangeWriter.process(changeContainer); }
@Override public void complete() { if (state.getSequenceNumber() > 0) { // Complete the writing of the change file. changeWriter.complete(); changeWriter.close(); changeWriter = null; } // Write the sequenced state file. replicationStore.saveState(state); // We must only complete the state writer after we've finished writing // the replication data and sequence numbered state. stateWriter.complete(); }
/** * {@inheritDoc} */ public void process(ChangeContainer changeContainer) { initialize(); osmChangeWriter.process(changeContainer); }
@Override public XmlChangeWriter saveData(long sequence) { File changeFile = sequenceFormatter.getFormattedName(sequence, ".osc.gz"); return new XmlChangeWriter(changeFile, CompressionMethod.GZip); } }
@Override public void process(ChangeContainer change) { changeWriter.process(change); }
@Override public void close() { if (changeWriter != null) { changeWriter.close(); changeWriter = null; } stateWriter.close(); } }
/** * {@inheritDoc} */ @Override protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) { String fileName; File file; CompressionMethod compressionMethod; XmlChangeWriter task; // Get the task arguments. fileName = getStringArgument( taskConfig, ARG_FILE_NAME, getDefaultStringArgument(taskConfig, DEFAULT_FILE_NAME) ); compressionMethod = getCompressionMethodArgument(taskConfig, fileName); // Create a file object from the file name provided. file = new File(fileName); // Build the task object. task = new XmlChangeWriter(file, compressionMethod); return new ChangeSinkManager(taskConfig.getId(), task, taskConfig.getPipeArgs()); } }
/** * {@inheritDoc} */ @Override protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) { String fileName; File file; CompressionMethod compressionMethod; XmlChangeWriter task; // Get the task arguments. fileName = getStringArgument( taskConfig, ARG_FILE_NAME, getDefaultStringArgument(taskConfig, DEFAULT_FILE_NAME) ); compressionMethod = getCompressionMethodArgument(taskConfig, fileName); // Create a file object from the file name provided. file = new File(fileName); // Build the task object. task = new XmlChangeWriter(file, compressionMethod); return new ChangeSinkManager(taskConfig.getId(), task, taskConfig.getPipeArgs()); } }
writer = new XmlChangeWriter(tmpFile, CompressionMethod.GZip);
/** * Tests acceptance of nodes in a delete change with lat/lon attribute not set. * * @throws Exception if something goes wrong. */ @Test public void testDeleteLatLonNotSet() throws Exception { XmlChangeReader xmlReader; XmlChangeWriter xmlWriter; File inputFile; File outputFile; inputFile = dataUtils.createDataFile("v0_6/xml-delete-no-coordinates.osc"); outputFile = dataUtils.newFile(); // Create and connect the xml tasks. xmlReader = new XmlChangeReader(inputFile, true, CompressionMethod.None); xmlWriter = new XmlChangeWriter(outputFile, CompressionMethod.None); xmlReader.setChangeSink(xmlWriter); // Process the xml. xmlReader.run(); // Validate that the output file matches the input file. dataUtils.compareFiles(inputFile, outputFile); }
/** * A basic test reading and writing an osm file testing both reader and * writer tasks. * * @throws IOException * if any file operations fail. */ @Test public void testSimple() throws IOException { XmlChangeReader xmlReader; XmlChangeWriter xmlWriter; File inputFile; File outputFile; inputFile = dataUtils.createDataFile("v0_6/xml-task-tests-v0_6.osc"); outputFile = dataUtils.newFile(); // Create and connect the xml tasks. xmlReader = new XmlChangeReader(inputFile, true, CompressionMethod.None); xmlWriter = new XmlChangeWriter(outputFile, CompressionMethod.None); xmlReader.setChangeSink(xmlWriter); // Process the xml. xmlReader.run(); // Validate that the output file matches the input file. dataUtils.compareFiles(inputFile, outputFile); }