use of de.westnordost.streetcomplete.data.changesets.OpenChangesetKey in project StreetComplete by westnordost.
the class OsmQuestChangesUploadTest method doTestHandleChangesetConflict.
private void doTestHandleChangesetConflict(ChangesetsDao changesetsDao, long userId, long firstChangesetId, long secondChangesetId) {
OsmQuest quest = createAnsweredQuestWithAppliableChange();
Element element = createElement();
MergedElementDao elementDb = mock(MergedElementDao.class);
OsmQuestDao questDb = mock(OsmQuestDao.class);
DownloadedTilesDao downloadedTilesDao = mock(DownloadedTilesDao.class);
OpenChangesetsDao manageChangesetsDb = mock(OpenChangesetsDao.class);
MapDataDao mapDataDao = createMapDataDaoThatReportsConflictOnUploadAndNodeDeleted();
when(mapDataDao.openChangeset(any(Map.class))).thenReturn(secondChangesetId);
SharedPreferences prefs = createPreferencesForUser(userId);
OsmQuestChangesUpload u = new OsmQuestChangesUpload(mapDataDao, questDb, elementDb, null, null, manageChangesetsDb, changesetsDao, downloadedTilesDao, prefs, null);
assertFalse(u.uploadQuestChange(firstChangesetId, quest, element, false, false));
verify(manageChangesetsDb).replace(new OpenChangesetKey("TestQuestType", "test case"), secondChangesetId);
verify(questDb).delete(quest.getId());
verify(elementDb).delete(Element.Type.NODE, A_NODE_ID);
verify(downloadedTilesDao).remove(any(Point.class));
}
use of de.westnordost.streetcomplete.data.changesets.OpenChangesetKey in project StreetComplete by westnordost.
the class AOsmQuestChangesUpload method handleChangesetConflict.
private boolean handleChangesetConflict(OsmQuest quest, Element element, boolean alreadyHandlingElementConflict) {
OsmElementQuestType questType = quest.getOsmElementQuestType();
long changesetId = createChangeset(questType, quest.getChangesSource());
OpenChangesetKey key = new OpenChangesetKey(questType.getClass().getSimpleName(), quest.getChangesSource());
changesetIdsCache.put(key, changesetId);
return uploadQuestChange(changesetId, quest, element, alreadyHandlingElementConflict, true);
}
use of de.westnordost.streetcomplete.data.changesets.OpenChangesetKey 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;
}
use of de.westnordost.streetcomplete.data.changesets.OpenChangesetKey in project StreetComplete by westnordost.
the class AOsmQuestChangesUpload method createChangeset.
private long createChangeset(OsmElementQuestType questType, String source) {
OpenChangesetKey key = new OpenChangesetKey(questType.getClass().getSimpleName(), source);
long changesetId = osmDao.openChangeset(createChangesetTags(questType, source));
openChangesetsDB.replace(key, changesetId);
return changesetId;
}
Aggregations