Ignore:
Timestamp:
2023-09-07T16:52:05+02:00 (15 months ago)
Author:
taylor.smock
Message:

Fix some potential DataIntegrityProblemException sources

This also fixes some lint issues.

merge-overlap: See #19627
reltoolbox: See #23074, #23077, #23123

Location:
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java

    r36102 r36132  
    174174                                candidateWay = tmp;
    175175                            }
    176                             commands.add(new DeleteCommand(w));
     176                            commands.add(DeleteCommand.delete(Collections.singleton(w)));
    177177                        }
    178178                    }
     
    204204    }
    205205
    206     private boolean isSuitableRelation(Relation newRelation) {
     206    private static boolean isSuitableRelation(Relation newRelation) {
    207207        return newRelation != null && "multipolygon".equals(newRelation.get("type")) && newRelation.getMembersCount() != 0;
    208208    }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java

    r36102 r36132  
    66import java.util.ArrayList;
    77import java.util.Collection;
     8import java.util.Collections;
    89import java.util.HashMap;
    910import java.util.List;
     
    3940    private final Way source;
    4041    private final List<RingSegment> segments;
    41     private Relation relation = null;
     42    private Relation relation;
    4243
    4344    public TheRing(Way source) {
     
    212213    }
    213214
    214     private boolean areSegmentsEqual(RingSegment seg1, RingSegment seg2) {
     215    private static boolean areSegmentsEqual(RingSegment seg1, RingSegment seg2) {
    215216        List<Node> nodes1 = seg1.getNodes();
    216217        List<Node> nodes2 = seg2.getNodes();
     
    262263     * Tries to arrange segments in order for each ring to have at least one.
    263264     * Also, sets source way for all rings.
    264      *
     265     * <p>
    265266     * If this method is not called, do not forget to call {@link #putSourceWayFirst()} for all rings.
    266267     */
     
    338339                    continue;
    339340                }
    340                 if (key.equals("natural") && sourceCopy.get("natural").equals("coastline")) {
     341                if ("natural".equals(key) && "coastline".equals(sourceCopy.get("natural"))) {
    341342                    continue;
    342343                }
     
    387388                foundOwnWay = true;
    388389            } else {
    389                 for (Relation rel : referencingRelations.keySet()) {
    390                     int relIndex = referencingRelations.get(rel);
     390                for (Map.Entry<Relation, Integer> entry : referencingRelations.entrySet()) {
     391                    Relation rel = entry.getKey();
     392                    int relIndex = entry.getValue();
    391393                    rel.addMember(new RelationMember(rel.getMember(relIndex).getRole(), w));
    392394                }
     
    397399        }
    398400        if (!foundOwnWay) {
    399             commands.add(new DeleteCommand(source));
     401            commands.add(DeleteCommand.delete(Collections.singleton(source)));
    400402        }
    401403        commands.addAll(relationCommands);
     
    407409
    408410    public static void updateCommandsWithRelations(List<Command> commands, Map<Relation, Relation> relationCache) {
    409         for (Relation src : relationCache.keySet()) {
    410             commands.add(new ChangeCommand(src, relationCache.get(src)));
     411        for (Map.Entry<Relation, Relation> entry : relationCache.entrySet()) {
     412            commands.add(new ChangeCommand(entry.getKey(), entry.getValue()));
    411413        }
    412414    }
     
    441443        private List<Node> nodes;
    442444        private RingSegment references;
    443         private Way resultingWay = null;
    444         private boolean wasTemplateApplied = false;
     445        private Way resultingWay;
     446        private boolean wasTemplateApplied;
    445447        private boolean isRing;
    446448
Note: See TracChangeset for help on using the changeset viewer.