Complete this step to create a node, at which your business process writes the quote created in the preceding step to your file system. A File control makes it easy to read, write, or append to a file in a file system.
Complete the following tasks to design your business process to write the combined price and availability quote to your file system:
The following tasks are optional. They are provided to deepen your understanding of File controls but are not required for the completion of the tutorial.
In this scenario, you add one instance of the File control to your business process.
directory-name—Enter the location in which you want the File control to write the file. You can use any location on your file system.
file name filter—Enter a name for the file. For example, enter quote.xml
.
Type of data—Select XmlObject from the drop-down list.
An instance of a File control, named myFileQuote, is created in your project and displayed under the Controls folder.
Note: | In the simple case, each instance of the File control allows you to manipulate a separate file. To learn about how your File control can operate on multiple files, see File Control. |
FileControlPropertiesDocument write(XmlObject someData)
FileControlPropertiesDocument write(XmlObject someData)
XmlObject someData
, which is the data type expected by the write
() method.Quote
variable to hold the quote in Step 9: Create Quote Document.)Note: | The node builder for this node contains a Receive Data tab. You can use this tab to specify a variable to which the data returned by the File control is assigned. For the purposes of this tutorial scenario, it is not required that you specify this variable; you can ignore the Receive Data tab. However, to learn how to specify a variable on the Receive Data tab, and a scenario in which you might subsequently use the variable, proceed to Note About File Control Properties. |
This step completes the design of your File control node. At run time, the quote document you created in Step 9: Create Quote Document is written to your file system in the location specified by you.
This optional section provides additional steps you can use to further define the Write Quote to File node you created in the preceding section. You are not required to complete the steps in this section to complete the tutorial. The steps are provided to help you understand and use the File Control Properties returned to your business process by the File control's FileControlPropertiesDocument write(XmlObject someData)
method.
When you use a File control to write a file to the file system as you do in this step, the control returns information about the file you wrote. The information is returned in a document of type XML: FileControlPropertiesDocument
. The FileControlPropertiesDocument
is valid against an XML Schema: DynamicProperties.xsd
. The Schema is provided for you in the project in your tutorial application. (See the project in the Package Explorer tab.)
The following steps describe how to design the Write Quote to File node in your business process to include assigning a variable to which the File Control Properties are assigned:
Note: | Before starting this section, you should have completed steps 1 through 7 as described in To Design a Control Send Node in Your Business Process to Interact With Your File Control. |
FileControlPropertiesDocument
, which is the data type returned by the write
() method.com.bea.wli.control.dynamicProperties.FileControlPropertiesDocument
. In the Select Variable Typed pane, expand system/DynamicProperties.xsd, then select FileControlProperties. Note: | By default the com.bea.wli.control.dynamicProperties.FileControlPropertiesDocument is selected in the Variable type field. |
This step completes the design of your File control node. At run time, the quote document you create in Step 9: Create Quote Document is written to your file system in the location specified by you. Information about the file you wrote is returned to the RequestQuote business process, and assigned to the fileProperties variable you created.
Note: | The Dynamic Properties.xsd XML Schema must be available in a project in your application before you can create a variable to hold the file control properties that are returned to your business process from the File control. Dynamic Properties.xsd is one of the system schemas available to you when you create BEA Products applications in BEA Workshop. |
In the preceding steps, you assigned the data returned from the File control to a variable named fileProperties. You can derive information about the file you wrote from fileProperties.
Click the Source view tab to view your RequestQuote.java file in Source view. By completing the steps described in the preceding section, the following code is written in your JAVA file in keeping with the work you did in the Design view.
The fileProperties variable declaration is shown in the following listing:
public com.bea.wli.control.dynamicProperties.FileControlPropertiesDocument fileProperties;
The write()
method on the myFileQuote control is shown in the following listing:
public void myFileQuoteWrite() throws Exception
{
//#START: CODE GENERATED - PROTECTED SECTION - you can safely add code
above this comment in this method. #//
// input transform
// return method call
this.fileProperties = myFileQuote.write(this.Quote);
// output transform
// output assignments
//#END: CODE GENERATED - PROTECTED SECTION - you can safely add code below
this comment in this method. #//
}
You can edit this method (outside the PROTECTED SECTION of code) to write code that derives information from the fileProperties variable. For example, the following line of code returns the FileMask:
this.fileProperties.getFileControlProperties().getFileMask()
To illustrate this example further, edit the public void fileQuoteWrite() method in Source View to include the line of code shown in bold in the following listing:
//#END: CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
System.out.println ("The RequestQuote Process logged the quote in the following file "
+ this.fileProperties.getFileControlProperties().getFileMask());
}
Note that you must add the code after the PROTECTED SECTION
comment. Code completion in the Source View helps you write the code. When you switch back to the Design view, note that the Write Quote to File node changes to include the following icon: . This is a visual reminder that you edited the code associated with this node in the Source view.
When you run the business process, the name you gave the file (the FileMask) is printed to the console.