Search in sources :

Example 1 with PeriodoDTO

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

the class TurmasEfetivasController method saveTurma.

public void saveTurma(TurmaEfetivaStep1Form step1Form, TurmaEfetivaStep2Form step2Form, List<FaseForm> fasesDataList) {
    TurmaEfetivaDTO dto;
    if (step1Form.getId() != null && step1Form.getId() > 0) {
        dto = atividadesEnsinoService.findTurmaEfetiva(step1Form.getId());
    } else {
        dto = new TurmaEfetivaDTO();
    }
    dto.setCurso(trainningService.findCurso(step1Form.getCursoId()));
    dto.setId(step1Form.getId());
    dto.setDataAtivacao(step1Form.getDataAtivacao());
    dto.setFolderId(step1Form.getFolderId());
    dto.setNumeroTurma(step1Form.getNumeroTurma());
    dto.setExtra(step1Form.isExtra());
    dto.setAdiado(step1Form.isAdiado());
    dto.setBCAAtivacao(step1Form.getBCAAtivacao());
    dto.setBCAEncerramento(step1Form.getBCAEncerramento());
    dto.setDataBCAAtivacao(step1Form.getDataBCAAtivacao());
    dto.setDataBCAEncerramento(step1Form.getDataBCAEncerramento());
    dto.setPrivatedIndicacoes(step1Form.isPrivatedIndicacoes());
    dto.setResponsavelApresentacaoId(step2Form.getResponsavelApresentacaoId());
    dto.setResponsavelConclusaoId(step2Form.getResponsavelConclusaoId());
    dto.setResponsavelMatriculaId(step2Form.getResponsavelMatriculaId());
    dto.setResponsavelPreMatriculaId(step2Form.getResponsavelPreMatriculaId());
    dto.setResponsavelSelecaoId(step2Form.getResponsavelSelecaoId());
    PeriodoDTO periodoIndicacao = new PeriodoDTO();
    if (step1Form.getInicioIndicacoes() != null) {
        periodoIndicacao.setDataInicio(step1Form.getInicioIndicacoes());
    }
    if (step1Form.getTerminoIndicacoes() != null) {
        periodoIndicacao.setDataTermino(step1Form.getTerminoIndicacoes());
    }
    dto.setPeriodoIndicacao(periodoIndicacao);
    dto.setExercicio(step1Form.getExercicio());
    dto.setQuantidadeVagas(step1Form.getQuantidadeVagas());
    dto.setResponsavelId(step2Form.getResponsavelId());
    dto.setOrganizacaoGestoraId(step1Form.getOrganizacaoGestoraId());
    FaseDTO[] fases = new FaseDTO[fasesDataList.size()];
    for (int i = 0; i < fases.length; i++) {
        FaseDTO fase = new FaseDTO();
        fase.setDataInicio(fasesDataList.get(i).getDataInicio());
        fase.setDataTermino(fasesDataList.get(i).getDataTermino());
        fase.setDescricao(fasesDataList.get(i).getDescricao());
        fase.setTipoFase(fasesDataList.get(i).getTipo());
        fase.setLocal(organizationalService.findOrganizacao(fasesDataList.get(i).getLocalId()));
        fases[i] = fase;
    }
    dto.setFases(fases);
    if (dto.getId() != null && dto.getId() > 0) {
        atividadesEnsinoService.updateTurmaEfetiva(dto);
    } else {
        atividadesEnsinoService.createTurmaEfetiva(dto);
    }
}
Also used : TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) FaseDTO(com.tomasio.projects.trainning.dto.FaseDTO)

Example 2 with PeriodoDTO

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

the class TurmasEfetivasController method saveInstrutor.

@RequestMapping("/save_instrutor")
public String saveInstrutor(Model model, @Valid IndicacaoInstrutor indicacao, BindingResult bindingResult, WebRequest request) {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    if (bindingResult.hasErrors()) {
        model.addAttribute("pessoa", organizationalService.findPessoa(indicacao.getPessoaId()));
        return "turmas_efetivas/form_instrutor";
    }
    IndicacaoInstrutorDTO dto = new IndicacaoInstrutorDTO();
    dto.setId(indicacao.getId());
    dto.setDataCriacao(new Date());
    // dto.setStatus(indicacao.getStatus());
    dto.setMatriculado(indicacao.isMatriculado());
    dto.setEmail(indicacao.getEmail());
    dto.setEmailChefia(indicacao.getEmailChefia());
    dto.setJustificativa(indicacao.getJustificativa());
    dto.setObservacao(indicacao.getObservacao());
    dto.setOrganizacao(organizationalService.findOrganizacao(indicacao.getOrganizacaoId()));
    dto.setPessoa(organizationalService.findPessoa(indicacao.getPessoaId()));
    dto.setPrioridade(indicacao.getPrioridade());
    dto.setTelefone(indicacao.getTelefone());
    dto.setTurma(atividadesEnsinoService.findTurmaEfetiva(indicacao.getTurmaId()));
    dto.setTelefoneChefia(indicacao.getTelefoneChefia());
    dto.setChefia(indicacao.getChefia());
    if (indicacao.getLocalId() != null) {
        OrganizacaoDTO local = organizationalService.findOrganizacao(indicacao.getLocalId());
        dto.setLocal(local);
    }
    CustoDTO custo = new CustoDTO();
    custo.setAjudaCustoPlanejado(indicacao.getAjudaCustoPlanejado());
    custo.setDiariasPlanejado(indicacao.getDiariasPlanejado());
    custo.setPassagensPlanejado(indicacao.getPassagensPlanejado());
    dto.setCusto(custo);
    PeriodoDTO periodo = new PeriodoDTO();
    if (indicacao.getDataInicio() != null && !indicacao.getDataInicio().equals("")) {
        try {
            periodo.setDataInicio(df.parse(indicacao.getDataInicio()));
        } catch (ParseException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        }
    }
    if (indicacao.getDataTermino() != null && !indicacao.getDataTermino().equals("")) {
        try {
            periodo.setDataTermino(df.parse(indicacao.getDataTermino()));
        } catch (ParseException ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        }
    }
    dto.setPeriodo(periodo);
    if (dto.getId() != null && dto.getId() > 0) {
        atividadesEnsinoService.updateIndicacao(dto);
    } else {
        atividadesEnsinoService.createIndicacao(dto);
    }
    return "redirect:detail/instrutores";
}
Also used : PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) CustoDTO(com.tomasio.projects.trainning.dto.CustoDTO) ParseException(java.text.ParseException) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO) SimpleDateFormat(java.text.SimpleDateFormat) IndicacaoInstrutorDTO(com.tomasio.projects.trainning.dto.IndicacaoInstrutorDTO) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PeriodoDTO

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

the class TurmasEfetivasController method saveConclusao.

@RequestMapping("/save_conclusao")
public String saveConclusao(Model model, WebRequest request) {
    String matriculaId = request.getParameter("alunoNaoConcluidoId");
    MatriculaDTO matricula = atividadesEnsinoService.findMatricula(Long.parseLong(matriculaId));
    ConclusaoDTO conclusao = new ConclusaoDTO();
    CapacitacaoDTO capacitacao = trainningService.findCurso(matricula.getTurma().getCurso().getId());
    PeriodoDTO periodo = new PeriodoDTO();
    periodo.setDataInicio(matricula.getTurma().getDataInicio());
    periodo.setDataTermino(matricula.getTurma().getDataTermino());
    int ano = 0;
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    if (matricula.getTurma().getExercicio() != null) {
        Integer.parseInt(df.format(matricula.getTurma().getExercicio()));
    }
    conclusao.setAno(ano);
    conclusao.setCapacitacao(capacitacao);
    conclusao.setLocal(matricula.getTurma().getLocal());
    conclusao.setMatricula(matricula);
    conclusao.setPeriodo(periodo);
    conclusao.setPessoa(matricula.getPessoa());
    try {
        atividadesEnsinoService.createConclusao(conclusao);
        model.addAttribute("successMessage", "Conclusão realizada com sucesso.");
    } catch (CoreException e) {
        model.addAttribute("errorMessage", e.getMessage());
    }
    model.addAttribute("tab", "concluidos");
    return "redirect:detail/conclusoes";
}
Also used : PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) NotificacaoMatriculaDTO(com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO) MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CertificadoConclusaoDTO(com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) CapacitacaoDTO(com.tomasio.projects.trainning.dto.CapacitacaoDTO) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PeriodoDTO

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

the class HistoryController method saveConclusao.

@RequestMapping("/save")
public String saveConclusao(Model model, @ModelAttribute("origin") String origin, @Valid ConclusaoFormBean form, BindingResult bindingResult, WebRequest request, final RedirectAttributes redirectAttributes) {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    Date dataInicio = null;
    Date dataTermino = null;
    try {
        dataInicio = df.parse(form.getDataInicio());
        dataTermino = df.parse(form.getDataTermino());
    } catch (ParseException ex) {
        Logger.getLogger(HistoryController.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (bindingResult.hasErrors()) {
        return "history/form";
    }
    ConclusaoDTO dto = new ConclusaoDTO();
    dto.setId(form.getId());
    dto.setCapacitacao(trainningService.findCurso(form.getCapacitacaoId()));
    dto.setComAproveitamento(true);
    dto.setLocal(form.getLocal());
    dto.setObservacao(form.getObservacao());
    dto.setPessoa(organizationalService.findPessoa(form.getPessoaId()));
    if (dataInicio != null && dataTermino != null) {
        PeriodoDTO periodo = new PeriodoDTO();
        periodo.setDataInicio(dataInicio);
        periodo.setDataTermino(dataTermino);
        dto.setPeriodo(periodo);
    }
    if (dto.getId() > 0) {
        try {
            atividadesEnsinoService.updateConclusao(dto);
            redirectAttributes.addFlashAttribute("selectedPerson", dto.getPessoa());
            redirectAttributes.addFlashAttribute("selectedCourse", dto.getCapacitacao());
            redirectAttributes.addFlashAttribute("successMessage", "Registro atualizado com sucesso.");
            return "redirect:" + origin;
        } catch (CoreException e) {
            redirectAttributes.addFlashAttribute("errorMessage", e.getMessage());
            return "history/form";
        }
    } else {
        try {
            ConclusaoDTO[] conclusoes = new ConclusaoDTO[1];
            conclusoes[0] = dto;
            atividadesEnsinoService.createConclusao(conclusoes);
            redirectAttributes.addFlashAttribute("selectedPerson", dto.getPessoa());
            redirectAttributes.addFlashAttribute("selectedCourse", dto.getCapacitacao());
            redirectAttributes.addFlashAttribute("successMessage", "Registro criado com sucesso.");
            return "redirect:" + origin;
        } catch (CoreException e) {
            redirectAttributes.addFlashAttribute("errorMessage", e.getMessage());
            return "history/form";
        }
    }
}
Also used : CoreException(com.tomasio.projects.trainning.exeption.CoreException) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PeriodoDTO

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

the class HistoryController method editConclusao.

@RequestMapping("/edit")
public String editConclusao(Model model, WebRequest request) {
    String origin = request.getParameter("origin");
    if (origin != null) {
        model.addAttribute("origin", origin);
    }
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    String conclusaoIdParam = request.getParameter("conclusaoId");
    ConclusaoDTO conclusao = atividadesEnsinoService.findConclusao(Long.parseLong(conclusaoIdParam));
    ConclusaoFormBean form = new ConclusaoFormBean();
    form.setId(conclusao.getId());
    form.setCapacitacaoId(conclusao.getCapacitacao().getId());
    form.setPessoaId(conclusao.getPessoa().getId());
    form.setObservacao(conclusao.getObservacao());
    form.setLocal(conclusao.getLocal());
    if (conclusao.getPeriodo() != null) {
        PeriodoDTO periodo = conclusao.getPeriodo();
        if (periodo.getDataInicio() != null) {
            form.setDataInicio(df.format(periodo.getDataInicio()));
        }
        if (periodo.getDataTermino() != null) {
            form.setDataTermino(df.format(periodo.getDataTermino()));
        }
    }
    model.addAttribute("pessoa", conclusao.getPessoa());
    model.addAttribute("curso", conclusao.getCapacitacao());
    model.addAttribute(form);
    return "history/form";
}
Also used : ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) ConclusaoFormBean(com.tomasio.projects.trainning.form.ConclusaoFormBean) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PeriodoDTO (com.tomasio.projects.trainning.dto.PeriodoDTO)21 SimpleDateFormat (java.text.SimpleDateFormat)13 Date (java.util.Date)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 ParseException (java.text.ParseException)8 HabilitacaoInstrutorEfetivaDTO (com.tomasio.projects.trainning.dto.HabilitacaoInstrutorEfetivaDTO)7 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)7 ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)4 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)3 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)3 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)3 CoreException (com.tomasio.projects.trainning.exeption.CoreException)3 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)2 CapacitacaoDTO (com.tomasio.projects.trainning.dto.CapacitacaoDTO)2 CertificadoConclusaoDTO (com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO)2 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)2 DistribuicaoDTO (com.tomasio.projects.trainning.dto.DistribuicaoDTO)2 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)2 NotificacaoMatriculaDTO (com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO)2 PlanejamentoDTO (com.tomasio.projects.trainning.dto.PlanejamentoDTO)2