Namespace: $k

$k

The i-views namespace

Classes

AbstractEditorConfiguration
AbstractTextDocument
Action
ActionResponse
ActionResult
ActionView
AlternativeGroupCondition
ApplicationConfiguration
Attribute
AttributeType
AttributeValueCondition
Blob
Cause
Choice
ChoiceRange
CollectionView
Color
Cookie
Copier
Crypto
Date
DateTime
Decision
Domain
ElementsCondition
EncryptedAccount
ExternalCommandJob
FlexDateTime
Folder
FolderElement
FormBooleanView
FormInputFieldView
FormSelectView
GeoPosition
GeoRange
GraphConfiguration
HasAttributeCondition
Hash
HasPropertyCondition
HasRelationCondition
HistoryChangeLogEntry
Hit
HttpConnection
HttpRequest
HttpResponse
InfluxClient
Instance
InstanceType
Interval
IntervalRange
Job
JSONRenderContext
JWT
KScript
KScriptDocument
LinkedQueryCondition
MailMessage
Mapping
Measurement
MQTTClient
Mustache
Mustache
NetEntity
NewCookie
NodeCategoryElements
NullDocument
OAuth
Operator
PanelConfiguration
PanelView
PersistentCollection
Property
PropertyFilter
PropertySourceCondition
PropertyType
PropertyView
QuantityKind
Query
QueryParameter
QueryParameterValue
QueryReference
QueryResult
RDFExporter
RDFImporter
Relation
RelationTargetCondition
RelationTargets
RelationType
ScriptJob
SemanticCollection
SemanticElement
SemanticElementCollection
Session
SharePointAppClient
SharePointClient
StructuredQuery
TableConfiguration
Tag
TaggingConfiguration
TaggingContext
TagTypeConfiguration
TextDocument
Time
Type
Unit
User
ValueRange
ValueString
VCMOptions
View
ViewConfiguration
XMLWriter
Zip
ZipContainer
ZipDirectory
ZipReader

Namespaces

exception
History
Registry

Members

static$k.LOG_DEBUG

Log level [DEBUG]

static$k.LOG_ERROR

Log level [ERROR]

static$k.LOG_NORMAL

Normal log level

static$k.LOG_WARNING

Log level [WARNING]

Returns the document that represents the output stream of some script environments.
The kind of object depends on the environment, but is usually an instance of $k.TextDocument.

See:
Example

$k.out.print("Name: ", this.name());

Methods

static$k.abortTransaction()

Aborts the current transaction. All changes will be rolled back. Has no effect if not transaction is active.
No error is thrown.


If the transaction function was called with a reject function,
then this function is called before rolling back the transaction.

Since:
  • 5.1.1

static$k.checkAccessRight(context) : Boolean

Check access right

Name Type Description
context object

List of possible operation types: createAttribute { attributeType, element }, createCompleteRelation { relationType, sourceElement, targetElement }, createConcept { superType }, createInstance { type }, createRelation { relationType, sourceElement, targetElement }, delete { element }, deleteAttribute { attribute, element }, deleteConcept { element }, deleteExtension { element, object }, deleteInstance { element }, deleteRelation { relation, element }, modify { element }, modifyAttributeValue { attribute, element }, modifySchema { element }, read { element }, readAttribute { attribute, element }, readConcept { type }, readExtension { element }, readInstance { object }, readObjectsOfType { type }, validateAttributeValue { attributeValue, language, attribute, element }, optional can additionally set the user, e.g. $k.checkAccessRight("read", { "user" : , "element" : })

Deprecated
  • Use $k.AccessRights.checkOperation()
    Throws:
    Type Description
    $k.exception.TypeError

    Unknown operation type

    $k.exception.TypeError

    Context is missing

    Returns:
    Type Description
    Boolean The decision as boolean

    static$k.define(id, dependencies, factory)

    Defines a module

    Name Type Description
    id string optional

    Optional module ID

    dependencies Array.<string>

    IDs of required modules

    factory

    Factory that returns the value of the module

    static$k.elevatedDo(f)

    Evaluates the function in an evelated context that does not check any access right. This function is only allowed in scripts that are controlled by administrators, otherwise an error is thrown.

    Elevating the context does not grant administration rights, e.g. new users cannot be created by non-admin users.

    Name Type Description
    f function

    Function that should be evaluated in a system context

    Since:
    • 4.1.0
    Throws:
    Type Description
    $k.exception.AccessDenied

    If an elevated context cannot be activated, e.g. in a script created by a user without administration rights

    Returns:
    The return value of the function

    static$k.filterWithAccessRights(operationType, elements, context, decision) : Array.<$k.SemanticElement>

    Filter semantic elements in array with access rights

    Name Type Description
    operationType string

    List of possible operation types: delete, deleteConcept, deleteInstance, modify, modifySchema, read, readExtension, readInstance

    elements Array.<$k.SemanticElement>
    context object optional
    decision object optional

    Default is true

    Deprecated
    • Use $k.AccessRights.filterElements()
      Throws:
      Type Description
      $k.exception.TypeError

      Unknown operation type

      $k.exception.TypeError

      Only semantic elements in array can be processed

      Returns:
      Type Description
      Array.<$k.SemanticElement> Returns the filtered semantic elements

      static$k.getAccessRightDecision(context) : $k.Decision

      Get access right decision

      Name Type Description
      context object

      List of possible operation types: createAttribute { attributeType, element }, createCompleteRelation { relationType, sourceElement, targetElement }, createConcept { superType }, createInstance { type }, createRelation { relationType, sourceElement, targetElement }, delete { element }, deleteAttribute { attribute, element }, deleteConcept { element }, deleteExtension { element, object }, deleteInstance { element }, deleteRelation { relation, element }, modify { element }, modifyAttributeValue { attribute, element }, modifySchema { element }, read { element }, readAttribute { attribute, element }, readConcept { type }, readExtension { element }, readInstance { object }, readObjectsOfType { type }, validateAttributeValue { attributeValue, language, attribute, element }, optional can additionally set the user, e.g. $k.checkAccessRight("read", { "user" : , "element" : })

      Since:
      • 5.3.2
      Deprecated
      • Use $k.AccessRights.getDecision()
        Throws:
        Type Description
        $k.exception.TypeError

        Unknown operation type

        $k.exception.TypeError

        Context is missing

        Returns:
        Type Description
        $k.Decision The decision

        static$k.getClientContext(key)

        Returns an object from the application client context. The application client context can be used to cache / transfer values across scripts.
        Use getTransactionContext(key) if possible.
        WARNING: do not use this function in REST scripts, "application client" refers to the entire bridge, thus the client context is shared by all users.
        The client context is resetted if

        • the client reconnects
        • client caches are flushed
        Name Type Description
        key string

        Key of the object

        Since:
        • 4.1.1
        Returns:
        The object with the given key

        static$k.getEnvironment(key) : string

        Returns a value from the environment. The environment must be configured in the configuration file:

        [scriptEnvironment]
        host=$(env:COMPUTERNAME)
        Name Type Description
        key string

        Key of the value

        Since:
        • 5.4.0
        Returns:
        Type Description
        string The environment value, or undefined if the key has not been configured.

        static$k.getTransactionContext(key)

        Returns an object from the transaction context. The client context can be used to cache / transfer values across scripts within the transaction.

        Name Type Description
        key string

        Key of the object

        Since:
        • 4.1.1
        Throws:
        Type Description
        $k.exception.TransactionError

        If no transaction is active

        Returns:
        The object with the given key

        static$k.isDebugEnabled() : boolean

        Returns true if running in a debugger

        Version:
        • Experimental feature, might be removed at any time
        Since:
        • 5.1.1
        Returns:
        Type Description
        boolean

        static$k.kscript(scriptName)

        Return a wrappper for the specified KScript

        Name Type Description
        scriptName string

        The registered name of the KScript

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

        If the script was not found or is not a KScript

        static$k.language() : string

        Returns the current language (ISO 639 2b)

        Since:
        • 4.1.1
        Returns:
        Type Description
        string Current language, eg. "eng"

        static$k.languageDo(language, f)

        Evaluates the function with the given language as current language

        Name Type Description
        language string

        Language to activate. Either ISO 639-1 (2-letter code, e.g. "en") or ISO 639-2B (3-letter code, e.g. "eng")

        f function

        Function that should be evaluated

        Since:
        • 4.1.1
        Throws:
        Type Description
        $k.exception.InvalidLanguage

        If an invalid language was specified

        Returns:
        The return value of the function

        static$k.locale() : string

        Returns the current locale

        Since:
        • 4.1.1
        Returns:
        Type Description
        string Current locale, eg. "en_US"

        static$k.localeDo(locale, f)

        Evaluates the function with the given locale as current locale

        Name Type Description
        locale string

        Locale, e.g. "en_GB"

        f function

        Function that should be evaluated

        Since:
        • 4.1.1
        Throws:
        Type Description
        $k.exception.InvalidLanguage

        If an invalid locale was specified

        Returns:
        The return value of the function

        static$k.log(object, level, channel)

        Log an object on the current log stream (if available)

        Name Type Description
        object

        Object to log. Will be converted with toString().

        level optional

        Log level. Either a number or a string ("debug", "normal", "warning", "error").

        channel string optional

        Optional log channel.

        Examples

        $k.log("New instance created");

        $k.log("The cake is a lie", $k.LOG_WARNING, "Portal");

        static$k.logData(data, message, level, channel)

        Log an object and additional structured data on the current log stream (if available)

        Name Type Description
        data object

        Data to log

        message optional

        Additional message. Will be converted with toString().

        level optional

        Log level. Either a number or a string ("debug", "normal", "warning", "error").

        channel string optional

        Optional log channel.

        Examples

        $k.logData({"size":42}, "New instance created");

        $k.logData({"companionCube":"dead"}, "The cake is a lie", $k.LOG_WARNING, "Portal");

        static$k.mapInstances(internalName, proto)

        Map the prototype of instances of the type with the internal name to the prototype object

        Name Type Description
        internalName string

        Internal name of the type of instances to map

        proto

        Prototype object

        Example

        function Person() { }
        Person.prototype.fullName = function() {
        return this.attributeValue("familyName").toUpperCase()
        + ", " + this.attributeValue("firstName");
        };
        $k.mapInstances("person", Person);
        var persons = $k.Registry.type("person").instances();
        for (var p in persons)
        $k.out.print(persons[p].fullName() + "\n");

        static$k.mapModule(moduleName, registryID)

        Maps a module ID to the ID of a registered script.
        Allows to register scripts containing modules under a different ID

        Name Type Description
        moduleName string

        The ID of the module

        registryID string

        The ID of the registered script

        static$k.mapTypes(internalName, proto)

        Map the prototype of types with the internal name to the prototype object

        Name Type Description
        internalName string

        Internal name of the type to map

        proto

        Prototype object

        static$k.module(moduleName, isLocal)

        Loads a module

        Name Type Description
        moduleName string

        The registered name of the module

        isLocal boolean optional

        (Since 4.0.2) True if the module script should be evaluated in a local environment, false if it should be evaluated in the environment of the caller. Default is false"

        Throws:
        Type Description
        $k.exception.ModuleError

        If the module was not found or defined more than once

        Returns:
        The model value

        static$k.noTriggersDo(f)

        Evaluates the function without performing any triggers

        Name Type Description
        f function

        Function that should be evaluated

        Since:
        • 4.1.0
        Returns:
        The return value of the function

        static$k.optimisticTransaction(f)

        Evaluates the function in a transaction and returns its return value.
        Does not check if the transaction has been accepted or rejected.
        Allows to start a transaction within another transaction, the nested transaction will be a part of the outer transaction

        Name Type Description
        f function

        Function that should be evaluated in a transaction

        See:
        Throws:
        Type Description
        $k.exception.TransactionError

        If a read-only transaction is already active

        Returns:
        The return value of the function

        static$k.require(dependencies, callback)

        Calls a function with required modules. Passes the value of each required module

        Name Type Description
        dependencies Array.<string>

        IDs of required modules

        callback function

        Callback function

        Throws:
        Type Description
        $k.exception.ModuleError

        If a required module was not found or defined more than once

        Returns:
        The return value of the callback function

        static$k.rootType() : $k.Type

        Returns the root type of the Knowledge Graph

        Deprecated
        • Use $k.Type.rootType()
          Returns:
          Type Description
          $k.Type

          static$k.setClientContext(key, value)

          Sets an object of the application client context. The application client context can be used to cache / transfer values across scripts.
          Use setTransactionContext(key, value) if possible.
          WARNING: do not use this function in REST scripts, "application client" refers to the entire bridge, thus the client context is shared by all users.
          The client context is resetted if

          • the client reconnects
          • client caches are flushed
          Name Type Description
          key string

          Key of the object

          value object

          The object to store

          Since:
          • 4.1.1

          static$k.setTransactionContext(key, value)

          Sets an object of the transaction context. The client context can be used to cache / transfer values across scripts within the transaction.

          Name Type Description
          key string

          Key of the object

          value object

          The object to store

          Since:
          • 4.1.1

          static$k.shortcutRelationType() : $k.Type

          Returns the parent type of all shortcut relation types

          Deprecated
          • Use $k.Type.shortcutRelationType()
            Returns:
            Type Description
            $k.Type

            static$k.sleep(delayMillis)

            Suspends the current thread for a given number of milliseconds. Note: This blocks the whole execution of the current client.

            Name Type Description
            delayMillis number

            The number of milliseconds to wait for. The function does not sleep if +-Infinity or NaN is set.

            Since:
            • 4.3.0

            static$k.softwareVersion() : object

            Returns the core software version

            Since:
            • 4.4.0
            Returns:
            Type Description
            object An object containing information about the core software version{major: 4, minor: 4, patch: 0, state: "Release"}

            static$k.symmetricRelationProperties() : boolean

            Returns true if symmetric relation properties are enabled

            Returns:
            Type Description
            boolean

            static$k.systemRelationType() : $k.Type

            Returns the parent type of all system relation types

            Deprecated
            • Use $k.Type.systemRelationType()
              Returns:
              Type Description
              $k.Type

              static$k.timeLimitedDo(timeout, f, timeoutFunction)

              Evaluates the function, but stops execution after the specified time and evaluates the (optional) timeout function.

              If the evaluated function has started a transaction, then this transaction will be rolled back. Outer transaction will not be rolled back. To avoid incomplete write operations, an exception is raised if a write transaction is active when calling this function.

              Name Type Description
              timeout number

              Timeout in milliseconds

              f function

              Function that should be evaluated

              timeoutFunction function optional

              Function that is evaluated when a timeout occurs.

              Since:
              • 4.2.0
              Throws:
              Type Description
              $k.exception.TransactionError

              If a write transaction is active

              Returns:
              The return value of the function, or the value of the timeout function when a timeout occurs, or undefined if no timout function is supplied
              Example

              $k.timeLimitedDo(1000,
              function() { return $k.Registry.query("longRunningQuery").findElements() },
              function() { throw "Query did not finish" }
              )

              static$k.topAttributeType() : $k.Type

              Returns the parent type of all attribute types

              Deprecated
              • Use $k.Type.topAttributeType()
                Returns:
                Type Description
                $k.Type

                static$k.topRelationType() : $k.Type

                Returns the parent type of all relation types

                Deprecated
                • Use $k.Type.topRelationType()
                  Returns:
                  Type Description
                  $k.Type

                  static$k.topTypes() : Array.<$k.Type>

                  Returns all top types except the top attribute and relation types

                  Deprecated
                  • Use $k.Type.topTypes()
                    Returns:
                    Type Description
                    Array.<$k.Type>

                    static$k.transaction(f, rejectFunction)

                    Evaluates the function in a transaction and returns its return value if the transaction has been accepted.
                    If the transaction is rejected due to concurrency conflicts, the optional reject function is performed.
                    This function does not allow to start a transaction within an outer transaction, use optimisticTransaction() instead.

                    Name Type Description
                    f function

                    Function that should be evaluated in a transaction

                    rejectFunction function optional

                    Optional function that is evaluated if the transaction is rejected.

                    See:
                    Throws:
                    Type Description
                    $k.exception.TransactionError

                    If another transaction is already active

                    Returns:
                    The return value of the function. If the transaction is rejected, the return value of the reject function (if defined) or undefined is returned.

                    static$k.transactionContext()

                    Returns an object that is bound to the active transaction. It can be used to cache / transfer values across scripts within the transaction.
                    Creates a new object if none has been set yet

                    Deprecated
                    • Use getTransactionContext(key) and setTransactionContext(key, value)
                      Throws:
                      Type Description
                      $k.exception.TransactionError

                      If no transaction is active

                      Returns:
                      The context object

                      static$k.translatedMessage(message, messageParameters)

                      Returns a translated string for the message. Fills in the message parameters if present. Returns undefined if the message is unknown.

                      Name Type Description
                      message string

                      The internal message identifier.

                      messageParameters Array optional

                      Optional message parameters in case of a fill-in-the-blanks message.

                      Since:
                      • 5.4.0
                      Examples

                      $k.translatedMessage("wouldYouLikeToSaveTheFileMLS");

                      $k.translatedMessage("delete3MLS",[victim.name()]);

                      static$k.user() : $k.User

                      Returns the current user

                      Returns:
                      Type Description
                      $k.User

                      static$k.userDo(user, f)

                      Runs the function in an context bound to the user.
                      This function is only allowed in scripts that are controlled by administrators, otherwise an error is thrown.


                      Access rights checking is enabled in the function, call $k.elevatedDo() to disable checks

                      Name Type Description
                      user $k.User

                      User or user instance

                      f function

                      Function that should be evaluated in the user context

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

                      If a user context cannot be activated, e.g. in a script created by a user without administration rights

                      Returns:
                      The return value of the function

                      static$k.userRelationType() : $k.Type

                      Returns the parent type of user-defined relation type

                      Returns:
                      Type Description
                      $k.Type

                      static$k.uuid() : string

                      Generates a UUID

                      Returns:
                      Type Description
                      string

                      static$k.volume() : string

                      Returns the name of the Knowledge Graph

                      Returns:
                      Type Description
                      string