Ignore:
Timestamp:
2009-06-23T22:03:37+02:00 (17 years ago)
Author:
Gubaer
Message:

new: MultiFetchServerObjectReader using APIs Multi Fetch method
update: now uses Multi Fetch to check for deleted primitives on the server
update: now uses Multi Fetch to update the selected primitives with the state from the server
fixed: cleaned up merging in MergeVisitor
new: conflict resolution dialog; now resolves conflicts due to different visibilities
new: replacement for realEqual() on OsmPrimitive and derived classes; realEqual now @deprecated
fixed: cleaning up OsmReader
fixed: progress indication in OsmApi

File:
1 edited

Legend:

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

    r1530 r1690  
    4343    public void putError(String text, Boolean isError)
    4444    {
    45         if(errors == null)
     45        if(errors == null) {
    4646            errors = new ArrayList<String>();
     47        }
    4748        String s = isError ? tr("Error: {0}", text) : tr("Warning: {0}", text);
    4849        errors.add(s);
     
    9192     * Visibility status as specified by the server. The visible attribute was
    9293     * introduced with the 0.4 API to be able to communicate deleted objects
    93      * (they will have visible=false). Currently JOSM does never deal with
    94      * these, so this is really for future use only.
     94     * (they will have visible=false).
    9595     */
    9696    public boolean visible = true;
     
    195195    @Override public boolean equals(Object obj) {
    196196        if (id == 0) return obj == this;
    197         if (obj instanceof OsmPrimitive) { // not null too
     197        if (obj instanceof OsmPrimitive)
    198198            return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass();
    199         }
    200199        return false;
    201200    }
     
    226225     */
    227226    public final void put(String key, String value) {
    228         if (value == null)
     227        if (value == null) {
    229228            remove(key);
    230         else {
    231             if (keys == null)
     229        } else {
     230            if (keys == null) {
    232231                keys = new HashMap<String, String>();
     232            }
    233233            keys.put(key, value);
    234234        }
     
    241241        if (keys != null) {
    242242            keys.remove(key);
    243             if (keys.isEmpty())
     243            if (keys.isEmpty()) {
    244244                keys = null;
     245            }
    245246        }
    246247        mappaintStyle = null;
     
    280281        version = osm.version;
    281282        incomplete = osm.incomplete;
     283        visible = osm.visible;
    282284        clearCached();
    283285        clearErrors();
     
    288290     * but for the whole object (for conflict resolving)
    289291     * @param semanticOnly if <code>true</code>, modified flag and timestamp are not compared
    290      */
     292     *
     293     * @deprecated
     294     * @see #hasEqualSemanticAttributes(OsmPrimitive)
     295     * @see #hasEqualTechnicalAttributes(OsmPrimitive)
     296     */
     297    @Deprecated
    291298    public boolean realEqual(OsmPrimitive osm, boolean semanticOnly) {
    292299        return id == osm.id
    293300        && incomplete == osm.incomplete
    294301        && deleted == osm.deleted
    295         && (semanticOnly || (modified == osm.modified
    296          && timestamp == osm.timestamp
    297          && version == osm.version
    298          && visible == osm.visible
    299          && (user == null ? osm.user==null : user==osm.user)))
     302        && (semanticOnly || (
     303                modified == osm.modified
     304                && timestamp == osm.timestamp
     305                && version == osm.version
     306                && visible == osm.visible
     307                && (user == null ? osm.user==null : user==osm.user))
     308        )
    300309        && (keys == null ? osm.keys==null : keys.equals(osm.keys));
     310    }
     311
     312    /**
     313     * Replies true if this primitive and other are equal with respect to their
     314     * semantic attributes.
     315     * <ol>
     316     *   <li>equal id</ol>
     317     *   <li>both are complete or both are incomplete</li>
     318     *   <li>both have the same tags</li>
     319     * </ol>
     320     * @param other
     321     * @return true if this primitive and other are equal with respect to their
     322     * semantic attributes.
     323     */
     324    public boolean hasEqualSemanticAttributes(OsmPrimitive other) {
     325        if (id != other.id)
     326            return false;
     327        if (incomplete && ! other.incomplete || !incomplete  && other.incomplete)
     328            return false;
     329        return (keys == null ? other.keys==null : keys.equals(other.keys));
     330    }
     331
     332    /**
     333     * Replies true if this primitive and other are equal with respect to their
     334     * technical attributes. The attributes:
     335     * <ol>
     336     *   <li>deleted</ol>
     337     *   <li>modified</ol>
     338     *   <li>timestamp</ol>
     339     *   <li>version</ol>
     340     *   <li>visible</ol>
     341     *   <li>user</ol>
     342     * </ol>
     343     * have to be equal
     344     * @param other the other primitive
     345     * @return true if this primitive and other are equal with respect to their
     346     * technical attributes
     347     */
     348    public boolean hasEqualTechnicalAttributes(OsmPrimitive other) {
     349        if (other == null) return false;
     350
     351        return
     352        deleted == other.deleted
     353        && modified == other.modified
     354        && timestamp == other.timestamp
     355        && version == other.version
     356        && visible == other.visible
     357        && (user == null ? other.user==null : user==other.user);
    301358    }
    302359
     
    312369        if (keys != null) {
    313370            for (Entry<String,String> e : keys.entrySet()) {
    314                 if (!uninteresting.contains(e.getKey())) {
     371                if (!uninteresting.contains(e.getKey()))
    315372                    return true;
    316                 }
    317373            }
    318374        }
     
    327383        if (keys != null) {
    328384            for (Entry<String,String> e : keys.entrySet()) {
    329                 if (directionKeys.contains(e.getKey())) {
     385                if (directionKeys.contains(e.getKey()))
    330386                    return true;
    331                 }
    332387            }
    333388        }
Note: See TracChangeset for help on using the changeset viewer.