Search in sources :

Example 1 with HistoryDTO

use of com.management.dto.HistoryDTO in project Internet-Software-Architectures by zivko11.

the class HistoryManager method ReadAll.

public ArrayList<HistoryDTO> ReadAll() {
    ModelMapper mapper = new ModelMapper();
    ArrayList<History> listEntities = (ArrayList<History>) historyRepository.findAll();
    ArrayList<HistoryDTO> listDTO = new ArrayList<HistoryDTO>();
    for (History tmp : listEntities) {
        try {
            HistoryDTO dto = mapper.map(tmp, HistoryDTO.class);
            listDTO.add(dto);
        } catch (Exception exc) {
            exc.printStackTrace();
            return null;
        }
    }
    return listDTO;
}
Also used : HistoryDTO(com.management.dto.HistoryDTO) ArrayList(java.util.ArrayList) History(com.management.entities.History) ModelMapper(org.modelmapper.ModelMapper)

Example 2 with HistoryDTO

use of com.management.dto.HistoryDTO in project Internet-Software-Architectures by zivko11.

the class HistoryManager method Read.

public HistoryDTO Read(int id) {
    ModelMapper mapper = new ModelMapper();
    HistoryDTO dto;
    try {
        History history = historyRepository.findOne(id);
        dto = mapper.map(history, HistoryDTO.class);
    } catch (Exception exc) {
        exc.printStackTrace();
        return null;
    }
    return dto;
}
Also used : HistoryDTO(com.management.dto.HistoryDTO) History(com.management.entities.History) ModelMapper(org.modelmapper.ModelMapper)

Aggregations

HistoryDTO (com.management.dto.HistoryDTO)2 History (com.management.entities.History)2 ModelMapper (org.modelmapper.ModelMapper)2 ArrayList (java.util.ArrayList)1