$k. Mapping

new Mapping()

Represents a (external) data mapping

Extends

Methods

deregister()

Deregisters the element. The id will be undefined afterwards. Equivalent to setId(undefined)

See
  • setId

exportElements()

Same as runExportOnElements()

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

id() → {string}

Returns the registered ID, or undefined if not registered.

Inherited From
Returns:
Type: 
string

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)
Parameters:
NameTypeDescription
rowFunctionfunction

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

errorFunctionfunction

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
Throws:

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

Type
$k.exception.MappingError
Returns:

This mapping

Type: 
Array.<$k.Mapping>

parentFolders() → {Array.<$k.Folder>}

Returns the folders that contain this element

Returns:
Type: 
Array.<$k.Folder>

registryType() → {string}

Returns the name of the registry that contains elements of this type

Returns:
Type: 
string

runExport() → {object}

Runs this mapping as export

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

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

Type
$k.exception.MappingError
Returns:

Object with the keys 'updated' and 'inserted' with the number of updated/inserted rows (databases only)

Type: 
object

runExportOnElements(elements) → {object}

Runs this mapping as export on some elements

Parameters:
NameTypeDescription
elementsArray.<$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:

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

Type
$k.exception.MappingError
Returns:

Object with the keys 'updated' and 'inserted' with the number of updated/inserted rows (databases only)

Type: 
object

runImport() → {Array.<object>}

Runs this mapping as import

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

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

Type
$k.exception.MappingError
Returns:

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:" "" }

Type: 
Array.<object>

setId(id, replaceScriptReferences)

Registers the element with the given ID. If the element has already been registered, then the id changes. If the id is undefined, then the element will be deregistered.

Parameters:
NameTypeDescription
idstring

The ID

replaceScriptReferencesboolean

True if ID references in scripts should be replaced. Only done when the old and the new ID is not undefined.

setParameter(name, value) → {$k.Mapping}

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

Parameters:
NameTypeDescription
namestring

Name of the parameter to set

value

Value of the parameter

Version
  • Experimental feature, might be removed at any time
Since
  • 4.1.0
Throws:
Returns:

This mapping

Type: 
$k.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)
Parameters:
NameTypeDescription
objectobject

Object with parameter names and values

Version
  • Experimental feature, might be removed at any time
Since
  • 4.1.0
Throws:
Returns:

This mapping

Type: 
$k.Mapping