com.webmethods.caf.faces.data.task.impl
Class AbstractTaskContentProvider

java.lang.Object
  extended by com.webmethods.caf.faces.bean.PageFlowScopeAdapter
      extended by com.webmethods.caf.faces.data.task.impl.AbstractTaskContentProvider
All Implemented Interfaces:
IPageFlowScopeAdapter, IContentProvider, IRefreshable, IRefreshableContentProvider, ITransactionalContentProvider, IUpdateableContentProvider, ITaskContentProvider, Serializable
Direct Known Subclasses:
TaskContentProvider

public abstract class AbstractTaskContentProvider
extends PageFlowScopeAdapter
implements ITaskContentProvider, Serializable

AbstractTaskContentProvider is the abstract base implementation class of ITaskContentProvider.
This class contains all base implementation for queuing, reading and updating a single task instance

See Also:
ITaskContentProvider, Serialized Form

Field Summary
protected  boolean m_adhocRouting
          Flag to enable ad-hoc routing (assignment) of the task
protected  boolean m_autoAccept
          Flag whether task should be automatically accepted before any edits take place.
protected  ITaskData m_currentTaskData
          Stores current task data being edited
protected  ITaskInfo m_currentTaskInfo
          Stores current task info bein edited
protected  int m_maxAllowedToAccept
          How many users are allowed to accept a task.
protected  boolean m_needAcceptToUpdate
          Flag whether task must be accepted before any edits take place.
protected  boolean m_needRefresh
          Flag whether task state needs to be refreshed
protected  ITaskData m_previousTaskData
          Stores task info before any edits took place
protected  ITaskInfo m_previousTaskInfo
          Stores task data before any edits took place
protected  String m_taskID
          Stores ID of the task
protected  String m_taskTypeID
          Stores task type ID.
 
Fields inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
fExpireWithPageFlow
 
Constructor Summary
AbstractTaskContentProvider()
          Default empty constructor
 
Method Summary
 void acceptTask()
          Accepts a task for the current user
 void applyChanges()
          Commits changes done to task info and business data.
 void applyChangesNoAccept()
          Commits changes done to task info and business data without requiring user to accept a task
 void cancelChanges()
          Reverts back all un-committed changes to the task
 void cancelTask()
          Cancels current task.
 void completeTask()
          Completes a task
 void deleteTask()
          Deletes a task
 boolean getAdhocRouting()
          Returns ad-hoc routing flag
 boolean getAutoAccept()
          Returns autoAccept flag
 String getCurrentUserID()
          Returns ID of the current user
 int getMaxAllowedToAccept()
          Returns max number of users allowed to accept a task.
 boolean getNeedAcceptToUpdate()
          Returns needAcceptToUpdate flag
 boolean getNeedInfoRefresh()
          Check whether the task info needs refresh.
 boolean getNeedRefresh()
          Returns true when IRefreshable.isAutoRefresh() is on and the result properties need to be refreshed from the data source by executing IRefreshable.refresh() method.
 Object[] getPropertyKeys()
          Returns list of properties supported by this content provider.
 String getTaskID()
          Returns task ID
 ITaskInfo getTaskInfo()
          Returns task info for current task ID.
 String getTaskTypeID()
          Returns task type ID
 String getTaskTypeName()
          Returns task type name
 Class getType(Object propertyKey)
          Returns java type of the given property
 Object getValue(Object propertyKey)
          Returns value of the given property
 boolean hasProperty(Object propertyKey)
          Checks if the given property is supported by this content provider
 void init(String taskID, ITaskInfo taskInfo, ITaskData taskData, boolean autoAccept)
          Initializes this content provider with given task.
 boolean isAutoRefresh()
          Returns true if the provider is currenlty in auto-refresh mode
 boolean isCurrentUserAccepted()
          Check whether current user accepted the task.
 boolean isReadOnly(Object propertyKey)
          Returns true if the given property is readonly.
 boolean isUpdateable()
          Checks if current user can apply changes to this task
protected abstract  ITaskData newTaskData()
          Creates new instance of task business data.
 void queueNewTask()
          Queues a new task with task info and data set.
 void refresh()
          Reloads current task state from taskID
 void reset()
          Resets all un-committed back to un-initialized state
 void resumeTask()
          Resumes a task
 void setAdhocRouting(boolean allowAdhocRouting)
          Sets ad-hoc routing flag
 void setAutoAccept(boolean autoAccept)
          Sets autoAccept flag
 void setAutoRefresh(boolean autorefresh)
          Sets auto refresh mode on.
 void setMaxAllowedToAccept(int maxAllowedToAccept)
          Sets max number of users allowed to accept a task
 void setNeedAcceptToUpdate(boolean needAcceptToUpdate)
          Sets needAcceptToUpdate flag
 void setNeedRefresh(boolean needRefresh)
          Tells the provider that the input parameters have changed and the output results need to be refreshed the next time any output property is requested via IContentProvider.getValue(Object).
 void setTaskID(String taskID)
          Sets new task ID to load.
 void setTaskTypeID(String taskTypeID)
          Set the task Type ID when queuing a new task
 void setValue(Object propertyKey, Object value)
          Sets new value of the given property
 boolean supportsAutoRefresh()
          Returns true if this content provider supports auto refresh feature.
 void suspendTask()
          Suspends a task
 void unacceptTask()
          Un-accepts a task from the current user
 
Methods inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
getExpireWithPageFlow, setExpireWithPageFlow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.webmethods.caf.faces.data.IContentProvider
toString
 

Field Detail

m_currentTaskData

protected ITaskData m_currentTaskData
Stores current task data being edited


m_previousTaskInfo

protected ITaskInfo m_previousTaskInfo
Stores task data before any edits took place


m_currentTaskInfo

protected ITaskInfo m_currentTaskInfo
Stores current task info bein edited


m_previousTaskData

protected ITaskData m_previousTaskData
Stores task info before any edits took place


m_taskID

protected String m_taskID
Stores ID of the task


m_taskTypeID

protected String m_taskTypeID
Stores task type ID. This is used when queuing new task


m_autoAccept

protected boolean m_autoAccept
Flag whether task should be automatically accepted before any edits take place. Default is true


m_needAcceptToUpdate

protected boolean m_needAcceptToUpdate
Flag whether task must be accepted before any edits take place. Default is true. If task is not accepted and this flag is set to true, then task will be auto-accepted or exception will be thrown when attempting to update a task


m_maxAllowedToAccept

protected int m_maxAllowedToAccept
How many users are allowed to accept a task. Default is 1


m_needRefresh

protected boolean m_needRefresh
Flag whether task state needs to be refreshed


m_adhocRouting

protected boolean m_adhocRouting
Flag to enable ad-hoc routing (assignment) of the task

Constructor Detail

AbstractTaskContentProvider

public AbstractTaskContentProvider()
Default empty constructor

Method Detail

init

public void init(String taskID,
                 ITaskInfo taskInfo,
                 ITaskData taskData,
                 boolean autoAccept)
Initializes this content provider with given task. This is used from task rules, so TaskContentProvider should exhibit special behavior: not requiring to accept for update, allowing max number of accepted, no need to refresh.

Parameters:
taskID - task ID
taskInfo - ITaskInfo
taskData - ITaskData
autoAccept - auto accept or not

getTaskID

public String getTaskID()
Returns task ID

Specified by:
getTaskID in interface ITaskContentProvider

getTaskTypeID

public String getTaskTypeID()
Returns task type ID

Specified by:
getTaskTypeID in interface ITaskContentProvider

getTaskTypeName

public String getTaskTypeName()
Returns task type name

Specified by:
getTaskTypeName in interface ITaskContentProvider

getAutoAccept

public boolean getAutoAccept()
Returns autoAccept flag

Specified by:
getAutoAccept in interface ITaskContentProvider

setAutoAccept

public void setAutoAccept(boolean autoAccept)
Sets autoAccept flag

Specified by:
setAutoAccept in interface ITaskContentProvider

getAdhocRouting

public boolean getAdhocRouting()
Returns ad-hoc routing flag

Specified by:
getAdhocRouting in interface ITaskContentProvider

setAdhocRouting

public void setAdhocRouting(boolean allowAdhocRouting)
Sets ad-hoc routing flag

Specified by:
setAdhocRouting in interface ITaskContentProvider

setTaskID

public void setTaskID(String taskID)
Sets new task ID to load. Setting a task ID will refresh state of the provider

Specified by:
setTaskID in interface ITaskContentProvider
Parameters:
taskID - task ID to set

setTaskTypeID

public void setTaskTypeID(String taskTypeID)
Set the task Type ID when queuing a new task

Parameters:
taskTypeID - task type ID to set

getTaskInfo

public ITaskInfo getTaskInfo()
Returns task info for current task ID. If task ID is not set then empty task info is returned allowing to queue a new task

Specified by:
getTaskInfo in interface ITaskContentProvider
Returns:
task info

completeTask

public void completeTask()
                  throws ContentProviderException
Completes a task

Specified by:
completeTask in interface ITaskContentProvider
Throws:
ContentProviderException

resumeTask

public void resumeTask()
                throws ContentProviderException
Resumes a task

Specified by:
resumeTask in interface ITaskContentProvider
Throws:
ContentProviderException

suspendTask

public void suspendTask()
                 throws ContentProviderException
Suspends a task

Specified by:
suspendTask in interface ITaskContentProvider
Throws:
ContentProviderException

acceptTask

public void acceptTask()
                throws ContentProviderException
Accepts a task for the current user

Specified by:
acceptTask in interface ITaskContentProvider
Throws:
ContentProviderException

unacceptTask

public void unacceptTask()
                  throws ContentProviderException
Un-accepts a task from the current user

Specified by:
unacceptTask in interface ITaskContentProvider
Throws:
ContentProviderException

applyChangesNoAccept

public void applyChangesNoAccept()
                          throws ContentProviderException
Commits changes done to task info and business data without requiring user to accept a task

Throws:
ContentProviderException

applyChanges

public void applyChanges()
                  throws ContentProviderException
Commits changes done to task info and business data. This operation will check if task is accepted by current user if appropriate flag is set and will auto-accept a task or throw an error if task is not accepted and auto-accept is not enabled

Specified by:
applyChanges in interface ITransactionalContentProvider
Throws:
ContentProviderException - if error happens during commit

cancelChanges

public void cancelChanges()
                   throws ContentProviderException
Reverts back all un-committed changes to the task

Specified by:
cancelChanges in interface ITransactionalContentProvider
Throws:
ContentProviderException

isUpdateable

public boolean isUpdateable()
                     throws Exception
Checks if current user can apply changes to this task

Returns:
return true if the current user can apply changes to this task
Throws:
Exception

reset

public void reset()
           throws Exception
Resets all un-committed back to un-initialized state

Throws:
Exception

refresh

public void refresh()
             throws ContentProviderException
Reloads current task state from taskID

Specified by:
refresh in interface IRefreshable
Throws:
ContentProviderException - if error loading data from the data source

queueNewTask

public void queueNewTask()
                  throws ContentProviderException
Queues a new task with task info and data set.

Specified by:
queueNewTask in interface ITaskContentProvider
Throws:
ContentProviderException

getNeedInfoRefresh

public boolean getNeedInfoRefresh()
Check whether the task info needs refresh.

Returns:
return true if task info needs refresh, e.g. for example if new task ID was set

getNeedRefresh

public boolean getNeedRefresh()

Returns true when IRefreshable.isAutoRefresh() is on and the result properties need to be refreshed from the data source by executing IRefreshable.refresh() method.

Implementations may return an accurate value from this method if they can track the changes to the input parameter properties or they may require the clients to call IRefreshable.setNeedRefresh(boolean) explicitely.

Specified by:
getNeedRefresh in interface IRefreshable
Returns:
true when the output properties are not up-to-date with the current input parameters, i.e. IRefreshable.refresh() needs to be executed manually or automatically.

isReadOnly

public boolean isReadOnly(Object propertyKey)
                   throws EvaluationException,
                          PropertyNotFoundException

Returns true if the given property is readonly. If it is readonly, IUpdateableContentProvider.setValue(Object, Object) will definitely fail.

Specified by:
isReadOnly in interface IUpdateableContentProvider
Parameters:
propertyKey - property key of type String or Integer
Returns:
true if the property is readonly
Throws:
EvaluationException
PropertyNotFoundException

setValue

public void setValue(Object propertyKey,
                     Object value)
              throws EvaluationException,
                     PropertyNotFoundException

Sets new value of the given property

Specified by:
setValue in interface IUpdateableContentProvider
Parameters:
propertyKey - property key of type String or Integer
value - new property value
Throws:
EvaluationException - if error happens during property assigment
PropertyNotFoundException - if property is not found

getPropertyKeys

public Object[] getPropertyKeys()
Returns list of properties supported by this content provider. Can return Object[0], never null.

Specified by:
getPropertyKeys in interface IContentProvider
Returns:
array of property keys which is typically of type String or Integer

getType

public Class getType(Object propertyKey)
              throws PropertyNotFoundException
Returns java type of the given property

Specified by:
getType in interface IContentProvider
Parameters:
propertyKey - the property key of type String or Integer
Returns:
property java Class
Throws:
PropertyNotFoundException - if property is not supported

getValue

public Object getValue(Object propertyKey)
                throws EvaluationException,
                       PropertyNotFoundException
Returns value of the given property

Specified by:
getValue in interface IContentProvider
Parameters:
propertyKey - the property key of type String or Integer
Returns:
value of the property, can be null
Throws:
EvaluationException - if error during property evaluation
PropertyNotFoundException - if property is not supported

hasProperty

public boolean hasProperty(Object propertyKey)
Checks if the given property is supported by this content provider

Specified by:
hasProperty in interface IContentProvider
Parameters:
propertyKey - property key of type String or Integer
Returns:
true if property is supported

isAutoRefresh

public boolean isAutoRefresh()
Returns true if the provider is currenlty in auto-refresh mode

Specified by:
isAutoRefresh in interface IRefreshable
Returns:
false if auto-refresh mode is off or not supported

setAutoRefresh

public void setAutoRefresh(boolean autorefresh)
                    throws ContentProviderException

Sets auto refresh mode on. When auto refresh mode is on, the provider calls IRefreshable.getNeedRefresh() to determine whether the refresh needs to be done before returning any result properties. If it returns true, the provider calls IRefreshable.refresh() method to updated the result properties.

Specified by:
setAutoRefresh in interface IRefreshable
Parameters:
autorefresh - true to turn it on
Throws:
ContentProviderException - if auto refresh mode is not supported
See Also:
IRefreshable.supportsAutoRefresh(), IRefreshable.getNeedRefresh(), IRefreshable.setNeedRefresh(boolean)

setNeedRefresh

public void setNeedRefresh(boolean needRefresh)
Tells the provider that the input parameters have changed and the output results need to be refreshed the next time any output property is requested via IContentProvider.getValue(Object).

Specified by:
setNeedRefresh in interface IRefreshable
Parameters:
needRefresh - true if the input parameters have changed

supportsAutoRefresh

public boolean supportsAutoRefresh()
Returns true if this content provider supports auto refresh feature.

Specified by:
supportsAutoRefresh in interface IRefreshable
Returns:
true when auto refresh is supported
See Also:
IRefreshable.setAutoRefresh(boolean)

getMaxAllowedToAccept

public int getMaxAllowedToAccept()
Returns max number of users allowed to accept a task. Default = 1

Specified by:
getMaxAllowedToAccept in interface ITaskContentProvider

setMaxAllowedToAccept

public void setMaxAllowedToAccept(int maxAllowedToAccept)
Sets max number of users allowed to accept a task

Specified by:
setMaxAllowedToAccept in interface ITaskContentProvider

getNeedAcceptToUpdate

public boolean getNeedAcceptToUpdate()
Returns needAcceptToUpdate flag

Specified by:
getNeedAcceptToUpdate in interface ITaskContentProvider

setNeedAcceptToUpdate

public void setNeedAcceptToUpdate(boolean needAcceptToUpdate)
Sets needAcceptToUpdate flag

Specified by:
setNeedAcceptToUpdate in interface ITaskContentProvider
Parameters:
needAcceptToUpdate - true means user must first accept a task before updating it

cancelTask

public void cancelTask()
                throws ContentProviderException
Cancels current task. This will set status of task to "cancelled"

Specified by:
cancelTask in interface ITaskContentProvider
Throws:
ContentProviderException

deleteTask

public void deleteTask()
                throws ContentProviderException
Deletes a task

Specified by:
deleteTask in interface ITaskContentProvider
Throws:
ContentProviderException

getCurrentUserID

public String getCurrentUserID()
                        throws ContentProviderException
Returns ID of the current user

Specified by:
getCurrentUserID in interface ITaskContentProvider
Throws:
ContentProviderException

newTaskData

protected abstract ITaskData newTaskData()
                                  throws ContentProviderException
Creates new instance of task business data. This must be overridden as each task type implements its business data in its unique class

Returns:
business data object
Throws:
ContentProviderException

isCurrentUserAccepted

public boolean isCurrentUserAccepted()
                              throws Exception
Check whether current user accepted the task.

Returns:
return true if the current user accpted the task.
Throws:
Exception