Search in sources :

Example 11 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType in project activityinfo by bedatadriven.

the class FilterAdapter method marshal.

@Override
public FilterElement marshal(Filter filter) throws Exception {
    FilterElement element = new FilterElement();
    element.dateRange = filter.getDateRange();
    for (DimensionType t : filter.getRestrictedDimensions()) {
        Restriction r = new Restriction();
        r.dimension = t.toString().toLowerCase();
        for (Integer id : filter.getRestrictions(t)) {
            r.categories.add(id.toString());
        }
        element.restrictions.add(r);
    }
    return element;
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType)

Example 12 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType in project activityinfo by bedatadriven.

the class DataEntryPlaceParser method updateFilter.

private void updateFilter(DataEntryPlace place, String[] qualifierParts) {
    DimensionType type = DimensionType.valueOf(qualifierParts[0]);
    Set<Integer> ids = Sets.newHashSet();
    for (int i = 1; i < qualifierParts.length; ++i) {
        ids.add(Integer.parseInt(qualifierParts[i]));
    }
    place.getFilter().addRestriction(type, ids);
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType)

Example 13 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType in project activityinfo by bedatadriven.

the class DataEntryPlaceParser method appendFilter.

private static void appendFilter(StringBuilder fragment, Filter filter) {
    for (DimensionType dimType : filter.getRestrictedDimensions()) {
        if (fragment.length() > 0) {
            fragment.append("-");
        }
        fragment.append(dimType.name());
        Set<Integer> ids = filter.getRestrictions(dimType);
        for (Integer id : ids) {
            fragment.append("+").append(id);
        }
    }
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType)

Example 14 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType 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 15 with DimensionType

use of org.activityinfo.shared.report.model.DimensionType in project activityinfo by bedatadriven.

the class ReportGenerator method generateReport.

private void generateReport(User user, Report report, Filter inheritedFilter, DateRange dateRange) {
    GeneratorUtils.resolveElementFilter(report, dateRange);
    Filter effectiveFilter = GeneratorUtils.resolveEffectiveFilter(report, inheritedFilter, dateRange);
    for (ReportElement element : report.getElements()) {
        generateElement(user, element, effectiveFilter, dateRange);
    }
    ReportContent content = new ReportContent();
    content.setFileName(generateFileName(report, dateRange, user));
    content.setFilterDescriptions(generateFilterDescriptions(effectiveFilter, Collections.<DimensionType>emptySet(), user));
    report.setContent(content);
}
Also used : DimensionType(org.activityinfo.shared.report.model.DimensionType) ReportContent(org.activityinfo.shared.report.content.ReportContent) Filter(org.activityinfo.shared.command.Filter) PivotChartReportElement(org.activityinfo.shared.report.model.PivotChartReportElement) TextReportElement(org.activityinfo.shared.report.model.TextReportElement) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement)

Aggregations

DimensionType (org.activityinfo.shared.report.model.DimensionType)17 Filter (org.activityinfo.shared.command.Filter)5 ArrayList (java.util.ArrayList)4 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)2 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 Set (java.util.Set)2 FilterDescription (org.activityinfo.shared.report.content.FilterDescription)2 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 BubbleLayerGenerator (org.activityinfo.server.report.generator.map.BubbleLayerGenerator)1 IconLayerGenerator (org.activityinfo.server.report.generator.map.IconLayerGenerator)1 LayerGenerator (org.activityinfo.server.report.generator.map.LayerGenerator)1 Margins (org.activityinfo.server.report.generator.map.Margins)1