Ignore:
Timestamp:
2012-08-13T02:37:03+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7716 - History shows same version number, wrong date, user, and CT for modified objects

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

Legend:

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

    r5346 r5440  
    1515 */
    1616public class HistoryNode extends HistoryOsmPrimitive {
     17   
    1718    /** the coordinates. May be null for deleted nodes */
    18 
    1919    private LatLon coords;
    2020
    21     public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords) {
    22         super(id, version, visible, user, changesetId, timestamp);
     21    /**
     22     * Constructs a new {@code HistoryNode}.
     23     *
     24     * @param id the id (> 0 required)
     25     * @param version the version (> 0 required)
     26     * @param visible whether the node is still visible
     27     * @param user the user (! null required)
     28     * @param changesetId the changeset id (> 0 required)
     29     * @param timestamp the timestamp (! null required)
     30     * @param coords the coordinates
     31     * @throws IllegalArgumentException if preconditions are violated
     32     */
     33    public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords) throws IllegalArgumentException {
     34        this(id, version, visible, user, changesetId, timestamp, coords, true);
     35    }
     36
     37    /**
     38     * Constructs a new {@code HistoryNode} with a configurable checking of historic parameters.
     39     * This is needed to build virtual HistoryNodes for modified nodes, which do not have a timestamp and a changeset id.
     40     *
     41     * @param id the id (> 0 required)
     42     * @param version the version (> 0 required)
     43     * @param visible whether the node is still visible
     44     * @param user the user (! null required)
     45     * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
     46     * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
     47     * @param coords the coordinates
     48     * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp}
     49     * @throws IllegalArgumentException if preconditions are violated
     50     * @since 5440
     51     */
     52    public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords, boolean checkHistoricParams) throws IllegalArgumentException {
     53        super(id, version, visible, user, changesetId, timestamp, checkHistoricParams);
    2354        setCoords(coords);
    2455    }
    2556
    26     public HistoryNode(Node p) {
    27         super(p);
    28         setCoords(p.getCoor());
     57    /**
     58     * Constructs a new {@code HistoryNode} from an existing {@link Node}.
     59     * @param n the node
     60     */
     61    public HistoryNode(Node n) {
     62        super(n);
     63        setCoords(n.getCoor());
    2964    }
    3065
     
    3469    }
    3570
     71    /**
     72     * Replies the coordinates. May be null.
     73     * @return the coordinates. May be null.
     74     */
    3675    public LatLon getCoords() {
    3776        return coords;
    3877    }
    3978
     79    /**
     80     * Sets the coordinates. Can be null.
     81     * @param coords the coordinates. Can be null.
     82     */
    4083    public void setCoords(LatLon coords) {
    4184        this.coords = coords;
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java

    r5339 r5440  
    4242
    4343    /**
    44      * constructor
    45      *
    46      * @param id the id (>0 required)
     44     * Constructs a new {@code HistoryOsmPrimitive}.
     45     *
     46     * @param id the id (> 0 required)
    4747     * @param version the version (> 0 required)
    4848     * @param visible whether the primitive is still visible
    49      * @param user  the user (! null required)
    50      * @param uid the user id (> 0 required)
    51      * @param changesetId the changeset id (may be null if the changeset isn't known)
     49     * @param user the user (! null required)
     50     * @param changesetId the changeset id (> 0 required)
    5251     * @param timestamp the timestamp (! null required)
    5352     *
    54      * @throws IllegalArgumentException thrown if preconditions are violated
     53     * @throws IllegalArgumentException if preconditions are violated
    5554     */
    5655    public HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException {
     56        this(id, version, visible, user, changesetId, timestamp, true);
     57    }
     58
     59    /**
     60     * Constructs a new {@code HistoryOsmPrimitive} with a configurable checking of historic parameters.
     61     * This is needed to build virtual HistoryOsmPrimitives for modified primitives, which do not have a timestamp and a changeset id.
     62     *
     63     * @param id the id (> 0 required)
     64     * @param version the version (> 0 required)
     65     * @param visible whether the primitive is still visible
     66     * @param user the user (! null required)
     67     * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
     68     * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
     69     * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp}
     70     *
     71     * @throws IllegalArgumentException if preconditions are violated
     72     * @since 5440
     73     */
     74    public HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Date timestamp, boolean checkHistoricParams) throws IllegalArgumentException {
    5775        ensurePositiveLong(id, "id");
    5876        ensurePositiveLong(version, "version");
    5977        CheckParameterUtil.ensureParameterNotNull(user, "user");
    60         CheckParameterUtil.ensureParameterNotNull(timestamp, "timestamp");
     78        if (checkHistoricParams) {
     79            ensurePositiveLong(changesetId, "changesetId");
     80            CheckParameterUtil.ensureParameterNotNull(timestamp, "timestamp");
     81        }
    6182        this.id = id;
    6283        this.version = version;
    6384        this.visible = visible;
    6485        this.user = user;
    65         // FIXME: restrict to IDs > 0 as soon as OsmPrimitive holds the
    66         // changeset id too
    6786        this.changesetId  = changesetId;
    6887        this.timestamp = timestamp;
    6988        tags = new HashMap<String, String>();
    7089    }
    71 
     90   
     91    /**
     92     * Constructs a new {@code HistoryOsmPrimitive} from an existing {@link OsmPrimitive}.
     93     * @param p the primitive
     94     */
    7295    public HistoryOsmPrimitive(OsmPrimitive p) {
    73         this(p.getId(), p.getVersion(), p.isVisible(),
    74                 p.getUser(),
    75                 p.getChangesetId(), p.getTimestamp());
    76     }
    77 
     96        this(p.getId(), p.getVersion(), p.isVisible(), p.getUser(), p.getChangesetId(), p.getTimestamp());
     97    }
     98
     99    /**
     100     * Replies a new {@link HistoryNode}, {@link HistoryWay} or {@link HistoryRelation} from an existing {@link OsmPrimitive}.
     101     * @param p the primitive
     102     * @return a new {@code HistoryNode}, {@code HistoryWay} or {@code HistoryRelation} from {@code p}.
     103     */
    78104    public static HistoryOsmPrimitive forOsmPrimitive(OsmPrimitive p) {
    79105        if (p instanceof Node) {
     
    173199    /**
    174200     * Replies the display name of a primitive formatted by <code>formatter</code>
     201     * @param formatter The formatter used to generate a display name
    175202     *
    176203     * @return the display name
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java

    r5266 r5440  
    3030     * @param visible whether the primitive is still visible
    3131     * @param user  the user (! null required)
    32      * @param uid the user id (> 0 required)
    3332     * @param changesetId the changeset id (> 0 required)
    3433     * @param timestamp the timestamp (! null required)
    3534     *
    36      * @throws IllegalArgumentException thrown if preconditions are violated
     35     * @throws IllegalArgumentException if preconditions are violated
    3736     */
    38     public HistoryRelation(long id, long version, boolean visible, User user, long changesetId,
    39             Date timestamp) throws IllegalArgumentException {
     37    public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException {
    4038        super(id, version, visible, user, changesetId, timestamp);
    4139    }
     40
    4241    /**
    4342     * constructor
     
    4746     * @param visible whether the primitive is still visible
    4847     * @param user  the user (! null required)
    49      * @param uid the user id (> 0 required)
     48     * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
     49     * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
     50     * @param checkHistoricParams If true, checks values of {@code changesetId} and {@code timestamp}
     51     *
     52     * @throws IllegalArgumentException if preconditions are violated
     53     * @since 5440
     54     */
     55    public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Date timestamp, boolean checkHistoricParams) throws IllegalArgumentException {
     56        super(id, version, visible, user, changesetId, timestamp, checkHistoricParams);
     57    }
     58
     59    /**
     60     * constructor
     61     *
     62     * @param id the id (>0 required)
     63     * @param version the version (> 0 required)
     64     * @param visible whether the primitive is still visible
     65     * @param user  the user (! null required)
    5066     * @param changesetId the changeset id (> 0 required)
    5167     * @param timestamp the timestamp (! null required)
     
    6278    }
    6379
    64     public HistoryRelation(Relation p) {
    65         super(p);
     80    /**
     81     * Constructs a new {@code HistoryRelation} from an existing {@link Relation}.
     82     * @param r the relation
     83     */
     84    public HistoryRelation(Relation r) {
     85        super(r);
    6686    }
    6787
  • trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java

    r5266 r5440  
    1212import org.openstreetmap.josm.data.osm.User;
    1313import org.openstreetmap.josm.data.osm.Way;
     14import org.openstreetmap.josm.tools.CheckParameterUtil;
    1415
    1516/**
     
    2223    private ArrayList<Long> nodeIds = new ArrayList<Long>();
    2324
    24     public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp) {
     25    /**
     26     * Constructs a new {@code HistoryWay}.
     27     *
     28     * @param id the id (> 0 required)
     29     * @param version the version (> 0 required)
     30     * @param visible whether the node is still visible
     31     * @param user the user (! null required)
     32     * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
     33     * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
     34     * @throws IllegalArgumentException if preconditions are violated
     35     */
     36    public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException {
    2537        super(id, version, visible, user, changesetId, timestamp);
    2638    }
    2739
    28     public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) {
     40    /**
     41     * Constructs a new {@code HistoryWay} with a configurable checking of historic parameters.
     42     * This is needed to build virtual HistoryWays for modified ways, which do not have a timestamp and a changeset id.
     43     *
     44     * @param id the id (> 0 required)
     45     * @param version the version (> 0 required)
     46     * @param visible whether the node is still visible
     47     * @param user the user (! null required)
     48     * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
     49     * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
     50     * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp}
     51     * @throws IllegalArgumentException if preconditions are violated
     52     * @since 5440
     53     */
     54    public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, boolean checkHistoricParams) throws IllegalArgumentException {
     55        super(id, version, visible, user, changesetId, timestamp, checkHistoricParams);
     56    }
     57
     58    /**
     59     * Constructs a new {@code HistoryWay} with a given list of node ids.
     60     *
     61     * @param id the id (> 0 required)
     62     * @param version the version (> 0 required)
     63     * @param visible whether the node is still visible
     64     * @param user the user (! null required)
     65     * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true)
     66     * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true)
     67     * @param nodeIdList the node ids (! null required)
     68     * @throws IllegalArgumentException if preconditions are violated
     69     */
     70    public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) throws IllegalArgumentException {
    2971        this(id, version, visible, user, changesetId, timestamp);
     72        CheckParameterUtil.ensureParameterNotNull(nodeIdList, "nodeIdList");
    3073        this.nodeIds.addAll(nodeIdList);
    3174    }
    3275
    33     public HistoryWay(Way p) {
    34         super(p);
     76    /**
     77     * Constructs a new {@code HistoryWay} from an existing {@link Way}.
     78     * @param w the way
     79     */
     80    public HistoryWay(Way w) {
     81        super(w);
    3582    }
    3683
Note: See TracChangeset for help on using the changeset viewer.