use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteManager method saveNoteNoTransactionMgmt.
/**
* Method saving a note and the associated foreign collection (comments) without transaction management.
* <p/>
* Do not call the DAO directly to save a note, use this method.
*
* @param note The note to save.
* @return The saved note.
* @see #saveNote(Note)
*/
private Note saveNoteNoTransactionMgmt(Note note) {
commentDao.deleteByNoteIdAndUpdated(note.getId(), false);
noteDao.createOrUpdate(note);
if (note.getComments() != null) {
for (Comment comment : note.getComments()) {
commentDao.createOrUpdate(comment);
}
}
bus.post(new NoteSavedEvent(note));
return note;
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteManager method createComment.
/**
* Create a Comment with the given parameters without modifying the Note.
*
* @param note The Note associated with the comment.
* @param action The action of the comment.
* @param comment The comment of the comment.
* @return The created comment.
*/
public Comment createComment(Note note, String action, String comment) {
Comment newComment = new Comment();
newComment.setText(comment);
switch(action) {
case NoteActivity.CLOSE:
newComment.setAction(Comment.ACTION_CLOSE);
break;
case NoteActivity.COMMENT:
newComment.setAction(Comment.ACTION_COMMENT);
break;
case NoteActivity.REOPEN:
newComment.setAction(Comment.ACTION_REOPEN);
break;
default:
newComment.setAction(Comment.ACTION_OPEN);
break;
}
newComment.setNote(note);
return newComment;
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteDetailFragment method setNote.
private void setNote(Note note) {
this.note = note;
List<Comment> comments = new ArrayList<>();
comments.addAll(note.getComments());
if (!comments.isEmpty()) {
for (Comment c : comments) {
if (c.getAction().equals("opened")) {
textViewCommentText.setText(c.getText());
}
}
}
textViewNoteStatus.setText("Note (" + note.getStatus() + ")");
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class CommentMapper method convertFromComment.
public List<CommentDto> convertFromComment(Collection<Comment> comments) {
List<CommentDto> result = new ArrayList<>();
for (Comment comment : comments) {
CommentDto commentDto = new CommentDto();
commentDto.setText(comment.getText());
commentDto.setAction(comment.getAction());
result.add(commentDto);
}
return result;
}
use of io.jawg.osmcontributor.model.entities.Comment in project osm-contributor by jawg.
the class NoteMapper method convertNoteDtosToNotes.
public List<Note> convertNoteDtosToNotes(List<NoteDto> dtos) {
List<Note> result = new ArrayList<>();
if (dtos != null) {
for (NoteDto dto : dtos) {
Note note = new Note();
note.setLatitude(dto.getLat());
note.setLongitude(dto.getLon());
note.setBackendId(dto.getId());
note.setUpdated(false);
note.setStatus(dto.getStatus());
DateTime dt = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", Locale.US);
try {
Date date = simpleDateFormat.parse(dto.getDate_created());
dt = new DateTime(date);
} catch (ParseException ex) {
System.out.println("Exception " + ex);
}
note.setCreatedDate(dt);
ArrayList<Comment> comments = new ArrayList<>(dto.getCommentDtoList().size());
for (CommentDto commentDto : dto.getCommentDtoList()) {
Comment comment = new Comment();
comment.setNote(note);
comment.setUpdated(false);
comment.setAction(commentDto.getAction());
comment.setText(commentDto.getText());
try {
Date date = simpleDateFormat.parse(commentDto.getDate());
dt = new DateTime(date);
} catch (ParseException ex) {
System.out.println("Exception " + ex);
}
comment.setCreatedDate(dt);
comments.add(comment);
}
note.setComments(comments);
result.add(note);
}
}
return result;
}
Aggregations