Search in sources :

Example 1 with PlanoDTO

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

the class Plano method createDTOMinimal.

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

Example 2 with PlanoDTO

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

the class PlanosController method showIndex.

@RequestMapping({ "/", "/index", "" })
public String showIndex(Model model, WebRequest request) {
    PlanoDTO[] planos = trainningService.findAllPlanos();
    model.addAttribute("total", planos.length);
    // model.addAttribute("planos", planos);
    List dataList = new ArrayList();
    for (PlanoDTO plano : planos) {
        Map item = new HashMap();
        item.put("id", plano.getId());
        item.put("sigla", plano.getSigla());
        item.put("descricao", plano.getDescricao());
        Long omId = plano.getOMResponsavelId();
        if (omId != null) {
            OrganizacaoDTO om = organizationalService.findOrganizacao(omId);
            if (om != null) {
                item.put("omsigla", om.getSigla());
            } else {
                item.put("omsigla", "não informada");
            }
        } else {
            item.put("omsigla", "não informada");
        }
        dataList.add(item);
    }
    model.addAttribute("planos", dataList);
    return "plano_cadastro";
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO) HashMap(java.util.HashMap) Map(java.util.Map) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PlanoDTO

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

the class PlanosController method savePlano.

@RequestMapping("/save")
public String savePlano(Model model, @Valid PlanoForm planoForm, BindingResult bindingResult, WebRequest request, final RedirectAttributes redirectAttributes) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("OMs", initializeSelectableOMs());
        return "plano_cadastro/form";
    }
    PlanoDTO dto = new PlanoDTO();
    dto.setId(planoForm.getId());
    dto.setSigla(planoForm.getSigla());
    dto.setDescricao(planoForm.getDescricao());
    dto.setDiasIndicacaoInicio(planoForm.getDiasIndicacaoInicio());
    dto.setDiasIndicacaoTermino(planoForm.getDiasIndicacaoTermino());
    dto.setOMResponsavelId(planoForm.getOrganizacaoId());
    if (dto.getId() != null) {
        try {
            trainningService.updatePlano(dto);
            // model.addAttribute("successMessage", "Plano atualizado com sucesso.");
            redirectAttributes.addFlashAttribute("successMessage", "Plano atualizado com sucesso!");
            return "redirect:detail?planoId=" + dto.getId();
        // return "plano_cadastro/detail";
        } catch (CoreException e) {
            model.addAttribute("errorMessage", e.getMessage());
            model.addAttribute("OMs", initializeSelectableOMs());
            return "plano_cadastro/form";
        }
    } else {
        try {
            Long planoId = trainningService.createPlano(dto);
            dto.setId(planoId);
            redirectAttributes.addFlashAttribute("successMessage", "Plano criado com sucesso!");
            // model.addAttribute("item", dto);
            return "redirect:detail?planoId=" + planoId;
        } catch (CoreException e) {
            model.addAttribute("errorMessage", e.getMessage());
            model.addAttribute("OMs", initializeSelectableOMs());
            return "plano_cadastro/form";
        }
    }
}
Also used : CoreException(com.tomasio.projects.trainning.exeption.CoreException) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PlanoDTO

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

the class PlanosController method editPlano.

@RequestMapping("/edit")
public String editPlano(Model model, WebRequest request) {
    String planoId = request.getParameter("planoId");
    PlanoDTO dto = trainningService.findPlano(Long.parseLong(planoId));
    PlanoForm planoForm = new PlanoForm();
    planoForm.setId(dto.getId());
    planoForm.setSigla(dto.getSigla());
    planoForm.setDescricao(dto.getDescricao());
    planoForm.setDiasIndicacaoInicio(dto.getDiasIndicacaoInicio());
    planoForm.setDiasIndicacaoTermino(dto.getDiasIndicacaoTermino());
    planoForm.setOrganizacaoId(dto.getOMResponsavelId());
    model.addAttribute("OMs", initializeSelectableOMs());
    model.addAttribute("formPlano", planoForm);
    return "plano_cadastro/form";
}
Also used : PlanoForm(com.tomasio.projects.trainning.form.PlanoForm) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PlanoDTO

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

the class PlanosController method showDetails.

@RequestMapping("/detail")
public String showDetails(Model model, WebRequest request) {
    String planoId = request.getParameter("planoId");
    PlanoDTO plano = trainningService.findPlano(Long.parseLong(planoId));
    // List dataList = new ArrayList();
    // dataList.add(data)
    Long omId = plano.getOMResponsavelId();
    Map item = new HashMap();
    item.put("id", plano.getId());
    if (omId != null) {
        OrganizacaoDTO om = organizationalService.findOrganizacao(omId);
        item.put("omsigla", om.getSigla());
    }
    item.put("sigla", plano.getSigla());
    item.put("descricao", plano.getDescricao());
    model.addAttribute("item", item);
    return "plano_cadastro/detail";
}
Also used : HashMap(java.util.HashMap) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO) HashMap(java.util.HashMap) Map(java.util.Map) PlanoDTO(com.tomasio.projects.trainning.dto.PlanoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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