Search in sources :

Example 1 with Loclibs

use of org.folio.rest.jaxrs.model.Loclibs in project mod-inventory-storage by folio-org.

the class LocationUnitAPI method getLocationUnitsLibraries.

@Override
public void getLocationUnitsLibraries(String query, int offset, int limit, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    String tenantId = getTenant(okapiHeaders);
    CQLWrapper cql;
    try {
        cql = getCQL(query, limit, offset, LIBRARY_TABLE);
    } catch (Exception e) {
        String message = logAndSaveError(e);
        asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsLibrariesResponse.withPlainInternalServerError(message)));
        return;
    }
    PostgresClient.getInstance(vertxContext.owner(), tenantId).get(LIBRARY_TABLE, Loclib.class, new String[] { "*" }, cql, true, true, reply -> {
        if (reply.failed()) {
            String message = logAndSaveError(reply.cause());
            asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsLibrariesResponse.withPlainBadRequest(message)));
        } else {
            Loclibs lib = new Loclibs();
            List<Loclib> items = (List<Loclib>) reply.result().getResults();
            lib.setLoclibs(items);
            lib.setTotalRecords(reply.result().getResultInfo().getTotalRecords());
            asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsLibrariesResponse.withJsonOK(lib)));
        }
    });
}
Also used : Loclibs(org.folio.rest.jaxrs.model.Loclibs) List(java.util.List) CQLWrapper(org.folio.rest.persist.cql.CQLWrapper) FieldException(org.z3950.zing.cql.cql2pgjson.FieldException) Loclib(org.folio.rest.jaxrs.model.Loclib)

Aggregations

List (java.util.List)1 Loclib (org.folio.rest.jaxrs.model.Loclib)1 Loclibs (org.folio.rest.jaxrs.model.Loclibs)1 CQLWrapper (org.folio.rest.persist.cql.CQLWrapper)1 FieldException (org.z3950.zing.cql.cql2pgjson.FieldException)1