Search in sources :

Example 51 with Filter

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

the class SitesResources method query.

@GET
@Produces(MediaType.APPLICATION_JSON)
public String query(@QueryParam("activity") List<Integer> activityIds, @QueryParam("database") List<Integer> databaseIds, @QueryParam("format") String format) throws IOException {
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, activityIds);
    filter.addRestriction(DimensionType.Database, databaseIds);
    List<SiteDTO> sites = dispatcher.execute(new GetSites(filter)).getData();
    StringWriter writer = new StringWriter();
    JsonGenerator json = Jackson.createJsonFactory(writer);
    writeJson(sites, json);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) JsonGenerator(org.codehaus.jackson.JsonGenerator) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 52 with Filter

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

Example 53 with Filter

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

the class PolygonLayerGenerator method query.

@Override
public void query(DispatcherSync dispatcher, Filter effectiveFilter) {
    Filter layerFilter = new Filter(effectiveFilter, layer.getFilter());
    layerFilter.addRestriction(DimensionType.Indicator, layer.getIndicatorIds());
    queryBounds(dispatcher, layerFilter);
    queryBuckets(dispatcher, layerFilter);
    color();
}
Also used : Filter(org.activityinfo.shared.command.Filter)

Example 54 with Filter

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

the class FilterAdapter method unmarshal.

@Override
public Filter unmarshal(FilterElement element) throws Exception {
    Filter filter = new Filter();
    filter.setDateRange(element.dateRange);
    for (Restriction r : element.restrictions) {
        for (String s : r.categories) {
            filter.addRestriction(findDimType(r.dimension), Integer.parseInt(s));
        }
    }
    return filter;
}
Also used : Filter(org.activityinfo.shared.command.Filter)

Example 55 with Filter

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

the class DataEntryPlaceParserTest method activityFilteredAndGrouped.

@Test
public void activityFilteredAndGrouped() {
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Activity, 33);
    AdminGroupingModel grouping = new AdminGroupingModel(1);
    verifyCorrectSerde(new DataEntryPlace(grouping, filter));
}
Also used : AdminGroupingModel(org.activityinfo.client.page.entry.grouping.AdminGroupingModel) Filter(org.activityinfo.shared.command.Filter) Test(org.junit.Test)

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