use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class NoteDaoTest method testPutAll.
public void testPutAll() {
Collection<Note> notes = new ArrayList<>();
Note n1 = createNote();
n1.id = 1;
notes.add(n1);
Note n2 = createNote();
n2.id = 2;
notes.add(n2);
dao.putAll(notes);
assertNotNull(dao.get(1));
assertNotNull(dao.get(2));
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class OsmNoteQuestDaoTest method testAddGetNoChanges.
public void testAddGetNoChanges() {
Note note = NoteDaoTest.createNote();
OsmNoteQuest quest = new OsmNoteQuest(note, questType);
noteDao.put(note);
dao.add(quest);
OsmNoteQuest dbQuest = dao.get(quest.getId());
checkEqual(quest, dbQuest);
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class OsmNoteQuestDaoTest method testGetPositions.
public void testGetPositions() {
Note note = NoteDaoTest.createNote();
note.position = new OsmLatLon(34, 35);
noteDao.put(note);
OsmNoteQuest quest = new OsmNoteQuest(note, questType);
dao.add(quest);
List<LatLon> positions = dao.getAllPositions(new BoundingBox(0, 0, 50, 50));
assertEquals(1, positions.size());
assertEquals(new OsmLatLon(34, 35), positions.get(0));
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class CreateNoteUpload method findAlreadyExistingNoteWithSameAssociatedElement.
private Note findAlreadyExistingNoteWithSameAssociatedElement(final CreateNote newNote) {
SingleElementHandler<Note> handler = new SingleElementHandler<Note>() {
@Override
public void handle(Note oldNote) {
if (newNote.hasAssociatedElement()) {
String firstCommentText = oldNote.comments.get(0).text;
String newNoteRegex = getAssociatedElementRegex(newNote);
if (firstCommentText.matches(newNoteRegex)) {
super.handle(oldNote);
}
}
}
};
final int hideClosedNoteAfter = 7;
osmDao.getAll(new BoundingBox(newNote.position.getLatitude(), newNote.position.getLongitude(), newNote.position.getLatitude(), newNote.position.getLongitude()), handler, 10, hideClosedNoteAfter);
return handler.get();
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class CreateNoteUpload method uploadCreateNote.
Note uploadCreateNote(CreateNote n) {
if (isAssociatedElementDeleted(n)) {
Log.i(TAG, "Dropped to be created note " + getCreateNoteStringForLog(n) + " because the associated element has already been deleted");
deleteNote(n);
return null;
}
Note newNote = createOrCommentNote(n);
if (newNote != null) {
// add a closed quest as a blocker so that at this location no quests are created.
// if the note was not added, don't do this (see below) -> probably based on old data
OsmNoteQuest noteQuest = new OsmNoteQuest(newNote, questType);
noteQuest.setStatus(QuestStatus.CLOSED);
noteDB.put(newNote);
noteQuestDB.add(noteQuest);
} else {
Log.i(TAG, "Dropped a to be created note " + getCreateNoteStringForLog(n) + " because a note with the same associated element has already been closed");
// so the problem has likely been solved by another mapper
}
deleteNote(n);
return newNote;
}
Aggregations