use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class OsmNoteQuestChangesUpload method uploadNoteChanges.
Note uploadNoteChanges(OsmNoteQuest quest) {
String text = quest.getComment();
try {
text += AttachPhotoUtils.uploadAndGetAttachedPhotosText(imageUploader, quest.getImagePaths());
Note newNote = osmDao.comment(quest.getNote().id, text);
/* Unlike OSM quests, note quests are never deleted when the user contributed to it
but must remain in the database with the status CLOSED as long as they are not
solved. The reason is because as long as a note is unsolved, the problem at that
position persists and thus it should still block other quests to be created.
(Reminder: Note quests block other quests)
*/
// so, not this: questDB.delete(quest.getId());
quest.setStatus(QuestStatus.CLOSED);
quest.setNote(newNote);
questDB.update(quest);
noteDB.put(newNote);
AttachPhotoUtils.deleteImages(quest.getImagePaths());
return newNote;
} catch (OsmConflictException e) {
// someone else already closed the note -> our contribution is probably worthless. Delete
questDB.delete(quest.getId());
noteDB.delete(quest.getNote().id);
AttachPhotoUtils.deleteImages(quest.getImagePaths());
Log.i(TAG, "Dropped the comment " + getNoteQuestStringForLog(quest) + " because the note has already been closed");
return null;
}
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class OsmNoteQuestDao method createObjectFrom.
@Override
protected OsmNoteQuest createObjectFrom(Cursor cursor) {
int colQuestId = cursor.getColumnIndexOrThrow(Columns.QUEST_ID), colNoteId = cursor.getColumnIndexOrThrow(Columns.NOTE_ID), colQuestStatus = cursor.getColumnIndexOrThrow(Columns.QUEST_STATUS), colComment = cursor.getColumnIndexOrThrow(Columns.COMMENT), colLastUpdate = cursor.getColumnIndexOrThrow(Columns.LAST_UPDATE), colImagePaths = cursor.getColumnIndexOrThrow(Columns.IMAGE_PATHS);
long questId = cursor.getLong(colQuestId);
String comment = null;
if (!cursor.isNull(colComment)) {
comment = cursor.getString(colComment);
}
QuestStatus status = QuestStatus.valueOf(cursor.getString(colQuestStatus));
ArrayList<String> imagePaths = new ArrayList<>();
if (!cursor.isNull(colImagePaths)) {
imagePaths = serializer.toObject(cursor.getBlob(colImagePaths), ArrayList.class);
}
Date lastUpdate = new Date(cursor.getLong(colLastUpdate));
Note note = null;
if (!cursor.isNull(colNoteId)) {
note = NoteDao.createObjectFrom(serializer, cursor);
}
return new OsmNoteQuest(questId, note, status, comment, lastUpdate, questType, imagePaths);
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class NoteDaoTest method testPutReplace.
public void testPutReplace() {
Note note = createNote();
dao.put(note);
note.status = Note.Status.CLOSED;
dao.put(note);
Note dbNote = dao.get(note.id);
checkEqual(note, dbNote);
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class NoteDaoTest method createNote.
static Note createNote() {
Note note = new Note();
note.position = new OsmLatLon(1, 1);
note.status = Note.Status.OPEN;
note.id = 5;
note.dateCreated = new Date(5000);
NoteComment comment = new NoteComment();
comment.text = "hi";
comment.date = new Date(5000);
comment.action = NoteComment.Action.OPENED;
comment.user = new User(5, "PingPong");
note.comments.add(comment);
return note;
}
use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.
the class NoteDaoTest method testPutGetWithClosedDate.
public void testPutGetWithClosedDate() {
Note note = createNote();
note.dateClosed = new Date(6000);
dao.put(note);
Note dbNote = dao.get(note.id);
checkEqual(note, dbNote);
}
Aggregations