@Override public ResourceParams resourceParams() { return delegate.resourceParams(); }
@Override public ResourceParamsDecorator resourceParams() { return new ResourceParamsDecorator(delegate.resourceParams()); }
default void readConfigEnvVars(ObjectsTree<Object> configVars, RequestContext ctx, PropertySink sink) { boolean runtimeValuePresent = ctx.resourceParams().value("runtime") != null; boolean runtimeRequested = runtimeValuePresent ? Boolean.parseBoolean(ctx.resourceParams().value("runtime")) : ctx.resourceParams().names().contains("runtime"); // If runtime is not set, we replace the config values if (!runtimeRequested && configVars != null) { sink.replaceConfig((names, object) -> { ResourcePath path = new ResourcePath(names); List<Object> values = configVars.objects(path).collect(Collectors.toList()); if (values != null && values.size() == 1) { return values.get(0); } return object; }); } }
String overwriteProperty = ctx.resourceParams().value(OVERWRITE); boolean overwrite = overwriteProperty != null && overwriteProperty.equals(Boolean.TRUE.toString()); String cleanProperty = ctx.resourceParams().value(CLEAN); if (cleanProperty != null && cleanProperty.equals(Boolean.TRUE.toString())) { if (parent.directory().exists()) {
private BasicDBList aggregate(RequestContext ctx) { BasicDBList queryObject = new BasicDBList(); if (ctx.resourceParams() != null && ctx.resourceParams().contains("q")) { String queryString = ctx.resourceParams().value("q"); DBObject paramObject = (DBObject) JSON.parse(queryString); if (paramObject instanceof BasicDBList) { queryObject = (BasicDBList) paramObject; } else { queryObject.add(paramObject); } } DBCollection dbCollection = parent().getDBCollection(); try { BasicDBList result = new BasicDBList(); AggregationOutput output = dbCollection.aggregate( (DBObject) queryObject.remove(0), queryObject.toArray(new DBObject[queryObject.size()])); for (DBObject dbObject : output.results()) { result.add(dbObject); } return result; } catch (Exception e) { logger().error("", e); throw new RuntimeException("Aggregation query failed: ", e); } }
@Override public void createMember(RequestContext ctx, ResourceState state, Responder responder) throws Exception { String action = ctx.resourceParams().value("action"); if (action == null || (!action.equals(CREATE) && !action.equals(UPDATE) && !action.equals(MERGE) && !action.equals(DELETE))) {
public int queryTableCount(String table, RequestContext ctx) throws SQLException, IOException { Catalog cat = parent.catalog(); Table t = cat.tableById(table); try (Connection con = parent.connection()) { String q = ctx.resourceParams().value("q"); if (q != null) { return queryBuilder.querySelectCountFromTable(con, t, q); } else { return queryBuilder.querySelectCountFromTable(con, t); } } }
ResourceParams resourceParams = ctx.resourceParams(); if (resourceParams != null) { if (resourceParams.contains("q")) {
@Override public void delete(RequestContext ctx, Responder responder) throws Exception { ResourceParams params = ctx.resourceParams(); boolean cascade = params != null && params.contains("cascade"); Catalog cat = parent.parent().catalog(); Table table = cat.table(new TableRef(parent.id())); try (Connection c = parent.parent().connection()) { queryBuilder.executeDelete(ctx, c, table, id, cascade); } this.row = null; responder.resourceDeleted(this); } }
for (String name: ctx.resourceParams().names()) { if ("offset".equals(name) || "limit".equals(name)) { continue; List<String> values = ctx.resourceParams().values(name); for (String value: values) { uriBuilder.addParam(name, value);
ResourceParams resourceParams = ctx.resourceParams(); if (resourceParams != null && resourceParams.contains("hint")) { String hint = resourceParams.value("hint");
public QueryResults queryTable(String table, String id, RequestContext ctx) throws SQLException, IOException { Catalog cat = parent.catalog(); Table t = cat.tableById(table); try (Connection con = parent.connection()) { String q = ctx.resourceParams().value("q"); if (id == null) { if (q != null) { return queryBuilder.querySelectFromTable(con, t, replaceIdsWithColumnNames(ctx.sorting()), ctx.pagination(), q); } else { return queryBuilder.querySelectFromTable(con, t, replaceIdsWithColumnNames(ctx.sorting()), ctx.pagination()); } } else { return queryBuilder.querySelectFromTableWhereId(con, t, id); } } }