Ignore:
Timestamp:
2010-02-23T08:58:12+01:00 (10 years ago)
Author:
jttt
Message:

Fix #4467 Don't silently drop locally deleted member primitives from downloaded ways and relation (fix the issue when deleted primitive is referenced)

Location:
trunk/src/org/openstreetmap/josm/command
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r2932 r3034  
    22package org.openstreetmap.josm.command;
    33
     4import java.util.ArrayList;
    45import java.util.Collection;
    56import java.util.HashMap;
    6 import java.util.HashSet;
     7import java.util.LinkedHashMap;
    78import java.util.Map;
    89import java.util.Map.Entry;
     
    3233
    3334    private static final class CloneVisitor extends AbstractVisitor {
    34         public Map<OsmPrimitive, PrimitiveData> orig = new HashMap<OsmPrimitive, PrimitiveData>();
     35        public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<OsmPrimitive, PrimitiveData>();
    3536
    3637        public void visit(Node n) {
     
    7273    public boolean executeCommand() {
    7374        CloneVisitor visitor = new CloneVisitor();
    74         Collection<OsmPrimitive> all = new HashSet<OsmPrimitive>();
     75        Collection<OsmPrimitive> all = new ArrayList<OsmPrimitive>();
    7576        fillModifiedData(all, all, all);
    7677        for (OsmPrimitive osm : all) {
  • trunk/src/org/openstreetmap/josm/command/CoordinateConflictResolveCommand.java

    r2512 r3034  
    2323
    2424    /** the conflict to resolve */
    25     private Conflict<Node> conflict;
     25    private Conflict<? extends OsmPrimitive> conflict;
    2626
    2727    /** the merge decision */
     
    3535     * @param decision the merge decision
    3636     */
    37     public CoordinateConflictResolveCommand(Node my, Node their, MergeDecisionType decision) {
    38         this.conflict = new Conflict<Node>(my,their);
     37    public CoordinateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
     38        this.conflict = conflict;
    3939        this.decision = decision;
    4040    }
     
    6161            // do nothing
    6262        } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
    63             Node my = conflict.getMy();
    64             Node their = conflict.getTheir();
     63            Node my = (Node)conflict.getMy();
     64            Node their = (Node)conflict.getTheir();
    6565            my.setCoor(their.getCoor());
    6666        } else
  • trunk/src/org/openstreetmap/josm/command/DeletedStateConflictResolveCommand.java

    r2945 r3034  
    2323
    2424    /** the conflict to resolve */
    25     private Conflict<OsmPrimitive> conflict;
     25    private Conflict<? extends OsmPrimitive> conflict;
    2626
    2727    /** the merge decision */
     
    3535     * @param decision the merge decision
    3636     */
    37     public DeletedStateConflictResolveCommand(OsmPrimitive my, OsmPrimitive their, MergeDecisionType decision) {
    38         this.conflict = new Conflict<OsmPrimitive>(my, their);
     37    public DeletedStateConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, MergeDecisionType decision) {
     38        this.conflict = conflict;
    3939        this.decision = decision;
    4040    }
     
    6161
    6262        if (decision.equals(MergeDecisionType.KEEP_MINE)) {
    63             if (conflict.getMy().isDeleted()) {
     63            if (conflict.getMy().isDeleted() || conflict.isMyDeleted()) {
    6464                // because my was involved in a conflict it my still be referred
    6565                // to from a way or a relation. Fix this now.
    6666                //
    6767                layer.data.unlinkReferencesToPrimitive(conflict.getMy());
     68                conflict.getMy().setDeleted(true);
    6869            }
    6970        } else if (decision.equals(MergeDecisionType.KEEP_THEIR)) {
     
    8687            Collection<OsmPrimitive> added) {
    8788        modified.add(conflict.getMy());
     89        modified.addAll(conflict.getMy().getReferrers());
    8890    }
    8991}
  • trunk/src/org/openstreetmap/josm/command/ModifiedConflictResolveCommand.java

    r2844 r3034  
    2424
    2525    /** the conflict to resolve */
    26     private Conflict<OsmPrimitive> conflict;
     26    private Conflict<? extends OsmPrimitive> conflict;
    2727
    2828    /**
     
    3131     * @param their their primitive (i.e. the primitive from the server)
    3232     */
    33     public ModifiedConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
    34         conflict = new Conflict<OsmPrimitive>(my, their);
     33    public ModifiedConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
     34        this.conflict = conflict;
    3535    }
    3636
  • trunk/src/org/openstreetmap/josm/command/TagConflictResolveCommand.java

    r2990 r3034  
    2929
    3030    /** the conflict to resolve */
    31     private Conflict<OsmPrimitive> conflict;
     31    private Conflict<? extends OsmPrimitive> conflict;
    3232
    3333    /** the list of merge decisions, represented as {@see TagMergeItem}s */
     
    5656     * @param mergeItems the list of merge decisions, represented as {@see TagMergeItem}s
    5757     */
    58     public TagConflictResolveCommand(OsmPrimitive my, OsmPrimitive their, List<TagMergeItem> mergeItems) {
    59         this.conflict = new Conflict<OsmPrimitive>(my,their);
     58    public TagConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict, List<TagMergeItem> mergeItems) {
     59        this.conflict = conflict;
    6060        this.mergeItems = mergeItems;
    6161    }
  • trunk/src/org/openstreetmap/josm/command/VersionConflictResolveCommand.java

    r2844 r3034  
    2424
    2525    /** the conflict to resolve */
    26     private Conflict<OsmPrimitive> conflict;
     26    private Conflict<? extends OsmPrimitive> conflict;
    2727
    2828    /**
     
    3131     * @param their their primitive (i.e. the primitive from the server)
    3232     */
    33     public VersionConflictResolveCommand(OsmPrimitive my, OsmPrimitive their) {
    34         conflict = new Conflict<OsmPrimitive>(my, their);
     33    public VersionConflictResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
     34        this.conflict = conflict;
    3535    }
    3636
     
    3939        String msg = "";
    4040        switch(OsmPrimitiveType.from(conflict.getMy())) {
    41             case NODE: msg = marktr("Resolve version conflict for node {0}"); break;
    42             case WAY: msg = marktr("Resolve version conflict for way {0}"); break;
    43             case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break;
     41        case NODE: msg = marktr("Resolve version conflict for node {0}"); break;
     42        case WAY: msg = marktr("Resolve version conflict for way {0}"); break;
     43        case RELATION: msg = marktr("Resolve version conflict for relation {0}"); break;
    4444        }
    4545        return new DefaultMutableTreeNode(
  • trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java

    r2512 r3034  
    4141     * @param mergedNodeList  the list of merged nodes
    4242     */
    43     public WayNodesConflictResolverCommand(Way my, Way their, List<Node> mergedNodeList) {
    44         conflict = new Conflict<Way>(my,their);
     43    @SuppressWarnings("unchecked")
     44    public WayNodesConflictResolverCommand(Conflict<? extends OsmPrimitive> conflict, List<Node> mergedNodeList) {
     45        this.conflict = (Conflict<Way>) conflict;
    4546        this.mergedNodeList = mergedNodeList;
    4647    }
Note: See TracChangeset for help on using the changeset viewer.