Author: sb
Date: Tue Feb 12 11:04:34 2008
New Revision: 7348
Log:
- Add ezcWorkflowExecutionVisualizerPlugin.
# Reorganize plugin directory.
Added:
trunk/Workflow/src/execution/plugin/listener.php
- copied unchanged from r7342,
trunk/Workflow/src/execution/plugin/execution_listener.php
trunk/Workflow/src/execution/plugin/visualizer.php (with props)
Removed:
trunk/Workflow/src/execution/plugin/execution_listener.php
Modified:
trunk/Workflow/design/class_diagram.png
trunk/Workflow/src/workflow_autoload.php
Modified: trunk/Workflow/design/class_diagram.png
==============================================================================
Binary files - no diff available.
Added: trunk/Workflow/src/execution/plugin/visualizer.php
==============================================================================
--- trunk/Workflow/src/execution/plugin/visualizer.php (added)
+++ trunk/Workflow/src/execution/plugin/visualizer.php [iso-8859-1] Tue Feb 12
11:04:34 2008
@@ -1,0 +1,108 @@
+<?php
+/**
+ * File containing the ezcWorkflowExecutionVisualizerPlugin class.
+ *
+ * @package Workflow
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Execution plugin that visualizes the execution.
+ *
+ * @package Workflow
+ * @version //autogen//
+ */
+class ezcWorkflowExecutionVisualizerPlugin extends ezcWorkflowExecutionPlugin
+{
+ /**
+ * The directory to which the DOT files are written.
+ *
+ * @var string
+ */
+ protected $directory;
+
+ /**
+ * Filename counter.
+ *
+ * @var integer
+ */
+ protected $fileCounter = 0;
+
+ /**
+ * Constructor.
+ *
+ * @param string $directory
+ * @throws ezcBaseFileNotFoundException when the directory does not exist
+ * @throws ezcBaseFilePermissionException when the directory is not
writable
+ */
+ public function __construct( $directory )
+ {
+ if ( !is_dir( $directory ) )
+ {
+ throw new ezcBaseFileNotFoundException( $directory );
+ }
+
+ if ( !is_writable( $directory ) )
+ {
+ throw new ezcBaseFilePermissionException( $directory,
ezcBaseFileException::WRITE );
+ }
+
+ $this->directory = $directory;
+ }
+
+ /**
+ * Called after a node has been activated.
+ *
+ * @param ezcWorkflowExecution $execution
+ * @param ezcWorkflowNode $node
+ */
+ public function afterNodeActivated( ezcWorkflowExecution $execution,
ezcWorkflowNode $node )
+ {
+ $this->visualize( $execution );
+ }
+
+ /**
+ * Called after a node has been executed.
+ *
+ * @param ezcWorkflowExecution $execution
+ * @param ezcWorkflowNode $node
+ */
+ public function afterNodeExecuted( ezcWorkflowExecution $execution,
ezcWorkflowNode $node )
+ {
+ $this->visualize( $execution );
+ }
+
+ /**
+ * Visualizes the current state of the workflow execution.
+ *
+ * @param ezcWorkflowExecution $execution
+ */
+ protected function visualize( ezcWorkflowExecution $execution )
+ {
+ $activatedNodes = array();
+
+ foreach ( $execution->getActivatedNodes() as $node )
+ {
+ $activatedNodes[] = $node->getId();
+ }
+
+ $visitor = new ezcWorkflowVisitorVisualization( $activatedNodes );
+ $execution->workflow->accept( $visitor );
+
+ file_put_contents(
+ sprintf(
+ '%s%s%s_%d_%d.dot',
+
+ $this->directory,
+ DIRECTORY_SEPARATOR,
+ $execution->workflow->name,
+ $execution->getId(),
+ ++$this->fileCounter
+ ),
+ $visitor->__toString()
+ );
+ }
+}
+?>
Propchange: trunk/Workflow/src/execution/plugin/visualizer.php
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/Workflow/src/execution/plugin/visualizer.php
------------------------------------------------------------------------------
svn:keywords = Id
Modified: trunk/Workflow/src/workflow_autoload.php
==============================================================================
--- trunk/Workflow/src/workflow_autoload.php [iso-8859-1] (original)
+++ trunk/Workflow/src/workflow_autoload.php [iso-8859-1] Tue Feb 12 11:04:34
2008
@@ -56,8 +56,9 @@
'ezcWorkflowConditionXor' =>
'Workflow/conditions/xor.php',
'ezcWorkflowDefinitionStorageXml' =>
'Workflow/definition_storage/xml.php',
'ezcWorkflowExecutionListener' =>
'Workflow/interfaces/execution_listener.php',
- 'ezcWorkflowExecutionListenerPlugin' =>
'Workflow/execution/plugin/execution_listener.php',
+ 'ezcWorkflowExecutionListenerPlugin' =>
'Workflow/execution/plugin/listener.php',
'ezcWorkflowExecutionNonInteractive' =>
'Workflow/execution/non_interactive.php',
+ 'ezcWorkflowExecutionVisualizerPlugin' =>
'Workflow/execution/plugin/visualizer.php',
'ezcWorkflowNodeAction' => 'Workflow/nodes/action.php',
'ezcWorkflowNodeCancel' => 'Workflow/nodes/cancel.php',
'ezcWorkflowNodeDiscriminator' =>
'Workflow/nodes/control_flow/discriminator.php',
--
svn-components mailing list
[EMAIL PROTECTED]
http://lists.ez.no/mailman/listinfo/svn-components