A JavaScript policy applies to source attributes in a data management service and is executed when the service is run. Use a service plan to add a JavaScript policy to a service.
A JavaScript policy includes JavaScript files that describe data transformations applied to attributes in a service. You can use JavaScript files with multiple attributes in an entity, but you can associate each attribute with only one file. A service can include multiple JavaScript policies. The JavaScript files are stored in the Other Files folder in the Data Project Explorer.
Use JavaScript to define a data transformation for an attribute. You can use JavaScript to mask numbers with random values, extract substrings, concatenate entity values, and perform other data transformations available by leveraging JavaScript. You can also use JavaScript functions to apply the date privacy, identity privacy, numeric privacy, and scramble privacy policies.
The transformations defined in a JavaScript policy occur after Optim™ performs any lookup or rule-based transformations on the source data.
For example, to retrieve the source ADDRESS attribute in the CUSTOMERS entity of the DEMO schema, use the following syntax:
record.getItem('/DEMO/CUSTOMERS/ADDRESS')When a source value is processed by the record.getItem() method, the value is converted to a Java data type during JavaScript processing. After JavaScript processing, the value is converted to the target database's data type.
Use the following table to determine how source data types are converted during JavaScript processing.
Source data type | Java type |
---|---|
Character | java.lang.String |
Character Varying | java.lang.String |
National Character | java.lang.String |
National Character Varying | java.lang.String |
Character Large Object | byte[] (for IBM® DB2®, java.sql.Clob) (for Oracle, char[]) |
National Character Large Object | byte[](for IBM DB2, java.sql.Clob) (for Oracle, char[]) |
Binary | byte[] |
Binary Varying | byte[] |
Binary Large Object | java.sql.Blob |
Boolean | java.lang.Boolean |
Date | java.util.Calendar |
Time | java.util.Calendar |
Timestamp | java.sql.Timestamp (for Oracle, java.lang.Object) |
Numeric | java.math.BigDecimal |
Decimal | java.lang.String |
Double Precision | java.lang.Double (for Oracle, java.lang.String) |
Real | java.lang.Double |
Float | java.lang.Double (for Oracle, java.math.BigDecimal) |
Small Integer | java.lang.Short |
Integer | java.lang.Integer |
Big Integer | java.lang.Long |
Interval | java.lang.Object |
XML | java.lang.Object |
Datalink | java.lang.Object |