Ignore:
Timestamp:
2009-09-07T23:06:19+02:00 (15 years ago)
Author:
Gubaer
Message:

Had to replace DataSet:getPrimitiveById(id) with DataSet:getPrimitiveById(id,type). Primitive ids are not globally unique, only per type of primitive.
Fixed problems in unit test, available unit tests passing again.

File:
1 edited

Legend:

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

    r2074 r2077  
    4141import org.openstreetmap.josm.data.osm.DataSet;
    4242import org.openstreetmap.josm.data.osm.OsmPrimitive;
     43import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    4344import org.openstreetmap.josm.gui.ExceptionDialogUtil;
    4445import org.openstreetmap.josm.gui.ExtendedDialog;
     
    191192     * @param id the primitive ID
    192193     */
    193     protected void synchronizePrimitive(final String id) {
    194         Main.worker.execute(new UpdatePrimitiveTask(Long.parseLong(id)));
     194    protected void synchronizePrimitive(final OsmPrimitiveType type, final long id) {
     195        Main.worker.execute(new UpdatePrimitiveTask(type, id));
    195196    }
    196197
     
    217218     * @param myVersion  the version of the primitive in the local dataset
    218219     */
    219     protected void handleUploadConflictForKnownConflict(String primitiveType, String id, String serverVersion, String myVersion) {
     220    protected void handleUploadConflictForKnownConflict(OsmPrimitiveType primitiveType, long id, String serverVersion, String myVersion) {
    220221        Object[] options = new Object[] {
    221                 tr("Synchronize {0} {1} only", tr(primitiveType), id),
     222                tr("Synchronize {0} {1} only", tr(primitiveType.getAPIName()), id),
    222223                tr("Synchronize entire dataset"),
    223224                tr("Cancel")
     
    232233                + "Click <strong>{5}</strong> to synchronize the entire local dataset with the server.<br>"
    233234                + "Click <strong>{6}</strong> to abort and continue editing.<br></html>",
    234                 tr(primitiveType), id, serverVersion, myVersion,
     235                tr(primitiveType.getAPIName()), id, serverVersion, myVersion,
    235236                options[0], options[1], options[2]
    236237        );
     
    247248        );
    248249        switch(ret) {
    249             case JOptionPane.CLOSED_OPTION: return;
    250             case JOptionPane.CANCEL_OPTION: return;
    251             case 0: synchronizePrimitive(id); break;
    252             case 1: synchronizeDataSet(); break;
    253             default:
    254                 // should not happen
    255                 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));
     250        case JOptionPane.CLOSED_OPTION: return;
     251        case JOptionPane.CANCEL_OPTION: return;
     252        case 0: synchronizePrimitive(primitiveType, id); break;
     253        case 1: synchronizeDataSet(); break;
     254        default:
     255            // should not happen
     256            throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));
    256257        }
    257258    }
     
    287288        );
    288289        switch(ret) {
    289             case JOptionPane.CLOSED_OPTION: return;
    290             case 1: return;
    291             case 0: synchronizeDataSet(); break;
    292             default:
    293                 // should not happen
    294                 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));
     290        case JOptionPane.CLOSED_OPTION: return;
     291        case 1: return;
     292        case 0: synchronizeDataSet(); break;
     293        default:
     294            // should not happen
     295            throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));
    295296        }
    296297    }
     
    306307        Matcher m = p.matcher(e.getErrorHeader());
    307308        if (m.matches()) {
    308             handleUploadConflictForKnownConflict(m.group(3), m.group(4), m.group(2),m.group(1));
     309            handleUploadConflictForKnownConflict(OsmPrimitiveType.from(m.group(3)), Long.parseLong(m.group(4)), m.group(2),m.group(1));
    309310        } else {
    310311            logger.warning(tr("Warning: error header \"{0}\" did not match expected pattern \"{1}\"", e.getErrorHeader(),pattern));
     
    326327     * @see UpdateSelectionAction#handlePrimitiveGoneException(long)
    327328     */
    328     protected void handleGoneForKnownPrimitive(String primitiveType, String id) {
     329    protected void handleGoneForKnownPrimitive(OsmPrimitiveType primitiveType, String id) {
    329330        UpdateSelectionAction act = new UpdateSelectionAction();
    330         act.handlePrimitiveGoneException(Long.parseLong(id));
     331        act.handlePrimitiveGoneException(Long.parseLong(id),primitiveType);
    331332    }
    332333
     
    344345        Matcher m = p.matcher(e.getErrorHeader());
    345346        if (m.matches()) {
    346             handleGoneForKnownPrimitive(m.group(1), m.group(2));
     347            handleGoneForKnownPrimitive(OsmPrimitiveType.from(m.group(1)), m.group(2));
    347348        } else {
    348349            logger.warning(tr("Error header \"{0}\" does not match expected pattern \"{1}\"",e.getErrorHeader(), pattern));
     
    424425        private Exception lastException = null;
    425426        private long id;
    426 
    427         public UpdatePrimitiveTask(long id) {
     427        private OsmPrimitiveType type;
     428
     429        public UpdatePrimitiveTask(OsmPrimitiveType type, long id) {
    428430            super(tr("Updating primitive"),false /* don't ignore exceptions */);
    429431            this.id = id;
     432            this.type = type;
    430433        }
    431434
     
    433436            try {
    434437                UpdateSelectionAction act = new UpdateSelectionAction();
    435                 act.updatePrimitive(id);
     438                act.updatePrimitive(type, id);
    436439            } catch (Exception sxe) {
    437440                if (uploadCancelled) {
Note: See TracChangeset for help on using the changeset viewer.