@Override protected Boolean executeCommand(CouchDbClient couchDbClient) { try { couchDbClient.update(objectToUpdate); return true; } catch (NoDocumentException e) { return false; } } }
@GET @Path("/files") @Override public Response getEndpoints() { CouchDbClient couchDbClient = getCouchDbClient(); List<JsonObject> endpoints = couchDbClient.view("_all_docs").includeDocs(true).query(JsonObject.class); String json = new Gson().toJson(endpoints); return Response.ok(json).build(); }
@Override public List<VirtualSensor> getVirtualSensors(String username) { CouchDbClient couchDbClient = couchDbClientSupplier.get(); List<VirtualSensor> virtualSensors = couchDbClient.view("_all_docs") .includeDocs(true) .query(VirtualSensor.class); couchDbClient.shutdown(); return virtualSensors; }
@Override public void deleteVisualization(String pipelineId) { try { CouchDbClient couchDbClient = couchDbClientSupplier.get(); List<RunningVisualization> currentVisualizations = getRunningVisualizations(); for (RunningVisualization viz : currentVisualizations) { if (viz.getPipelineId() != null) { if (viz.getPipelineId().equals(pipelineId)) couchDbClient.remove(viz); } } couchDbClient.shutdown(); } catch (NoDocumentException e) { e.printStackTrace(); } } }
protected CouchDbClientWrapper createClient() { return new CouchDbClientWrapper(new CouchDbClient(database, createDatabase, protocol, hostname, port, username, password)); }
public static CouchDbClient getCouchDbAdapterTemplateClient() { CouchDbClient dbClient = new CouchDbClient(props("adaptertemplate")); dbClient.setGsonBuilder(GsonSerializer.getAdapterGsonBuilder()); return dbClient; }
public Response save(Object doc) { return client.save(doc); }
@Override public void close() throws IOException { shutdown(); } }
public Response remove(Object doc) { return client.remove(doc); }
public Object get(String id) { return client.find(id); }
@GET @Path("/files") @Override public Response getEndpoints() { CouchDbClient couchDbClient = getCouchDbClient(); List<JsonObject> endpoints = couchDbClient.view("_all_docs").includeDocs(true).query(JsonObject.class); String json = new Gson().toJson(endpoints); return Response.ok(json).build(); }
@GET @Produces(MediaType.APPLICATION_JSON) @GsonWithIds @Override public Response getAllData(@PathParam("table") String table) { CouchDbClient couchDbClient = Utils.getCoucbDbClient(table); List<JsonObject> result = couchDbClient.view("_all_docs").includeDocs(true).query(JsonObject.class); String json = new Gson().toJson(result); couchDbClient.shutdown(); return Response.ok(json).build(); } }
public static CouchDbClient getCouchDbReplicatorClient() { CouchDbClient dbClient = new CouchDbClient(props("_replicator")); return dbClient; }
public static CouchDbClient getCouchDbPipelineClient() { CouchDbClient dbClient = new CouchDbClient(props("pipeline")); dbClient.setGsonBuilder(GsonSerializer.getGsonBuilder()); return dbClient; }
@Override protected Boolean executeCommand(CouchDbClient couchDbClient) { Response response = couchDbClient.save(objectToPersist); return response.getError() == null; } }
public T execute() { CouchDbClient couchDbClient = couchDbClientSupplier.get(); T result = executeCommand(couchDbClient); couchDbClient.shutdown(); return result; } }