use of io.jawg.osmcontributor.rest.dtos.osm.CommentDto 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.rest.dtos.osm.CommentDto 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