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);
}
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;
}
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);
}
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);
}
}
}
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);
}
Aggregations