// Return if is needed to serialize and save properties after this call because properties that
  // does not exist on current filter or data providers must be deleted from persistence.
  // return: must clear serialized trash properties after deserialize process saving this data.
  public boolean deserializeComponentData(String serializedData) throws Exception {
    // Load options and visible properties
    if (serializedData == null || serializedData.trim().length() == 0) {
      log.info("No data to deserialize.");
      return false;
    }

    DOMParser parser = new DOMParser();
    parser.parse(new InputSource(new StringReader(serializedData)));
    Document doc = parser.getDocument();
    NodeList nodes = doc.getElementsByTagName("dashboard_filter");
    if (nodes.getLength() > 1) {
      log.error("Each dashboard filter component just can parse one <dashboard_filter>");
      return false;
    }
    if (nodes.getLength() == 0) {
      log.info("No data to deserialize.");
      return false;
    }

    boolean needsToSerializeAfter = false;
    serializedProperties = serializedData;
    Node rootNode = nodes.item(0);
    nodes = rootNode.getChildNodes();
    for (int x = 0; x < nodes.getLength(); x++) {
      Node node = nodes.item(x);
      if (node.getNodeName().equals("property")) {
        // Parse visible properties.
        String dataProviderCode = node.getAttributes().getNamedItem("providerCode").getNodeValue();
        String propertyId = node.getAttributes().getNamedItem("id").getNodeValue();
        String sectionId = null;
        boolean visible = false;
        NodeList subnodes = node.getChildNodes();
        for (int i = 0; i < subnodes.getLength(); i++) {
          Node subnode = subnodes.item(i);
          if (subnode.getNodeName().equals("section")) {
            sectionId = subnode.getFirstChild().getNodeValue();
          }
          if (subnode.getNodeName().equals("visible")) {
            visible = Boolean.valueOf(subnode.getFirstChild().getNodeValue()).booleanValue();
          }
        }
        Long lSectionId = sectionId != null ? Long.decode(sectionId) : null;
        DashboardFilterProperty filterProp =
            new DashboardFilterProperty(
                dataProviderCode, propertyId, getFilter(), lSectionId, true);
        filterProp.setVisible(visible);
        if (filterProp.isPropertyAlive()) properties.add(filterProp);
        else needsToSerializeAfter = true;
      } else if (node.getNodeName().equals("options")) {
        // Parse component options.
        NodeList options = node.getChildNodes();
        String showRefreshButton = null;
        String showPropertyNames = null;
        String showClearButton = null;
        String showApplyButton = null;
        String showSubmitOnChange = null;
        String showShortViewMode = null;
        String showLegend = null;
        String showAutoRefresh = null;
        for (int i = 0; i < options.getLength(); i++) {
          Node option = options.item(i);
          if (option.getNodeName().equals("showRefreshButton"))
            showRefreshButton = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("showPropertyNames"))
            showPropertyNames = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("showClearButton"))
            showClearButton = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("showApplyhButton"))
            showApplyButton = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("showSubmitOnChange"))
            showSubmitOnChange = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("shortViewMode"))
            showShortViewMode = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("showLegend"))
            showLegend = option.getFirstChild().getNodeValue();
          if (option.getNodeName().equals("showAutoRefresh"))
            showAutoRefresh = option.getFirstChild().getNodeValue();
        }
        this.showPropertyNames = Boolean.valueOf(showPropertyNames).booleanValue();
        this.showRefreshButton = Boolean.valueOf(showRefreshButton).booleanValue();
        this.showApplyButton = Boolean.valueOf(showApplyButton).booleanValue();
        this.showClearButton = Boolean.valueOf(showClearButton).booleanValue();
        this.showSubmitOnChange = Boolean.valueOf(showSubmitOnChange).booleanValue();
        this.isShortMode = Boolean.valueOf(showShortViewMode).booleanValue();
        this.showLegend = Boolean.valueOf(showLegend).booleanValue();
        this.showAutoRefresh = Boolean.valueOf(showAutoRefresh).booleanValue();

        // Enable auto-refresh if necessary on start.
        if (this.showAutoRefresh) setRefreshEnabled(true);
      }
    }
    return needsToSerializeAfter;
  }
  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);
    }
  }