Hi Surej,
Am Dienstag, 13. November 2007 schrieb surej ns:
> Hi,
> i have saved the work flow in db.I have some doubt on the same
>
>
> // Set up database connection.
> $db = ezcDbFactory::create( 'mysql://test:[EMAIL PROTECTED]/test' );
>
> // Set up workflow definition storage (database).
> $definition = new ezcWorkflowDatabaseDefinitionStorage( $db );
>
> // Load latest version of workflow named "Test".
> $workflow = $definition->loadByName( 'Test' );
>
> $execution = new ezcWorkflowDatabaseExecution( $db );
> // Pass workflow object to workflow executer.
> $execution->workflow = $workflow;
>
> // Start workflow execution.
> $id = $execution->start();
>
>
> This code starts take a workflow(task) for execution am i correct..
Seems to look fine.
> Please provide me with some sample code for the following
> 1) what is the code to list the task waiting for a user to approve
> (what is the procedure to fetch the data from db)
Till now I do not have a performant idea how to solve that via the
workflow component. And I think, this is not covered by the
component... Your application needs to take care about that. When a
user triggered the workflow, you need to check, which user is the next
one. This is application/workflow specific logic. Then you need to save
the execution id somehow related to the next user who is responsible.
For that I proposed a table like this in the last mail:
workflow_states:
- execution_id (the id of the workflow execution)
- user_id (the id of the user who needs to trigger the workflow
the next time)
Now a short example. The team leader enters a site
tl_pending_workflows.php that should list him all the workflows waiting
for his input. The list could be created from the workflow_states table
where you filter for "user_id = <team leader>". Then you can create a
list of links pointing to tl_approve_workflow.php?id=<execution_id>. If
you click on that link, the team leader gets a page, where he can
approve or reject via a form. The form's value will be uses as input
variables to resume() the workflow execution. If he approved, the
execution id will be stored in workflow_states with project managers
user id.
> 2) So when u user approve How can I save the execution to db or
> update the db
The workflow suspend()s itself, if it is not finished but can not go on
at the moment. This is the case if you are in an input node where the
variables are not available yet. When suspending, the execution state
with all it's variables will be stored in database.
Like written above, the next user needs to fetch all his relevant
execution ids (from workflow_states table). Then he can trigger
(=resume()) a workflow as he wants. You only need to take care about
workflow_states table.
> 3) If the user disapprove the none should end …How can
> I achieve that
I hope this will become more clear when I reply to your other mail soon.
> 4) Also how to get the current state of a work flow..
If you load an execution, you can fetch the variables via
$execution->getVariable( $varName ) or $execution->getVariables(). Also
you can fetch the variables the workflow is waiting for like
$execution->getWaitingFor(). This returns the variables the actual
input node needs to get before going on. Via those functions you should
be able to fetch the actual state. (The question is, if you need this
in your case, as you perhaps intentionally know the state from your
workflow_states table.)
Hope that helps
Thomas
--
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components