Changeset 29548 in osm for applications


Ignore:
Timestamp:
2013-05-01T00:12:19+02:00 (12 years ago)
Author:
donvip
Message:

[josm_reverter] fix #josm8646 + code cleanup/update

Location:
applications/editors/josm/plugins/reverter
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/build.xml

    r29503 r29548  
    44    <property name="commit.message" value="Reverter: Update MultiOsmReader to support null data after redaction"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="5865"/>
     6    <property name="plugin.main.version" value="5874"/>
    77
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r29347 r29548  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
     5import java.util.Arrays;
    56import java.util.Collections;
    67import java.util.HashSet;
     
    103104     * @return <code>true</code> if {@see ChangesetDataSetEntry} conforms to current RevertType
    104105     */
    105     private boolean CheckOsmChangeEntry(ChangesetDataSetEntry entry) {
     106    private boolean checkOsmChangeEntry(ChangesetDataSetEntry entry) {
    106107        if (revertType == RevertType.FULL) return true;
    107108        if (revertType == RevertType.SELECTION_WITH_UNDELETE &&
     
    152153        for (Iterator<ChangesetDataSetEntry> it = cds.iterator();it.hasNext();) {
    153154            ChangesetDataSetEntry entry = it.next();
    154             if (!CheckOsmChangeEntry(entry)) continue;
     155            if (!checkOsmChangeEntry(entry)) continue;
    155156            if (entry.getModificationType() == ChangesetModificationType.CREATED) {
    156157                created.add(entry.getPrimitive());
     
    173174
    174175    /**
    175      * fetch objects that was updated or deleted by changeset
     176     * fetch objects that were updated or deleted by changeset
    176177     * @param progressMonitor
    177178     * @throws OsmTransferException
     
    182183        progressMonitor.beginTask("Downloading objects history",updated.size()+deleted.size()+1);
    183184        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                }
    193191            }
    194192            nds = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true));
     
    322320        }
    323321
    324 
    325322        //////////////////////////////////////////////////////////////////////////
    326323        // Check reversion against current dataset and create necessary conflicts
     
    335332        for (Iterator<ChangesetDataSetEntry> it = cds.iterator();it.hasNext();) {
    336333            ChangesetDataSetEntry entry = it.next();
    337             if (!CheckOsmChangeEntry(entry)) continue;
     334            if (!checkOsmChangeEntry(entry)) continue;
    338335            HistoryOsmPrimitive hp = entry.getPrimitive();
    339336            OsmPrimitive dp = ds.getPrimitiveById(hp.getPrimitiveId());
     
    345342                    && (hp.isVisible() || dp.isVisible()) &&
    346343                    /* 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())) {
    352348                cmds.add(new ConflictAddCommand(layer,CreateConflict(dp,
    353349                        entry.getModificationType() == ChangesetModificationType.CREATED)));
  • applications/editors/josm/plugins/reverter/src/reverter/MultiOsmReader.java

    r28820 r29548  
    1818public class MultiOsmReader extends OsmReader {
    1919
    20     public void AddData(InputStream source) throws IllegalDataException {
     20    public void addData(InputStream source) throws IllegalDataException {
    2121        try {
    2222            InputStreamReader ir = UTFInputStreamReader.create(source, "UTF-8");
     
    3030        }
    3131    }
    32     public void ProcessData() throws IllegalDataException {
     32   
     33    public void processData() throws IllegalDataException {
    3334        prepareDataSet();
    3435    }
  • applications/editors/josm/plugins/reverter/src/reverter/OsmServerMultiObjectReader.java

    r28820 r29548  
    1212import org.openstreetmap.josm.io.OsmServerReader;
    1313import org.openstreetmap.josm.io.OsmTransferException;
     14import org.openstreetmap.josm.tools.Utils;
    1415import org.xml.sax.SAXException;
    1516
    16 
    1717public 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);
    2122    }
    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 {
    2325        StringBuffer sb = new StringBuffer();
    2426        sb.append(type.getAPIName());
     
    3032        InputStream in = getInputStream(sb.toString(), progressMonitor.createSubTaskMonitor(1, true));
    3133        try {
    32             rdr.AddData(in);
     34            rdr.addData(in);
    3335        } catch (Exception e) {
    3436            throw new OsmTransferException(e);
    3537        } finally {
    3638            progressMonitor.finishTask();
    37             if (in!=null) {
    38                 try {
    39                     in.close();
    40                 } catch(Exception e) {}
    41             }
     39            Utils.close(in);
    4240        }
    4341    }
     
    5351        progressMonitor.subTask(tr("Preparing history data..."));
    5452        try {
    55             rdr.ProcessData();
     53            rdr.processData();
    5654            return rdr.getDataSet();
    5755        } catch (Exception e) {
Note: See TracChangeset for help on using the changeset viewer.