|
private | checkMap () |
| verifies the input map in the constructor
|
|
private | checkMapField (string k, reference fh, hash th) |
| perform per-field pre-processing on the passed map in the constructor More...
|
|
nothing | commit () |
| commits the transaction
|
|
| constructor (SqlUtil::Table table, hash map, *hash opts) |
| builds the object based on a hash providing field mappings, data constraints, and optionally custom mapping logic More...
|
|
| constructor (SqlUtil::AbstractTable table, hash map, *hash opts) |
| builds the object based on a hash providing field mappings, data constraints, and optionally custom mapping logic More...
|
|
SqlUtil::AbstractTable | getTable () |
| returns the underlying SqlUtil::AbstractTable object
|
|
string | getTableName () |
| returns the table name
|
|
private bool | hasMapping (hash fh) |
| returns True if the field has a mapping, False if not
|
|
hash | insertRow (hash rec) |
| inserts a row into the target table based on a mapped input record; commits the transaction More...
|
|
hash | insertRowNoCommit (hash rec) |
| inserts a row into the target table based on a mapped input record; does not commit the transaction More...
|
|
private | mapFieldType (string key, hash m, reference v, hash rec) |
| performs type handling
|
|
hash | optionKeys () |
| returns a list of valid constructor options for this class (can be overridden in subclasses) More...
|
|
nothing | rollback () |
| rolls back the transaction
|
|
hash | validKeys () |
| returns a list of valid field keys for this class (can be overridden in subclasses) More...
|
|
provides an inbound data mapper to a Table target
builds the object based on a hash providing field mappings, data constraints, and optionally custom mapping logic
The target table is also scanned using SqlUtil and column definitions are used to update the target record specification, also if there are any columns with NOT NULL constraints and no default value, mapping, or constant value, then a MAP-ERROR exception is thrown
- Example:
const DbMapper = (
"id": ("sequence": "seq_inventory_example"),
"store_code": "StoreCode",
"product_code": "ProductCode",
"product_desc": "ProductDescription",
"ordered": "Ordered",
"available": "Available",
"in_transit": "InTransit",
"total":
int sub (any $x,
hash $rec) {
return $rec.Available.toInt() + $rec.Ordered.toInt() + $rec.InTransit.toInt(); },
);
my InboundTableMapper $map($table, DbMapper);
- Parameters
-
table | the target table object |
map | a hash providing field mappings; each hash key is the name of the output field; each value is either True (meaning no translations are done; the data is copied 1:1) or a hash describing the mapping; see Mapper Specification Format for detailed documnentation for this option |
opts | an optional hash of options for the mapper; see Mapper Options for a description of valid mapper options |
- Exceptions
-
MAP-ERROR | the map hash has a logical error (ex: "trunc" key given without "maxlen" , invalid map key) |
builds the object based on a hash providing field mappings, data constraints, and optionally custom mapping logic
The target table is also scanned using SqlUtil and column definitions are used to update the target record specification, also if there are any columns with NOT NULL constraints and no default value, mapping, or constant value, then a MAP-ERROR exception is thrown
- Example:
const DbMapper = (
"id": ("sequence": "seq_inventory_example"),
"store_code": "StoreCode",
"product_code": "ProductCode",
"product_desc": "ProductDescription",
"ordered": "Ordered",
"available": "Available",
"in_transit": "InTransit",
"total":
int sub (any $x,
hash $rec) {
return $rec.Available.toInt() + $rec.Ordered.toInt() + $rec.InTransit.toInt(); },
);
my InboundTableMapper $map($table, DbMapper);
- Parameters
-
table | the target table object |
map | a hash providing field mappings; each hash key is the name of the output field; each value is either True (meaning no translations are done; the data is copied 1:1) or a hash describing the mapping; see Mapper Specification Format for detailed documnentation for this option |
opts | an optional hash of options for the mapper; see Mapper Options for a description of valid mapper options |
- Exceptions
-
MAP-ERROR | the map hash has a logical error (ex: "trunc" key given without "maxlen" , invalid map key) |