Changeset 3034 in josm for trunk


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
Files:
27 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    }
  • trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java

    r2979 r3034  
    2121    private final T my;
    2222    private final T their;
     23    private final boolean isMyDeleted;
    2324
    2425    public Conflict(T my, T their) {
     26        this(my, their, false);
     27    }
     28
     29    public Conflict(T my, T their, boolean isMyDeleted) {
    2530        this.my = my;
    2631        this.their = their;
     32        this.isMyDeleted = isMyDeleted;
    2733    }
    2834
     
    96102        return true;
    97103    }
     104
     105    /**
     106     *
     107     * @return True if my primitive was deleted but it has set non deleted status because it's referred by another
     108     * primitive and references to deleted primitives are not allowed.
     109     */
     110    public boolean isMyDeleted() {
     111        return isMyDeleted;
     112    }
    98113}
  • trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java

    r2949 r3034  
    3333 * </ul>
    3434 */
    35 public class ConflictCollection implements Iterable<Conflict<?>>{
    36     private final List<Conflict<?>> conflicts;
     35public class ConflictCollection implements Iterable<Conflict<? extends OsmPrimitive>>{
     36    private final List<Conflict<? extends OsmPrimitive>> conflicts;
    3737    private CopyOnWriteArrayList<IConflictListener> listeners;
    3838
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r3033 r3034  
    1313import java.util.logging.Logger;
    1414
     15import org.openstreetmap.josm.data.conflict.Conflict;
    1516import org.openstreetmap.josm.data.conflict.ConflictCollection;
    1617import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    160161     * @param other
    161162     */
     163    //TODO This method is probably useless
    162164    protected void fixIncompleteParentWays(Node other) {
    163165        Node myNode = (Node)getMergeTarget(other);
     
    224226                    newNodes.add(targetNode);
    225227                    if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) {
    226                         conflicts.add(targetNode, sourceNode);
     228                        conflicts.add(new Conflict<OsmPrimitive>(targetNode, sourceNode, true));
     229                        targetNode.setDeleted(false);
    227230                    }
    228231                } else {
     
    255258                newMembers.add(newMember);
    256259                if (targetMember.isDeleted() && !conflicts.hasConflictForMy(targetMember)) {
    257                     conflicts.add(targetMember, sourceMember.getMember());
     260                    conflicts.add(new Conflict<OsmPrimitive>(targetMember, sourceMember.getMember(), true));
     261                    targetMember.setDeleted(false);
    258262                }
    259263            } else {
     
    319323            for (OsmPrimitive referrer: source.getReferrers()) {
    320324                if (targetDataSet.getPrimitiveById(referrer.getPrimitiveId()) == null) {
    321                     conflicts.add(target, source);
     325                    conflicts.add(new Conflict<OsmPrimitive>(target, source, true));
     326                    target.setDeleted(false);
    322327                    break;
    323328                }
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r2863 r3034  
    2727
    2828    private static long getNextLocalUid() {
    29         synchronized(User.class) {
    30             return uidCounter.decrementAndGet();
    31         }
     29        return uidCounter.decrementAndGet();
    3230    }
    3331
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ConflictResolver.java

    r2945 r3034  
    1919import org.openstreetmap.josm.command.SequenceCommand;
    2020import org.openstreetmap.josm.command.VersionConflictResolveCommand;
     21import org.openstreetmap.josm.data.conflict.Conflict;
    2122import org.openstreetmap.josm.data.osm.Node;
    2223import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    7778    private OsmPrimitive my;
    7879    private OsmPrimitive their;
     80    private Conflict<? extends OsmPrimitive> conflict;
    7981
    8082    private ImageIcon mergeComplete;
     
    228230     *
    229231     */
    230     public void populate(OsmPrimitive my, OsmPrimitive their) {
    231         setMy(my);
    232         setTheir(their);
    233         propertiesMerger.populate(my, their);
     232    public void populate(Conflict<? extends OsmPrimitive> conflict) {
     233        setMy(conflict.getMy());
     234        setTheir(conflict.getTheir());
     235        this.conflict = conflict;
     236        propertiesMerger.populate(conflict);
    234237        if (propertiesMerger.getModel().hasVisibleStateConflict()) {
    235238            tabbedPane.setEnabledAt(1, false);
     
    239242        }
    240243        tabbedPane.setEnabledAt(0, true);
    241         tagMerger.populate(my, their);
     244        tagMerger.populate(conflict);
    242245        tabbedPane.setEnabledAt(1, true);
    243246
     
    246249            tabbedPane.setEnabledAt(3,false);
    247250        } else if (my instanceof Way) {
    248             nodeListMerger.populate(my, their);
     251            nodeListMerger.populate(conflict);
    249252            tabbedPane.setEnabledAt(2, true);
    250253            tabbedPane.setEnabledAt(3, false);
     
    252255            tabbedPane.setIconAt(3, null);
    253256        } else if (my instanceof Relation) {
    254             relationMemberMerger.populate(my, their);
     257            relationMemberMerger.populate(conflict);
    255258            tabbedPane.setEnabledAt(2, false);
    256259            tabbedPane.setTitleAt(2,tr("Nodes"));
     
    271274        if (propertiesMerger.getModel().hasVisibleStateConflict()) {
    272275            if (propertiesMerger.getModel().isDecidedVisibleState()) {
    273                 commands.addAll(propertiesMerger.getModel().buildResolveCommand(my, their));
     276                commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict));
    274277            }
    275278        } else {
    276279            if (tagMerger.getModel().getNumResolvedConflicts() > 0) {
    277                 commands.add(tagMerger.getModel().buildResolveCommand(my, their));
    278             }
    279             commands.addAll(propertiesMerger.getModel().buildResolveCommand(my, their));
     280                commands.add(tagMerger.getModel().buildResolveCommand(conflict));
     281            }
     282            commands.addAll(propertiesMerger.getModel().buildResolveCommand(conflict));
    280283            if (my instanceof Way && nodeListMerger.getModel().isFrozen()) {
    281284                NodeListMergeModel model  =(NodeListMergeModel)nodeListMerger.getModel();
    282                 commands.add(model.buildResolveCommand((Way)my, (Way)their));
     285                commands.add(model.buildResolveCommand(conflict));
    283286            } else if (my instanceof Relation && relationMemberMerger.getModel().isFrozen()) {
    284287                RelationMemberListMergeModel model  =(RelationMemberListMergeModel)relationMemberMerger.getModel();
     
    286289            }
    287290            if (isResolvedCompletely()) {
    288                 commands.add(new VersionConflictResolveCommand(my, their));
    289                 commands.add(new ModifiedConflictResolveCommand(my, their));
     291                commands.add(new VersionConflictResolveCommand(conflict));
     292                commands.add(new ModifiedConflictResolveCommand(conflict));
    290293            }
    291294        }
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/IConflictResolver.java

    r2945 r3034  
    22package org.openstreetmap.josm.gui.conflict.pair;
    33
     4import org.openstreetmap.josm.data.conflict.Conflict;
    45import org.openstreetmap.josm.data.osm.OsmPrimitive;
    56
     
    78
    89    void deletePrimitive(boolean deleted);
    9     void populate(OsmPrimitive my, OsmPrimitive their);
     10    void populate(Conflict<? extends OsmPrimitive> conflict);
    1011
    1112}
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModel.java

    r2949 r3034  
    99
    1010import org.openstreetmap.josm.command.WayNodesConflictResolverCommand;
     11import org.openstreetmap.josm.data.conflict.Conflict;
    1112import org.openstreetmap.josm.data.osm.DataSet;
    1213import org.openstreetmap.josm.data.osm.Node;
     
    6162     * @param their  their way. Must not be null
    6263     * @return the command
    63      * @exception IllegalArgumentException thrown, if my is null or not a {@see Way}
    64      * @exception IllegalArgumentException thrown, if their is null or not a {@see Way}
    6564     * @exception IllegalStateException thrown, if the merge is not yet frozen
    6665     */
    67     public WayNodesConflictResolverCommand buildResolveCommand(Way my, Way their) {
    68         CheckParameterUtil.ensureParameterNotNull(my, "my");
    69         CheckParameterUtil.ensureParameterNotNull(their, "their");
     66    public WayNodesConflictResolverCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
    7067        if (! isFrozen())
    7168            throw new IllegalArgumentException(tr("Merged nodes not frozen yet. Cannot build resolution command."));
    72         return new WayNodesConflictResolverCommand(my, their, getMergedEntries());
     69        return new WayNodesConflictResolverCommand(conflict, getMergedEntries());
    7370    }
    7471
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMerger.java

    r2945 r3034  
    44import javax.swing.JTable;
    55
     6import org.openstreetmap.josm.data.conflict.Conflict;
    67import org.openstreetmap.josm.data.osm.Node;
    78import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    6364    }
    6465
    65     public void populate(OsmPrimitive my, OsmPrimitive their) {
    66         ((NodeListMergeModel)model).populate((Way)my, (Way)their);
     66    public void populate(Conflict<? extends OsmPrimitive> conflict) {
     67        ((NodeListMergeModel)model).populate((Way)conflict.getMy(), (Way)conflict.getTheir());
    6768    }
    6869
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java

    r2940 r3034  
    2121import org.openstreetmap.josm.command.PurgePrimitivesCommand;
    2222import org.openstreetmap.josm.command.UndeletePrimitivesCommand;
     23import org.openstreetmap.josm.data.conflict.Conflict;
    2324import org.openstreetmap.josm.data.coor.LatLon;
    2425import org.openstreetmap.josm.data.osm.DataSet;
     
    161162     * @param their their version of the primitive
    162163     */
    163     public void populate(OsmPrimitive my, OsmPrimitive their) {
    164         this.my = my;
     164    public void populate(Conflict<? extends OsmPrimitive> conflict) {
     165        this.my = conflict.getMy();
     166        OsmPrimitive their = conflict.getTheir();
    165167        if (my instanceof Node) {
    166168            myCoords = ((Node)my).getCoor();
     
    171173        }
    172174
    173         myDeletedState = my.isDeleted();
     175        myDeletedState =  conflict.isMyDeleted() || my.isDeleted();
    174176        theirDeletedState = their.isDeleted();
    175177
     
    418420     * @return the list of commands
    419421     */
    420     public List<Command> buildResolveCommand(OsmPrimitive my, OsmPrimitive their) throws OperationCancelledException{
    421         ArrayList<Command> cmds = new ArrayList<Command>();
     422    public List<Command> buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) throws OperationCancelledException{
     423        OsmPrimitive my = conflict.getMy();
     424        List<Command> cmds = new ArrayList<Command>();
    422425        if (hasVisibleStateConflict() && isDecidedVisibleState()) {
    423426            if (isVisibleStateDecision(MergeDecisionType.KEEP_MINE)) {
     
    436439        }
    437440        if (hasCoordConflict() && isDecidedCoord()) {
    438             cmds.add(new CoordinateConflictResolveCommand((Node)my, (Node)their, coordMergeDecision));
     441            cmds.add(new CoordinateConflictResolveCommand(conflict, coordMergeDecision));
    439442        }
    440443        if (hasDeletedStateConflict() && isDecidedDeletedState()) {
    441             cmds.add(new DeletedStateConflictResolveCommand(my, their, deletedMergeDecision));
     444            cmds.add(new DeletedStateConflictResolveCommand(conflict, deletedMergeDecision));
    442445        }
    443446        return cmds;
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMerger.java

    r2945 r3034  
    2222import javax.swing.JPanel;
    2323
     24import org.openstreetmap.josm.data.conflict.Conflict;
    2425import org.openstreetmap.josm.data.coor.LatLon;
    2526import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    718719    }
    719720
    720     public void populate(OsmPrimitive my, OsmPrimitive their) {
    721         model.populate(my, their);
     721    public void populate(Conflict<? extends OsmPrimitive> conflict) {
     722        model.populate(conflict);
    722723    }
    723724}
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMerger.java

    r2945 r3034  
    55import javax.swing.JTable;
    66
     7import org.openstreetmap.josm.data.conflict.Conflict;
    78import org.openstreetmap.josm.data.osm.OsmPrimitive;
    89import org.openstreetmap.josm.data.osm.Relation;
     
    5455    }
    5556
    56     public void populate(OsmPrimitive my, OsmPrimitive their) {
     57    public void populate(Conflict<? extends OsmPrimitive> conflict) {
    5758        RelationMemberListMergeModel model = (RelationMemberListMergeModel)getModel();
    58         model.populate((Relation)my, (Relation)their);
     59        model.populate((Relation)conflict.getMy(), (Relation)conflict.getTheir());
    5960    }
    6061
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeModel.java

    r2945 r3034  
    1212
    1313import org.openstreetmap.josm.command.TagConflictResolveCommand;
     14import org.openstreetmap.josm.data.conflict.Conflict;
    1415import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1516import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     
    189190    }
    190191
    191     public TagConflictResolveCommand buildResolveCommand(OsmPrimitive my, OsmPrimitive their) {
    192         return new TagConflictResolveCommand(my,  their, tagMergeItems);
     192    public TagConflictResolveCommand buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
     193        return new TagConflictResolveCommand(conflict, tagMergeItems);
    193194    }
    194195
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java

    r2945 r3034  
    2626import javax.swing.event.ListSelectionListener;
    2727
     28import org.openstreetmap.josm.data.conflict.Conflict;
    2829import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2930import org.openstreetmap.josm.gui.conflict.pair.IConflictResolver;
     
    421422    }
    422423
    423     public void populate(OsmPrimitive my, OsmPrimitive their) {
    424         model.populate(my, their);
     424    public void populate(Conflict<? extends OsmPrimitive> conflict) {
     425        model.populate(conflict.getMy(), conflict.getTheir());
    425426        mineTable.getSelectionModel().setSelectionInterval(0, 0);
    426427        theirTable.getSelectionModel().setSelectionInterval(0, 0);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r2945 r3034  
    144144        }
    145145
    146         Conflict<?> c = conflicts.get(index);
    147         OsmPrimitive my = c.getMy();
    148         OsmPrimitive their = c.getTheir();
     146        Conflict<? extends OsmPrimitive> c = conflicts.get(index);
    149147        ConflictResolutionDialog dialog = new ConflictResolutionDialog(Main.parent);
    150         dialog.getConflictResolver().populate(my, their);
     148        dialog.getConflictResolver().populate(c);
    151149        dialog.setVisible(true);
    152150
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergerTest.java

    r2041 r3034  
    66import javax.swing.JFrame;
    77
     8import org.openstreetmap.josm.data.conflict.Conflict;
    89import org.openstreetmap.josm.data.osm.Node;
     10import org.openstreetmap.josm.data.osm.OsmPrimitive;
    911import org.openstreetmap.josm.data.osm.Way;
    10 import org.openstreetmap.josm.gui.conflict.pair.nodes.NodeListMerger;
    1112
    1213public class NodeListMergerTest extends JFrame {
     
    3536        w2.addNode(new Node(6));
    3637
    37         nodeListMerger.populate(w1, w2);
     38        nodeListMerger.populate(new Conflict<OsmPrimitive>(w1, w2));
    3839
    3940    }
     
    4950            w2.addNode(new Node(i));
    5051        }
    51         nodeListMerger.populate(w1, w2);
     52        nodeListMerger.populate(new Conflict<OsmPrimitive>(w1, w2));
    5253
    5354    }
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java

    r2077 r3034  
    77
    88import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.data.conflict.Conflict;
    910import org.openstreetmap.josm.data.coor.LatLon;
    1011import org.openstreetmap.josm.data.osm.Node;
     12import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1113import org.openstreetmap.josm.data.projection.Epsg4326;
    12 import org.openstreetmap.josm.gui.conflict.pair.properties.PropertiesMerger;
    1314
    1415public class PropertiesMergerTest extends JFrame{
     
    3132        their.setCoor(new LatLon(10,10));
    3233
    33         merger.getModel().populate(my, their);
     34        merger.getModel().populate(new Conflict<OsmPrimitive>(my, their));
    3435    }
    3536
  • trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberMergerTest.java

    r2041 r3034  
    66import javax.swing.JFrame;
    77
     8import org.openstreetmap.josm.data.conflict.Conflict;
    89import org.openstreetmap.josm.data.osm.Node;
     10import org.openstreetmap.josm.data.osm.OsmPrimitive;
    911import org.openstreetmap.josm.data.osm.Relation;
    1012import org.openstreetmap.josm.data.osm.RelationMember;
    1113import org.openstreetmap.josm.data.osm.Way;
    12 import org.openstreetmap.josm.gui.conflict.pair.relation.RelationMemberMerger;
    1314
    1415public class RelationMemberMergerTest extends JFrame {
     
    2829        r2.addMember(new RelationMember("role3", new Relation(3)));
    2930
    30         merger.populate(r1, r2);
     31        merger.populate(new Conflict<OsmPrimitive>(r1, r2));
    3132
    3233    }
  • trunk/test/functional/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialogTest.java

    r1912 r3034  
    44import javax.swing.JFrame;
    55
     6import org.openstreetmap.josm.data.conflict.Conflict;
    67import org.openstreetmap.josm.data.osm.Node;
     8import org.openstreetmap.josm.data.osm.OsmPrimitive;
    79import org.openstreetmap.josm.data.osm.Way;
    810
     
    2729        w2.addNode(new Node(11));
    2830
    29         dialog.getConflictResolver().populate(w1, w2);
     31        dialog.getConflictResolver().populate(new Conflict<OsmPrimitive>(w1, w2));
    3032    }
    3133
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r3025 r3034  
    815815     * Their dataset includes a way with three nodes, the first one being my node.
    816816     *
    817      * => the merged way should include two nodes only. the deleted node should still be
    818      * in the data set.
     817     * => the merged way should include all three nodes. Deleted node should have deleted=false and
     818     * special conflict with isDeleted should exist
    819819     *
    820820     */
     
    848848        theirWay.addNode(tn2);
    849849        theirWay.addNode(tn3);
    850         User user = User.getById(1111);
    851         if (user == null) {
    852             User.createOsmUser(1111, "their");
    853         }
    854         theirWay.setUser(user);
     850        theirWay.setUser(User.createOsmUser(1111, "their"));
    855851        theirWay.setTimestamp(new Date());
    856852        their.addPrimitive(theirWay);
     
    860856
    861857        assertEquals(1, visitor.getConflicts().size());
     858        assertTrue(visitor.getConflicts().get(0).isMyDeleted());
    862859
    863860        Way myWay = (Way)my.getPrimitiveById(4, OsmPrimitiveType.WAY);
     
    865862
    866863        Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
    867         assertTrue(!myWay.getNodes().contains(n));
    868         assertTrue(n != null);
    869 
    870         //a node was removed from the way,it should thus be modified
    871         assertTrue(myWay.isModified());
     864        assertTrue(myWay.getNodes().contains(n));
     865
     866        assertFalse(myWay.isModified());
    872867    }
    873868
     
    876871     * Their dataset includes a relation with three nodes, the first one being my node.
    877872     *
    878      * => the merged relation should include two nodes only. the deleted node should still be
    879      * in the data set
     873     * => the merged relation should include all three nodes. There should be conflict for deleted
     874     * node with isMyDeleted set
    880875     *
    881876     */
     
    884879
    885880
    886         Node n1 = new Node(new LatLon(0,0));
    887         n1.setOsmId(1,1);
    888         n1.setDeleted(true);
    889         my.addPrimitive(n1);
    890 
    891 
    892         Node n3 = new Node(new LatLon(0,0));
    893         n3.setOsmId(1,1);
    894         their.addPrimitive(n3);
    895 
    896         Node n4 = new Node(new LatLon(1,1));
    897         n4.setOsmId(2,1);
    898         their.addPrimitive(n4);
    899 
    900         Node n5 = new Node(new LatLon(2,2));
    901         n5.setOsmId(3,1);
    902         their.addPrimitive(n5);
     881        Node mn1 = new Node(new LatLon(0,0));
     882        mn1.setOsmId(1,1);
     883        mn1.setDeleted(true);
     884        my.addPrimitive(mn1);
     885
     886
     887        Node tn1 = new Node(new LatLon(0,0));
     888        tn1.setOsmId(1,1);
     889        their.addPrimitive(tn1);
     890
     891        Node tn2 = new Node(new LatLon(1,1));
     892        tn2.setOsmId(2,1);
     893        their.addPrimitive(tn2);
     894
     895        Node tn3 = new Node(new LatLon(2,2));
     896        tn3.setOsmId(3,1);
     897        their.addPrimitive(tn3);
    903898
    904899
     
    906901        theirRelation.setOsmId(4,1);
    907902
    908         theirRelation.addMember(new RelationMember("", n3));
    909         theirRelation.addMember(new RelationMember("", n4));
    910         theirRelation.addMember(new RelationMember("", n5));
     903        theirRelation.addMember(new RelationMember("", tn1));
     904        theirRelation.addMember(new RelationMember("", tn2));
     905        theirRelation.addMember(new RelationMember("", tn3));
    911906        their.addPrimitive(theirRelation);
    912907
    913908        DataSetMerger visitor = new DataSetMerger(my,their);
    914909        visitor.merge();
    915 
    916         assertEquals(0,visitor.getConflicts().size());
    917 
    918         Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION);
    919         assertEquals(2, r.getMembersCount());
    920910
    921911        Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
    922912        assertTrue(n != null);
    923913
    924         assertTrue(r.isModified());
     914        assertEquals(1, visitor.getConflicts().size());
     915        assertTrue(visitor.getConflicts().hasConflictForMy(n));
     916        assertTrue(visitor.getConflicts().get(0).isMyDeleted());
     917
     918        Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION);
     919        assertEquals(3, r.getMembersCount());
     920
     921        assertFalse(r.isModified());
    925922    }
    926923
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r3025 r3034  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.conflict.Conflict;
    1415import org.openstreetmap.josm.data.coor.LatLon;
    1516import org.openstreetmap.josm.data.osm.DataSet;
    1617import org.openstreetmap.josm.data.osm.Node;
     18import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1719import org.openstreetmap.josm.data.osm.Relation;
    1820import org.openstreetmap.josm.data.osm.Way;
     
    4749    }
    4850
     51    private void populate(OsmPrimitive my, OsmPrimitive their) {
     52        model.populate(new Conflict<OsmPrimitive>(my, their));
     53    }
     54
    4955    @Test
    5056    public void populate() {
     
    5561        d1.addPrimitive(n1);
    5662        d2.addPrimitive(n2);
    57         model.populate(n1, n2);
     63        populate(n1, n2);
    5864
    5965        Way w1 = new Way(1);
     
    6167        d1.addPrimitive(w1);
    6268        d2.addPrimitive(w2);
    63         model.populate(w2, w2);
     69        populate(w2, w2);
    6470
    6571        Relation r1 = new Relation(1);
     
    6773        d1.addPrimitive(r1);
    6874        d2.addPrimitive(r2);
    69         model.populate(r1, r2);
     75        populate(r1, r2);
    7076    }
    7177
     
    7985        d1.addPrimitive(n1);
    8086        d2.addPrimitive(n2);
    81         model.populate(n1, n2);
     87        populate(n1, n2);
    8288        assertFalse(model.hasCoordConflict());
    8389
    8490        n1.setCoor(new LatLon(1,1));
    85         model.populate(n1, n2);
     91        populate(n1, n2);
    8692        assertTrue(model.hasCoordConflict());
    8793
     
    8995        n1.cloneFrom(new Node(1));
    9096        n2.setCoor(new LatLon(2,2));
    91         model.populate(n1, n2);
     97        populate(n1, n2);
    9298        assertTrue(model.hasCoordConflict());
    9399
    94100        n1.setCoor(new LatLon(1,1));
    95101        n2.setCoor(new LatLon(2,2));
    96         model.populate(n1, n2);
     102        populate(n1, n2);
    97103        assertTrue(model.hasCoordConflict());
    98104
Note: See TracChangeset for help on using the changeset viewer.