Search in sources :

Example 16 with Note

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));
}
Also used : Note(de.westnordost.osmapi.notes.Note) ArrayList(java.util.ArrayList)

Example 17 with Note

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);
}
Also used : Note(de.westnordost.osmapi.notes.Note)

Example 18 with Note

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));
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 19 with Note

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();
}
Also used : Note(de.westnordost.osmapi.notes.Note) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) SingleElementHandler(de.westnordost.osmapi.common.SingleElementHandler)

Example 20 with Note

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;
}
Also used : Note(de.westnordost.osmapi.notes.Note)

Aggregations

Note (de.westnordost.osmapi.notes.Note)32 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)10 Date (java.util.Date)8 LatLon (de.westnordost.osmapi.map.data.LatLon)5 ArrayList (java.util.ArrayList)5 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)4 NoteComment (de.westnordost.osmapi.notes.NoteComment)3 Way (de.westnordost.osmapi.map.data.Way)2 QuestStatus (de.westnordost.streetcomplete.data.QuestStatus)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 View (android.view.View)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 Handler (de.westnordost.osmapi.common.Handler)1 SingleElementHandler (de.westnordost.osmapi.common.SingleElementHandler)1 OsmConflictException (de.westnordost.osmapi.common.errors.OsmConflictException)1 NotesDao (de.westnordost.osmapi.notes.NotesDao)1 User (de.westnordost.osmapi.user.User)1 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)1 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)1