Search in sources :

Example 1 with Locinsts

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

the class LocationUnitAPI method getLocationUnitsInstitutions.

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

Aggregations

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