Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 3 TIBCO BusinessWorks Example : Creating the TestFileOperations Process

Creating the TestFileOperations Process
This section guides you through creating a simple process definition using TIBCO Designer Add-in for TIBCO Business Studio. The process, which is named TestFileOperations, polls a directory for a specified file and writes a new file to a specified result 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 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. The time of the file change is represented as the number of milliseconds since January 1, 1970.
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"
Before you start to design the process, create a directory for the test data. Then create a text file with some simple content (for example, "Roses are red and violets are blue.") in the directory. This file will be needed by the File Poller activity. This example uses the directory C:\TEMP\testdata and the file PolledFileTest.txt. The result directory is specified in a global variable and can be modified before running the process.
To create the TestFileOperations process, follow these steps:
1.
Open the TIBCO Designer project created in the previous section (for example tutorial) in the TIBCO Designer perspective. You can do so in the following ways:
2.
If no palettes are displayed in the palette view, select the menu Designer >Palettes > Options > Switch Palette Mode to display the palettes.
3.
4.
In the DABS Main view, type the name TestFileOperations in the Name field to rename the process. Then click Apply.
5.
Save your project by choosing File > Save from the menu or by clicking the icon in the toolbar.
To set the result file directory in the Global Variables view, follow these steps:
1.
To open the Global Variables view, select Window > Show View > Global Variables in the menu bar.
The Global Variables view is opened beside the Project Explorer.
2.
3.
4.
Click OK to save and close the Global Variables editor.
5.
To add activities to the process, follow these steps:
1.
Double-click the TestFileOperations process in the Project Explorer to open the process in the DABS Main view.
The Start and End activities should be displayed in the DABS Main view.
2.
If the File palette is not one of the available palettes, choose Designer > Palettes > Activities > File to make the palette available.
3.
4.
a.
b.
Click Browse 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. (for example, C:\TEMP\testdata\FilePollerTest.txt)
c.
Accept default values for the Polling Interval, Include Existing Files, and Exclude File Content fields. The Content as field is set to text by default. Select the appropriate encoding for your operating system in the Encoding field.
d.
Click Apply.
5.
6.
Name the Write File activity WriteTestResult, then click Apply.
7.
In the DABS Main view, select the Create transition icon on the dynamic toolbar.
8.
The result should appear as follows:
9.
Choose File > Save from the menu.
The process now includes appropriately connected activities. However, to include information about the name and content of the result files, the data flow between the activities has to be mapped.
To map the data flow between activities, follow these steps:
1.
2.
3.
a.
b.
c.
Add "\TestResult-" between <<string1>> and <<string2>> and ".txt" after <<string2>> so that the new file is created in the specified directory, with name TestResult-action.txt.
d.
Select $_globalVariables/GlobalVariables/ResultFileDirectory and drag it over the <<string1>>.
e.
Drag $CheckFile/EventSourceOuputTextClass/action over <<string2>>.
The formula should look like this:
      concat($_globalVariables/ns1:GlobalVariables/
      ResultFileDirectory,"\TestResult-",
      $CheckFile/ns:EventSourceOuputTextClass/action,".txt" )
f.
Click Apply to accept the formula and dismiss the XPath Formula Builder by clicking Close.
g.
Select the textContent field in the Activity Input pane and click the XPath Formula Builder icon.
h.
i.
Add " ", between <<string1>> and <<string2>> so that there is a space between the two strings in the concat function.
j.
k.
The formula mustlook like:
      concat($CheckFile/EventSourceOutputTextClass/fileContent/
      textContent," ",$CheckFile/EventSourceOutputTextClass/
      timeOccurred )
l.
Click Apply to accept the formula and dismiss the XPath Formula Builder by clicking Close.
4.
Click Apply on the activity’s Input tab, then choose File > Save to save your project.
You are now ready to test the project.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved