Search in sources :

Example 11 with PlanoDTO

use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method searchPlanoByDescricao.

@Override
@Transactional(readOnly = true)
public PlanoDTO[] searchPlanoByDescricao(String term) {
    PlanoDAO dao = factory.getPlanoDAO();
    PlanoDTO[] planosArray = null;
    try {
        List<Plano> planos = dao.searchByDescricao(term);
        if (planos != null) {
            planosArray = new PlanoDTO[planos.size()];
            for (int i = 0; i < planos.size(); i++) {
                planosArray[i] = planos.get(i).createDTOWithoutDependencies();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return planosArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PlanoDAO(com.tomasio.projects.trainning.dao.PlanoDAO) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) Plano(com.tomasio.projects.trainning.model.Plano) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with PlanoDTO

use of com.tomasio.projects.trainning.dto.PlanoDTO 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 13 with PlanoDTO

use of com.tomasio.projects.trainning.dto.PlanoDTO 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)

Example 14 with PlanoDTO

use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.

the class ImportPlanosImpl method execute.

@Override
public void execute() {
    try {
        DAOFactory factory = DAOUtil.getDAOFactory();
        PlanoDAO dao = factory.getPlanoDAO();
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/dctp?user=root&password=123456");
        Statement stm = conn.createStatement();
        ResultSet rs = stm.executeQuery("SELECT * FROM plano");
        while (rs.next()) {
            String sigla = rs.getString("Plano");
            String descricao = rs.getString("Plano");
            PlanoDTO plano = new PlanoDTO();
            plano.setSigla(sigla);
            plano.setDescricao(descricao);
        // dao.create(plano);
        }
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(ImportCursosImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
// catch (DAOException ex) {
// Logger.getLogger(ImportCursosImpl.class.getName()).log(Level.SEVERE, null, ex);
// }
}
Also used : DAOFactory(com.tomasio.projects.trainning.dao.DAOFactory) PlanoDAO(com.tomasio.projects.trainning.dao.PlanoDAO) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO)

Example 15 with PlanoDTO

use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.

the class Plano method createDTO.

public PlanoDTO createDTO() {
    PlanoDTO dto = createDTOWithoutDependencies();
    dto.setSigla(this.sigla);
    dto.setDescricao(this.descricao);
    dto.setId(this.id);
    dto.setDiasIndicacaoInicio(diasIndicacaoInicio);
    dto.setDiasIndicacaoTermino(diasIndicacaoTermino);
    dto.setObjectId(this.getObjectId());
    return dto;
}
Also used : PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO)

Aggregations

PlanoDTO (com.tomasio.projects.trainning.dto.PlanoDTO)15 PlanoDAO (com.tomasio.projects.trainning.dao.PlanoDAO)6 Plano (com.tomasio.projects.trainning.model.Plano)5 Transactional (org.springframework.transaction.annotation.Transactional)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 HashMap (java.util.HashMap)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 DAOException (com.tomasio.projects.trainning.exception.DAOException)3 Map (java.util.Map)3 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)2 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DAOFactory (com.tomasio.projects.trainning.dao.DAOFactory)1 FolhaRostoDTO (com.tomasio.projects.trainning.dto.FolhaRostoDTO)1 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)1 PlanoForm (com.tomasio.projects.trainning.form.PlanoForm)1 ParseException (java.text.ParseException)1 HashSet (java.util.HashSet)1 WebMethod (javax.jws.WebMethod)1