Search in sources :

Example 1 with SyncNewNodeErrorEvent

use of io.jawg.osmcontributor.rest.events.error.SyncNewNodeErrorEvent in project osm-contributor by jawg.

the class SyncManager method remoteAddPoi.

/**
 * Add a Poi to the backend.
 *
 * @param poi         The Poi to add to the backend.
 * @param changeSetId The changeSet in which the Poi is sent.
 * @return Whether the addition was a success or not.
 */
private boolean remoteAddPoi(final Poi poi, String changeSetId) {
    Backend.CreationResult creationResult = backend.addPoi(poi, changeSetId);
    switch(creationResult.getStatus()) {
        case SUCCESS:
            poi.setBackendId(creationResult.getBackendId());
            poi.setUpdated(false);
            poiManager.savePoi(poi);
            OsmAnswers.remotePoiAction(poi.getType().getTechnicalName(), "add");
            return true;
        case FAILURE_UNKNOWN:
        default:
            poiManager.deletePoi(poi);
            bus.post(new SyncNewNodeErrorEvent(poi.getName(), poi.getId()));
            return false;
    }
}
Also used : Backend(io.jawg.osmcontributor.rest.Backend) SyncNewNodeErrorEvent(io.jawg.osmcontributor.rest.events.error.SyncNewNodeErrorEvent)

Aggregations

Backend (io.jawg.osmcontributor.rest.Backend)1 SyncNewNodeErrorEvent (io.jawg.osmcontributor.rest.events.error.SyncNewNodeErrorEvent)1