Changeset 2963 in josm for trunk


Ignore:
Timestamp:
2010-02-10T21:51:28+01:00 (10 years ago)
Author:
jttt
Message:

Throw DatasetIntegrityException when somebody is trying to add node/member from different dataset

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r2932 r2963  
    240240        this(id, allowNegativeId);
    241241        this.version = (id > 0 ? version : 0);
     242        setIncomplete(id > 0 && version == 0);
    242243    }
    243244
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r2932 r2963  
    345345
    346346    private void fireMembersChanged() {
    347         if (getDataSet() != null) {
    348             getDataSet().fireRelationMembersChanged(this);
     347        DataSet dataSet = getDataSet();
     348        if (dataSet != null) {
     349            for (RelationMember rm: members) {
     350                if (rm.getMember().getDataSet() != dataSet)
     351                    throw new DataIntegrityProblemException("Relation member must be part of the same dataset as relation");
     352            }
     353            dataSet.fireRelationMembersChanged(this);
    349354        }
    350355    }
  • trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java

    r2598 r2963  
    5151        return true;
    5252    }
     53
     54    @Override
     55    public String toString() {
     56        return type + " " + id;
     57    }
    5358}
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r2932 r2963  
    365365
    366366    private void fireNodesChanged() {
    367         if (getDataSet() != null) {
     367        DataSet dataSet = getDataSet();
     368        if (dataSet != null) {
     369            for (Node n: nodes) {
     370                if (n.getDataSet() != dataSet)
     371                    throw new DataIntegrityProblemException("Nodes in way must be in the same dataset");
     372            }
    368373            getDataSet().fireWayNodesChanged(this);
    369374        }
Note: See TracChangeset for help on using the changeset viewer.