Search in sources :

Example 6 with Plano

use of com.tomasio.projects.trainning.model.Plano in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findPlanoBySigla.

@Override
@Transactional(readOnly = true)
public PlanoDTO findPlanoBySigla(String sigla) {
    PlanoDAO dao = factory.getPlanoDAO();
    Plano plano = null;
    try {
        plano = dao.findBySigla(sigla);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    if (plano != null) {
        return plano.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PlanoDAO(com.tomasio.projects.trainning.dao.PlanoDAO) Plano(com.tomasio.projects.trainning.model.Plano) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Plano

use of com.tomasio.projects.trainning.model.Plano in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findAllPlanos.

@Override
@Transactional(readOnly = true)
public PlanoDTO[] findAllPlanos() {
    PlanoDAO dao = factory.getPlanoDAO();
    List<Plano> planos = (List<Plano>) findAll(dao);
    List<PlanoDTO> dtos = new ArrayList<>();
    assemblyDTO(dtos, planos, PlanoDTO.class, Plano.class);
    PlanoDTO[] resultArray = dtos.toArray(new PlanoDTO[dtos.size()]);
    return resultArray;
}
Also used : ArrayList(java.util.ArrayList) PlanoDAO(com.tomasio.projects.trainning.dao.PlanoDAO) ArrayList(java.util.ArrayList) List(java.util.List) Plano(com.tomasio.projects.trainning.model.Plano) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Plano

use of com.tomasio.projects.trainning.model.Plano in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findPlano.

@Override
@Transactional(readOnly = true)
public PlanoDTO findPlano(Long id) {
    PlanoDAO dao = factory.getPlanoDAO();
    Plano plano = (Plano) find(dao, id);
    if (plano != null) {
        PlanoDTO dto = new PlanoDTO();
        assemblyDTO(dto, plano);
        return dto;
    } else {
        return null;
    }
}
Also used : PlanoDAO(com.tomasio.projects.trainning.dao.PlanoDAO) Plano(com.tomasio.projects.trainning.model.Plano) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PlanoDAO (com.tomasio.projects.trainning.dao.PlanoDAO)8 Plano (com.tomasio.projects.trainning.model.Plano)8 Transactional (org.springframework.transaction.annotation.Transactional)8 PlanoDTO (com.tomasio.projects.trainning.dto.PlanoDTO)5 DAOException (com.tomasio.projects.trainning.exception.DAOException)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1