Class: Mapping

$k. Mapping

new $k.Mapping()

Represents a (external) data mapping

Extends

Methods

exportElements()

Same as runExportOnElements()

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.3.1

iterateRows(rowFunction, errorFunction) : Array.<$k.Mapping>

Uses the mapping as data-source and validates each row with the validation-function.
Possible parameters:

  • bindings: database bindings (object with name and value) to use to replace parameters in select statements (database and import only)
  • caption: should the first row in the file be ignored, because it contains captions (CSV mappings only)
  • captions: Table captions (table mappings only)
  • dbEnvironment: database environment string (Oracle mappings only)
  • dbHostname: database host name to connect to (MySQL mappings only
  • dbPassword: database users password to use (databases only)
  • dbUsername: database user name to use (databases only)
  • disabledQueryParameters: List of disabled query parameters
  • encoding: encoding to use
  • importString: use this string instead of configured data source
  • isJson: is the source a json file (XML mappings only)
  • logTopicsToFolder: should the modified/created topics be logged to folders (false to switch off, true requires configured folder object in mapping) (import only)
  • netEntity: use this NetEntity as file input or output. For output to text (CSV etc.) set the charset of the entity before export, the encoding of the mapping is ignored.
  • queryParameters: Query parameters object ( e.g. {searchString: 'Goethe'}). Use disabledQueryParameters to deactivate parameters.
  • quote: should the cell values should be enclosed with quotes (CSV mappings only)
  • separator: separator to use in plain text files (CSV mappings only)
  • triggers: should triggers be be activated during import (import only)

Name Type Description
rowFunction function

function to process each row in a table. The function is invoked with the arguments:

  • <array> row: array of column values, including undefined/null values for empty columns

  • <number> index: number of the row in the input table

  • <object> table context: object to store context information over multiple rows, initialized with table meta data: {

    • <array> captions: array of caption strings, if the mappings provides these



errorFunction function

function invoked on internal errors (invalid file etc):

  • <string> error: error text

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.2.0-tilbago
Throws:
Type Description
$k.exception.MappingError

Unhandled errors while importing from the table data source (e.g. no connection to database, file not found, ...).

Returns:
Type Description
Array.<$k.Mapping> This mapping

runExport() : object

Runs this mapping as export

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.1.0
Throws:
Type Description
$k.exception.MappingError

Unhandled error while exporting to the data source (e.g. no connection to database, file not found)

Returns:
Type Description
object Object with the keys 'updated' and 'inserted' with the number of updated/inserted rows (databases only)

runExportOnElements(elements) : object

Runs this mapping as export on some elements

Name Type Description
elements Array.<$k.SemanticElement>

List of semantic elements to export via this mapping

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.1.0
Throws:
Type Description
$k.exception.MappingError

Unhandled error while exporting to the data source (e.g. no connection to database, file not found)

Returns:
Type Description
object Object with the keys 'updated' and 'inserted' with the number of updated/inserted rows (databases only)

runImport() : Array.<object>

Runs this mapping as import

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.1.0
Throws:
Type Description
$k.exception.MappingError

Unhandled error while importing from the data source (e.g. no connection to database, file not found).

Returns:
Type Description
Array.<object> Object with information about the import.

{
"errorCount": ,
"log": [ logEntry1, logEntry2, ... ]
}
Each log entry contains some or all of the following properties:

{
"message" : "",
"caption" : "<name of column/schema element>",
"data" : "",
"mapping" : "",
"category" : "",
"row:" ""
}

setParameter(name, value) : $k.Mapping

Set a single mapping parameter value overriding this parameter in the mapping definition

Name Type Description
name string

Name of the parameter to set

value

Value of the parameter

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.1.0
See:
Throws:
Type Description
$k.exception.TypeError

If the value does not match the expected type for the parameter

$k.exception.InvalidValue

If the name is not a valid parameter for mappings

Returns:
Type Description
$k.Mapping This mapping

setParameters(object) : $k.Mapping

Set a group of parameter values overriding the parameter in the mapping definition.


Possible parameters:


  • bindings: database bindings (object with name and value) to use to replace parameters in select statements (database and import only)

  • caption: should the first row in the file be ignored, because it contains captions (CSV mappings only)

  • captions: Table captions (table mappings only)

  • dbEnvironment: database environment string (Oracle mappings only)

  • dbHostname: database host name to connect to (MySQL mappings only

  • dbPassword: database users password to use (databases only)

  • dbUsername: database user name to use (databases only)

  • disabledQueryParameters: List of disabled query parameters

  • encoding: encoding to use

  • importString: use this string instead of configured data source

  • isJson: is the source a json file (XML mappings only)

  • logTopicsToFolder: should the modified/created topics be logged to folders (false to switch off, true requires configured folder object in mapping) (import only)

  • netEntity: use this NetEntity as file input or output. For output to text (CSV etc.) set the charset of the entity before export, the encoding of the mapping is ignored.

  • queryParameters: Query parameters object ( e.g. {searchString: 'Goethe'}). Use disabledQueryParameters to deactivate parameters.

  • quote: should the cell values should be enclosed with quotes (CSV mappings only)

  • separator: separator to use in plain text files (CSV mappings only)

  • triggers: should triggers be be activated during import (import only)


Name Type Description
object object

Object with parameter names and values

Version:
  • Experimental feature, might be removed at any time
Since:
  • 4.1.0
Throws:
Type Description
$k.exception.TypeError

If the passed object or any value does not match the expected type for the parameter

$k.exception.InvalidValue

If a name is not a valid parameter for mappings

Returns:
Type Description
$k.Mapping This mapping

Intherited methods