Search in sources :

Example 1 with CommentDto

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;
}
Also used : Comment(io.jawg.osmcontributor.model.entities.Comment) ArrayList(java.util.ArrayList) CommentDto(io.jawg.osmcontributor.rest.dtos.osm.CommentDto)

Example 2 with CommentDto

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;
}
Also used : Comment(io.jawg.osmcontributor.model.entities.Comment) Note(io.jawg.osmcontributor.model.entities.Note) ArrayList(java.util.ArrayList) CommentDto(io.jawg.osmcontributor.rest.dtos.osm.CommentDto) ParseException(java.text.ParseException) NoteDto(io.jawg.osmcontributor.rest.dtos.osm.NoteDto) SimpleDateFormat(java.text.SimpleDateFormat) DateTime(org.joda.time.DateTime) Date(java.util.Date)

Aggregations

Comment (io.jawg.osmcontributor.model.entities.Comment)2 CommentDto (io.jawg.osmcontributor.rest.dtos.osm.CommentDto)2 ArrayList (java.util.ArrayList)2 Note (io.jawg.osmcontributor.model.entities.Note)1 NoteDto (io.jawg.osmcontributor.rest.dtos.osm.NoteDto)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1