Ignore:
Timestamp:
2009-12-10T18:42:41+01:00 (14 years ago)
Author:
Gubaer
Message:

New: JOSM reading, writing, merging changeset attribute
fixed #4090: Add changeset:* search option to JOSM's search engine

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

Legend:

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

    r2598 r2604  
    1717public final class Changeset implements Tagged {
    1818    /** the changeset id */
    19     private long id;
     19    private int id;
    2020    /** the user who owns the changeset */
    2121    private User user;
     
    5050     * @param id the id
    5151     */
    52     public Changeset(long id) {
     52    public Changeset(int id) {
    5353        this.id = id;
    5454        this.incomplete = id > 0;
     
    9090
    9191    public int compareTo(Changeset other) {
    92         return Long.valueOf(getId()).compareTo(other.getId());
     92        return Integer.valueOf(getId()).compareTo(other.getId());
    9393    }
    9494
     
    102102    }
    103103
    104     public long getId() {
     104    public int getId() {
    105105        return id;
    106106    }
    107107
    108     public void setId(long id) {
     108    public void setId(int id) {
    109109        this.id = id;
    110110    }
     
    234234        final int prime = 31;
    235235        int result = 1;
    236         result = prime * result + (int) (id ^ (id >>> 32));
     236        result = prime * result + (id ^ (id >>> 32));
    237237        if (id > 0)
    238238            return prime * result + getClass().hashCode();
     
    306306        return id <= 0;
    307307    }
     308
     309    public void mergeFrom(Changeset other) {
     310        if (other == null)
     311            return;
     312        if (id != other.id)
     313            return;
     314        this.user = other.user;
     315        this.createdAt = other.createdAt;
     316        this.closedAt = other.closedAt;
     317        this.open  = other.open;
     318        this.min = other.min;
     319        this.max = other.max;
     320        this.tags.clear();
     321        this.tags.putAll(other.tags);
     322    }
    308323}
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r2603 r2604  
    238238
    239239    /**
     240     * The id of the changeset this primitive was last uploaded to.
     241     * 0 if it wasn't uploaded to a changeset yet of if the changeset
     242     * id isn't known.
     243     */
     244    private int changesetId;
     245
     246    /**
    240247     * Creates a new primitive for the given id. If the id > 0, the primitive is marked
    241248     * as incomplete.
     
    577584    public void setUser(User user) {
    578585        this.user = user;
     586    }
     587
     588
     589    /**
     590     * Replies the id of the changeset this primitive was last uploaded to.
     591     * 0 if this primitive wasn't uploaded to a changeset yet or if the
     592     * changeset isn't known.
     593     *
     594     * @return the id of the changeset this primitive was last uploaded to.
     595     */
     596    public int getChangesetId() {
     597        return changesetId;
     598    }
     599
     600
     601    /**
     602     * Sets the changeset id of this primitive. Can't be set on a new
     603     * primitive.
     604     *
     605     * @param changesetId the id. >= 0 required.
     606     * @throws IllegalStateException thrown if this primitive is new.
     607     * @throws IllegalArgumentException thrown if id < 0
     608     */
     609    public void setChangesetId(int changesetId) throws IllegalStateException, IllegalArgumentException {
     610        if (changesetId < 0)
     611            throw new IllegalArgumentException(tr("Parameter ''{0}'' >= 0 expected, got {1}", "changesetId", changesetId));
     612        if (isNew() && changesetId > 0)
     613            throw new IllegalStateException(tr("Can''t assign a changesetId > 0 to a new primitive. Value of changesetId is {0}", changesetId));
     614        this.changesetId = changesetId;
    579615    }
    580616
     
    916952     * use this only in the data initializing phase
    917953     */
    918     public void cloneFrom(OsmPrimitive osm) {
    919         setKeys(osm.getKeys());
    920         id = osm.id;
    921         timestamp = osm.timestamp;
    922         version = osm.version;
    923         setIncomplete(osm.isIncomplete());
    924         flags = osm.flags;
    925         user= osm.user;
     954    public void cloneFrom(OsmPrimitive other) {
     955        setKeys(other.getKeys());
     956        id = other.id;
     957        timestamp = other.timestamp;
     958        version = other.version;
     959        setIncomplete(other.isIncomplete());
     960        flags = other.flags;
     961        user= other.user;
     962        changesetId = other.changesetId;
    926963        clearCached();
    927964    }
     
    951988        flags = other.flags;
    952989        user= other.user;
     990        changesetId = other.changesetId;
    953991    }
    954992
     
    10001038        && version == other.version
    10011039        && isVisible() == other.isVisible()
    1002         && (user == null ? other.user==null : user==other.user);
     1040        && (user == null ? other.user==null : user==other.user)
     1041        && changesetId == other.changesetId;
    10031042    }
    10041043
     
    10981137        timestamp = data.getTimestamp();
    10991138        user = data.getUser();
     1139        changesetId = data.getChangesetId();
    11001140        setDeleted(data.isDeleted());
    11011141        setModified(data.isModified());
     
    11181158        data.setModified(isModified());
    11191159        data.setVisible(isVisible());
     1160        data.setChangesetId(changesetId);
    11201161    }
    11211162
  • trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java

    r2598 r2604  
    4646    private int version;
    4747    private int timestamp;
     48    private int changesetId;
    4849
    4950    public boolean isModified() {
     
    8990        this.timestamp = timestamp;
    9091    }
     92
     93    public int getChangesetId() {
     94        return changesetId;
     95    }
     96
     97    public void setChangesetId(int changesetId) {
     98        this.changesetId = changesetId;
     99    }
     100
    91101    public Map<String, String> getKeys() {
    92102        return keys;
Note: See TracChangeset for help on using the changeset viewer.