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