use of org.activityinfo.shared.command.result.AdminLevelResult in project activityinfo by bedatadriven.
the class AdminLevelPanel method setIndicators.
public void setIndicators(Collection<Integer> indicatorIds) {
showLoading();
GetAdminLevels query = new GetAdminLevels();
query.setIndicatorIds(Sets.newHashSet(indicatorIds));
dispatcher.execute(query, new AsyncCallback<AdminLevelResult>() {
@Override
public void onFailure(Throwable caught) {
showLoadingFailed();
}
@Override
public void onSuccess(AdminLevelResult result) {
showOptions(result.getData());
}
});
}
use of org.activityinfo.shared.command.result.AdminLevelResult in project activityinfo by bedatadriven.
the class GetAdminLevelsHandler method execute.
@Override
public void execute(GetAdminLevels command, ExecutionContext context, final AsyncCallback<AdminLevelResult> callback) {
if (CollectionUtil.isEmpty(command.getIndicatorIds())) {
callback.onSuccess(new AdminLevelResult(new ArrayList<AdminLevelDTO>()));
return;
}
String hasPolygonsSubQuery = "exists (select e.adminentityid from adminentity e " + "where e.adminlevelid=level.adminlevelid and geometry is not null)";
SqlQuery.select().appendColumn("level.adminlevelId", "id").appendColumn("level.name", "name").appendColumn(hasPolygonsSubQuery, "polygons").from(Tables.INDICATOR, "i").innerJoin(Tables.ACTIVITY, "a").on("i.activityId=a.activityId").innerJoin(Tables.USER_DATABASE, "db").on("a.databaseid=db.databaseid").innerJoin(Tables.COUNTRY, "c").on("db.countryid=c.countryid").innerJoin(Tables.ADMIN_LEVEL, "level").on("level.countryid=c.countryid").where("i.indicatorId").in(command.getIndicatorIds()).groupBy("level.adminlevelid").groupBy("level.name").execute(context.getTransaction(), new SqlResultCallback() {
@Override
public void onSuccess(SqlTransaction tx, SqlResultSet results) {
List<AdminLevelDTO> levels = Lists.newArrayList();
for (SqlResultSetRow row : results.getRows()) {
AdminLevelDTO level = new AdminLevelDTO();
level.setId(row.getInt("id"));
level.setName(row.getString("name"));
level.setPolygons(row.getBoolean("polygons"));
levels.add(level);
}
callback.onSuccess(new AdminLevelResult(levels));
}
});
}
use of org.activityinfo.shared.command.result.AdminLevelResult in project activityinfo by bedatadriven.
the class GetAdminLevelsHandlerTest method test.
@Test
public void test() {
GetAdminLevels query = new GetAdminLevels();
query.setIndicatorIds(Sets.newHashSet(1));
AdminLevelResult result = execute(query);
System.out.println(result.getData());
}
Aggregations