Creating the FileTest Process
This section guides you through creating a simple process definition. The process, which will be named FileTest
, polls a directory for a specified file and writes a new file to the same directory each time the file changes. The new file’s name includes the type of change that occurred to the original file (create, modify, or remove). The new file’s content is the same as the polled file’s content, but the time of the change in the file is appended to the end of the file. The time of the file change is represented as the number of milliseconds since January 1, 1970.
The tutorial uses a variable file name to illustrate how to use the ActiveMatrix BusinessWorks mapping capabilities.
File Poller
activity. This example uses the directory c:\tibco\test
and the file PolledFileTest.txt
To create the FileTest process, follow these steps:
Procedure
-
In TIBCO Designer, select the project name (for example
tutorial
) in the project panel. -
In the palette panel, select the Process palette.
If no palettes are in the palette panel, click the Switch Palette Mode
icon to display the palettes.
-
From the palette panel, drag a Process Definition resource into the design panel.
-
In the configuration panel, type the name
FileTest
in the Name field to rename the process. Then click Apply. -
Save your project by choosing Project > Save from the menu.
For more information about processes, see TIBCO ActiveMatrix BusinessWorks™ Concepts and TIBCO ActiveMatrix BusinessWorks™ Process Design.
To add activities to the process, follow these steps:
Procedure
-
Select FileTest process in the project tree.
The Start and End activities should be displayed in the design panel.
-
Find the File palette in the palette panel and select it.
-
Drag a File Poller activity into the design panel (but not on top of the
Start
activity).The Start activity is replaced by the File Poller activity.
-
With the File Poller still selected, enter the following values in the configuration panel:
-
Name the File Poller
TestFilePoller
. -
Click the Browse button to the right of the File Name field and select the file you want to poll. Use the Select File dialog to locate the directory and file you created.
-
Leave the Polling Interval, Include Existing Files, and Exclude File Content fields as they are. Select text in the drop-down list in the Content as field, and select the appropriate encoding for your operating system in the Encoding field.
-
Click the Apply button.
-
-
Drag a Create File activity into the design panel and place it to the right of TestFilePoller.
-
Name the Create File activity CreateTestFile, and select the Overwrite check box, then click the Apply button.
-
Drag a Write File activity into the design panel and place it to the right of the CreateTestFile activity (before the End activity).
-
Name the Write File activity
WriteToTestFile
, then click the Apply button. -
In the toolbar, select the Transition icon
.
-
Select the TestFilePoller process starter and drag a transition to the CreateTestFile activity. Connect the CreateTestFile and WriteToTestFile and the WriteToTestFile and End activities in the same manner.
-
Choose Project > Save from the menu.


The result should appear as follows:

The process now includes appropriately connected activities. However, no information about the name and content of the files is included. To set those, you use the TIBCO Designer mapping facilities.
The goal in this exercise is to create a file that has the name File<
changeType
>.txt
, where <
changeType
>
is the type of change that occurred to the original file (create, modify, or remove). The contents of the changed file is then written to the new file, and the time the change in the file occurred is appended to the end of the contents. For example, if the text in the changed file is "The cherry blossoms are beautiful." the content of the new file will be "The cherry blossoms are beautiful. 1017163931036"
To map the data flow between activities, follow these steps:
Procedure
-
Choose the Select icon
in the toolbar, if it is not already selected.
-
Select the CreateTestFile activity and choose the Input tab in the configuration panel. Expand the CreateActivityInputClass item in the activity input tree by clicking on the plus sign (+) to the left of the item.
-
Click the plus (+) sign next to the process variable
$TestFilePoller
in the Process Data panel and expand the schema tree containing the output of theTestFilePoller
process starter. -
In the right panel, select the fileName element in the Activity Input pane, then click the XPath Formula Builder (pencil) icon.
-
In the XPath Formula Builder dialog that appears, follow these steps:
-
Select the Functions tab, open the String folder, select concat, and drag it into the XPath Formula panel.
The display in the right panel changes to display a
concat
XPath expression. -
Replace
<< string1 >
> with"c:\tibco\test\File"
(include the quotes). -
In the left panel, select the Data tab, choose the $TestFilePoller/EventSourceOutputTextClass/action element and drag it over
<<
string2
>>
. A red box appears over<<
string2
>>
indicating you can release the data over this item and the correct XPath expression will appear. -
Add a comma after
$TestFilePoller/EventSourceOutputTextClass/action
, then add the string".txt"
(include the quotes).The expression should look like the following:
concat("c:\tibco\test\File",
$TestFilePoller/EventSourceOutputTextClass
/action, ".txt")
-
-
Click the Apply button to accept the formula and dismiss the XPath Formula Builder by clicking Close. Then click the Apply button in the Input tab of the activity.
-
Select the WriteToTestFile activity, then click the Input tab in the configuration panel.
-
Map the data as follows:
-
Select
$CreateTestFile/CreateActivityOutputClass/fileInfo/fullName
and drag it to the fileName item in the Activity Input pane.You do not need to use the XPath Formula Builder to map this item because you do not need to use XPath functions. The content of the field is exactly the same as the value of the $CreateTestFile/CreateActivityOutputClass/fileInfo/fullName process variable.
-
In the right panel, select the textContent field and click the XPath Formula Builder icon.
-
In the XPath Formula Builder, drag a concat function into the XPath formula panel.
-
Add
" ",
between<<
string1
>>
and<<
string2
>>
so that there is a space between the two strings in theconcat
function. -
Click the Data tab and drag.
$TestFilePoller/EventSourceOutputTextClass/fileContent/textContent
over<<
string1
>>
. -
Drag
$TestFilePoller/EventSourceOutputTextClass/timeOccurred
over<<
string2
>>
.The formula should look like this:
concat(
$TestFilePoller/EventSourceOutputTextClass/
fileContent/textContent
," ",$TestFilePoller/
EventSourceOutputTextClass/timeOccurred
) -
Click the Apply button to accept the formula and dismiss the XPath Formula Builder by clicking Close.
-
-
Click the Apply button on the activity’s Input tab, then choose Project > Save to save your project.

Each activity’s output is available to subsequent activities in the process definition. You can use data from previous activities to specify the input of the current activity. For example, you can use the content of the original text file as the content of the new text file.
The left panel of the Input tab contains a list of data from all activities preceding the current activity in the process diagram. Each activity’s name appears with a dollar sign ($) in front of it to indicate that this is a process variable.
The right panel of the Input tab lists the current activity’s input.
You are now ready to test the project.