Package ecar.pojo.historico

Examples of ecar.pojo.historico.HistoricoPontoCriticoPtc


            }
            catch (Exception e){
              e.printStackTrace();
            }
          }
          HistoricoPontoCriticoPtc hptc = new HistoricoPontoCriticoPtc();
          hptc.carregar(pontoCriticoNovo);
          ptcDao.gerarHistorico(hptc, Historico.INCLUIR, usuarioLogado);
        }       
      }
      catch (Exception e){
        e.printStackTrace();
View Full Code Here


         * @param historico
   * @throws Exception
   */
  public void alterar(PontoCriticoPtc pontoCritico, HttpServletRequest request, UsuarioUsu usuario, HistoricoPtc historico) throws Exception {
    Transaction tx = null;
    HistoricoPontoCriticoPtc pojoHistorico = new HistoricoPontoCriticoPtc();
    PontoCriticoPtc ptcNegocio = (PontoCriticoPtc) buscar(PontoCriticoPtc.class, pontoCritico.getCodPtc());
    try {
      tx = session.beginTransaction();
      ArrayList objetos = new ArrayList();
      super.inicializarLogBean();
      PontoCriticoPtc pontoCriticoOld = (PontoCriticoPtc) buscar(PontoCriticoPtc.class, Long.valueOf(pontoCritico.getCodPtc()));
      /*** Historico ***/
      historico.gerarHistorico(pontoCriticoOld);
      /*** Historico ***/
      /* apaga os filhos para serem gravados novamente */
      if (pontoCritico.getPontoCriticoCorPtccores() != null) {
        Iterator itAtb = pontoCritico.getPontoCriticoCorPtccores().iterator();
        while (itAtb.hasNext()) {
          PontocriticoCorPtccor ptcCor = (PontocriticoCorPtccor) itAtb.next();
          session.delete(ptcCor);
          objetos.add(ptcCor);
        }
      }
      else
        pontoCritico.setPontoCriticoCorPtccores(new HashSet<PontocriticoCorPtccor>());
      pontoCritico.setPontoCriticoCorPtccores(null);
      /* apaga os filhos para serem gravados novamente */
      if (pontoCritico.getPontoCriticoSisAtributoPtcSatbs() != null && !pontoCritico.getPontoCriticoSisAtributoPtcSatbs().isEmpty()) {
        Iterator itAtb = pontoCritico.getPontoCriticoSisAtributoPtcSatbs().iterator();
        while (itAtb.hasNext()) {
          PontoCriticoSisAtributoPtcSatb pontoCriticoSisAtributoPtcSatb = (PontoCriticoSisAtributoPtcSatb) itAtb.next();
         
                    if(pontoCriticoSisAtributoPtcSatb.getSisAtributoSatb().getSisGrupoAtributoSga().getSisTipoExibicGrupoSteg().getCodSteg() == Input.IMAGEM){
                     
                      String nomeCampo = request.getParameter("a" + pontoCriticoSisAtributoPtcSatb.getSisAtributoSatb().getSisGrupoAtributoSga().getCodSga().toString());
                     
                      if (nomeCampo != null && nomeCampo.equals("")){
                       
                  String fullFile = pontoCriticoSisAtributoPtcSatb.getInformacao();
                 
                  if (fullFile.lastIndexOf("=") != -1)    
                    fullFile = fullFile.substring(fullFile.lastIndexOf("=") + 1);
               
                  File f = new File(fullFile);
                  if( f.exists() )
                    FileUpload.apagarArquivo(fullFile);
                      }
                    }
         
          session.delete(pontoCriticoSisAtributoPtcSatb);
          objetos.add(pontoCriticoSisAtributoPtcSatb);
        }
      }
      else
        pontoCritico.setPontoCriticoSisAtributoPtcSatbs(new HashSet<PontoCriticoSisAtributoPtcSatb>());
      pontoCritico.setPontoCriticoSisAtributoPtcSatbs(null);
      this.setPontoCritico(request, pontoCritico);
      pontoCritico.setUsuarioUsuByCodUsuUltManutPtc(usuario);
      pontoCritico.setDataUltManutencaoPtc(Data.getDataAtual());
      List filhos = new ArrayList();
      if (pontoCritico.getPontoCriticoCorPtccores() != null) {
        filhos.addAll(pontoCritico.getPontoCriticoCorPtccores());
      }
      if (pontoCritico.getPontoCriticoSisAtributoPtcSatbs() != null) {
        for (Object object : pontoCritico.getPontoCriticoSisAtributoPtcSatbs()) {
          PontoCriticoSisAtributoPtcSatb ptcSatb = (PontoCriticoSisAtributoPtcSatb) object;
          ptcSatb.gerarTiposValores();
        }
        filhos.addAll(pontoCritico.getPontoCriticoSisAtributoPtcSatbs());
      }
      session.update(pontoCritico);
      objetos.add(pontoCritico);
      Iterator it = filhos.iterator();
      while (it.hasNext()) {
        PaiFilho object = (PaiFilho) it.next();
        object.atribuirPKPai();
        // salva os filhos
        session.save(object);
        objetos.add(object);
      }
      tx.commit();
      session.merge(pontoCritico);
      pojoHistorico.carregar(pontoCritico);
      tx = session.beginTransaction();
      gerarHistorico(pojoHistorico, Historico.ALTERAR, ((ecar.login.SegurancaECAR) request.getSession().getAttribute("seguranca")).getUsuario());
      tx.commit();
      if (super.logBean != null) {
        super.logBean.setCodigoTransacao(Data.getHoraAtual(false));
View Full Code Here

         * @param usuario
         * @throws ECARException
   */
  public void excluir(String[] codigosParaExcluir, UsuarioUsu usuario) throws ECARException {
    Transaction tx = null;
    HistoricoPontoCriticoPtc pojoHistorico = new HistoricoPontoCriticoPtc();
    try {
      super.inicializarLogBean();
      tx = session.beginTransaction();
      List<PontoCriticoPtc> listaPontoCriticoPtc = new ArrayList<PontoCriticoPtc>();
      for (int i = 0; i < codigosParaExcluir.length; i++) {
        /*if(codigosParaExcluir[i].indexOf(",") != -1){
          throw new ECARException("itemEstrutura.pontoCritico.exclusao.jaExcluidos");
        }*/       
        PontoCriticoPtc pontoCritico = (PontoCriticoPtc) this.buscar(PontoCriticoPtc.class, Long.valueOf(codigosParaExcluir[i]));
        if (pontoCritico.getIndExcluidoPtc() != null && "S".equals(pontoCritico.getIndExcluidoPtc())) {
          throw new ECARException("itemEstrutura.pontoCritico.exclusao.jaExcluidos");
        }
        listaPontoCriticoPtc.add(pontoCritico);
      }
     
      for (PontoCriticoPtc pontoCritico : listaPontoCriticoPtc) {     
      //for (int i = 0; i < codigosParaExcluir.length; i++) {
        //PontoCriticoPtc pontoCritico = (PontoCriticoPtc) this.buscar(PontoCriticoPtc.class, Long.valueOf(codigosParaExcluir[i]));
        if (pontoCritico.getApontamentoApts() != null && pontoCritico.getApontamentoApts().size() > 0) {
          throw new ECARException("itemEstrutura.pontoCritico.exclusao.possuiApontamentos");
        }
        else {
          // PontoCriticoPtc old = (PontoCriticoPtc)
          // pontoCritico.clone();
          PontoCriticoPtc old = (PontoCriticoPtc) buscar(PontoCriticoPtc.class, Long.valueOf(pontoCritico.getCodPtc()));
          pontoCritico.setDataUltManutencaoPtc(Data.getDataAtual());
          pontoCritico.setUsuarioUsuByCodUsuUltManutPtc(usuario);
          pontoCritico.setIndExcluidoPtc(Dominios.SIM);
          /******** Historico *********/
          HistoricoPtc historico = new HistoricoPtc(pontoCritico, HistoricoPtc.exclusao, session, new ConfiguracaoDao(request), request);
          historico.gerarHistorico(old);
          /******** Historico *********/
          pojoHistorico.carregar(pontoCritico);
          if (pontoCritico.getPontoCriticoCorPtccores() == null)
            pojoHistorico.setPontoCriticoCorPtccores(new HashSet<PontocriticoCorPtccor>());
          if (pontoCritico.getPontoCriticoSisAtributoPtcSatbs() == null)
            pojoHistorico.setPontoCriticoSisAtributoPtcSatbs(new HashSet<PontoCriticoSisAtributoPtcSatb>());
          gerarHistorico(pojoHistorico, Historico.EXCLUIR, ((ecar.login.SegurancaECAR) request.getSession().getAttribute("seguranca")).getUsuario());//pojoHistorico.getUsuarioUsu());//((ecar.login.SegurancaECAR) request.getSession().getAttribute("seguranca")).getUsuario());
          session.update(pontoCritico);
        }
      }
      tx.commit();
View Full Code Here

         * @param usuarioUsu
         * @throws ECARException
   */
  public void salvar(PontoCriticoPtc pontoCritico, UsuarioUsu usuarioUsu) throws ECARException {
    super.inicializarLogBean();
    HistoricoPontoCriticoPtc pojoHistorico = new HistoricoPontoCriticoPtc();
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      pontoCritico.setDataInclusaoPtc(Data.getDataAtual());
      pontoCritico.setUsuarioUsuInclusao(usuarioUsu);
      pontoCritico.setIndExcluidoPtc("N");
      session.save(pontoCritico);
      pojoHistorico.carregar(pontoCritico);
      List filhos = new ArrayList();
      if (pontoCritico.getPontoCriticoCorPtccores() != null) {
        filhos.addAll(pontoCritico.getPontoCriticoCorPtccores());
      }
      if (pontoCritico.getPontoCriticoSisAtributoPtcSatbs() != null) {
View Full Code Here

   * de item a cada vez que � chamado
         * @throws ECARException
   */

  public void cargaInicialHistorico() throws ECARException{
    HistoricoPontoCriticoPtc pojoHistorico = new HistoricoPontoCriticoPtc();
    HistoricoDao historicoDao = new HistoricoDao(request);
    Transaction tx=null;
    try {
      String[] ordem = new String[] {"codPtc", "asc"};
      List<Long> listaIdObjetoSerializado = historicoDao.listaIdObjetoSerializado(HistoricoPontoCriticoPtc.class);
      List<PontoCriticoPtc> lista = getPontoCriticoPtcSemHistorico(listaIdObjetoSerializado);
      Iterator itLista = lista.iterator();
      int count = 1;
      PontoCriticoPtc ptc = null;
      while (itLista.hasNext() && count <= 100){
        ptc = (PontoCriticoPtc) itLista.next();
        System.out.println("Codigo PTC: " + ptc.getCodPtc());
        System.out.println("Contador PTC: " + count);
        tx = session.beginTransaction();
        pojoHistorico.carregar(ptc);
        if (("N").equals(ptc.getIndExcluidoPtc()))
          gerarHistorico(pojoHistorico, Historico.INCLUIR, ((ecar.login.SegurancaECAR) request.getSession().getAttribute("seguranca")).getUsuario());
        else
          gerarHistorico(pojoHistorico, Historico.EXCLUIR, ((ecar.login.SegurancaECAR) request.getSession().getAttribute("seguranca")).getUsuario());
       
View Full Code Here

TOP

Related Classes of ecar.pojo.historico.HistoricoPontoCriticoPtc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.