@Override public void search( List<String> testQuery, SqlTransaction tx, final AsyncCallback<List<Integer>> callback) { final List<Integer> ids = new ArrayList<Integer>(); String tableName = "Location"; final String primaryKey = "LocationID"; SqlQuery.select(primaryKey) .from(tableName.toLowerCase()) .whereLikes("Name") .likeMany(testQuery) .execute( tx, new SqlResultCallback() { @Override public void onSuccess(SqlTransaction tx, SqlResultSet results) { for (SqlResultSetRow row : results.getRows()) { ids.add(row.getInt(primaryKey)); } callback.onSuccess(ids); } @Override public boolean onFailure(SqlException e) { return super.onFailure(e); } }); }
@Override public void setupQuery(PivotSites command, SqlQuery query) { query.from(Tables.TARGET_VALUE, "V"); query.leftJoin(Tables.TARGET, "Target").on("V.TargetId = Target.TargetId"); query.leftJoin(Tables.INDICATOR, "Indicator").on("V.IndicatorId = Indicator.IndicatorId"); query.leftJoin(Tables.ACTIVITY, "Activity").on("Activity.ActivityId = Indicator.ActivityId"); query.leftJoin(Tables.SITE, "Site").on("Site.ActivityId = Activity.ActivityId"); query .leftJoin(Tables.USER_DATABASE, "UserDatabase") .on("UserDatabase.DatabaseId = Activity.DatabaseId"); // don't use an actual sum query, target value is the same regardless of the number of sites query.appendColumn(String.valueOf(IndicatorDTO.AGGREGATE_SUM), ValueFields.AGGREGATION); query.appendColumn("V.Value", ValueFields.SUM); query.appendColumn("COUNT(V.Value)", ValueFields.COUNT); }