/**
 * IProcessSearchService.java
 * Created Jan 10, 2007
 * Copyright (C) Tandberg Television 2007
 */
package com.tandbergtv.workflow.driver.service;

import java.util.Date;
import java.util.List;

import com.tandbergtv.workflow.core.ProcessStatus;
import com.tandbergtv.workflow.core.WorkflowProcess;
import com.tandbergtv.workflow.core.WorkflowTemplate;
import com.tandbergtv.workflow.core.service.Service;
import com.tandbergtv.workflow.util.SearchCriteria;

/**
 * Provides a mechanism for locating processes based on a certain criteria. There are several
 * convenience methods for the most frequently used searches, in other cases the caller must
 * compose a SearchCriteria.
 * 
 * Implementations do not guarantee performance characteristics.
 * 
 * @author Sahil Verma
 */
public interface IProcessSearchService extends Service {
	
	/**
	 * Returns the number of processes that are currently in the specified state
	 * 
	 * @param status
	 * @return
	 */
	int count(ProcessStatus status);
	
	/**
	 * Returns the number of processes that are currently in the specified state
	 * which were created after the cutOffDate
	 * @param status
	 * @param cutOffDate
	 * @return
	 */
	int count(ProcessStatus status, Date cutOffDate);
	
	/**
	 * Returns the number of processes that are in either of the specified states
	 * 
	 * @param status
	 * @return
	 */
	int count(List<ProcessStatus> statuslist);
	
	/**
	 * Returns the number of processes of the specified template that are in either of the specified
	 * states
	 * 
	 * @param template
	 * @param status
	 * @return
	 */
	int count(WorkflowTemplate template, ProcessStatus... status);

	/**
	 * Returns the number of processes that match the specified criteria
	 * 
	 * @param criteria
	 * @return
	 */
	int count(SearchCriteria criteria);
	
	/**
	 * Retrieves a list of processes that is in the specified state
	 * 
	 * @param status
	 * @return
	 */
	List<WorkflowProcess> findAllByStatus(ProcessStatus status);
	
	/**
	 * A convenience method that retrieves a list of processes that are in one of the specified states. 
	 * Note that ACTIVE is a union - passing one of the states that are included in the union together 
	 * with ACTIVE will lead to undefined behavior
	 * 
	 * @param statuslist The plural of status is status or statuses in Latin and English,
	 * respectively. In Java it is statuslist.
	 * @return
	 */
	List<WorkflowProcess> findAllByStatus(List<ProcessStatus> statuslist);
	
	/**
	 * A convenience method that retrieves a list of processes that are in one of the specified states. 
	 * Note that ACTIVE is a union - passing one of the states that are included in the union together 
	 * with ACTIVE will lead to undefined behavior
	 * 
	 * @param statuslist The plural of status is status or statuses in Latin and English,
	 * respectively. In Java it is statuslist.
	 * @return
	 */
	List<WorkflowProcess> findAllByStatus(ProcessStatus... statuslist);
	
	/**
	 * Retrieves the list of processes based on the parameters specified in the SearchCriteria.
	 * 
	 * @param searchCriteria 
	 * @return
	 */
	List<WorkflowProcess> search(SearchCriteria searchCriteria);
}
