Ignore:
Timestamp:
2021-04-11T21:56:50+02:00 (4 years ago)
Author:
simon04
Message:

see #14176 - Migrate OsmPrimitive to Instant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java

    r16453 r17749  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.time.Instant;
    67import java.util.Arrays;
    78import java.util.Date;
     
    112113                // A changeset does not contain all referred primitives, this is the map of incomplete ones
    113114                // For each incomplete primitive, we'll have to get its state at date it was referred
    114                 Map<OsmPrimitive, Date> toLoad = new HashMap<>();
     115                Map<OsmPrimitive, Instant> toLoad = new HashMap<>();
    115116                for (OsmPrimitive p : downloadedData.allNonDeletedPrimitives()) {
    116117                    if (p.isIncomplete()) {
    117                         Date timestamp = p.getReferrers().stream()
     118                        Instant timestamp = p.getReferrers().stream()
    118119                                .filter(ref -> !ref.isTimestampEmpty())
    119120                                .findFirst()
    120                                 .map(AbstractPrimitive::getTimestamp)
     121                                .map(AbstractPrimitive::getInstant)
    121122                                .orElse(null);
    122123                        toLoad.put(p, timestamp);
     
    138139    private static final class HistoryLoaderAndListener extends HistoryLoadTask implements HistoryDataSetListener {
    139140
    140         private final Map<OsmPrimitive, Date> toLoad;
    141 
    142         private HistoryLoaderAndListener(Map<OsmPrimitive, Date> toLoad) {
     141        private final Map<OsmPrimitive, Instant> toLoad;
     142
     143        private HistoryLoaderAndListener(Map<OsmPrimitive, Instant> toLoad) {
    143144            this.toLoad = toLoad;
    144145            this.setChangesetDataNeeded(false);
     
    150151        @Override
    151152        public void historyUpdated(HistoryDataSet source, PrimitiveId id) {
    152             Map<OsmPrimitive, Date> toLoadNext = new HashMap<>();
    153             for (Iterator<Entry<OsmPrimitive, Date>> it = toLoad.entrySet().iterator(); it.hasNext();) {
    154                 Entry<OsmPrimitive, Date> entry = it.next();
     153            Map<OsmPrimitive, Instant> toLoadNext = new HashMap<>();
     154            for (Iterator<Entry<OsmPrimitive, Instant>> it = toLoad.entrySet().iterator(); it.hasNext();) {
     155                Entry<OsmPrimitive, Instant> entry = it.next();
    155156                OsmPrimitive p = entry.getKey();
    156157                History history = source.getHistory(p.getPrimitiveId());
    157                 Date date = entry.getValue();
     158                Instant date = entry.getValue();
    158159                // If the history has been loaded and a timestamp is known
    159160                if (history != null && date != null) {
    160161                    // Lookup for the primitive version at the specified timestamp
    161                     HistoryOsmPrimitive hp = history.getByDate(date);
     162                    HistoryOsmPrimitive hp = history.getByDate(Date.from(date));
    162163                    if (hp != null) {
    163164                        PrimitiveData data;
Note: See TracChangeset for help on using the changeset viewer.