Interpreting the results that wftk sends back

Previous: Datasheet interface ] [ Top: To-do manager ] [ Next: Miscellaneous utility functions ]

When wftk is run to start a process or to complete a task, it returns a series of lines which encode what should happen next. Most important of these is what tasks to activate. The wftk_interpret function takes a list of lines returned from the wftk core engine, and does the task creation and notification specified.
 
proc wftk_interpret {db process workflow} {
   while {[llength $workflow] > 0} {
      set cmd [lindex $workflow 0]
      set workflow [lrange $workflow 1 end]

      switch [string range $cmd 0 0] {
         A {
             See Starting tasks
         }
         L {
             See Handling notifications
         }
         F {
             See Completing the process
         }
      }
   }
}


Starting tasks
Task creation, at least, is relatively straightforward.
 
set p [split [string range $cmd 2 end] -]

set fields [list id status created]
set values [list '[lindex $p 0]' 'active' '[now]']

lappend fields process
lappend values "'$process'"

lappend fields owner
set owner [lindex $p 1]
if ![string compare $owner "!user"] {
   upvar user user
   set owner $user
}
lappend values '[sql_safe_string $owner]'

lappend fields description
lappend values '[sql_safe_string [join [lrange $p 2 end] -]]'

set query "insert into task ("
append query [join $fields ", "]
append query ") values ("
append query [join $values ", "]
append query ")"

ns_db dml $db $query


Handling notifications


Completing the process
 
set query "update process set status='complete' where id='$process'"
ns_db dml $db $query
Previous: Datasheet interface ] [ Top: To-do manager ] [ Next: Miscellaneous utility functions ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.