Value formats for database output
Include inferred entities in Batch Processor output
When the Batch Processor writes out csv output it writes them in the following manner:
Value Type | Output Format | Uncertain or Unknown |
---|---|---|
Number and Currency |
Numeric values written as decimal numbers with a period as the decimal separator. The number is formatted up to 15 significant decimal places; for example: |
Both written as blank |
String | String values are written as is. | Both written as blank |
Boolean | Boolean are always written as "true" or "false" | Both written as blank |
Date |
Date values are always written in the format "yyyy-MM-dd" where:
|
Both written as blank |
DateTime |
Date time are always written in the format "yyyy-MM-dd HH:mm:ss" where:
|
Both written as blank |
Time |
Time are always written in the format "HH:mm:ss" where:
|
Both written as blank |
Batch Processor results are written to the database using JDBC. It is recommended that where possible, the output column in the database matches the Oracle Policy Automation attribute (date and datetime, numbers and so on).
When writing date or datetime attributes to the database, the resulting value will depend on the data type of the table column to which it is being written:
For boolean values, a global boolean format is provided to control the value written to the database; see the topic Specify the global boolean format.
Null values are always treated as uncertain; except for string types which will produce output ofempty string.
When the output of the batch processor is set to coverage (--coverage <coverage file>) the result is a single file which can be imported into Oracle Policy Modeling as follows:
For more information see the Oracle Policy Modeling User's Guide.
When the output of the Batch Processor is set to test cases (--exporttsc <filename>), the result is a single file which can be imported into Oracle Policy Modeling as follows:
For more information see the Oracle Policy Modeling User's Guide.
When the output of the Batch Processor is set to sessions (--export <export dir>) the result is a set of OPA sessions, generated as XML files. There will be one session file generated for each case.
A session XML file can be used in Oracle Policy Modeling debugger. To load an individual session file into an active debugger session in Oracle Policy Modeling as follows:
The Batch Processor supports the ability to include inferred entities as output when writing to DB tables or CSV data files. The output will include the containment relationships of the inferred entities, but will not include any other inferred relationship details. Inferred entity output is only supported for database output or test script output; other output types such as session data, do not include inferred entities.
To include instances of an inferred entity in the output, the CSV input directory must include a data file that the Batch Processor can match to the inferred entity. The data file mapping rules are the same as those for non-inferred entities:
As with non-inferred entities, implicit mappings are supported when reading from CSV data files. When reading from a database, a configuration file with explicit mappings is required. If no explicit or implicit mapping can be found for an inferred entity, instances of the inferred entity will not be included in the output.
When writing inferred entity output, the Batch Processor will apply the following assumptions:
Assumption | |
---|---|
The output destination is empty |
Before the Batch Processor is run with inferred entity output, the output destination for the inferred entity output should be empty
|
All output attributes are identified |
Every attribute to be included in the output of an inferred entity must be identified as an output attribute. Attributes identified as input, or not identified in the implicit or explicit mapping will be excluded from the output.
|
When writing inferred entity output, the Batch Processor is creating new rows in the table which require unique primary key values. If writing to a database table that includes an auto-generating primary key, setting the primary-key-auto attribute to true in the entity configuration instructs the Batch Processor to allow the database to provide the primary key values when new rows are inserted:
<mapping entity="benefit" table="benefit-mapped" primary-key="#" primary-key-auto="true"> <attribute ... /></mapping>
If the primary-key-auto attribute is set to false, is excluded, or the Batch Processor is writing output to CSV files, then the Batch Processor will attempt to generate the primary key values. If the generated key causes a key violation with existing data when writing new rows with generated keys, the entire block of cases will be rolled back and the Batch Processor will stop and report the error.
The following are simple examples of how instances of the inferred Benefit entity can be included in the output, using explicit configuration and implicit configuration. The examples are based on the Inferred Benefits example rulebase provided with Oracle Policy Automation and located at: examples\rulebases\InferredBenefits.zip.
The CSV input directory contains a CSV file named benefit-mapped.csv. This file contains a row of column headings only and contains no data. The column headings are not marked as output, and do not match the public names of the inferred entity attributes:
The XML configuration file contains a <mapping> element for the benefit entity:
... <mapping entity="benefit" table="benefit-mapped" primary-key="#" > <attribute name="benefit_name" field="b-name" output="true" /> <attribute name="benefit_total_eligible" field="b-total" output="true" /> <relationship name="all-benefits" source-entity="global" foreign-key="g-key" /> </mapping> ...
The explicit mapping instructs the Batch Processor to map the inferred benefit entity to the benefit-mapped.csv file with the identified output columns for the entity attributes.
The CSV input directory contains a CSV file named benefit.csv, matching the public name of the benefit entity from the rulebase; no explicit mapping is provided. The file contains a row of column headings only and no data. The column headings are marked as output and match the public names of the inferred entity attributes:
In the absence of an explicit mapping provided by a configuration file, the Batch Processor will match the benefit.csv _file name to the public name of the _benefit entity. The identified output columns will be mapped to the entity attributes with matching public names.