The <action> tag defines an action to be performed by the Job Server. The actions are executed in the order in which they occur in the document. The formula language can be used for the arguments attribute.
Static methods are called up. To this purpose the following syntax is used:
<action name="<class name>:<static method name>" arguments="List{<argument1>, <argument2>}" />
The tag has no sub-elements.
Attribute | Usage | Values | Default value | Description |
---|---|---|---|---|
name | required | Absolute name of the action or command, e.g. T_Ecad_Ui.UpdateExtensions. In order to call a static method the name of the static method is attached to the absolute name of the class, separated by a colon. |
||
arguments | required | List of arguments that are passed to the action or command. When defining the arguments, it is implied that this indicates the job object that recognizes a trigger property. The formula language can be used in order to determine an object as an argument. A property of the trigger can be accessed with the syntax trigger.<Trigger property>. The properties for File Trigger, WebService Trigger and both File Trigger as well as WebService Trigger are differentiated. File Trigger:
WebService Trigger:
File Trigger and WebService Trigger:
|
<?xml version="1.1"?>
<jobdefinition name="='test'+ trigger.fileName" continueOnError="false" model="K:\customers\2.4\64869_JobServer\JobServer\model.eox" xmlns:xi="http://www.w3.org/2001/XInclude">
<fileTrigger>
<failedFolder value="K:\customers\2.4\64869_JobServer\JobServer\error" />
<incomingFolder value="K:\customers\2.4\64869_JobServer\JobServer\input" />
<outputFolder value="K:\customers\2.4\64869_JobServer\JobServer\output" />
<filter value="*.px" />
</fileTrigger>
<actions>
<action name="T_Mechatronic_ModularSystem.Action.ImportPXAction" arguments="List{trigger.filePath}" />
<action name="Engineering.ExportPXCommand" arguments="List{'TestProj',trigger.additionalResultsDir + 'proj.px',true}" />
<action name="T_Mechatronic_ModularSystem.Action.SendMailOnEndCommand" arguments="List{trigger.outputFolder,trigger.failedFolder,trigger.jobName}" />
</actions>
</jobdefinition>
A static method is created as follows:
- Create a mechatronics component (for example StaticClass).
- Open the Methods editor.
- At least one method is added (for example setResultData).
- Mark the Class method check box.
- Select a language (for example Java).
- Add at least one argument (for example data).
- Create the code of the method to be executed in the code window.
This method is called in the following Job definition:
<?xml version='1.0' encoding='UTF-8'?>
<jobdefinition name="Job Name"
model="/C:/jobserver/eox/basis.eox"
xmlns:xi='http://www.w3.org/2001/XInclude'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='C:/jobserver/xsd/jmx.xsd'>
<webserviceTrigger>
<failedFolder value="C:/jobserver/worker/error" />
<outputFolder value="C:/jobserver/worker/out" />
</webserviceTrigger>
<actions>
<action name="T_Mechatronic_ModularSystem.Actions.StaticClass:setResultData"
arguments="List{'testContent'}" />
</actions>
</jobdefinition>
Example code for an action whose argument contains a formula:
<?xml version="1.1"?>
<jobdefinition name="testJob" continueOnError="false" model="K:\JobServer\model.eox" xmlns:xi="http://www.w3.org/2001/XInclude">
<webserviceTrigger>
<failedFolder value="K:\JobServer\error" />
<outputFolder value="K:\JobServer\output" />
</webserviceTrigger>
<actions>
<action name="T_Mechatronic_ModularSystem.Action.ImportPXAction" arguments="List{trigger.params.value('file')}" />
<action name="Customizing_Engineering.SetResultDataToObjectNameAction" arguments="List{absRef('TestProj.Mechatronik.Feeder.Discard')}"/>
<action name="Engineering.ExportPXCommand" arguments="List{'TestProj',trigger.additionalResultsDir + 'proj.px',true}" />
</actions>
</jobdefinition>
Description:
With the first action (ImportPXAction) components are imported and added to the project. The second action (SetResultDataToObjectNameAction) references the name of the component that can be determined via the formula absRef('TestProj.Mechatronic.Feeder.Discard'). The name of the determined component is used for the naming of the generated data.
Example code for an action that offers the target file for downloading in the user interface:
<?xml version="1.1"?>
<jobdefinition name="testJob" continueOnError="false" model="\\share\models\model.eox" xmlns:xi="http://www.w3.org/2001/XInclude">
<webserviceTrigger>
<failedFolder value="failed" />
<outputFolder value="output" />
</webserviceTrigger>
<actions>
<action name="T_Mechatronic_ModularSystem.Action.ImportPXAction" arguments="List{trigger.params.value('file')}" />
<action name="Customizing_Engineering.SetResultDataToObjectNameAction" arguments="List{absRef('TestProj.Mechatronik.Feeder.Discard')}"/>
<action name="Engineering.ExportPXCommand" arguments="List{'TestProj',trigger.additionalResultsDir + 'proj.px',true}" />
<action name="T_Mechatronic_ModularSystem.Commands.MarkFileForDownloadCommand" arguments="List{trigger.outputFolder + 'results\\proj1.px'}"/>
</actions>
</jobdefinition>
Description:
The MarkFileForDownloadCommand command generates a link to the target file of the Job.
The link to the target file is displayed as a symbol in the user interface:
Note:
The action shown in the example uses a command whose implementation has to be created self with scripting.
The script uses the markFileForDownload method from the IJobAPI class. The method expects the path to the target file as the parameter.
Example for the implementation:
import com.mind8.mechatronic.skill.api.IJobAPI;
IJobAPI.DEFAULT.markFileForDownload(pathToFile);
<?xml version="1.1"?><jobdefinition name="Job8" continueOnError="true" model="EOX\Tutorial_JobServer.eox" xmlns:xi="http://www.w3.org/2001/XInclude">
<fileTrigger>
<failedFolder value="error" />
<incomingFolder value="input" />
<outputFolder value="output" />
<filter value="*.imx" />
</fileTrigger>
<actions>
<action name="Engineering.ImportIMXCommand" arguments="=List{trigger.filePath}" />
<action name="Engineering.SaveObjectCommand" arguments="=List{absRef('NewFeeder.Mechatronic.Feeder')}" />
<action name="Engineering.ExportEOXCommand" arguments="=List{trigger.outputFolder + 'results\\Model.eox',List{'NewFeeder'}}" />
<action name="JobServer.MarkFileForDownloadCommand" arguments="=List{trigger.outputFolder + 'results\\Model.eox'}" />
</actions>
</jobdefinition>
Description:
All model changes are first saved through the Engineering.SaveObjectCommand command. Then the model data is written into an EOX file with the Engineering.ExportEOXCommand command.
The MarkFileForDownloadCommand command generates a link to the EOX file.
To offer multiple files for download, the JobServer.MarkFileForDownloadCommand has to be performed for each individual file.
Note:
To download target files the browser has to be set so that popup windows are allowed for this application.