Search in sources :

Example 1 with Loccamps

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

the class LocationUnitAPI method getLocationUnitsCampuses.

@Override
public void getLocationUnitsCampuses(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, CAMPUS_TABLE);
    } catch (Exception e) {
        String message = logAndSaveError(e);
        asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesResponse.withPlainInternalServerError(message)));
        return;
    }
    PostgresClient.getInstance(vertxContext.owner(), tenantId).get(CAMPUS_TABLE, Loccamp.class, new String[] { "*" }, cql, true, true, reply -> {
        if (reply.failed()) {
            String message = logAndSaveError(reply.cause());
            asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesResponse.withPlainBadRequest(message)));
        } else {
            Loccamps camps = new Loccamps();
            List<Loccamp> items = (List<Loccamp>) reply.result().getResults();
            camps.setLoccamps(items);
            camps.setTotalRecords(reply.result().getResultInfo().getTotalRecords());
            asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesResponse.withJsonOK(camps)));
        }
    });
}
Also used : Loccamp(org.folio.rest.jaxrs.model.Loccamp) List(java.util.List) CQLWrapper(org.folio.rest.persist.cql.CQLWrapper) FieldException(org.z3950.zing.cql.cql2pgjson.FieldException) Loccamps(org.folio.rest.jaxrs.model.Loccamps)

Aggregations

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