Esempio n. 1
0
 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
 public void agregarEntidadesPoliticas(Long idRed, String[] idEntidades, String[] idCuentas)
     throws Exception {
   try {
     List<Entidad> lista = new ArrayList<Entidad>();
     Map<Long, String> mapaEntidadCuenta = new HashMap<Long, String>();
     for (int i = 0; i < idEntidades.length; i++) {
       Entidad entidad = new Entidad();
       entidad.setIdEntidad(new Long(idEntidades[i]));
       lista.add(entidad);
       mapaEntidadCuenta.put(entidad.getIdEntidad(), idCuentas[i]);
     }
     Red red = new Red(idRed);
     for (Entidad f : lista) {
       EntidadPolitica ep = new EntidadPolitica();
       ep.setEntidad(f);
       ep.setRed(red);
       ep.setNumeroCuenta(mapaEntidadCuenta.get(f.getIdEntidad()));
       epFacade.save(ep);
     }
   } catch (Exception e) {
     context.setRollbackOnly();
     e.printStackTrace();
     throw e;
   }
 }
Esempio n. 2
0
 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
 @WebMethod
 public Long[] getProximoRangoOrden(@WebParam Long idRecaudador) throws Exception {
   try {
     synchronized (RedFacadeImpl.bloqueo) {
       Recaudador rec = this.recaudadorFacade.getLocked(idRecaudador);
       Red red = this.getLocked(rec.getRed().getIdRed());
       Long rangoValores[] = new Long[2];
       rangoValores[0] = red.getNumeroOrdenProximo();
       // incluye el extremo
       rangoValores[1] = rangoValores[0] + (rec.getNumeroOrdenTamRango() - 1);
       red.setNumeroOrdenProximo(rangoValores[1] + 1);
       this.merge(red);
       RedRecaudadorNumeroOrden rrno = new RedRecaudadorNumeroOrden();
       rrno.setFechaHora(new Date());
       rrno.setNumeroInicial(rangoValores[0]);
       rrno.setNumeroFinal(rangoValores[1]);
       rrno.setRecaudador(rec);
       rrno.setRed(rec.getRed());
       this.redRecNumeroOrdenFacade.merge(rrno);
       return rangoValores;
     }
   } catch (Exception e) {
     context.setRollbackOnly();
     e.printStackTrace();
     return new Long[0];
   }
 }
Esempio n. 3
0
  @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  public void agregarFacturadores(Long idRed, String[] idFacturadores, String[] idCuentas)
      throws Exception {
    try {
      HabilitacionFactRed ejemplo = new HabilitacionFactRed();
      ejemplo.setRed(new Red(idRed));
      // se trae todos los facturadores de esta red
      List<Facturador> listaFacturadoresHabilitados = this.obtenerFacturadoresHabilitados(idRed);
      // aqui se cargara los facturadores recibidos
      List<Facturador> listaFacturadoresRecibidos = new ArrayList<Facturador>();
      // Map<Long, Long> mapaFacturadorCuenta = new HashMap();
      Map<Long, String> mapaFacturadorCuenta = new HashMap<Long, String>();
      for (int i = 0; i < idFacturadores.length; i++) {
        Facturador facturador = new Facturador();
        facturador.setIdFacturador(new Long(idFacturadores[i]));
        listaFacturadoresRecibidos.add(facturador);
        // mapaFacturadorCuenta.put(facturador.getIdFacturador(), new Long(idCuentas[i]));
        mapaFacturadorCuenta.put(facturador.getIdFacturador(), idCuentas[i]);
      }
      // en esta lista se cargara los que deberan agregarse
      // que dueron los recibidos y que no estan habilitados actualmente
      List<Facturador> listaFacturadoresParaAgregar = new ArrayList<Facturador>();
      // copiamos todos los recibidos
      listaFacturadoresParaAgregar.addAll(listaFacturadoresRecibidos);
      // sacamos los que ya estan habilitados
      // y la lista ya tendra solo aquellos que habra que agregar
      listaFacturadoresParaAgregar.removeAll(listaFacturadoresHabilitados);

      // en esta lista se cargara los que deberan borrarse
      // que estan habilitados actualmente pero que no estan entre los recibidos
      // por tanto hay que borrarlos
      List<Facturador> listaFacturadoresParaBorrar = new ArrayList<Facturador>();
      // copiamos todos los recibidos
      listaFacturadoresParaBorrar.addAll(listaFacturadoresHabilitados);
      // sacamos los que ya estan habilitados
      // y la lista ya tendra solo aquellos que habra que agregar
      listaFacturadoresParaBorrar.removeAll(listaFacturadoresRecibidos);

      // agregamos los nuevos
      for (Facturador f : listaFacturadoresParaAgregar) {
        HabilitacionFactRed hab = new HabilitacionFactRed();
        HabilitacionFactRedPK habPK = new HabilitacionFactRedPK();
        habPK.setRed(idRed);
        habPK.setFacturador(f.getIdFacturador());
        hab.setHabilitacionFactRedPK(habPK);
        // hab.setCuenta(new Cuenta(mapaFacturadorCuenta.get(f.getIdFacturador())));
        hab.setNumeroCuenta(mapaFacturadorCuenta.get(f.getIdFacturador()));
        habilitacionFacturadorRedFacade.save(hab);
      }

      // borramos los que ya no estan
      HabilitacionFactRedPK habPK = new HabilitacionFactRedPK();
      habPK.setRed(idRed);
      for (Facturador f : listaFacturadoresParaBorrar) {
        habPK.setFacturador(f.getIdFacturador());
        this.habilitacionFacturadorRedFacade.delete(habPK);
      }
    } catch (Exception e) {
      context.setRollbackOnly();
      e.printStackTrace();
      throw e;
    }
  }