TSt.dcl 4.12 KB
Newer Older
1 2 3 4 5 6 7 8 9
definition module TSt
/**
* This module defines the core task state data structure
* which is transformed by tasks
*/
import StdMaybe
import Time, Html
import HSt

10
// The task state
11 12 13 14 15 16 17
:: *TSt 		=	{ tasknr 		:: !TaskNr									// for generating unique form-id's
					, activated		:: !Bool   									// if true activate task, if set as result task completed	
					, userId		:: !UserId									// id of user to which task is assigned
					, workflowLink	:: !WorkflowLink							// process table entry information
					, staticInfo	:: !StaticInfo								// info which does not change during a run
					, html			:: !HtmlTree								// accumulator for html code
					, options		:: !Options									// iData lifespan and storage format
18
					, trace			:: !Bool									// default: False
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
					, hst			:: !HSt										// iData state
					}
									
:: TaskNr			:== [Int]													// task nr i.j is adminstrated as [j,i]
:: WorkflowLink		:== (Entry,ProcessIds)										// entry in table together with unique id which is used for checking whether the reference is still valid
:: Entry			:== Int
:: ProcessIds		:== (!UserId,!ProcessNr,!WorkflowLabel)						// user id, process id and name given to a workflow process; is used as unique identifier in process table
:: UserId			:== Int														// a user id of an iTask user must be a unique integer value
:: ProcessNr		:== Int
:: WorkflowLabel	:== String
:: StaticInfo	=	{ currentUserId	:: UserId									// id of application user 
					, threadTableLoc:: !Lifespan								// where to store the server thread table, default is Session
					}
:: Options		=	{ tasklife		:: !Lifespan								// default: Session		
					, taskstorage	:: !StorageFormat							// default: PlainString
					, taskmode		:: !Mode									// default: Edit
					, gc			:: !GarbageCollect							// default: Collect
					}
:: GarbageCollect 	
				=	Collect 													// garbage collect iTask administration
				|	NoCollect													// no garbage collection
				
:: HtmlTree		=	BT [HtmlTag] [InputId]										// simple code with possible event handler definitions
				|	(@@:) infix  0 !TaskDescription !HtmlTree					// code with id of user attached to it
				|	(+-+) infixl 1 !HtmlTree !HtmlTree							// code to be placed next to each other				
				|	(+|+) infixl 1 !HtmlTree !HtmlTree							// code to be placed below each other				
45
				|	CondAnd !String !Int [(!CondAndDescription,!HtmlTree)]		// list of subtasks to display in different tabs by worklist handler 
46
				|	DivCode !String !HtmlTree									// code that should be labeled with a div, used for Ajax and Client technology
47
				|	TaskTrace TraceInfo !HtmlTree								// trace information used for displaying the task tree
48

49
:: TraceInfo 	=	{ trTaskNr		:: !TaskNrId									// tasknr 
50 51 52 53 54 55
					, trTaskName	:: !String									// name of the combinator
					, trActivated	:: !Bool									// is the task finshed or not
					, trUserId		:: !UserId									// who is performing the task (can also be determined from the contect)
					, trValue		:: !String									// what is the current value of task (serialized to string)
					, trOptions		:: !Options									// options of this task
					}
56 57

// Task meta information
58 59 60 61 62 63
:: CondAndDescription
				=	{ caTaskNrId	:: !TaskNrId								// tasknr as string
					, caIndex		:: !Int										// index of and task
					, caStatus		:: !Bool									// is sub task finished
					}

64 65 66 67 68
:: TaskDescription
				=	{ delegatorId	:: !UserId									// id of the work delegator
					, taskWorkerId	:: !UserId									// id of worker on the task
					, taskNrId		:: !TaskNrId								// tasknr as string
					, processNr		:: !ProcessNr								// entry in process table
69
					, workflowLabel	:: !WorkflowLabel							// name of the workflow
70 71 72
					, taskLabel		:: !String									// name of the task
					, timeCreated	:: !Time
					, taskPriority	:: !TaskPriority
73
					, curStatus		:: !Bool
74 75 76 77 78
					}
					
:: TaskNrId		:== String
:: TaskPriority	=	HighPriority | NormalPriority | LowPriority

79 80 81 82

//Tasks are packed TSt transition functions
:: Task a = Task !(*TSt -> *(!a,!*TSt))

83
//Initialization
84 85 86 87 88 89 90
mkTst :: !UserId !Lifespan !Lifespan !*HSt -> *TSt

//Apply a task state transition
appTaskTSt :: !(Task a) !*TSt -> (!a,!*TSt)