001: /*
002: * Copyright (c) 2002-2003 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.workflow.spi;
006:
007: import com.opensymphony.module.propertyset.PropertySet;
008:
009: import com.opensymphony.workflow.StoreException;
010: import com.opensymphony.workflow.query.WorkflowExpressionQuery;
011: import com.opensymphony.workflow.query.WorkflowQuery;
012:
013: import java.util.*;
014:
015: /**
016: * Interface for pluggable workflow stores configured in osworkflow.xml.
017: * Only one instance of a workflow store is ever created, meaning that
018: * if your persistence connections (such as java.sql.Connection) time out,
019: * it would be un-wise to use just one Connection for the entire object.
020: *
021: * @author <a href="mailto:plightbo@hotmail.com">Pat Lightbody</a>
022: */
023: public interface WorkflowStore {
024: //~ Methods ////////////////////////////////////////////////////////////////
025:
026: /**
027: * Set the state of the workflow instance.
028: * @param entryId The workflow instance id.
029: * @param state The state to move the workflow instance to.
030: */
031: public void setEntryState(long entryId, int state)
032: throws StoreException;
033:
034: /**
035: * Returns a PropertySet that is associated with this workflow instance ID.
036: * @param entryId The workflow instance id.
037: * @return a property set unique to this entry ID
038: */
039: public PropertySet getPropertySet(long entryId)
040: throws StoreException;
041:
042: /**
043: * Persists a step with the given parameters.
044: *
045: * @param entryId The workflow instance id.
046: * @param stepId the ID of the workflow step associated with this new
047: * Step (not to be confused with the step primary key)
048: * @param owner the owner of the step
049: * @param startDate the start date of the step
050: * @param status the status of the step
051: * @param previousIds the previous step IDs
052: * @return a representation of the workflow step persisted
053: */
054: public Step createCurrentStep(long entryId, int stepId,
055: String owner, Date startDate, Date dueDate, String status,
056: long[] previousIds) throws StoreException;
057:
058: /**
059: * Persists a new workflow entry that has <b>not been initialized</b>.
060: *
061: * @param workflowName the workflow name that this entry is an instance of
062: * @return a representation of the workflow instance persisted
063: */
064: public WorkflowEntry createEntry(String workflowName)
065: throws StoreException;
066:
067: /**
068: * Returns a list of all current steps for the given workflow instance ID.
069: *
070: * @param entryId The workflow instance id.
071: * @return a List of Steps
072: * @see com.opensymphony.workflow.spi.Step
073: */
074: public List findCurrentSteps(long entryId) throws StoreException;
075:
076: /**
077: * Pulls up the workflow entry data for the entry ID given.
078: *
079: * @param entryId The workflow instance id.
080: * @return a representation of the workflow instance persisted
081: */
082: public WorkflowEntry findEntry(long entryId) throws StoreException;
083:
084: /**
085: * Returns a list of all steps that are finished for the given workflow instance ID.
086: *
087: * @param entryId The workflow instance id.
088: * @return a List of Steps
089: * @see com.opensymphony.workflow.spi.Step
090: */
091: public List findHistorySteps(long entryId) throws StoreException;
092:
093: /**
094: * Called once when the store is first created.
095: *
096: * @param props properties set in osworkflow.xml
097: */
098: public void init(Map props) throws StoreException;
099:
100: /**
101: * Mark the specified step as finished.
102: * @param step the step to finish.
103: * @param actionId The action that caused the step to finish.
104: * @param finishDate the date when the step was finished.
105: * @param status The status to set the finished step to.
106: * @param caller The caller that caused the step to finish.
107: * @return the finished step
108: */
109: public Step markFinished(Step step, int actionId, Date finishDate,
110: String status, String caller) throws StoreException;
111:
112: /**
113: * Called when a step is finished and can be moved to workflow history.
114: *
115: * @param step the step to be moved to workflow history
116: */
117: public void moveToHistory(Step step) throws StoreException;
118:
119: /**
120: * @deprecated use {@link WorkflowStore#query(WorkflowExpressionQuery)} instead.
121: * @param query the query to use
122: * @return a List of workflow instance ID's
123: */
124: public List query(WorkflowQuery query) throws StoreException;
125:
126: /**
127: * @param query the query to use
128: * @return a List of workflow instance ID's
129: */
130: public List query(WorkflowExpressionQuery query)
131: throws StoreException;
132: }
|