Changeset 29548 in osm for applications
- Timestamp:
- 2013-05-01T00:12:19+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/reverter
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/build.xml
r29503 r29548 4 4 <property name="commit.message" value="Reverter: Update MultiOsmReader to support null data after redaction"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="58 65"/>6 <property name="plugin.main.version" value="5874"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r29347 r29548 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.util.Arrays; 5 6 import java.util.Collections; 6 7 import java.util.HashSet; … … 103 104 * @return <code>true</code> if {@see ChangesetDataSetEntry} conforms to current RevertType 104 105 */ 105 private boolean CheckOsmChangeEntry(ChangesetDataSetEntry entry) {106 private boolean checkOsmChangeEntry(ChangesetDataSetEntry entry) { 106 107 if (revertType == RevertType.FULL) return true; 107 108 if (revertType == RevertType.SELECTION_WITH_UNDELETE && … … 152 153 for (Iterator<ChangesetDataSetEntry> it = cds.iterator();it.hasNext();) { 153 154 ChangesetDataSetEntry entry = it.next(); 154 if (! CheckOsmChangeEntry(entry)) continue;155 if (!checkOsmChangeEntry(entry)) continue; 155 156 if (entry.getModificationType() == ChangesetModificationType.CREATED) { 156 157 created.add(entry.getPrimitive()); … … 173 174 174 175 /** 175 * fetch objects that w asupdated or deleted by changeset176 * fetch objects that were updated or deleted by changeset 176 177 * @param progressMonitor 177 178 * @throws OsmTransferException … … 182 183 progressMonitor.beginTask("Downloading objects history",updated.size()+deleted.size()+1); 183 184 try { 184 for (HistoryOsmPrimitive entry : updated) { 185 rdr.ReadObject(entry.getPrimitiveId(), cds.getEarliestVersion(entry.getPrimitiveId())-1, 186 progressMonitor.createSubTaskMonitor(1, true)); 187 if (progressMonitor.isCanceled()) return; 188 } 189 for (HistoryOsmPrimitive entry : deleted) { 190 rdr.ReadObject(entry.getPrimitiveId(), cds.getEarliestVersion(entry.getPrimitiveId())-1, 191 progressMonitor.createSubTaskMonitor(1, true)); 192 if (progressMonitor.isCanceled()) return; 185 for (HashSet<HistoryOsmPrimitive> collection : Arrays.asList(new HashSet[]{updated, deleted})) { 186 for (HistoryOsmPrimitive entry : collection) { 187 PrimitiveId id = entry.getPrimitiveId(); 188 rdr.readObject(id, cds.getEarliestVersion(id)-1, progressMonitor.createSubTaskMonitor(1, true)); 189 if (progressMonitor.isCanceled()) return; 190 } 193 191 } 194 192 nds = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)); … … 322 320 } 323 321 324 325 322 ////////////////////////////////////////////////////////////////////////// 326 323 // Check reversion against current dataset and create necessary conflicts … … 335 332 for (Iterator<ChangesetDataSetEntry> it = cds.iterator();it.hasNext();) { 336 333 ChangesetDataSetEntry entry = it.next(); 337 if (! CheckOsmChangeEntry(entry)) continue;334 if (!checkOsmChangeEntry(entry)) continue; 338 335 HistoryOsmPrimitive hp = entry.getPrimitive(); 339 336 OsmPrimitive dp = ds.getPrimitiveById(hp.getPrimitiveId()); … … 345 342 && (hp.isVisible() || dp.isVisible()) && 346 343 /* Don't create conflict if changeset object and dataset object 347 * has same semantic attributes(but different versions) 348 */ 349 !hasEqualSemanticAttributes(dp,hp)) { 350 351 344 * has same semantic attributes (but different versions) */ 345 !hasEqualSemanticAttributes(dp,hp) 346 /* Don't create conflict if the object has to be deleted but has already been deleted */ 347 && !(toDelete.contains(dp) && dp.isDeleted())) { 352 348 cmds.add(new ConflictAddCommand(layer,CreateConflict(dp, 353 349 entry.getModificationType() == ChangesetModificationType.CREATED))); -
applications/editors/josm/plugins/reverter/src/reverter/MultiOsmReader.java
r28820 r29548 18 18 public class MultiOsmReader extends OsmReader { 19 19 20 public void AddData(InputStream source) throws IllegalDataException {20 public void addData(InputStream source) throws IllegalDataException { 21 21 try { 22 22 InputStreamReader ir = UTFInputStreamReader.create(source, "UTF-8"); … … 30 30 } 31 31 } 32 public void ProcessData() throws IllegalDataException { 32 33 public void processData() throws IllegalDataException { 33 34 prepareDataSet(); 34 35 } -
applications/editors/josm/plugins/reverter/src/reverter/OsmServerMultiObjectReader.java
r28820 r29548 12 12 import org.openstreetmap.josm.io.OsmServerReader; 13 13 import org.openstreetmap.josm.io.OsmTransferException; 14 import org.openstreetmap.josm.tools.Utils; 14 15 import org.xml.sax.SAXException; 15 16 16 17 17 public class OsmServerMultiObjectReader extends OsmServerReader { 18 private MultiOsmReader rdr = new MultiOsmReader(); 19 public void ReadObject(PrimitiveId id, int version, ProgressMonitor progressMonitor) throws OsmTransferException { 20 ReadObject(id.getUniqueId(), version, id.getType(), progressMonitor); 18 private final MultiOsmReader rdr = new MultiOsmReader(); 19 20 public void readObject(PrimitiveId id, int version, ProgressMonitor progressMonitor) throws OsmTransferException { 21 readObject(id.getUniqueId(), version, id.getType(), progressMonitor); 21 22 } 22 public void ReadObject(long id,int version,OsmPrimitiveType type,ProgressMonitor progressMonitor) throws OsmTransferException { 23 24 public void readObject(long id,int version,OsmPrimitiveType type,ProgressMonitor progressMonitor) throws OsmTransferException { 23 25 StringBuffer sb = new StringBuffer(); 24 26 sb.append(type.getAPIName()); … … 30 32 InputStream in = getInputStream(sb.toString(), progressMonitor.createSubTaskMonitor(1, true)); 31 33 try { 32 rdr. AddData(in);34 rdr.addData(in); 33 35 } catch (Exception e) { 34 36 throw new OsmTransferException(e); 35 37 } finally { 36 38 progressMonitor.finishTask(); 37 if (in!=null) { 38 try { 39 in.close(); 40 } catch(Exception e) {} 41 } 39 Utils.close(in); 42 40 } 43 41 } … … 53 51 progressMonitor.subTask(tr("Preparing history data...")); 54 52 try { 55 rdr. ProcessData();53 rdr.processData(); 56 54 return rdr.getDataSet(); 57 55 } catch (Exception e) {
Note:
See TracChangeset
for help on using the changeset viewer.