Search in sources :

Example 6 with DimensionType

use of org.activityinfo.legacy.shared.command.DimensionType in project activityinfo by bedatadriven.

the class TableGenerator method generate.

@Override
public void generate(User user, TableElement element, Filter inheritedFilter, DateRange dateRange) {
    Filter filter = GeneratorUtils.resolveElementFilter(element, dateRange);
    Filter effectiveFilter = inheritedFilter == null ? filter : new Filter(inheritedFilter, filter);
    TableContent content = new TableContent();
    content.setFilterDescriptions(generateFilterDescriptions(filter, Collections.<DimensionType>emptySet(), user));
    TableData data = generateData(element, effectiveFilter);
    content.setData(data);
    if (element.getMap() != null) {
        mapGenerator.generate(user, element.getMap(), effectiveFilter, dateRange);
        Map<Integer, String> siteLabels = element.getMap().getContent().siteLabelMap();
        for (SiteDTO row : data.getRows()) {
            row.set("map", siteLabels.get(row.getId()));
        }
    }
    element.setContent(content);
}
Also used : DimensionType(org.activityinfo.legacy.shared.command.DimensionType) Filter(org.activityinfo.legacy.shared.command.Filter) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) TableData(org.activityinfo.legacy.shared.reports.content.TableData) TableContent(org.activityinfo.legacy.shared.reports.content.TableContent)

Example 7 with DimensionType

use of org.activityinfo.legacy.shared.command.DimensionType in project activityinfo by bedatadriven.

the class BaseGenerator method generateFilterDescriptions.

protected List<FilterDescription> generateFilterDescriptions(Filter filter, Set<DimensionType> excludeDims, User user) {
    List<FilterDescription> list = new ArrayList<FilterDescription>();
    Set<DimensionType> filterDims = filter.getRestrictedDimensions();
    filterDims.removeAll(excludeDims);
    for (DimensionType type : filterDims) {
        DimensionLabels labels = dispatcher.execute(new GetDimensionLabels(type, filter.getRestrictions(type)));
        list.add(new FilterDescription(type, labels.getLabels()));
    }
    return list;
}
Also used : DimensionType(org.activityinfo.legacy.shared.command.DimensionType) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) FilterDescription(org.activityinfo.legacy.shared.reports.content.FilterDescription) ArrayList(java.util.ArrayList) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) DimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels.DimensionLabels)

Example 8 with DimensionType

use of org.activityinfo.legacy.shared.command.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.legacy.shared.command.DimensionType)

Example 9 with DimensionType

use of org.activityinfo.legacy.shared.command.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.legacy.shared.command.DimensionType)

Example 10 with DimensionType

use of org.activityinfo.legacy.shared.command.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.legacy.shared.command.DimensionType) ReportContent(org.activityinfo.legacy.shared.reports.content.ReportContent) Filter(org.activityinfo.legacy.shared.command.Filter)

Aggregations

DimensionType (org.activityinfo.legacy.shared.command.DimensionType)10 Filter (org.activityinfo.legacy.shared.command.Filter)5 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)2 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 GetDimensionLabels (org.activityinfo.legacy.shared.command.GetDimensionLabels)1 DimensionLabels (org.activityinfo.legacy.shared.command.GetDimensionLabels.DimensionLabels)1 BaseMap (org.activityinfo.legacy.shared.model.BaseMap)1 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)1 TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)1 FilterDescription (org.activityinfo.legacy.shared.reports.content.FilterDescription)1 GoogleBaseMap (org.activityinfo.legacy.shared.reports.content.GoogleBaseMap)1 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)1 ReportContent (org.activityinfo.legacy.shared.reports.content.ReportContent)1 TableContent (org.activityinfo.legacy.shared.reports.content.TableContent)1 TableData (org.activityinfo.legacy.shared.reports.content.TableData)1 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)1 Extents (org.activityinfo.model.type.geo.Extents)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1