use of org.folio.rest.jaxrs.model.Loccamp in project mod-inventory-storage by folio-org.
the class LocationUnitAPI method getLocationUnitsCampusesById.
@Override
public void getLocationUnitsCampusesById(String id, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
String tenantId = getTenant(okapiHeaders);
Criterion criterion;
try {
Criteria criteria = new Criteria(CAMP_SCHEMA_PATH);
criteria.addField(ID_FIELD_NAME);
criteria.setOperation("=");
criteria.setValue(id);
criterion = new Criterion(criteria);
} catch (Exception e) {
String message = logAndSaveError(e);
asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesByIdResponse.withPlainInternalServerError(message)));
return;
}
PostgresClient.getInstance(vertxContext.owner(), tenantId).get(CAMPUS_TABLE, Loccamp.class, criterion, true, false, getReply -> {
if (getReply.failed()) {
String message = logAndSaveError(getReply.cause());
asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesByIdResponse.withPlainInternalServerError(message)));
} else {
List<Loccamp> items = (List<Loccamp>) getReply.result().getResults();
if (items.isEmpty()) {
asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesByIdResponse.withPlainNotFound(messages.getMessage(lang, MessageConsts.ObjectDoesNotExist))));
} else if (items.size() > 1) {
String message = "Multiple campuses found with the same id";
logger.error(message);
asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesByIdResponse.withPlainInternalServerError(message)));
} else {
asyncResultHandler.handle(Future.succeededFuture(LocationUnitsResource.GetLocationUnitsCampusesByIdResponse.withJsonOK(items.get(0))));
}
}
});
}
use of org.folio.rest.jaxrs.model.Loccamp 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)));
}
});
}
Aggregations