Search in sources :

Example 6 with CursoDTO

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

the class CursosController method index.

@RequestMapping({ "/", "/index", "" })
public String index(Model model, WebRequest request) {
    String search = request.getParameter("search");
    List<Map<Object, Object>> dataList = new ArrayList<Map<Object, Object>>();
    CursoDTO[] cursos = trainningService.searchCurso(search, null, null, null, null);
    for (CursoDTO cursoDTO : cursos) {
        Map<Object, Object> item = new HashMap<Object, Object>();
        item.put("id", cursoDTO.getId());
        item.put("codigo", cursoDTO.getCodigo());
        item.put("descricao", cursoDTO.getDescricao());
        if (cursoDTO.getPlano() != null) {
            item.put("plano", cursoDTO.getPlano().getSigla());
        } else {
            item.put("plano", "-");
        }
        if (cursoDTO.getArea() != null) {
            item.put("area", cursoDTO.getArea().getSigla());
        } else {
            item.put("area", "-");
        }
        dataList.add(item);
    }
    model.addAttribute("dataList", dataList);
    model.addAttribute("total", dataList.size());
    return "cursos";
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with CursoDTO

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

the class CursosController method saveCurso.

@RequestMapping("/save")
public String saveCurso(Model model, @Valid CursoForm cursoForm, BindingResult bindingResult, WebRequest request) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("areas", initializeSelectableAreas());
        model.addAttribute("planos", initializeSelectablePlanos());
        return "cursos/form";
    }
    CursoDTO dto = new CursoDTO();
    dto.setId(cursoForm.getId());
    dto.setArea(trainningService.findArea(cursoForm.getAreaId()));
    dto.setPlano(trainningService.findPlano(cursoForm.getPlanoId()));
    dto.setCodigo(cursoForm.getCodigo());
    dto.setDescricao(cursoForm.getDescricao());
    dto.setCodigoVelho(cursoForm.getCodigoVelho());
    dto.setInstrucao(cursoForm.isInstrucao());
    dto.setQuantidadeVagas(cursoForm.getQuantidadeVagas());
    dto.setDuracao(cursoForm.getDuracao());
    dto.setAtivo(cursoForm.isAtivo());
    dto.setVisivel(cursoForm.isVisivel());
    dto.setEhGT(cursoForm.isEhGT());
    dto.setEstrangeiro(cursoForm.isEstrangeiro());
    FolhaRostoDTO folhaRosto = new FolhaRostoDTO();
    folhaRosto.setDisciplinas(cursoForm.getDisciplinas());
    folhaRosto.setObjetivo(cursoForm.getObjetivo());
    folhaRosto.setPreRequisitos(cursoForm.getPreRequisitos());
    folhaRosto.setObservacoes(cursoForm.getObservacoes());
    dto.setFolhaRosto(folhaRosto);
    if (dto.getId() > 0) {
        try {
            trainningService.updateCurso(dto);
            model.addAttribute("successMessage", "Curso atualizado com sucesso.");
            model.addAttribute("curso", dto);
            return "cursos/detail";
        } catch (CoreException e) {
            model.addAttribute("errorMessage", e.getMessage());
            model.addAttribute("areas", initializeSelectableAreas());
            model.addAttribute("planos", initializeSelectablePlanos());
            return "cursos/form";
        }
    } else {
        try {
            Long cursoId = trainningService.createCurso(dto);
            dto.setId(cursoId);
            model.addAttribute("successMessage", "Curso criado com sucesso.");
            model.addAttribute("curso", dto);
            return "cursos/detail";
        // } catch (CoreException e) {
        } catch (DataIntegrityViolationException e) {
            // model.addAttribute("errorMessage", e.getMessage());
            model.addAttribute("errorMessage", "O Curso " + dto.getCodigo() + " já existe Cadastrado no Sistema!");
            model.addAttribute("areas", initializeSelectableAreas());
            model.addAttribute("planos", initializeSelectablePlanos());
            return "cursos/form";
        }
    }
}
Also used : CoreException(com.tomasio.projects.trainning.exeption.CoreException) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) FolhaRostoDTO(com.tomasio.projects.trainning.dto.FolhaRostoDTO) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with CursoDTO

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

the class CursosController method detailCurso.

@RequestMapping("/detail")
public String detailCurso(Model model, WebRequest request) {
    String cursoId = request.getParameter("cursoId");
    CursoDTO dto = trainningService.findCurso(Long.parseLong(cursoId));
    LogDTO[] logs = systemService.findAllLogByObjectId(dto.getObjectId());
    model.addAttribute("logs", logs);
    model.addAttribute("curso", dto);
    return "cursos/detail";
}
Also used : LogDTO(com.tomasio.projects.trainning.dto.LogDTO) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with CursoDTO

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

the class HistoryController method showPersonHistory.

@RequestMapping("/person")
public String showPersonHistory(Model model, WebRequest request) {
    String pessoaIdParam = request.getParameter("pessoaId");
    PessoaDTO pessoa = null;
    if (pessoaIdParam == null || pessoaIdParam.equals("") || pessoaIdParam.equals("NULL")) {
        pessoa = (PessoaDTO) model.asMap().get("selectedPerson");
        if (pessoa == null) {
            model.addAttribute("target", "view");
            return "redirect:select_pessoa";
        }
    } else {
        pessoa = organizationalService.findPessoa(Long.parseLong(pessoaIdParam));
        model.addAttribute("selectedPerson", pessoa);
    }
    ConclusaoDTO[] conclusoes = atividadesEnsinoService.findAllConcluidosByPessoa(pessoa.getId(), true);
    List<Map<Object, Object>> conclusoesDataList = new ArrayList<Map<Object, Object>>();
    for (ConclusaoDTO conclusaoDTO : conclusoes) {
        // if (conclusaoDTO.getPessoa().isAtivo()) {
        Map<Object, Object> item = new HashMap<Object, Object>();
        if (conclusaoDTO.getCapacitacao() instanceof CursoDTO) {
            CursoDTO curso = (CursoDTO) conclusaoDTO.getCapacitacao();
            item.put("codigo", curso.getCodigo());
            item.put("descricao", curso.getDescricao());
        }
        item.put("local", conclusaoDTO.getLocal());
        item.put("observacao", conclusaoDTO.getObservacao());
        if (conclusaoDTO.getPeriodo() != null) {
            item.put("periodo", conclusaoDTO.getPeriodo().getPeriodoFormatted());
        }
        item.put("editable", (conclusaoDTO.getMatricula() == null));
        item.put("id", conclusaoDTO.getId());
        conclusoesDataList.add(item);
    // }
    }
    model.addAttribute("conclusoesDataList", conclusoesDataList);
    model.addAttribute("pessoa", pessoa);
    model.addAttribute("emails", pessoa.getEmails());
    model.addAttribute("telefones", pessoa.getTelefones());
    return "history/person";
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with CursoDTO

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

the class HistoryController method showCourseHistory.

@RequestMapping("/course")
public String showCourseHistory(Model model, WebRequest request) {
    String cursoIdParam = request.getParameter("cursoId");
    CursoDTO curso = null;
    if (cursoIdParam == null || cursoIdParam.equals("") || cursoIdParam.equals("NULL")) {
        curso = (CursoDTO) model.asMap().get("selectedCourse");
        if (curso == null) {
            model.addAttribute("target", "view");
            return "redirect:select_curso";
        }
    } else {
        curso = trainningService.findCurso(Long.parseLong(cursoIdParam));
        model.addAttribute("selectedCourse", curso);
    }
    ConclusaoDTO[] conclusoes = atividadesEnsinoService.findAllConcluidosByCapacitacao(curso.getId(), true);
    List<Map<Object, Object>> conclusoesDataList = new ArrayList<Map<Object, Object>>();
    for (ConclusaoDTO conclusaoDTO : conclusoes) {
        if (conclusaoDTO.getPessoa().isAtivo()) {
            Map<Object, Object> item = new HashMap<Object, Object>();
            item.put("tarjeta", conclusaoDTO.getPessoa().getTargetaCompletaOM());
            item.put("local", conclusaoDTO.getLocal());
            item.put("observacao", conclusaoDTO.getObservacao());
            item.put("editable", (conclusaoDTO.getMatricula() == null));
            item.put("id", conclusaoDTO.getId());
            if (conclusaoDTO.getPeriodo() != null) {
                item.put("periodo", conclusaoDTO.getPeriodo().getPeriodoFormatted());
            }
            conclusoesDataList.add(item);
        }
    }
    model.addAttribute("conclusoesDataList", conclusoesDataList);
    model.addAttribute("curso", curso);
    return "history/course";
}
Also used : ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)44 HashMap (java.util.HashMap)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ArrayList (java.util.ArrayList)11 Map (java.util.Map)10 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)8 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)7 FolhaRostoDTO (com.tomasio.projects.trainning.dto.FolhaRostoDTO)6 TurmaPlanejadaDTO (com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)6 DAOException (com.tomasio.projects.trainning.exception.DAOException)6 CoreException (com.tomasio.projects.trainning.exeption.CoreException)6 List (java.util.List)6 CursoDAO (com.tomasio.projects.trainning.dao.CursoDAO)5 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)5 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)5 HabilitacaoInstrutorEfetivaDTO (com.tomasio.projects.trainning.dto.HabilitacaoInstrutorEfetivaDTO)4 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)4 IOException (java.io.IOException)4 Date (java.util.Date)4 OdfTable (org.odftoolkit.odfdom.doc.table.OdfTable)4