public DashboardFilterProperty[] getBeingFilteredProperties() { List results = new ArrayList(); Iterator it = properties.iterator(); while (it.hasNext()) { DashboardFilterProperty dashboardFilterProperty = (DashboardFilterProperty) it.next(); if (dashboardFilterProperty.isBeingFiltered()) results.add(dashboardFilterProperty); } return (DashboardFilterProperty[]) results.toArray(new DashboardFilterProperty[results.size()]); }
public CommandResponse actionFilter(CommandRequest request) { try { // Init attributes for start applying the filter. filterPropertyErrors.clear(); // Parse parameters and set the filter. Iterator visiblePropertiesIt = properties.iterator(); while (visiblePropertiesIt.hasNext()) { DashboardFilterProperty dashboardFilterProperty = (DashboardFilterProperty) visiblePropertiesIt.next(); // Is property already in the dashboard filter?. Then is not possible to filter by this // property, it's already added to dashboard filter. if (dashboardFilterProperty.isBeingFiltered()) continue; if (!dashboardFilterProperty.isPropertyAlive()) { log.warn( "Trying to filter by " + dashboardFilterProperty.getPropertyId() + ". This property is not in any dataset."); continue; } if (!dashboardFilterProperty.isVisible()) continue; Object[] result; try { result = requestProcessor.parseDashboardProperty( request.getRequestObject(), dashboardFilterProperty); } catch (Exception e) { log.error("Error parsing property " + dashboardFilterProperty.getPropertyId() + ".", e); continue; } if (result.length != 3) { log.error( "Error parsing property: '" + dashboardFilterProperty.getPropertyId() + "' for dataProvider: '" + dashboardFilterProperty.getDataProviderCode() + "'"); continue; } Collection allowedValues = (Collection) result[0]; Object minValue = result[1]; Object maxValue = result[2]; if (allowedValues == null && minValue == null && maxValue == null) continue; // Set the filter with this property. Dashboard currentDashboard = DashboardHandler.lookup().getCurrentDashboard(); if (currentDashboard.filter( dashboardFilterProperty.getPropertyId(), minValue, true, maxValue, true, allowedValues, FilterByCriteria.ALLOW_ANY)) { return new ShowCurrentScreenResponse(); } } } catch (Exception e) { log.error("Error trying to filter properties for dashboard", e); } return null; }