/*
   * Returns list of sensors currently loaded in the system
   * */
  public static String getListOfSensors() {
    StringBuilder s = new StringBuilder();
    Iterator iter = Mappings.getAllVSensorConfigs();

    sensors.clear();
    coordinates.clear();

    while (iter.hasNext()) {
      VSensorConfig sensorConfig = (VSensorConfig) iter.next();
      Double longitude = sensorConfig.getLongitude();
      Double latitude = sensorConfig.getLatitude();
      Double altitude = sensorConfig.getAltitude();
      String sensor = sensorConfig.getName();

      if ((latitude != null) && (longitude != null) && (altitude != null)) {
        Point point = new Point(latitude, longitude, altitude);
        coordinates.add(point);
        sensors.add(sensor);
        s.append(sensor)
            .append(" => ")
            .append(longitude)
            .append(" : ")
            .append(latitude)
            .append("\n");
      }
    }
    return s.toString();
  }
 public synchronized void close() {
   for (Connection conn : allConnections) {
     try {
       conn.rollback();
     } catch (SQLException ex) {
       throw new RuntimeException(ex);
     }
   }
   allConnections.clear();
 }
  /** @roseuid 3F3A89D40175 */
  public void shutdown() {
    logger.debug("Enter");

    Iterator iter;
    PooledConnection pooledConnection;

    SHUTTING_DOWN = true;
    iter = connectionPool.iterator();
    while (iter.hasNext()) {
      pooledConnection = (PooledConnection) iter.next();

      try {
        if (!pooledConnection.getConnection().isClosed()) {
          pooledConnection.getConnection().close();
        }
      } catch (Exception ex) {
        // We don't care what happens here, we're on the way out!
      }
    }

    connectionPool.clear();
  }
Пример #4
0
 public void buscarVentas(String nombre) {
   ventasEncontradas = DaoApartados.findByNombre(nombre, AppInstance.boutique().getId());
   ventasView.clear();
   Object[] row;
   for (VentaApartado v : ventasEncontradas) {
     row = new Object[4];
     row[0] = v.getId();
     row[1] = v.getCliente();
     row[2] = v.getDomicilio();
     row[3] = v.getTelefono();
     ventasView.add(row);
   }
 }
Пример #5
0
    protected void mergePatches(List<SchemaPatch> patches) {
      final List<DatabaseObject> objects = new ArrayList<>();

      Collections.sort(patches);

      for (SchemaPatch patch : patches) {
        validatePatch(patches, patch);

        objects.clear();
        List<DatabaseObject> tempObjects = new ArrayList<>();
        tempObjects.addAll(patch.getObjects());
        patch.clearObjects();
        patch.addObjects(mergeDatabaseObjects(tempObjects));

        targetStore.addPatch(patch);
      }
    }
Пример #6
0
  @Test
  public void testGetCustomerWithConnection() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("findCustomers", List.class, Connection.class)
            .createStrictMock();
    Customer customer = EasyMock.createStrictMock(Customer.class);
    Connection connection = EasyMock.createStrictMock(Connection.class);
    int custId = 322;
    List<ICustomer> customerList = new LinkedList<ICustomer>();
    customerList.add(customer);

    Capture<List<SearchConstraint>> capture = new Capture<List<SearchConstraint>>();
    EasyMock.expect(dao.findCustomers(EasyMock.capture(capture), EasyMock.eq(connection)))
        .andReturn(customerList);

    EasyMock.replay(dao, customer, connection);
    assertEquals("Wrong customer returned.", customer, dao.getCustomer(custId, connection));
    EasyMock.verify(dao, customer, connection);
    assertEquals("Wrong # of constraints.", 1, capture.getValue().size());
    SearchConstraint constraint = capture.getValue().get(0);
    assertEquals(
        "Wrong property in constraint.",
        ICustomerService.PROP_CUSTOMER_ID,
        constraint.getProperty());
    assertEquals(
        "Wrong operator in constraint.",
        SearchConstraintOperator.CONSTRAINT_EQUALS,
        constraint.getOperator());
    assertEquals("Wrong value in constraint.", custId, constraint.getValue());

    // no customers
    customerList.clear();
    EasyMock.reset(dao, customer, connection);
    capture = new Capture<List<SearchConstraint>>();
    EasyMock.expect(dao.findCustomers(EasyMock.capture(capture), EasyMock.eq(connection)))
        .andReturn(customerList);

    EasyMock.replay(dao, customer, connection);
    assertEquals(
        "Should not have found a customer returned.", null, dao.getCustomer(custId, connection));
    EasyMock.verify(dao, customer, connection);
  }
Пример #7
0
  public void seleccionarVenta(int index) {
    pagosView.clear();
    productosView.clear();
    // Obtenemos los productos vendidos en la venta/ si es -1 estoy refrescando los datos de la
    // venta previamente
    // seleccionada
    if (index != -1) {
      ventaSeleccionada = ventasEncontradas.get(index);
    } else {
      ventaSeleccionada = (VentaApartado) DaoVentas.findByIdNoFinalizada(ventaSeleccionada.getId());
    }
    total = 0;
    abonado = 0;
    ventaSeleccionada.setProductosVendidos(
        DaoVentas.getProductosVendidos(ventaSeleccionada.getId()));
    Object[] row = null;
    for (ProductoVendido pv : ventaSeleccionada.getProductosVendidos()) {
      row = new Object[7];
      row[0] = "1";
      row[1] = pv.getDescripcion();
      row[2] = pv.getEtiqueta();
      row[3] = AppInstance.number.format(pv.getPrecioInicial());
      row[4] = pv.getDescuento() + "%";
      row[5] = AppInstance.number.format(pv.getPrecioFinal());
      switch (pv.getEntregado()) {
        case 0:
          row[6] = "No";
          break;
        case 1:
          row[6] = "Si";
          montoUsado += pv.getPrecioFinal();
          break;
      }
      productosView.add(row);

      total += pv.getPrecioFinal();
    }
    // Obtenemos los pagos realizados en la venta
    ventaSeleccionada.setPagos(DaoVentas.getPagos(ventaSeleccionada.getId()));

    for (Pago p : ventaSeleccionada.getPagos()) {
      row = new Object[4];
      row[0] = p.getId();
      row[1] = AppInstance.formatoLargo.format(p.getFecha());
      row[2] = AppInstance.number.format(p.getMonto());
      if (p instanceof PagoTarjetaCredito) {
        PagoTarjetaCredito pt = (PagoTarjetaCredito) p;
        row[3] =
            "T Credito/debito "
                + pt.getBanco()
                + ((pt.getMeses() > 0) ? pt.getMeses() + " meses sin intereses" : "");
      } else if (p instanceof PagoVale) {
        PagoVale pv = (PagoVale) p;
        row[3] = "Vale no. " + pv.getIdVale();

      } else if (p instanceof PagoCheque) {
        PagoCheque pch = (PagoCheque) p;
        row[3] = "Cheque no. " + pch.getNoCheque() + " de " + pch.getBanco();

      } else if (p instanceof PagoDevolucion) {
        PagoDevolucion pv = (PagoDevolucion) p;
        row[3] = "Descuento por entrega de vale no. " + pv.getVale().getId();
        pv = null;
      } else if (p instanceof PagoTransferenciaBancaria) {
        PagoTransferenciaBancaria pb = (PagoTransferenciaBancaria) p;
        row[3] = "Depósito/transf. bancaria, ref: " + pb.getNoReferencia();
      } else if (p instanceof Pago) {
        row[3] = "Efectivo";
      }
      abonado += p.getMonto();
      pagosView.add(row);
    }
    montoPendiente = total - abonado;
    montoDisponible = abonado - montoUsado;
    // Retornamos la venta.

  }