package de.thomasjacob.improve.presentation.issue.search;

import de.thomasjacob.improve.logic.issue.IssueDao;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorForm;


public class IssueSearchForm extends ValidatorForm
{
	private String filterDeveloper = "";

	private String filterReporter = "";

	private String filterIssueId = "";

	private String filterPriority = "";

	private String filterProjectId = "";

	private String filterSearchString = "";

	private String filterStatus = "";

	private String filterType = "";

	public static IssueSearchForm getInstance(HttpServletRequest request)
	{
		HttpSession session = request.getSession();
		IssueSearchForm form = (IssueSearchForm) session.getAttribute("issueSearchForm");
		if (form == null)
		{
			form = new IssueSearchForm();
			session.setAttribute("issueSearchForm", form);
		}

		return form;
	}

	private int order = IssueDao.ORDER_BY_ID;

	public String getFilterDeveloper()
	{
		return filterDeveloper;
	}

	public String getFilterReporter()
	{
		return filterReporter;
	}

	public String getFilterIssueId()
	{
		return filterIssueId;
	}

	public String getFilterPriority()
	{
		return filterPriority;
	}

	public String getFilterProjectId()
	{
		return filterProjectId;
	}

	public String getFilterSearchString()
	{
		return filterSearchString;
	}

	public String getFilterStatus()
	{
		return filterStatus;
	}

	public String getFilterType()
	{
		return filterType;
	}

	public int getOrder()
	{
		return order;
	}

	public void reset(ActionMapping mapping, HttpServletRequest request)
	{
		super.reset(mapping, request);

		filterProjectId = "";
		filterType = "";
		filterPriority = "";
		filterStatus = "";
		filterReporter = "";
		filterDeveloper = "";
		filterIssueId = "";
		filterSearchString = "";
	}

	public void setFilterDeveloper(String filterDeveloper)
	{
		this.filterDeveloper = filterDeveloper;
	}

	public void setFilterReporter(String filterReporter)
	{
		this.filterReporter = filterReporter;
	}

	public void setFilterIssueId(String filterIssueId)
	{
		this.filterIssueId = filterIssueId;
	}

	public void setFilterPriority(String filterPriority)
	{
		this.filterPriority = filterPriority;
	}

	public void setFilterProjectId(String filterProjectId)
	{
		this.filterProjectId = filterProjectId;
	}

	public void setFilterSearchString(String filterSearchString)
	{
		this.filterSearchString = filterSearchString;
	}

	public void setFilterStatus(String filterStatus)
	{
		this.filterStatus = filterStatus;
	}

	public void setFilterType(String filterType)
	{
		this.filterType = filterType;
	}

	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
	{
		// TODO Auto-generated method stub
		return super.validate(mapping, request);
	}

	public void setOrder(int order)
	{
		this.order = order;
	}
}
