Search in sources :

Example 1 with GenerateElement

use of org.activityinfo.shared.command.GenerateElement 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);
    }
}
Also used : SiteResult(org.activityinfo.shared.command.result.SiteResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) PivotContent(org.activityinfo.shared.report.content.PivotContent) GetSites(org.activityinfo.shared.command.GetSites) GenerateElement(org.activityinfo.shared.command.GenerateElement) SearchResult(org.activityinfo.shared.command.result.SearchResult) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GenerateElement (org.activityinfo.shared.command.GenerateElement)1 GetSites (org.activityinfo.shared.command.GetSites)1 SearchResult (org.activityinfo.shared.command.result.SearchResult)1 SiteResult (org.activityinfo.shared.command.result.SiteResult)1 PivotContent (org.activityinfo.shared.report.content.PivotContent)1 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)1