Document Generator - Sample Code (TxtDocumentGenerator)
The Document Generator in this example does the following:
- Generates a 'txt' file when the “custom-document-type” Custom Property is detected
- Sends other requests to the BIPublisherDocumentGenerator
The sample code will cover the following:
- Create a simple Document Generator plugin
- Basic methodology to access instance data in the Web Determinations Interview session (passed into the called Document Generator method)
- Use of the existing BIPublisherDocumentGenerator class
Setup
This sample code needs the following to run:
- The 'HealthyEating' rulebase that can be found at examples\rulebases\compiled\HealthyEating.zip in either the Java or .NET Oracle Policy Automation Runtime package.
- TxtDocumentGenerator (Document Generator plugin)
About the Document Generation Rulebase:
- Setup to display document generation links for 'HTML' and 'PDF' documents using the default Document Generator plugin
- The document links are only displayed once the goal attribute ('visibility_summary_end' - 'the end of interview items should be displayed on the summary screen') has been determined and reached.
- For the HTML and PDF document links, they are driven by template files in the rulebase package
- To setup display of ‘TXT’ files using TxtDocumentGenerator:
- Copy the HealthyEating rulebase source from examples\rulebases\source (in either the java or .NET runtime zip file) to a place on your machine where it can be unzipped.
- Unzip and then open the HealthyEating rulebase in Oracle Policy Modeling.
- Go to File -> Project Properties.
- Select Custom Property Definitions -> Interview Document.
- Add new property “custom-document-type”. Click OK.
- Open Screens.xint.
- Under DocGen folder, create new Document.
- Set document name (that is, “Text Document”).
- Select any output type and click OK.
- Right click on the “Text Document” icon and select Custom Properties.
- Set the value of “custom-document-type” to any string. Click OK.
- In the summary screen, add a new Document Control to reference “Text Document”.
- Set the visibility attribute to “visibility_summary_end”. Click OK.
About the TxtDocumentGenerator plugin:
- This is a demonstration of how to create a simple Document Generator plugin, and using the InterviewSession object passed to the generateDocument() method to access data from the interview
- This Document Generation plugin generates a .txt file
- Only returns a .txt file if the custom property “custom-document-type” is detected and the property value is not blank.
To setup this scenario:
- Open the HealthyEating rulebase in Oracle Policy Modeling, and run Build.
- Copy the compiled rulebase .zip file (HealthyEating.zip) from the project output directory to the rulebase folder in Oracle Web Determinations (for example, <webroot>\WEB-INF\classes\rulebases)
- Copy and install the TxtDocumentGenerator.jar file or the TxtDocumentGenerator.dll file (located in examples\interview-engine\document-generator in either the Java or .NET runtime zip file) into Web Determinations; for more information, refer to Create a Plugin
- Run a Web Determinations Interview.
Source Code
To view the source code for the TxtDocumentGenerator sample, refer to examples/interview-engine/document-generator in either the Java or .NET runtime zip file.