Search in sources :

Example 1 with OpenChangesetInfo

use of de.westnordost.streetcomplete.data.changesets.OpenChangesetInfo in project StreetComplete by westnordost.

the class AOsmQuestChangesUpload method closeOpenChangesets.

public synchronized void closeOpenChangesets() {
    long timePassed = System.currentTimeMillis() - openChangesetsDB.getLastQuestSolvedTime();
    if (timePassed < OpenChangesetsDao.CLOSE_CHANGESETS_AFTER_INACTIVITY_OF)
        return;
    for (OpenChangesetInfo info : openChangesetsDB.getAll()) {
        try {
            osmDao.closeChangeset(info.changesetId);
            Log.i(TAG, "Closed changeset #" + info.changesetId + ".");
        } catch (OsmConflictException e) {
            Log.w(TAG, "Couldn't close changeset #" + info.changesetId + " because it has already been closed.");
        } finally {
            // done!
            openChangesetsDB.delete(info.key);
        }
    }
}
Also used : OsmConflictException(de.westnordost.osmapi.common.errors.OsmConflictException) OpenChangesetInfo(de.westnordost.streetcomplete.data.changesets.OpenChangesetInfo)

Example 2 with OpenChangesetInfo

use of de.westnordost.streetcomplete.data.changesets.OpenChangesetInfo in project StreetComplete by westnordost.

the class AOsmQuestChangesUpload method getChangesetIdOrCreate.

private long getChangesetIdOrCreate(OsmElementQuestType questType, String source) {
    String questTypeName = questType.getClass().getSimpleName();
    OpenChangesetKey key = new OpenChangesetKey(questTypeName, source);
    Long cachedChangesetId = changesetIdsCache.get(key);
    if (cachedChangesetId != null)
        return cachedChangesetId;
    OpenChangesetInfo changesetInfo = openChangesetsDB.get(key);
    long result;
    if (changesetInfo != null && changesetInfo.changesetId != null) {
        result = changesetInfo.changesetId;
    } else {
        result = createChangeset(questType, source);
    }
    changesetIdsCache.put(key, result);
    return result;
}
Also used : OpenChangesetKey(de.westnordost.streetcomplete.data.changesets.OpenChangesetKey) OpenChangesetInfo(de.westnordost.streetcomplete.data.changesets.OpenChangesetInfo)

Aggregations

OpenChangesetInfo (de.westnordost.streetcomplete.data.changesets.OpenChangesetInfo)2 OsmConflictException (de.westnordost.osmapi.common.errors.OsmConflictException)1 OpenChangesetKey (de.westnordost.streetcomplete.data.changesets.OpenChangesetKey)1