/** * Query the records of model. */ default QueryListResult queryList(QueryOptions options) { return queryList(options, null); }
/** * Query the total count of records. */ default QueryListResult count(CountOptions options) { return count(options, null); }
@Override protected ModelQueryExecutor newQueryExecutor(ModelExecutorContext context) { return super.newQueryExecutor(context).fromSqlView(entity.getQueryView()); } }
/** * Gets the record of the specified id. */ protected ApiResponse get(Object id, QueryOptionsBase options) { ModelQueryExecutor executor = mef.newQueryExecutor(mec); QueryOneResult result = executor.queryOne(id, options); return ApiResponse.of(result.getRecord()); }
@Override protected ModelQueryExecutor newQueryExecutor(ModelExecutorContext context) { return super.newQueryExecutor(context).fromSqlView(entity.getQueryView()); } }
@Override public Object apply(ActionParams params) { MApiModel am = am(); ModelExecutorContext context = new SimpleModelExecutorContext(api, dao, am, em, params); ModelQueryExecutor executor = newQueryExecutor(context); Object id = id(params); QueryOptionsBase options = getWithId(params, 0); QueryOneResult result = executor.queryOne(id, options); if (null != result.getEntity()) { return ApiResponse.of(result.getEntity()); } else if (result.getRecord() == null) { throw new NotFoundException(am.getName() + " '" + id.toString() + "' not found"); } else { return ApiResponse.of(result.getRecord()); } }
/** * Query the records of model with the given filter fields. */ default QueryListResult queryList(QueryOptions options, Map<String, Object> filters) { return queryList(options, filters, null); }
@Override public Object apply(ActionParams params) { MApiModel am = am(); ModelExecutorContext context = new SimpleModelExecutorContext(api, dao, am, em, params); ModelQueryExecutor executor = newQueryExecutor(context); CountOptions options = getWithoutId(params, 0); QueryListResult result = executor.count(options, null); return ApiResponse.of(result.getCount()); }
public List<Record> queryList(QueryOptions options) { return newQueryExecutor().queryList(options).list; }
public QueryListResult query(QueryOptions options) { return newQueryExecutor().queryList(options); }
/** * Query the model records with the {@link QueryOptions}. */ protected ApiResponse<List<T>> queryList(QueryOptions options, Map<String, Object> filters, Consumer<ModelQueryExecutor> executorCallback, Consumer<CriteriaQuery> queryCallback, boolean filterByParams) { ModelQueryExecutor executor = mef.newQueryExecutor(mec); if(null != executorCallback) { executorCallback.accept(executor); } QueryListResult result = executor.queryList(options, filters, queryCallback, filterByParams); if (result.getCount() == -1) { return ApiResponse.of(result.getList()); } else { return ApiResponse.of(result.getList()).setHeader("X-Total-Count", String.valueOf(result.getCount())); } }
@Override public Object apply(ActionParams params) { MApiModel am = am(); ModelExecutorContext context = new SimpleModelExecutorContext(api, dao, am, em, params); ModelQueryExecutor executor = newQueryExecutor(context); QueryOptions options = getWithoutId(params, 0); QueryListResult result = executor.queryList(options); if (null != result.getEntity()) { return ApiResponse.of(result.getEntity()); } if (result.getCount() == -1) { return ApiResponse.of(result.getList()); } else { return ApiResponse.of(result.getList()).setHeader("X-Total-Count", String.valueOf(result.getCount())); } }