Search in sources :

Example 6 with Validate

use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.

the class BooksDemoAPI method postRmbtestsBooks.

@Validate
@Override
public void postRmbtestsBooks(Book entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
    OutStream stream = new OutStream();
    stream.setData(entity);
    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostRmbtestsBooksResponse.withJsonCreated("/dummy/location", stream)));
}
Also used : OutStream(org.folio.rest.tools.utils.OutStream) Validate(org.folio.rest.annotations.Validate)

Example 7 with Validate

use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.

the class JobAPI method getJobsJobconfs.

@Validate
@Override
public void getJobsJobconfs(String query, String orderBy, Order order, int offset, int limit, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
    try {
        Criterion criterion = Criterion.json2Criterion(query);
        criterion.setLimit(new Limit(limit)).setOffset(new Offset(offset));
        org.folio.rest.persist.Criteria.Order or = getOrder(order, orderBy);
        if (or != null) {
            criterion.setOrder(or);
        }
        System.out.println("sending... getJobsJobconfs");
        vertxContext.runOnContext(v -> {
            try {
                PostgresClient.getInstance(vertxContext.owner()).get(RTFConsts.JOB_CONF_COLLECTION, JobConf.class, criterion, true, reply -> {
                    JobsConfs ps = new JobsConfs();
                    @SuppressWarnings("unchecked") List<JobConf> jobConfs = (List<JobConf>) reply.result().getResults();
                    ps.setJobConfs(jobConfs);
                    ps.setTotalRecords(jobConfs.size());
                    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsResponse.withJsonOK(ps)));
                });
            } catch (Exception e) {
                log.error(e);
                asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
            }
        });
    } catch (Exception e) {
        log.error(e);
        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
    }
}
Also used : Criteria(org.folio.rest.persist.Criteria.Criteria) Offset(org.folio.rest.persist.Criteria.Offset) Criterion(org.folio.rest.persist.Criteria.Criterion) JobsConfs(org.folio.rest.jaxrs.model.JobsConfs) List(java.util.List) Limit(org.folio.rest.persist.Criteria.Limit) JobConf(org.folio.rest.jaxrs.model.JobConf) Validate(org.folio.rest.annotations.Validate)

Example 8 with Validate

use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.

the class JobAPI method postJobsJobconfsByJobconfsIdJobs.

@Validate
@Override
public void postJobsJobconfsByJobconfsIdJobs(String jobconfsId, String lang, Job entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
    System.out.println("sending... postJobsJobconfsByJobconfsIdJobs");
    entity.setJobConfId(jobconfsId);
    try {
        vertxContext.runOnContext(v -> {
            try {
                PostgresClient.getInstance(vertxContext.owner()).save(RTFConsts.JOBS_COLLECTION, entity, reply -> {
                    try {
                        OutStream stream = new OutStream();
                        stream.setData(entity);
                        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withJsonCreated(reply.result(), stream)));
                    } catch (Exception e) {
                        log.error(e);
                        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
                    }
                });
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
            }
        });
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
    }
}
Also used : OutStream(org.folio.rest.tools.utils.OutStream) Validate(org.folio.rest.annotations.Validate)

Example 9 with Validate

use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.

the class JobAPI method postJobsJobconfs.

@Validate
@Override
public void postJobsJobconfs(String lang, JobConf entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
    System.out.println("sending... postJobsJobconfs");
    try {
        vertxContext.runOnContext(v -> {
            try {
                PostgresClient.getInstance(vertxContext.owner()).save(RTFConsts.JOB_CONF_COLLECTION, entity, reply -> {
                    OutStream stream = new OutStream();
                    stream.setData(entity);
                    asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsResponse.withJsonCreated(reply.result(), stream)));
                });
            } catch (Exception e) {
                log.error(e);
                asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
            }
        });
    } catch (Exception e) {
        log.error(e);
        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(PostJobsJobconfsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
    }
}
Also used : OutStream(org.folio.rest.tools.utils.OutStream) Validate(org.folio.rest.annotations.Validate)

Example 10 with Validate

use of org.folio.rest.annotations.Validate in project raml-module-builder by folio-org.

the class JobAPI method getJobsJobconfsByJobconfsIdJobs.

@Validate
@Override
public void getJobsJobconfsByJobconfsIdJobs(String jobconfsId, String query, String orderBy, Order order, int offset, int limit, String lang, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) throws Exception {
    System.out.println("sending... getJobsJobconfsByJobconfsIdJobs");
    try {
        Criterion criterion = Criterion.json2Criterion(query);
        criterion.setLimit(new Limit(limit)).setOffset(new Offset(offset));
        org.folio.rest.persist.Criteria.Order or = getOrder(order, orderBy);
        if (or != null) {
            criterion.setOrder(or);
        }
        vertxContext.runOnContext(v -> {
            try {
                PostgresClient.getInstance(vertxContext.owner()).get(RTFConsts.JOBS_COLLECTION, Job.class, criterion, true, reply -> {
                    try {
                        @SuppressWarnings("unchecked") List<Job> jobs = (List<Job>) reply.result().getResults();
                        Jobs jobList = new Jobs();
                        jobList.setJobs(jobs);
                        jobList.setTotalRecords(jobs.size());
                        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsResponse.withJsonOK(jobList)));
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
                    }
                });
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
            }
        });
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        asyncResultHandler.handle(io.vertx.core.Future.succeededFuture(GetJobsJobconfsByJobconfsIdJobsResponse.withPlainInternalServerError(messages.getMessage(lang, MessageConsts.InternalServerError))));
    }
}
Also used : Criteria(org.folio.rest.persist.Criteria.Criteria) Offset(org.folio.rest.persist.Criteria.Offset) Criterion(org.folio.rest.persist.Criteria.Criterion) Jobs(org.folio.rest.jaxrs.model.Jobs) List(java.util.List) Limit(org.folio.rest.persist.Criteria.Limit) Job(org.folio.rest.jaxrs.model.Job) Validate(org.folio.rest.annotations.Validate)

Aggregations

Validate (org.folio.rest.annotations.Validate)66 FieldException (org.z3950.zing.cql.cql2pgjson.FieldException)42 CQLParseException (org.z3950.zing.cql.CQLParseException)32 List (java.util.List)27 OutStream (org.folio.rest.tools.utils.OutStream)27 Criteria (org.folio.rest.persist.Criteria.Criteria)16 Criterion (org.folio.rest.persist.Criteria.Criterion)16 PostgresClient (org.folio.rest.persist.PostgresClient)16 CQLWrapper (org.folio.rest.persist.cql.CQLWrapper)13 JsonObject (io.vertx.core.json.JsonObject)4 Map (java.util.Map)4 Response (javax.ws.rs.core.Response)4 TenantTool (org.folio.rest.tools.utils.TenantTool)4 InputStream (java.io.InputStream)3 BodyPart (javax.mail.BodyPart)3 io.vertx.core (io.vertx.core)2 AsyncResult (io.vertx.core.AsyncResult)2 Context (io.vertx.core.Context)2 Handler (io.vertx.core.Handler)2 Logger (io.vertx.core.logging.Logger)2