Search in sources :

Example 1 with History

use of com.management.entities.History in project Internet-Software-Architectures by zivko11.

the class HistoryManager method Create.

public boolean Create(HistoryDTO dto) {
    ModelMapper mapper = new ModelMapper();
    History history;
    try {
        history = mapper.map(dto, History.class);
        historyRepository.save(history);
    } catch (Exception exc) {
        exc.printStackTrace();
        return false;
    }
    return true;
}
Also used : History(com.management.entities.History) ModelMapper(org.modelmapper.ModelMapper)

Example 2 with History

use of com.management.entities.History 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 3 with History

use of com.management.entities.History 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)

Example 4 with History

use of com.management.entities.History in project Internet-Software-Architectures by zivko11.

the class HistoryManager method Update.

public boolean Update(HistoryDTO dto) {
    ModelMapper mapper = new ModelMapper();
    History tmp;
    try {
        tmp = mapper.map(dto, History.class);
    } catch (Exception exc) {
        exc.printStackTrace();
        return false;
    }
    historyRepository.save(tmp);
    return true;
}
Also used : History(com.management.entities.History) ModelMapper(org.modelmapper.ModelMapper)

Aggregations

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