$k. Copier

Helper for copying objects.

Constructor

new $k.Copier()

Methods

copy(object) → {$k.SemanticElement}

Copies the object and related objects. By default, a shallow copy with all properties and meta properties of the original object is created. Shallow copy means that for all relations of the original object, a new relation to the same target is created at the copy. Properties are only copied if allowed by the schema, i.e. no attributes with unique values are included, and no relations are shallow copied for which the relation target cannot have multiple relations of this kind.

Parameters:
NameTypeDescription
object$k.SemanticElement

The object to copy

Since
  • 5.1.1
Returns:
Type: 
$k.SemanticElement

registerCopy(original, copy)

Registers a copy of the original. It will be used instead of creating a new copy. Can be used to customize the copied structure.

Parameters:
NameTypeDescription
original$k.SemanticElement

The original object

copy$k.SemanticElement

The copy

Since
  • 5.3.3

setActivateTriggers(bool)

If set to false, triggers will be deactivated for the copy process. By default, triggers are enabled.

Parameters:
NameTypeDescription
boolboolean
Since
  • 5.3.2

setDeepCopyFilter(checkFunction)

Sets the filter function for relation targets that should be deep copied. By default, no target is copied. Note that the property filter function and deep copy filter function is also evaluated for all deep copied relation targets.

Parameters:
NameTypeDescription
checkFunctionfunction

The function is called for each target of a copied relation and should return true if the target object should be deep copied. If the return value is false, the copied relation will point to the same object as the original relation.

Since
  • 5.0.3

setPostCopyCallback(checkFunction)

Sets the copy callback function function

Parameters:
NameTypeDescription
checkFunctionfunction

The function is called after an object is copied. It receives the original object and the copy.

Since
  • 5.1.1

setPropertyFilter(filterFunction)

Sets the property filter function. By default, all properties and their meta properties are copied.

Parameters:
NameTypeDescription
filterFunctionfunction

The function is called with each property and meta property of the original object and should return true if the property should be copied.

Since
  • 5.0.3

setPropertyPostCopyCallback(checkFunction)

Sets the property copy callback function

Parameters:
NameTypeDescription
checkFunctionfunction

The function is called after a property is copied. It receives the original property and the copy.

Since
  • 5.1.1