コード例 #1
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);
    }
  }
コード例 #2
0
  /**
   * Retorna perfil de acesso ativo do grupo.
   *
   * @param grupo
   * @return
   * @throws Exception
   */
  public PerfilAcessoGrupoDTO obterPerfilAcessoGrupo(final GrupoDTO grupo)
      throws PersistenceException {
    List list = new ArrayList<>();
    final List fields = new ArrayList<>();
    final StringBuilder sql = new StringBuilder();
    final List parametros = new ArrayList<>();

    sql.append("SELECT idperfil FROM perfilacessogrupo WHERE idgrupo = ? AND datafim IS NULL");
    parametros.add(grupo.getIdGrupo());

    fields.add("idPerfilAcessoGrupo");

    list = this.execSQL(sql.toString(), parametros.toArray());

    if (list != null && !list.isEmpty()) {
      return (PerfilAcessoGrupoDTO) this.listConvertion(this.getBean(), list, fields).get(0);
    } else {
      return null;
    }
  }