use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class SearchHandler method processFilter.
private void processFilter(final ExecutionContext context, final AsyncCallback<SearchResult> callback, final Filter resultFilter) {
final SearchResult searchResult = new SearchResult();
if (resultFilter.getRestrictedDimensions().size() > 0) {
// pivot data query
final PivotTableReportElement pivotTable = createSearchPivotTableElement();
pivotTable.setFilter(resultFilter);
GenerateElement<PivotContent> zmd = new GenerateElement<PivotContent>(pivotTable);
context.execute(zmd, new AsyncCallback<PivotContent>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(PivotContent content) {
content.setEffectiveFilter(resultFilter);
searchResult.setPivotTabelData(content);
// recent sites query
GetSites getSites = createGetSitesCommand(resultFilter);
context.execute(getSites, new AsyncCallback<SiteResult>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(SiteResult resultSites) {
searchResult.setRecentAdditions(resultSites.getData());
callback.onSuccess(searchResult);
}
});
}
});
} else {
// Return empty searchresult when no filtered entities found
callback.onSuccess(searchResult);
}
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class KmlDataServlet method querySites.
private List<SiteDTO> querySites(User user, SchemaDTO schema, int activityId) {
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, activityId);
return dispatcher.execute(new GetSites(filter)).getData();
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class PointLayerGenerator method queryFor.
private GetSites queryFor(Filter effectiveFilter, PointMapLayer layer) {
Filter layerFilter = new Filter(effectiveFilter, layer.getFilter());
for (int id : layer.getIndicatorIds()) {
Indicator indicator = indicators.get(id);
if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SITE_COUNT) {
layerFilter.addRestriction(DimensionType.Activity, indicator.getActivity().getId());
} else {
layerFilter.addRestriction(DimensionType.Indicator, indicator.getId());
}
}
layerFilter.addRestriction(DimensionType.Indicator, physicalIndicators(layer));
GetSites query = new GetSites();
query.setFilter(layerFilter);
query.setFetchAttributes(false);
query.setFetchAdminEntities(layer.getClustering() instanceof AdministrativeLevelClustering);
query.setFetchAllIndicators(false);
query.setFetchIndicators(physicalIndicators(layer));
return query;
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitePointsHandler method execute.
@Override
public void execute(GetSitePoints command, ExecutionContext context, final AsyncCallback<SitePointList> callback) {
Filter filter = new Filter();
if (command.getActivityId() != 0) {
filter.addRestriction(DimensionType.Activity, command.getActivityId());
}
context.execute(new GetSites(filter), new AsyncCallback<SiteResult>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(SiteResult result) {
callback.onSuccess(toPointList(result.getData()));
}
});
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method duplicated.
@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void duplicated() {
// A given site can be appear multiple times in the list if it is the
// source
// of one or more indicators
setUser(1);
GetSites cmd = new GetSites();
SiteResult result = execute(cmd);
assertThat(result.getData().size(), equalTo(3));
}
Aggregations