Esempio n. 1
0
  public void atualizaTblGrupoExecutor(
      DocumentHTML document,
      HttpServletRequest request,
      HttpServletResponse response,
      RegraEscalonamentoDTO regraEscalonamentoDTO)
      throws Exception {
    // Restaurar tabela de escalonamento de grupos
    HTMLTable tblGrupoExecutor = document.getTableById("tblGrupoExecutor");
    tblGrupoExecutor.deleteAllRows();

    EscalonamentoService escalonamentoService =
        (EscalonamentoService)
            ServiceLocator.getInstance()
                .getService(EscalonamentoService.class, WebUtil.getUsuarioSistema(request));
    Collection<EscalonamentoDTO> colEscalonamentoDTOs =
        escalonamentoService.findByRegraEscalonamento(regraEscalonamentoDTO);
    regraEscalonamentoDTO.setColEscalonamentoDTOs(colEscalonamentoDTOs);

    if ((tblGrupoExecutor != null) && (colEscalonamentoDTOs != null)) {
      tblGrupoExecutor.addRowsByCollection(
          colEscalonamentoDTOs,
          new String[] {
            "", "idGrupoExecutor", "descricao", "prazoExecucao", "idPrioridade", "descrPrioridade"
          },
          null,
          "",
          new String[] {"gerarImgDelGrupoExecutor"},
          null,
          null);
    }
    document.executeScript(
        "HTMLUtils.applyStyleClassInAllCells('tblGrupoExecutor', 'tblGrupoExecutor');");
  }
Esempio n. 2
0
 public void excluir(
     DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   RegraEscalonamentoDTO regraEscalonamentoDTO = (RegraEscalonamentoDTO) document.getBean();
   RegraEscalonamentoService service =
       (RegraEscalonamentoService)
           ServiceLocator.getInstance().getService(RegraEscalonamentoService.class, null);
   if (regraEscalonamentoDTO.getIdRegraEscalonamento() != null) {
     service.delete(regraEscalonamentoDTO);
     document.alert(UtilI18N.internacionaliza(request, "regraEscalonamento.excluida"));
   }
   HTMLForm form = document.getForm("form");
   form.clear();
   document.setBean(new RegraEscalonamentoDTO());
   HTMLTable tblGrupoExecutor = document.getTableById("tblGrupoExecutor");
   tblGrupoExecutor.deleteAllRows();
 }
Esempio n. 3
0
 public void save(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   RegraEscalonamentoDTO regraEscalonamentoDTO = (RegraEscalonamentoDTO) document.getBean();
   RegraEscalonamentoService service =
       (RegraEscalonamentoService)
           ServiceLocator.getInstance().getService(RegraEscalonamentoService.class, null);
   Collection<EscalonamentoDTO> grupos_serialize =
       br.com.citframework.util.WebUtil.deserializeCollectionFromRequest(
           EscalonamentoDTO.class, "grupos_serialize", request);
   if (grupos_serialize != null) {
     regraEscalonamentoDTO.setColEscalonamentoDTOs(grupos_serialize);
   }
   if (regraEscalonamentoDTO != null && service != null) {
     regraEscalonamentoDTO.setCriaProblema(
         regraEscalonamentoDTO.getCriaProblema() == null
             ? "N"
             : regraEscalonamentoDTO.getCriaProblema());
     regraEscalonamentoDTO.setEnviarEmail(
         regraEscalonamentoDTO.getEnviarEmail() == null
             ? "N"
             : regraEscalonamentoDTO.getEnviarEmail());
     if (regraEscalonamentoDTO.getIdRegraEscalonamento() == null) {
       service.create(regraEscalonamentoDTO);
       document.alert(UtilI18N.internacionaliza(request, "MSG05"));
     } else {
       service.update(regraEscalonamentoDTO);
       document.alert(UtilI18N.internacionaliza(request, "MSG06"));
     }
     HTMLForm form = document.getForm("form");
     form.clear();
     document.setBean(new RegraEscalonamentoDTO());
     HTMLTable tblGrupoExecutor = document.getTableById("tblGrupoExecutor");
     tblGrupoExecutor.deleteAllRows();
     load(document, request, response);
   }
 }
Esempio n. 4
0
  public void preencherComboContrato(
      DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws ServiceException, Exception {
    RegraEscalonamentoDTO regraEscalonamentoDTO = (RegraEscalonamentoDTO) document.getBean();

    ContratoService contratoService =
        (ContratoService) ServiceLocator.getInstance().getService(ContratoService.class, null);
    ClienteService clienteService =
        (ClienteService) ServiceLocator.getInstance().getService(ClienteService.class, null);
    FornecedorService fornecedorService =
        (FornecedorService) ServiceLocator.getInstance().getService(FornecedorService.class, null);
    ContratosGruposService contratosGruposService =
        (ContratosGruposService)
            ServiceLocator.getInstance().getService(ContratosGruposService.class, null);
    Collection colContratos = contratoService.list();
    ContratoDTO contratoDtoAux = new ContratoDTO();

    UsuarioDTO usuario = WebUtil.getUsuario(request);
    if (usuario == null) {
      document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
      document.executeScript(
          "window.location = '"
              + Constantes.getValue("SERVER_ADDRESS")
              + request.getContextPath()
              + "'");
      return;
    }

    String COLABORADORES_VINC_CONTRATOS =
        ParametroUtil.getValorParametroCitSmartHashMap(
            br.com.centralit.citcorpore.util.Enumerados.ParametroSistema
                .COLABORADORES_VINC_CONTRATOS,
            "N");
    if (COLABORADORES_VINC_CONTRATOS == null) {
      COLABORADORES_VINC_CONTRATOS = "N";
    }
    Collection colContratosColab = null;
    if (COLABORADORES_VINC_CONTRATOS.equalsIgnoreCase("S")) {
      colContratosColab = contratosGruposService.findByIdEmpregado(usuario.getIdEmpregado());
    }
    Collection<ContratoDTO> listaContratos = new ArrayList<ContratoDTO>();
    ((HTMLSelect) document.getSelectById("idContrato")).removeAllOptions();
    if (colContratos != null) {
      if (colContratos.size() > 1) {
        ((HTMLSelect) document.getSelectById("idContrato"))
            .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione"));
      }

      for (Iterator it = colContratos.iterator(); it.hasNext(); ) {
        ContratoDTO contratoDto = (ContratoDTO) it.next();
        if (contratoDto.getDeleted() == null || !contratoDto.getDeleted().equalsIgnoreCase("y")) {
          if (COLABORADORES_VINC_CONTRATOS.equalsIgnoreCase(
              "S")) { // Se parametro de colaboradores por contrato ativo, entao filtra.
            if (colContratosColab == null) {
              continue;
            }
            if (!isContratoInList(contratoDto.getIdContrato(), colContratosColab)) {
              continue;
            }
          }

          if (regraEscalonamentoDTO != null
              && regraEscalonamentoDTO.getIdRegraEscalonamento() != null) {
            this.restore(document, request, response);
          }

          String nomeCliente = "";
          String nomeForn = "";
          ClienteDTO clienteDto = new ClienteDTO();
          clienteDto.setIdCliente(contratoDto.getIdCliente());
          clienteDto = (ClienteDTO) clienteService.restore(clienteDto);
          if (clienteDto != null) {
            nomeCliente = clienteDto.getNomeRazaoSocial();
          }
          FornecedorDTO fornecedorDto = new FornecedorDTO();
          fornecedorDto.setIdFornecedor(contratoDto.getIdFornecedor());
          fornecedorDto = (FornecedorDTO) fornecedorService.restore(fornecedorDto);
          if (fornecedorDto != null) {
            nomeForn = fornecedorDto.getRazaoSocial();
          }
          contratoDtoAux.setIdContrato(contratoDto.getIdContrato());
          if (contratoDto.getSituacao().equalsIgnoreCase("A")) {
            String nomeContrato =
                ""
                    + contratoDto.getNumero()
                    + " de "
                    + UtilDatas.convertDateToString(
                        TipoDate.DATE_DEFAULT,
                        contratoDto.getDataContrato(),
                        WebUtil.getLanguage(request))
                    + " ("
                    + nomeCliente
                    + " - "
                    + nomeForn
                    + ")";
            ((HTMLSelect) document.getSelectById("idContrato"))
                .addOption("" + contratoDto.getIdContrato(), nomeContrato);
            contratoDto.setNome(nomeContrato);
            listaContratos.add(contratoDto);
          }
        }
      }
    }
  }
Esempio n. 5
0
  public void restore(
      DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    RegraEscalonamentoDTO regraEscalonamentoDTO = (RegraEscalonamentoDTO) document.getBean();
    RegraEscalonamentoService service =
        (RegraEscalonamentoService)
            ServiceLocator.getInstance()
                .getService(RegraEscalonamentoService.class, WebUtil.getUsuarioSistema(request));
    regraEscalonamentoDTO = (RegraEscalonamentoDTO) service.restore(regraEscalonamentoDTO);

    if ((regraEscalonamentoDTO != null)
        && (regraEscalonamentoDTO.getIdRegraEscalonamento() != null)) {

      EmpregadoService empregadoService =
          (EmpregadoService)
              ServiceLocator.getInstance()
                  .getService(EmpregadoService.class, WebUtil.getUsuarioSistema(request));
      if (regraEscalonamentoDTO.getIdSolicitante() != null) {
        EmpregadoDTO empregadoDTO =
            empregadoService.restoreByIdEmpregado(regraEscalonamentoDTO.getIdSolicitante());
        regraEscalonamentoDTO.setNomeSolicitante(
            ((empregadoDTO == null) || (empregadoDTO.getNome() == null))
                ? ""
                : empregadoDTO.getNome());
      }
      ServicoService servicoService =
          (ServicoService)
              ServiceLocator.getInstance()
                  .getService(ServicoService.class, WebUtil.getUsuarioSistema(request));
      if (regraEscalonamentoDTO.getIdServico() != null) {
        ServicoDTO servicoDTO = servicoService.findById(regraEscalonamentoDTO.getIdServico());
        regraEscalonamentoDTO.setServico(
            ((servicoDTO == null) || (servicoDTO.getNomeServico() == null))
                ? ""
                : servicoDTO.getNomeServico());
      }

      if (regraEscalonamentoDTO.getIdGrupo() != null) {
        GrupoService grupoService =
            (GrupoService)
                ServiceLocator.getInstance()
                    .getService(GrupoService.class, WebUtil.getUsuarioSistema(request));
        GrupoDTO grupoDTO = grupoService.listGrupoById(regraEscalonamentoDTO.getIdGrupo());
        regraEscalonamentoDTO.setGrupo(
            ((grupoDTO == null) || (grupoDTO.getDescricao() == null))
                ? ""
                : grupoDTO.getDescricao());
      }
    }
    atualizaTblGrupoExecutor(document, request, response, regraEscalonamentoDTO);
    HTMLForm form = document.getForm("form");
    form.clear();
    if (regraEscalonamentoDTO != null) {
      form.setValues(regraEscalonamentoDTO);
    }
  }