use of com.extjs.gxt.ui.client.data.BaseListLoadResult in project activityinfo by bedatadriven.
the class LocationTypeProxy method load.
@Override
public void load(DataReader<ListLoadResult<LocationTypeEntry>> reader, Object loadConfig, AsyncCallback<ListLoadResult<LocationTypeEntry>> callback) {
dispatcher.execute(new GetSchema()).then(new Function<SchemaDTO, ListLoadResult<LocationTypeEntry>>() {
@Override
public ListLoadResult<LocationTypeEntry> apply(SchemaDTO schema) {
// Build a dictionary of databases that have been shared with the user
Map<Integer, String> databaseNames = new HashMap<>();
for (UserDatabaseDTO db : schema.getDatabases()) {
databaseNames.put(db.getId(), db.getName());
}
List<LocationTypeEntry> list = new ArrayList<>();
for (LocationTypeDTO locationType : schema.getCountryById(countryId).getLocationTypes()) {
if (!locationType.isDeleted()) {
if (locationType.getDatabaseId() == null) {
list.add(new LocationTypeEntry(locationType));
} else {
list.add(new LocationTypeEntry(locationType, databaseNames.get(locationType.getDatabaseId())));
}
}
}
Collections.sort(list);
return new BaseListLoadResult<>(list);
}
}).then(callback);
}
use of com.extjs.gxt.ui.client.data.BaseListLoadResult in project activityinfo by bedatadriven.
the class DimensionProxy method load.
@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<DimensionModel>> callback) {
final List<DimensionModel> list = Lists.newArrayList();
list.add(new DimensionModel(DimensionType.Indicator, I18N.CONSTANTS.indicator()));
list.add(new DimensionModel(DimensionType.Partner, I18N.CONSTANTS.partner()));
list.add(new DimensionModel(DimensionType.Project, I18N.CONSTANTS.project()));
list.add(new DimensionModel(DimensionType.Target, I18N.CONSTANTS.realizedOrTargeted()));
list.add(new DimensionModel(DateUnit.YEAR));
list.add(new DimensionModel(DateUnit.QUARTER));
list.add(new DimensionModel(DateUnit.MONTH));
list.add(new DimensionModel(DateUnit.WEEK_MON));
list.add(new DimensionModel(DimensionType.Location, I18N.CONSTANTS.location()));
if (model.getIndicators().isEmpty()) {
callback.onSuccess(new BaseListLoadResult<>(list));
} else {
Dimensions.loadDimensions(dispatcher, model).then(new Function<Dimensions, ListLoadResult<DimensionModel>>() {
@Override
public ListLoadResult<DimensionModel> apply(Dimensions input) {
list.addAll(input.getAttributeDimensions());
list.addAll(input.getAdminLevelDimensions());
return new BaseListLoadResult<>(list);
}
}).then(callback);
}
}
Aggregations