org.imixs.workflow.jee.ejb
Class WorkflowSchedulerBean

java.lang.Object
  extended by org.imixs.workflow.jee.ejb.WorkflowSchedulerBean
All Implemented Interfaces:
org.imixs.workflow.jee.ejb.WorkflowScheduler

@DeclareRoles(value="org.imixs.ACCESSLEVEL.MANAGERACCESS")
@RunAs(value="org.imixs.ACCESSLEVEL.MANAGERACCESS")
public class WorkflowSchedulerBean
extends Object
implements org.imixs.workflow.jee.ejb.WorkflowScheduler

This is the implementation of a scheduled workflow service. The EJB implementation can be used as a Timer Service to process scheduled workflow activities. A scheduled workflow activity can be defined using the IX Workflow modeller. The service verifies if a workitem should be processed scheduled and processes such a workitem automatically. The TimerService can be started using the method scheduleWorkflow. The Methods findTimerDescription and findAllTimerDescriptions are used to lookup enabled and running service instances. Each Method expects or generates a TimerDescription Object. This object is an instance of a ItemCollection. To create a new timer the ItemCollection should contain the following attributes: datstart - Date Object datstop - Date Object numInterval - Integer Object (interval in seconds) id - String - unique identifier for the schedule Service. $modelversion - String - identifies the model which schould be managed by the service the following additional attributes are generated by the finder methods and can be used by an application to verfiy the status of a running instance: nextTimeout - Next Timeout - pint of time when the service will be scheduled timeRemaining - Timeout in milliseconds statusmessage - text message How a worklist will be processed: If the ActivityEntity has defined a EQL statement (attribute txtscheduledview) then the method selects the workitems by this query. Otherwise the method use the standard method getWorklistByProcessID()

Author:
rsoika

Constructor Summary
WorkflowSchedulerBean()
           
 
Method Summary
 void cancelScheduleWorkflow(String id)
          Cancels a running timer instance.
 Collection<org.imixs.workflow.ItemCollection> findAllTimerDescriptions()
          This method returns a collection of running timerServices.
 org.imixs.workflow.ItemCollection findTimerDescription(String id)
          This Method lookups a TimerService.
 void processWorkItems(javax.ejb.Timer timer)
          This is the mehtod which processed scheuduled workitems when the timer is called.
 void scheduleWorkflow(org.imixs.workflow.ItemCollection timerdescription)
          This Method starts a new TimerService.
 boolean workItemInDue(org.imixs.workflow.ItemCollection doc, org.imixs.workflow.ItemCollection docActivity)
          This method checks if a workitem (doc) is in due.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkflowSchedulerBean

public WorkflowSchedulerBean()
Method Detail

scheduleWorkflow

public void scheduleWorkflow(org.imixs.workflow.ItemCollection timerdescription)
                      throws Exception
This Method starts a new TimerService. The method expects an ItemCollection (timerdescription) with the following informations: datstart - Date Object datstop - Date Object numInterval - Integer Object (interval in seconds) id - String - unique identifier for the schedule Service. The param 'id' should contain a unique identifier (e.g. the EJB Name) as only one scheduled Workflow should run inside a WorkflowInstance. If a timer with the id is already running the method stops this timer object first and reschedules the timer. The method throws an exception if the timerdescription contains invalid attributes or values.

Specified by:
scheduleWorkflow in interface org.imixs.workflow.jee.ejb.WorkflowScheduler
Throws:
Exception

findTimerDescription

public org.imixs.workflow.ItemCollection findTimerDescription(String id)
                                                       throws Exception
This Method lookups a TimerService. The method returns a ItemCollection with the TimerDescirpiton for the specific timer object. If no Timer was found the method returns an empty timer Description.

Specified by:
findTimerDescription in interface org.imixs.workflow.jee.ejb.WorkflowScheduler
Parameters:
id - identifies the timer object
Returns:
ItemCollection containing the TimerDescription
Throws:
Exception

findAllTimerDescriptions

public Collection<org.imixs.workflow.ItemCollection> findAllTimerDescriptions()
                                                                       throws Exception
This method returns a collection of running timerServices.

Specified by:
findAllTimerDescriptions in interface org.imixs.workflow.jee.ejb.WorkflowScheduler
Throws:
Exception

cancelScheduleWorkflow

public void cancelScheduleWorkflow(String id)
                            throws Exception
Cancels a running timer instance. After cancel a timer the corresponding timerDescripton (ItemCollection) is no longer valid

Specified by:
cancelScheduleWorkflow in interface org.imixs.workflow.jee.ejb.WorkflowScheduler
Throws:
Exception

processWorkItems

public void processWorkItems(javax.ejb.Timer timer)
This is the mehtod which processed scheuduled workitems when the timer is called.

Parameters:
timer -

workItemInDue

public boolean workItemInDue(org.imixs.workflow.ItemCollection doc,
                             org.imixs.workflow.ItemCollection docActivity)
This method checks if a workitem (doc) is in due. There are 4 different cases which will be compared: The case is determined by the keyScheduledBaseObject of the activity entity Basis : keyScheduledBaseObject "last process"=1, "last Modification"=2 "Creation"=3 "Field"=4 The logic is not the best one but it works. So we are open for any kind of improvements

Returns:
true if workitem is is due


Copyright © 2006-2011 Imixs Software Solutions GmbH. All Rights Reserved.