Tutorial: Designing Your First Business Process

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Step 10: Write Quote to File System

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:

  1. Create Instance of File Control
  2. Design Control Send Node to Interact with File Control
  3. (Optional) Assign File Control Properties to a Variable
  4. (Optional) Use the File Control Properties

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.

 


Create Instance of File Control

  1. Click on the Data Palette Controls tab and choose Integration Controls > File.
  2. The Insert Control dialog box is displayed.

  3. Enter myFileQuote as the name of the control, and click Next.
  4. In the Create Control dialog box, enter MyFileQuote in the Name field, and click Next.
    1. In the Insert Control - File dialog box, specify the following:
      • 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.
    2. Click Finish.
    3. An instance of a file control, named myFileQuote, is created in your project and displayed under Controls in the Data Palette.

  5. From the Oracle Workshop for WebLogic menu, select File > Save.
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.

 


Design Control Send Node to Interact with File Control

  1. Expand the myFileQuote control instance in the Data Palette, and select the following method:
  2. FileControlPropertiesDocument write(XmlObject someData)
  3. Drag the method and drop it in the RequestQuote business process immediately after the Combine Price and Avail Quotes node.
  4. Rename the node to Write Quote to File.
  5. Double-click the Write Quote to File node.
  6. In the General Settings tab, confirm that myFileQuote is displayed in the Control field and that the following method is selected in the Method field:
  7. FileControlPropertiesDocument write(XmlObject someData)
  8. Select the Send Data tab.
  9. The Control Expects field contains XmlObject someData, which is the data type that the write() method expects.

  10. In the Select variables to assign field, select Quote (QuoteDocument), which you created in Step 9: Create Quote Document.
  11. 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.
  12. Click Close to close the node builder.
  13. From the Oracle Workshop for WebLogic menu, select File > Save.
  14. This step completes the design of your file control node.

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.

File Control Properties

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.

 


Assign File Control Properties to a Variable

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.
  1. If the Write Quote to File node is not already open, double-click the node to open it.
  2. Select the Receive Data tab.
  3. The Control Returns field contains FileControlPropertiesDocument, which is the data type returned by the write() method.

  4. In the Select variables to assign field, select Create new variable....
  5. The Create Variable dialog box is displayed.

  6. In the Variable Name field, enter fileProperties.
  7. Select the XML tab.
  8. Expand the Typed node (by clicking the + symbol adjacent to it), and progressively expand the nodes up to schemas\system.
  9. Under system, expand DynamicProperties.xsd, and select FileControlProperties.
  10. The Type Name field shows com.bea.wli.control.dynamicProperties.FileControlPropertiesDocument.

  11. Click OK to create the new variable.
  12. The fileProperties variable is displayed in the Receive Data tab, and also in the Data Palette.

  13. Click Close to close the node builder.
  14. From the Oracle Workshop for WebLogic menu, select File Arrow symbol Save.
  15. 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.

 


Use the File Control Properties

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:

Listing 11-1 Code for write() Method
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.


  Back to Top       Previous  Next