Workflow command

From ControlTier

Revision as of 17:15, 13 December 2009 by Ahonor (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page describes how to define a command using the "WorkflowCommand" command-type.

This command type is useful if you want to call a sequence of commands defined in your type.

Contents

Create or choose a type

You can add the command to an existing type definition or you can create a new type. To create a new type run:

$ ctl -m ProjectBuilder -c create-type -- -type workflowcommands

The create-type command will generate a type.xml file where you can define your command.

Edit Type definition

This example defines:

To declare a command a workflow command-type specify: command-type="WorkflowCommand".

Then use the workflow tag and reference the commands it will call via command elements.

<types xmlns:cmd="http://open.controltier.com/base/Modules/Commands#" 
       xmlns:module="http://open.controltier.com/base/Modules#" 
       xmlns:type="http://open.controltier.com/base/Types#">
  <type name="workflowcommands" role="concrete" 
	uniqueInstances="true">
    <description>Some example workflows</description>
    <supertype>
      <typereference name="Managed-Entity"/>
    </supertype>
   <command-settings>
      <notification notify="false"/>
      <template-directory></template-directory>
      <dependency-view parents="false" children="true" proximity="1"/>
      <logger name="workflowcommands"/>
    </command-settings>
    <commands>
 
      <command name="command1" description="primitive command" command-type="AntCommand">
	<implementation>
	  <echo>doing command1</echo>
	</implementation>
      </command>
 
      <command name="command2" description="primitive command" command-type="AntCommand">
	<implementation>
	  <echo>doing command2</echo>
	</implementation>
      </command>
 
      <command name="command3" description="primitive command" command-type="AntCommand">
	<implementation>
	  <echo>doing command3</echo>
	</implementation>
      </command>
 
      <command name="Workflow1" description="first workflow command"		
	       command-type="WorkflowCommand" is-static="true"
	       error-handler-type="FAIL">
	<workflow threadcount="1">
	  <command name="command1"/>
	  <command name="command2"/>
	</workflow>
      </command>
 
      <command name="Workflow2" description="second workflow command"		
	       command-type="WorkflowCommand" is-static="true"
	       error-handler-type="FAIL">
	<workflow threadcount="1">
	  <command name="Workflow1"/>
	  <command name="command3"/>
	</workflow>
      </command>
 
    </commands>
  </type>
</types>

Build the type

Use the "build-type" command to generate the command files.

$ ctl -m ProjectBuilder -c build-type -- -type workflowcommands -upload -deploy

The -upload and -deploy flag cause the generated type to be uploaded to Workbench and then deployed to the local client.

Run the command

The workflowcommands type is now deployed and the new commands can be run.

First run "Workflow1". You will see command1 and command2 invoked:

$ ctl -m workflowcommands -c Workflow1
Start: "first workflow command" commands: command1,command2
begin workflow command (1/2) -> "command1 " ...
doing command1
end workflow command (1/2) -> "command1 "
begin workflow command (2/2) -> "command2 " ...
doing command2
end workflow command (2/2) -> "command2 "
[command.timer.default.workflowcommands.Workflow1: 0.343 sec]
Workflow completed. execution time: 0.343 sec

Now, try "Workflow2". It will run Workflow1 and then command3:

$ ctl -m workflowcommands -c Workflow2
Start: "second workflow command" commands: Workflow1,command3
begin workflow command (1/2) -> "Workflow1 " ...
Start: "first workflow command" commands: command1,command2
begin workflow command (1/2) -> "command1 " ...
doing command1
end workflow command (1/2) -> "command1 "
begin workflow command (2/2) -> "command2 " ...
doing command2
end workflow command (2/2) -> "command2 "
[command.timer.default.workflowcommands.Workflow1: 0.438 sec]
Workflow completed. execution time: 0.438 sec
end workflow command (1/2) -> "Workflow1 "
begin workflow command (2/2) -> "command3 " ...
doing command3
end workflow command (2/2) -> "command3 "
[command.timer.default.workflowcommands.Workflow2: 0.815 sec]
Workflow completed. execution time: 0.815 sec


Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export