public void beforeRenderComponent() { super.beforeRenderComponent(); // Initialize the dashboard (loads all its kpi panels) DashboardHandler.lookup().getCurrentDashboard(); // Get the filter. DashboardFilter filter = getFilter(); // Check all visible properties exist. Iterator props = properties.iterator(); while (props.hasNext()) { DashboardFilterProperty dashboardFilterProperty = (DashboardFilterProperty) props.next(); if (!dashboardFilterProperty.isPropertyAlive()) props.remove(); } // Check if filtered properties for this filter component are already in dashboard filter. DashboardFilterProperty[] beingFilteredProps = getBeingFilteredProperties(); for (int i = 0; i < beingFilteredProps.length; i++) { List dfProperties = Arrays.asList(filter.getPropertyIds()); DashboardFilterProperty beignFilteredProp = beingFilteredProps[i]; if (!dfProperties.contains(beignFilteredProp.getPropertyId())) beignFilteredProp.setBeignFiltered(false); } // Check filtered properties and hide from available filter properties (set property not // visible) String[] propIds = filter.getPropertyIds(); for (int i = 0; i < propIds.length; i++) { String propId = propIds[i]; DashboardFilterProperty prop = getDashboardFilterProperty(propId); if (prop == null) { DashboardFilterProperty parentProperty = filter.getPropertyInParentDashboards(propId); if (parentProperty != null) { prop = new DashboardFilterProperty( parentProperty.getDataProviderCode(), propId, getFilter(), null, true); properties.add(prop); } } else { prop.setBeignFiltered(true); } } }
public void actionStore(CommandRequest request) { Map parameters = request.getRequestObject().getParameterMap(); // Initialize parameters and properties to default. showPropertyNames = false; showRefreshButton = false; showApplyButton = false; showClearButton = false; showSubmitOnChange = false; isShortMode = false; showLegend = false; showAutoRefresh = false; properties.clear(); notAllowedProperties.clear(); // Component options. if (parameters.containsKey(PARAM_SHOW_REFRESH_BUTTON)) showRefreshButton = true; if (parameters.containsKey(PARAM_SHOW_PROPERTY_NAMES)) showPropertyNames = true; if (parameters.containsKey(PARAM_SHOW_CLEAR_BUTTON)) showClearButton = true; if (parameters.containsKey(PARAM_SHOW_APPLY_BUTTON)) showApplyButton = true; if (parameters.containsKey(PARAM_SHOW_SUBMIT_ON_CHANGE)) showSubmitOnChange = true; if (parameters.containsKey(PARAM_SHORT_MODE)) isShortMode = true; if (parameters.containsKey(PARAM_SHOW_LEGEND)) showLegend = true; if (parameters.containsKey(PARAM_SHOW_AUTO_REFRESH)) showAutoRefresh = true; // Component properties. DashboardFilterProperty[] allProperties = getAllPropertiesForCurrentFilter(); for (int i = 0; i < allProperties.length; i++) { DashboardFilterProperty property = allProperties[i]; String dataProviderCode = property.getDataProviderCode(); String propertyId = property.getPropertyId(); String visibleParamKey = new StringBuffer() .append(PARAM_VISIBLE) .append("/") .append(dataProviderCode) .append("/") .append(propertyId) .toString(); String drillDownParamKey = new StringBuffer() .append(PARAM_SECTION) .append("/") .append(dataProviderCode) .append("/") .append(propertyId) .toString(); boolean isVisible = parameters.containsKey(visibleParamKey); Long sectionId = null; if (parameters.containsKey(drillDownParamKey)) { String sectionIdStr = ((String[]) parameters.get(drillDownParamKey))[0]; if (!PARAM_DRILLDOWN_DISABLED.equals(sectionIdStr)) sectionId = Long.decode(sectionIdStr); } if (!isVisible && sectionId == null) continue; // Property must be added? DashboardFilterProperty prop = getDashboardFilterPropertyForCurrentFilter(dataProviderCode, propertyId); if (prop == null) prop = new DashboardFilterProperty(dataProviderCode, propertyId, getFilter(), null, false); // Check if another property with same identifier. if (getDashboardFilterProperty(propertyId) != null) { // Another property with same id is already set to the filter. // Filter cannot use two properties with same property id., so show warning. notAllowedProperties.add(prop); continue; } // Add property to this component. properties.add(prop); // Set property parameters prop.setBeignFiltered(false); prop.setVisible(isVisible); prop.setSectionId(sectionId); } }