
package de.ivu.elect.jee.presentation.search;

import java.io.Serializable;

import javax.inject.Inject;

import org.apache.deltaspike.core.api.scope.GroupedConversation;

public abstract class AbstractSearchParameters implements Serializable {

  private static final long serialVersionUID = 1L;

  public static final String WILDCARD_CHARACTER = WildcardConverter.WILDCARD_CHARACTER_DEFAULT;
  public static final String NEGATION_CHARACTER = "-";
  public static final String OPTIONAL_CHARACTER = "*";

  public static final String WILDCARD_TOOLTIP_MSG_KEY = "entity.search.filter.wildcard.tooltip";
  public static final String NEGATION_TOOLTIP_MSG_KEY  = "entity.search.filter.minus.tooltip";
  public static final String NEGATION_AND_WILDCARD_TOOLTIP_MSG_KEY  = "entity.search.filter.wildcard.und.minus.tooltip";

  @Inject
  private transient GroupedConversation conversation;

  private boolean initialized;

  private boolean collapsed;

  // First ist der erste Index in der Tabelle, der bei der Pagination dargestellt wird. Er wird aus pragmatischen Gründen hier gespeichert, da der SuchParameter Conversation-Scope ist und first zurükgesetzt wird bei Änderungen des Parameters.
  private int first = 0;

  public AbstractSearchParameters() {
    super();
  }

  public int getFirst() {
    return first;
  }

  public void setFirst(int first) {
    this.first = first;
  }

  public void resetFirst() {
    setFirst(0);
  }

  public boolean isInitialized() {
    return initialized;
  }

  public void setInitialized(boolean initialized) {
    this.initialized = initialized;
  }

  public boolean isCollapsed() {
    return collapsed;
  }

  public void setCollapsed(boolean collapsed) {
    this.collapsed = collapsed;
  }

  public void reset() {
    conversation.close();

    resetFirst();

    setCollapsed(false);
    setInitialized(false);
  }
}
