Search in sources :

Example 41 with Filter

use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.

the class DataEntryPlaceParser method parse.

@Override
public DataEntryPlace parse(String token) {
    DataEntryPlace place = new DataEntryPlace();
    if (!token.isEmpty()) {
        String[] parts = token.split("/");
        new Filter();
        if (parts.length > 0) {
            String[] qualifiers = parts[0].split("\\-");
            for (String qualifier : qualifiers) {
                String[] qualifierParts = qualifier.split("\\+");
                if (qualifierParts[0].equals("groupByAdmin")) {
                    AdminGroupingModel grouping = new AdminGroupingModel(Integer.parseInt(qualifierParts[1]));
                    place.setGrouping(grouping);
                } else {
                    updateFilter(place, qualifierParts);
                }
            }
        }
    }
    return place;
}
Also used : AdminGroupingModel(org.activityinfo.client.page.entry.grouping.AdminGroupingModel) Filter(org.activityinfo.shared.command.Filter)

Example 42 with Filter

use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.

the class SearchPresenter method onSearch.

@Override
public void onSearch(SearchEvent searchEvent) {
    if (!Strings.isNullOrEmpty(searchEvent.getQuery())) {
        view.setSearchQuery(searchEvent.getQuery());
        view.getLoadingMonitor().beforeRequest();
        service.execute(new Search(searchEvent.getQuery()), view.getLoadingMonitor(), new AsyncCallback<SearchResult>() {

            @Override
            public void onFailure(Throwable caught) {
                // TODO handle failure
                view.getLoadingMonitor().onServerError();
            }

            @Override
            public void onSuccess(SearchResult result) {
                view.setSearchResults(result.getPivotTabelData());
                Filter filter = result.getPivotTabelData() == null ? null : result.getPivotTabelData().getEffectiveFilter();
                view.setFilter(createFilter(filter, result.getPivotTabelData()));
                view.getLoadingMonitor().onCompleted();
                view.setSitePoints(SitePointList.fromSitesList(result.getRecentAdditions()));
                view.setSites(fromSitesList(result.getRecentAdditions()));
            }

            private Map<DimensionType, List<SearchResultEntity>> createFilter(Filter effectiveFilter, PivotContent pivotContent) {
                Map<DimensionType, List<SearchResultEntity>> newFilter = new HashMap<DimensionType, List<SearchResultEntity>>();
                if (effectiveFilter != null) {
                    for (DimensionType type : effectiveFilter.getRestrictedDimensions()) {
                        List<SearchResultEntity> entities = new ArrayList<SearchResultEntity>();
                        for (Integer entityId : effectiveFilter.getRestrictions(type)) {
                            String name = getName(entityId, type, pivotContent);
                            String link = GWT.getHostPageBaseURL() + "#search/" + type.toString() + ":" + name;
                            SearchResultEntity entity = new SearchResultEntity(entityId, name, link, type);
                            entities.add(entity);
                        }
                        newFilter.put(type, entities);
                    }
                }
                return newFilter;
            }

            private String getName(Integer entityId, DimensionType type, PivotContent pivotTable) {
                for (FilterDescription fd : pivotTable.getFilterDescriptions()) {
                    if (fd.getDimensionType() == type) {
                        return fd.getLabels().get(entityId);
                    }
                }
                return "noName";
            }
        });
    }
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) SearchResult(org.activityinfo.shared.command.result.SearchResult) Filter(org.activityinfo.shared.command.Filter) Search(org.activityinfo.shared.command.Search) PivotContent(org.activityinfo.shared.report.content.PivotContent) SitePointList(org.activityinfo.shared.command.result.SitePointList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 43 with Filter

use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.

the class LayerFilterPanel method createNewFilterAndFireEvent.

private void createNewFilterAndFireEvent() {
    Filter filter = new Filter();
    filter.setDateRange(dateWidget.getValue().getDateRange());
    Filter partnerFilter = partnerFilterWidget.getValue();
    if (partnerFilter.hasRestrictions()) {
        filter.addRestriction(DimensionType.Partner, partnerFilter.getRestrictions(DimensionType.Partner));
    }
    Filter attributeGroupFilter = attributeGroupWidgets.getValue();
    if (attributeGroupFilter.hasRestrictions()) {
        filter.addRestriction(AttributeGroupFilterWidget.DIMENSION_TYPE, attributeGroupFilter.getRestrictions(AttributeGroupFilterWidget.DIMENSION_TYPE));
    }
    setValue(filter);
}
Also used : Filter(org.activityinfo.shared.command.Filter)

Example 44 with Filter

use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.

the class LayerFilterPanel method setValue.

@Override
public void setValue(Filter value, boolean fireEvents) {
    if (value == null) {
        value = new Filter();
    } else {
        this.filter = value;
        dateWidget.setValue(value, false);
        partnerFilterWidget.setValue(value, false);
    }
    if (fireEvents) {
        ValueChangeEvent.fire(this, value);
    }
}
Also used : Filter(org.activityinfo.shared.command.Filter)

Example 45 with Filter

use of org.activityinfo.shared.command.Filter in project activityinfo by bedatadriven.

the class PivotTableEditor method createFilterPane.

private void createFilterPane() {
    filterPane = new PivotFilterPanel(eventBus, service);
    filterPane.applyBaseFilter(new Filter());
    BorderLayoutData west = new BorderLayoutData(Style.LayoutRegion.WEST);
    west.setMinSize(250);
    west.setSize(250);
    west.setCollapsible(true);
    west.setSplit(true);
    west.setMargins(new Margins(0, 0, 0, 0));
    add(filterPane, west);
}
Also used : PivotFilterPanel(org.activityinfo.client.report.editor.chart.PivotFilterPanel) Filter(org.activityinfo.shared.command.Filter) BorderLayoutData(com.extjs.gxt.ui.client.widget.layout.BorderLayoutData) Margins(com.extjs.gxt.ui.client.util.Margins)

Aggregations

Filter (org.activityinfo.shared.command.Filter)59 GetSites (org.activityinfo.shared.command.GetSites)8 Test (org.junit.Test)8 GetSchema (org.activityinfo.shared.command.GetSchema)5 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)5 DimensionType (org.activityinfo.shared.report.model.DimensionType)5 ArrayList (java.util.ArrayList)4 SiteDTO (org.activityinfo.shared.dto.SiteDTO)4 DateRange (org.activityinfo.shared.report.model.DateRange)4 StringWriter (java.io.StringWriter)3 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)3 SiteResult (org.activityinfo.shared.command.result.SiteResult)3 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)3 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)3 Margins (com.extjs.gxt.ui.client.util.Margins)2 BorderLayoutData (com.extjs.gxt.ui.client.widget.layout.BorderLayoutData)2 JsonElement (com.google.gson.JsonElement)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 List (java.util.List)2