TIF ENOVIA/3DExperience Connector - Launch External Process
This kind of integration job is used for launching one or more external processes(es), with input that could consist of files that are checked-out from the ENOVIA/3DEXPERIENCE database and/or just metadata created via a payload configuration.
The output from the external processing can either be checked back into the ENOVIA/3DEXPERIENCE, for example if you perform conversion of files, or you can collect the output and send it to a destination, such as FTP or Webservice etc.
Before digging into the details of the configuration format for such a job, we will start by showing an example of how such a configuration can look alike.
The example below illustrates how to utilize the external process to convert files inside ENOVIA/3DEXPERIENCE into different formats. For readability, only one conversion is included. It is however possible to run several executions to create multiple different output variants.
<Job>
<ExternalProcess>
<Prepare>
<MkDir dir="input" id="in" />
<MkDir dir="output" id="out" />
<Checkout format="generic" file="*.png,*.jpg,*.gif" into="${path:in}/${filename}" id="src-file" />
</Prepare>
<Exec forEachFileRef="src-file">
<Executable>/usr/bin/magick</Executable>
<Arguments>
<Arg>${path:src-file}</Arg>
<Arg>-resize</Arg>
<Arg>120x120</Arg>
<Arg>${path:out}${separator}${filename:src-file}</Arg>
</Arguments>
<PostActions>
<Checkin
src="${path:out}${separator}${filename:src-file}"
format="Thumbnail"
fileName="${filename:src-file}"
overwrite="true" />
</PostActions>
</Exec>
</ExternalProcess>
<Events>
<Error>
<SendMail>
<TO>...</TO>
<CC>...</CC>
<Subject>...</Subject>
<Message>
message...
${STACK_TRACE}
</Message>
</SendMail>
</Error>
</Events>
</Job>
Another example illustrating how to generate some output that later is transferred to another system is shown below:
<Job>
<ExternalProcess>
<Prepare>
<SetParam name="currentState" select="current" />
<SetParam name="someAttribute" select="attribute[Some Attribute]" />
<ExtractPayload id="payload" config="MyPayloadConfig.xml" into="data.xml" />
<Checkout id="src-file" format="generic" fileName="*.abc" into="${filename}" />
</Prepare>
<Exec>
<Executable>/usr/bin/app</Executable>
<Arguments>
<Arg>${path:payload}</Arg>
<Arg>${currentState}</Arg>
<Arg>${someAttribute}</Arg>
</Arguments>
</Exec>
<Output stdout="true" stderr="true">
<Match dir="/" name="*.*" />
</Output>
<Destinations>
<File id="..." />
</Destinations>
</ExternalProcess>
</Job>
Many configuration aspects are the same as for transfer data.
The main difference is the <ExternalProcess>
element, which is described in the next chapter.
Configuration Details
The <ExternalProcess>
element allows the following content
<Prepare>
-
Defines any preparations required. For example checkout files from ENOVIA/3DEXPERIENCE, extract some payload data, set some parameters or create directories.
<Exec>
-
Describes what external process to execute, and what argument to pass. You can define multiple
<Exec>
elements if you need to invoke different processes or invoke with different arguments. <Output>
-
Optional element used to describe what output to collect from the external process. This is often used together with
<Destinations>
. <Destinations>
-
Defines destinations. Please read more here.
Each of these elements are defined in more detail in the next chapters.
Prepare
Preparing the external process execution is normally required. You may for example do any of the below:
- Create directory or directories
-
Whenever you launch an external process, a dedicated working directory is created and the process is launched with that directory as working dir. You can create additional subdirectories here-in. That is accomplished by the
<MkDir>
element. - Checkout of files
-
You may check out one or more files from the object, which you launch the job for. That is done via the
<Checkout>
element. - Creation of Payload data
-
You can also create metadata content using a payload definition. This is accomplished via the
<ExtractPayload>
element. - Set parameters
-
You can also set additional job-parameters that are available during the job execution. This is accomplished via the
<SetParam>
element.
For each of the prepare actions, you need to specify an id, which later is used when referencing the file or directory. The id is used in many macros, to resolve its path, absolute path, name or extension. Example:
|
Element | Attributes | Description | ||
---|---|---|---|---|
|
|
Creates a directory within the working dir. The dir attribute specifies the name of the directory. |
||
|
|
Checks out one or more files from ENOVIA.
The The |
||
|
|
Extracts the payload for the current object using the specified configuration and store the result in the specified file. |
||
|
|
Can be used to set job parameters resolved from the current object, which the job is executed around. In some cases when you only need one or a few attributes from the source object available, then it is easier to resolve these via the SetParam instead of using the ExtractPayload. The latter should be used when you have more data to be extracted. |
Exec
The <Exec>
element defines what to execute and what arguments to supply to the external process.
This element supports the following attributes:
Attribute | Description |
---|---|
forEachFileRef |
Defines an optional ID that refers to a file or files, which is provided by a prepare action. If the file reference ID refers to a collection of files, the executable will be executed for each of them. |
processTimeout |
Defines a timeout in milliseconds, which if exceeded will cause the external process to be stopped. Note that by default, no limit is specified. |
And the supported child elements are
Element | Attributes | Description |
---|---|---|
|
- |
Defines the executable to be invoked. Example: |
|
|
Defines additional environment variables to be set while during the process execution. |
|
- |
Defines the arguments to pass to the external process (see below). |
|
- |
Defines optional post actions to be performed. Currently, only Checkin is a supported post operation. |
The <Arguments>
element allows nested <Arg>
elements.
Each occurrence of such child element will result in an argument to be passed at the same position.
The <Arg> element may contain macros, which can be used to resolve against the file-ids from the preparation tasks OR against job parameters.
See: this document for more info around job macros.
|
To reference file/directory information created by the preparation actions, see the table below for information:
Example | Description |
---|---|
|
Resolves the path relative from the working dir to the file with the specified ID. |
|
Resolves the absolute path to the file with the specified ID |
|
Returns the file name of the file with the specified ID |
|
Returns the file name excluding its suffix of the file with the specified ID |
|
Returns the suffix of the file with the specified ID |
Other supported macros:
Example | Description |
---|---|
|
The path separator for the current platform |
|
The separator for the current platform |
|
The ID of the current business object |
|
The workdir for the current execution (the absolute path) |
The currently supported post actions defined below <PostActions>
are shown below:
Element | Attributes | Description |
---|---|---|
|
|
Checks in the source file into ENOVIA. |
Output
The <Output>
element is used when you want to collect the output from your external process.
The output will typically be a ZIP file unless you only want to collect the standard output OR standard error from the external process.
To get standard output or standard error as output without being zipped, set either attribute "stdout" OR "stderr" true, not both. Do not include any Match child elements. |
This element supports the following attributes:
Attribute | Description |
---|---|
stdout |
Defines if to include standard output. Default is false. |
stderr |
Defines if to include standard error. Default is false. |
returnFirstMatch |
An option that allows by-passing the creation of a ZIP file and just return the first found file according to the match instructions.
Note that setting this to TRUE also requires at least one nested |
And the supported child elements are
Element | Attributes | Description |
---|---|---|
|
|
Defines what content to include in the generated ZIP file. |
The <Match>
element will define what files to be included in the generated ZIP file.
Use wildcards on the name attribute to match more than one file.
Configuration example:
<Output stdout="true">
<Match dir="${path:out-dir}" name="*.png" />
<Match dir="${path:out-dir}" name="*.gif" />
</Output>