$k. Instance

new Instance(type, paramopt, languageopt, optionsopt) → {$k.Instance}

Create a new instance of the type

Parameters:
NameTypeAttributesDescription
type

Type or internal name

paramstring<optional>

The name of the new instance

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

optionsobject<optional>

Options

  • cluster: {$k.SemanticElement} Store the new instance the cluster of the element
Since
  • 5.1.1
Throws:
Returns:

The created instance

Type: 
$k.Instance

Extends

Methods

attribute(type) → {$k.Attribute}

Returns the attribute of the type (including sub-attributes), or undefined if no attribute exists

Parameters:
NameTypeDescription
type

AttributeType or internal name

Throws:

If there is more than one attribute of this type

Type
$k.exception.NotUnique
Returns:
Type: 
$k.Attribute

attributes(typeopt) → {Array.<$k.Attribute>}

Returns all attributes of the type (including sub-attributes). Returns all attributes if the type is undefined

Parameters:
NameTypeAttributesDescription
type<optional>

AttributeType or internal name or undefined

Throws:

If type is not an attribute

Type
$k.exception.SchemaError
Returns:
Type: 
Array.<$k.Attribute>

attributeValue(type, languageopt)

Returns the value of the attribute, or undefined if there is no such attribute

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Throws:

If there is more than one attribute of this type

Type
$k.exception.NotUnique
Returns:

The value of the attribute

attributeValueString(type, languageopt) → {string}

Returns the value string of the attribute, or undefined if there is no such attribute

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Since
  • 4.1.0
Throws:

If there is more than one attribute of this type

Type
$k.exception.NotUnique
Returns:

The value string of the attribute

Type: 
string

callBehaviour(method, argsopt)

Calls an internal behavior method

Parameters:
NameTypeAttributesDescription
methodstring

Name of the method

argsArray.<object><optional>

Arguments of the call

Throws:

When the behavior method raises an exception

Type
$k.exception.RuntimeError

changeLog() → {Array.<object>}

Get the change log object of this SemanticElement as object

Returns:

A list of change log entries, each an conforming the below schema. Null if no change log is present for the SemanticElement.

{ "$schema" : "http://json-schema.org/draft-04/schema#", "type" : "object", "properties" : { "tag" : { "type" : "string", "enum" : ["AttributeEvent", "RelationEvent"], "description" : "is this a change for an attribute or a relation" }, "type" : { "type" : "string", "enum" : ["modify", "create", "delete", "executeMapping"], "description" : "what kind of change is logged in this event" }, "timestamp" : { "type" : "string", "description" : "time of the change; format: ISO 8601 timestamp string without timezone", }, "topic" : { "type" : "object", "description" : "id and label of the changed object", "properties" : { "label" : { "type" : "string" }, "id" : { "type" : "string" } } }, "user" : { "type" : "object", "description" : "id and name of the user object which performed the change", "properties" : { "label" : { "type" : "string" }, "id" :{ "type" : "string" } } }, "property" : { "type" : "object", "description" : "id and label of the changed property type", "properties" : { "conceptId" : { "type" : "string" }, "label" : { "type" : "string" } } }, "value" : { "type" : "string", "description" : "string representation of the new value" }, "language" : { "type" : "string", "description" : "language of the changed value; format: ISO639 3-letter code" }, "oldValue" : { "type" : "string", "description" : "string representation of the previous value" }, "target" : { "type" : "object", "description" : "id and label of the relation target object", "properties" : { "id" : { "type" : "string" }, "label" : { "type" : "string" } } }, "required" : [ "type", "tag", "timestamp", "topic" ] } }

Type: 
Array.<object>

changeType(jseType, ignoreLossOfPropertiesopt) → {boolean}

Change type

Parameters:
NameTypeAttributesDescription
jseType

Type or internal name

ignoreLossOfPropertiesboolean<optional>

Ignore loss of properties; default: false

Since
  • 5.3.0
Throws:

If "ignoreLossOfProperties" is not set to true and properties will be lost when changing type

Type
$k.exception.SchemaError
Returns:

True if properties have been lost

Type: 
boolean

copy() → {$k.Instance}

Create a copy of me

Throws:
Returns:
Type: 
$k.Instance

copyProperties(propertyNames, target) → {$k.Instance}

Create copies of the named properties at the target

Parameters:
NameTypeDescription
propertyNamesArray.<string>

PropertyTypes or internal names

target$k.Instance

Target object

Throws:

If anything bad happens during copy

Type
$k.exception.RuntimeError
Returns:
Type: 
$k.Instance

core() → {$k.SemanticElement}

Returns the extended element, if this is an extension. Returns the element itself otherwise

Returns:
Type: 
$k.SemanticElement

createAttribute(type, value, languageopt) → {$k.Attribute}

Creates a new attribute with the given value

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

value

Value of the attribute. Pass undefined for attribute types without value.

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Throws:
Returns:
Type: 
$k.Attribute
Example
person.createAttribute("alias", "Tester");

createAttributeFromString(type, valueString, languageopt) → {$k.Attribute}

Creates a new attribute and set the value from the string representation

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

valueStringstring

String represantation of the value

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Deprecated
  • Use setAttributeValue($k.ValueString(valueString), language) instead
Throws:
Returns:
Type: 
$k.Attribute
Example
person.createAttributeFromString("dateOfBirth", "2.3.1968", "de");

createExtension(type) → {$k.Instance}

Create an extension of the given type

Parameters:
NameTypeDescription
type

Type or internal name

Throws:
Returns:
Type: 
$k.Instance

createRelation(type, target, inverseopt) → {$k.Relation}

Creates a new relation

Parameters:
NameTypeAttributesDescription
type

RelationType or internal name

target$k.SemanticElement

The relation target.

inverse<optional>

RelationType or internal name of the inverse Relation. The default inverse relation type will be used if this parameter is undefined.

Throws:
Returns:
Type: 
$k.Relation

domain() → {$k.Domain}

Returns the domain of the instance

Since
  • 4.1.0
Returns:
Type: 
$k.Domain

element() → {$k.SemanticElement}

Returns this element. Allows to send element() either to a $k.Hit or a semantic element

Since
  • 4.3.0
Returns:
Type: 
$k.SemanticElement

ensureAttributeValue(type, value, languageopt) → {$k.Attribute}

Returns an existing attribute with the given value. Otherwise creates and returns an additional attribute with the given value, or returns an existing attribute with modified value if the schema does not allow multiple occurrences.

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

value

The value that should be set.

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Since
  • 4.3.0
Throws:
Returns:
Type: 
$k.Attribute

ensureRelationTarget(type, target, inverseopt) → {$k.Relation}

Returns a existing relation to the target. Otherwise creates and returns an additional relation to the target, or returns an existing relation relocateded to the target if the schema does not allow multiple occurrences

Parameters:
NameTypeAttributesDescription
type

RelationType or internal name

target$k.SemanticElement

The relation target.

inverse<optional>

RelationType or internal name of the inverse Relation. Only applies, if a new relation will be created. The default inverse relation type will be used if this parameter is undefined.

Since
  • 4.3.0
Throws:
Returns:
Type: 
$k.Relation

extensions() → {Array.<$k.Instance>}

Returns the extension instances

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

hasPossibleAttribute(type) → {boolean}

Returns true if the type is a possible attribute of this element

Parameters:
NameTypeDescription
type

AttributeType or internal name

Returns:
Type: 
boolean

hasPossibleRelation(type) → {boolean}

Returns true if the type is a possible relation of this element

Parameters:
NameTypeDescription
type

RelationType or internal name

Returns:
Type: 
boolean

icon(sizeopt, languageopt) → {blob}

Returns the icon of the element as blob

Parameters:
NameTypeAttributesDescription
sizearray<optional>

Size of icon as array

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Since
  • 4.1.0
Returns:
Type: 
blob

iconAttribute(sizeopt, languageopt) → {attribute}

Returns the icon of the element as blob attribute

Parameters:
NameTypeAttributesDescription
sizearray<optional>

Size of icon as array

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Since
  • 5.3.0
Returns:
Type: 
attribute

idNumber()

Deprecated
  • Use idString() instead
See
  • idString

idString() → {string}

Returns the element ID as string (ID123_456). Returns undefined for non-persistent elements (system relations etc.)

Returns:
Type: 
string

inheritedAttribute(type) → {$k.Attribute}

Returns the own attribute or the inherited attribute of the supertype(s). If there is more than one supertype, the attribute must be unique. If this is not a type, then this function is equivalent to attribute().

Parameters:
NameTypeDescription
type

AttributeType or internal name

Throws:

If there is more than one value of this type

Type
$k.exception.NotUnique
Returns:

The inherited attribute, or undefined if there is no attribute

Type: 
$k.Attribute

inheritedAttributeValue(type, languageopt)

Returns the value of the own attribute or of the inherited value of the supertype(s). If there is more than one supertype, the value must be unique. If this is not a type, then this function is equivalent to attribute(value).

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Throws:

If there is more than one value of this type

Type
$k.exception.NotUnique
Returns:

The inherited value, or undefined if there is no attribute

intrafindConvertAndTagDocument(urlopt) → {object}

Converts a document blob or URL located document to an object containing metadata and tags using intrafinds API functions

Parameters:
NameTypeAttributesDescription
urlstring<optional>

Url to convert a document from instead of the semantic element this function was called for

Throws:

If the configuration is missing or incomplete

Type
$k.exception.RuntimeError
Returns:
Type: 
object

intrafindConvertDocument(urlopt) → {object}

Converts a document blob or URL located document to an object containing the meta data using intrafinds API functions

Parameters:
NameTypeAttributesDescription
urlstring<optional>

Url to convert a document from instead of the semantic element this function was called for

Throws:

If the configuration is missing or incomplete

Type
$k.exception.RuntimeError
Returns:
Type: 
object

isInvalid() → {boolean}

True if the semantic element was deleted (e.g. by a rollback or remove()

Returns:
Type: 
boolean

kPathEvaluate(pathString)

Parameters:
NameTypeDescription
pathString

localAddProperty(property) → {$k.Instance}

Add the property to a local instance - the original topic and property remain unchanged. Danger zone: The local instance prepared in this way may behave unexpected. It can be used for visualization or mapping but has not yet been approved for other purposes.

Parameters:
NameTypeDescription
property$k.Property

The property to be added

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

If I am no local instance

Type
$k.exception.SchemaError
Returns:
Type: 
$k.Instance

locatorString(locatorTypesopt) → {string}

Returns the element locator as string

Parameters:
NameTypeAttributesDescription
locatorTypesarray<optional>
Since
  • 4.0.2
Returns:
Type: 
string

modificationNumber() → {number}

Returns the modification number for the cluster conatining as 64 bit integer. Returns 0 for newly created topics that are not yet assigned to a cluster. Returns undefined for non-persistent elements (system relations etc.). An unchanged modification number indicates that the element is unchanged. A changed modification number does not necessarily indicate that the topic changed, because there might have been changes in other objects contained in the same cluster.

Returns:
Type: 
number

name(languageopt) → {string}

Returns the name of the element

Parameters:
NameTypeAttributesDescription
languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Returns:
Type: 
string

openInKnowledgeBuilder(user)

Parameters:
NameTypeDescription
user$k.User
Version
  • Experimental feature, might be removed at any time

possibleExtensions() → {Array.<$k.Type>}

Returns all possible extension types

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

possibleProperties(filteropt) → {Array.<$k.PropertyType>}

Returns the possible properties of this element.

Parameters:
NameTypeAttributesDescription
filterstring | $k.PropertyFilter<optional>

Optional filter that defines which properties are returned

Returns:
Type: 
Array.<$k.PropertyType>
Examples
// Possible properties, excluding shortcut / system relations
possibleProperties();
// Possible properties, including system relations
possibleProperties($k.PropertyFilter.setSystemRelations());
// Same as above, using a literal object to define the filter
possibleProperties({ systemRelations: true });

primaryCore() → {$k.SemanticElement}

Returns the primary element.

  • if the receiver is an instance or type, then the receiver itself is returned.
  • if the receiver is an extension, then the extended instance is returned.
  • if the receiver is a property, then the primary core of the source is returned.
Since
  • 4.2.0
Returns:
Type: 
$k.SemanticElement

properties(filteropt) → {Array.<$k.Property>}

Returns all properties of the property type

Parameters:
NameTypeAttributesDescription
filterstring | $k.PropertyFilter<optional>

Filter that defines which properties are returned

Returns:
Type: 
Array.<$k.Property>
Examples
// All properties 
properties();
// All relations with internal name "contains", including sub-relations
properties(new $k.PropertyFilter().setType("contains"));
// All relations with internal name "contains", without sub-relations
properties(new $k.PropertyFilter().setExact().setType("contains"));
// Same as above, using a literal object to define the filter
properties({ exact: true, type: "contains" });

relation(type) → {$k.Relation}

Returns the relation of the type (including sub-relations), or undefined if no relation exists

Parameters:
NameTypeDescription
type

RelationType or internal name

Throws:
Returns:
Type: 
$k.Relation

relations(typeopt) → {Array.<$k.Relation>}

Returns all relations of the type (including sub-relations). If type is undefined, all user relations (excluding inverse one way relations) are returned.

Parameters:
NameTypeAttributesDescription
type<optional>

RelationType or internal name or undefined

Throws:

If type is not a relation type

Type
$k.exception.TypeError
Returns:
Type: 
Array.<$k.Relation>

relationTarget(type) → {$k.SemanticElement}

Returns the target of the relation of the relation type, or undefined if there is no such relation

Parameters:
NameTypeDescription
type

RelationType or internal name

Throws:
Returns:
Type: 
$k.SemanticElement

relationTargets(type) → {Array.<$k.SemanticElement>}

Returns the targets of the relations of the relation type. Each target is only returned once, even if multiple relations point to the same target. Returns all relation targets if the type is undefined

Parameters:
NameTypeDescription
type

RelationType or internal name or undefined

Throws:

If type is not a relation type

Type
$k.exception.TypeError
Returns:
Type: 
Array.<$k.SemanticElement>

remove()

Deletes the element and all attached properties

Throws:

removeProperties(filteropt)

Removes all properties of the property type

Parameters:
NameTypeAttributesDescription
filterstring | $k.PropertyFilter<optional>

Filter that defines which properties are removed

Since
  • 5.4.0
Throws:

If deleting one of the properties is not allowed

Type
$k.exception.AccessDenied

render(contextopt, keyFilteropt, detailFilteropt) → {object}

Renders the element as a literal object using the associated view configuration. Uses the optional context topic to detect a suitable configuration

Parameters:
NameTypeAttributesDescription
contextobject<optional>

Element that defines the context.

keyFilterobject<optional>

Alternative 1 (preferred): a $k.JSONRenderContext Alternative 2 (compatibility only): A filter. See $k.JSONRenderContext.prototype.setFilters().

detailFilterobject<optional>

Only used if the key filter is not a $k.JSONRenderContext. See $k.JSONRenderContext.prototype.setLevelsOfDetail()

Returns:

The rendered object

Type: 
object

renderJSON(contextopt, excludedKeysopt, detailFilteropt) → {object}

Render the element as a JavaScript object using the associated view configuration. Uses the optional context topic to detect a suitable configuration

Parameters:
NameTypeAttributesDescription
context$k.SemanticElement<optional>

Element that defines the context.

excludedKeysArray.<string><optional>

Collection of property names that are excluded

detailFilterobject<optional>

Only used if the key filter is not a $k.JSONRenderContext. See $k.JSONRenderContext.prototype.setLevelsOfDetail()

Deprecated
  • Use render(context, {"exclude": excludedKeys}) instead
Returns:

The rendered JSON object

Type: 
object

renderTemplate(template, entity, conversionopt, variablesopt)

Render a document based on a given print template

Parameters:
NameTypeAttributesDescription
template$k.SemanticElement

the template that will be applied

entity$k.NetEntity

The render target

conversion$k.SemanticElement<optional>

The semantic element representing the document conversion

variablesobject<optional>

Additional variables to pass to the template

Since
  • 4.4.0
Throws:

When the element could not be rendered

Type
$k.exception.RuntimeError

setAttributeFromString(type, valueString, languageopt)

Sets the value of the attribute from the string representation. Creates a new attribute if no such attribute exists

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

valueStringstring

String represantation of the value

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Deprecated
  • Use setAttributeValue(type, $k.ValueString(valueString), language) instead
Throws:

setAttributeValue(type, value, languageopt)

Sets the value of the attribute. Creates a new attribute if no such attribute exists

Parameters:
NameTypeAttributesDescription
type

AttributeType or internal name

value

The value that should be set.

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Throws:

setName(name, languageopt)

Sets the name of the element

Parameters:
NameTypeAttributesDescription
namestring

The name

languagestring<optional>

Either an ISO 639-1 or ISO 639-2B language code (e.g. "en" or "eng"), or a locale name without encoding (e.g. "en_US"). Locale names and language codes are not interchangeable, e.g. the values for "de" and "de_DE" are separated. If not defined, the locale/language of the process will be used. Ignored if the attribute is not translated.

Throws:

setRelationTarget(type, target, inverseopt)

Sets the target of the relation. Creates a new relation if no such relation exists

Parameters:
NameTypeAttributesDescription
type

RelationType or internal name

target$k.SemanticElement

The relation target.

inverse<optional>

RelationType or internal name of the inverse Relation. Only applies, if a new relation will be created. The default inverse relation type will be used if this parameter is undefined.

Since
  • 4.3.0
Throws:

type() → {$k.Type}

Returns the type of the element. If the topic is a type, the type itself is returned

Returns:
Type: 
$k.Type

updateMapping()

Update the prototype after sending $k.mapInstances(). Only required if this element was referenced before setting the mapping.