use of io.georocket.client.GeoRocketClient in project georocket by georocket.
the class AbstractQueryCommand method query.
/**
* Query data store using a search query and a layer
* @param query the search query (may be null)
* @param layer the layer to export (may be null)
* @param out the writer to write the results to
* @param handler the handler that should be called when all
* chunks have been exported
* @throws IOException if the query or the layer was invalid
*/
protected void query(String query, String layer, PrintWriter out, Handler<Integer> handler) throws IOException {
GeoRocketClient client = createClient();
client.getStore().search(query, layer, ar -> {
if (ar.failed()) {
error(ar.cause().getMessage());
if (!(ar.cause() instanceof NoSuchElementException) && !(ar.cause() instanceof NoStackTraceThrowable)) {
log.error("Could not query store", ar.cause());
}
handler.handle(1);
} else {
ar.result().handler(buf -> {
out.write(buf.toString("utf-8"));
});
ar.result().endHandler(v -> {
client.close();
handler.handle(0);
});
}
});
}
use of io.georocket.client.GeoRocketClient in project georocket by georocket.
the class AddTagCommand method doRun.
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out, Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().appendTags(query, layer, tags, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not add the tags", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
use of io.georocket.client.GeoRocketClient in project georocket by georocket.
the class GetPropertyCommand method doRun.
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out, Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().getPropertyValues(property, query, layer, ar -> {
if (ar.failed()) {
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not get values of property " + property, t);
}
handler.handle(1);
} else {
ar.result().handler(buf -> {
out.write(buf.toString("utf-8"));
});
ar.result().endHandler(v -> {
client.close();
handler.handle(0);
});
}
});
}
use of io.georocket.client.GeoRocketClient in project georocket by georocket.
the class DeleteCommand method doRun.
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out, Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().delete(query, layer, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not delete from store", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
use of io.georocket.client.GeoRocketClient in project georocket by georocket.
the class RemovePropertyCommand method doRun.
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out, Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().removeProperties(query, layer, properties, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not remove properties", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
Aggregations