/**
 * IPersistenceService.java
 * Created Aug 1, 2007
 * Copyright (c) Tandberg Television 2007
 */
package com.tandbergtv.workflow.driver.service;

import java.io.Serializable;

import com.tandbergtv.workflow.core.CustomToken;
import com.tandbergtv.workflow.core.WorkflowProcess;
import com.tandbergtv.workflow.core.service.Service;
import com.tandbergtv.workflow.driver.DriverRuntimeException;

/**
 * Persists processes
 * 
 * @author Sahil Verma
 */
public interface IPersistenceService extends Service {
	
	/**
	 * Retrieves a process using the specified key
	 *  
	 * @param id
	 * @return
	 */
	WorkflowProcess get(Serializable id);
	
	/**
	 * Creates and assigns a unique identifier to the specified process
	 * 
	 * @param process
	 */
	Serializable create(WorkflowProcess process);
	
	/**
	 * Persists the process instance
	 * 
	 * @param process
	 * @throws DriverRuntimeException
	 */
	void save(WorkflowProcess process);
	
	/**
	 * Retrieves a token using the specified key
	 * 
	 * @param id
	 * @return
	 */
	CustomToken getToken(Serializable id);
	
	/**
	 * Persists the token's process instance
	 * 
	 * @param token
	 */
	void save(CustomToken token);
}
