public CarroDeCompras read(String id) throws ExecutionException, InterruptedException, UnknownHostException { initRIAK a = new initRIAK(); cluster = a.setUpCluster(); RiakClient client = new RiakClient(cluster); Location carroLocation = new Location(booksBucket, id); FetchValue fetchMobyDickOp = new FetchValue.Builder(carroLocation).build(); CarroDeCompras carro = client.execute(fetchMobyDickOp).getValue(CarroDeCompras.class); cluster.shutdown(); return carro; }
public void save(CarroDeCompras carro) throws UnknownHostException, ExecutionException, InterruptedException { initRIAK a = new initRIAK(); cluster = a.setUpCluster(); RiakClient client = new RiakClient(cluster); Location mobyDickLocation = new Location(booksBucket, carro.cliente.Id); StoreValue storeBookOp = new StoreValue.Builder(carro).withLocation(mobyDickLocation).build(); client.execute(storeBookOp); System.out.println("Carro de compras almacenado"); cluster.shutdown(); }
public void delete(String id) throws ExecutionException, InterruptedException { Location carroLocation = new Location(booksBucket, id); DeleteValue deleteOp = new DeleteValue.Builder(carroLocation).build(); client.execute(deleteOp); }