In this step, you create a node for the business process to write the price and availability information to your file system. A file control enables processes to read, write, or append to a file in a file system.
This step includes the following tasks:
The third and fourth tasks are optional. They are provided to help you learn more about file controls, and are not required for completion of the tutorial.
The Insert Control dialog box is displayed.
myFileQuote
as the name of the control, and click Next.MyFileQuote
in the Name field, and click Next.Note: | In the simple case, each instance of the file control allows you to manipulate a separate file. For information about using a file control to manipulate multiple files, see File Control. |
FileControlPropertiesDocument write(XmlObject someData)
FileControlPropertiesDocument write(XmlObject someData)
The Control Expects field contains XmlObject someData
, which is the data type that the write()
method expects.
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, see File Control Properties. |
At run time, the quote document that you created in Step 9: Create Quote Document is written to your file system in the location specified by you.
The next two sections provide additional (optional) steps for further defining the Write Quote to File node that you created in the preceding section. These steps are not necessary for completing the tutorial. They are provided to help you understand and use the file control properties that are returned to your business process by the 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 typed XML document, FileControlPropertiesDocument
, which is valid against the XML schema, DynamicProperties.xsd
. The schema is available in the utility project under \schemas\system
.
Note: | To be able to use file control APIs, the DynamicProperties.xsd schema must be available in the schemas folder of your application’s utility or web project. |
This section describes 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 in Design Control Send Node to Interact with File Control. |
The Control Returns field contains FileControlPropertiesDocument
, which is the data type returned by the write()
method.
The Create Variable dialog box is displayed.
fileProperties
.
The Type Name field shows com.bea.wli.control.dynamicProperties.FileControlPropertiesDocument
.
The fileProperties
variable is displayed in the Receive Data tab, and also in the Data Palette.
This step completes the design of your file control node. At run time, the quote document that you create in Step 9: Create Quote Document is written to your file system in the location specified by you. Information about the file that you wrote is returned to the RequestQuote business process, and assigned to the fileProperties
variable.
In the previous section, you assigned the data returned from the file control to a variable named fileProperties
. You can now extract information about the file that you wrote from the fileProperties
variable.
Click the Source view tab to view the code in the RequestQuote.java
file.
Declaration of the fileProperties
variable is shown in the following line:
public com.bea.wli.control.dynamicProperties.FileControlPropertiesDocument fileProperties;
The write()
method on the myFileQuote
control is coded as 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) and write code for deriving information from the fileProperties
variable.
For example, the following line of code returns the file mask:
this.fileProperties.getFileControlProperties().getFileMask()
To extend this example further, edit the public void fileQuoteWrite()
method in the Source view to include the following line of code after the PROTECTED SECTION.
System.out.println
("The RequestQuote Process logged the quote in the following file " + this.fileProperties.getFileControlProperties().getFileMask());
In the Design view, the icon adjacent to the Write Quote to File node changes to .
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 file mask) is printed to the console.
For more information, see “File Control” in Using Integration Controls.