The K-Infinity namespace
Classes
- AbstractEditorConfiguration
- AbstractTextDocument
- ActionResponse
- AlternativeGroupCondition
- Attribute
- AttributeType
- AttributeValueCondition
- Blob
- Cause
- Choice
- ChoiceRange
- Color
- Cookie
- Date
- DateTime
- Domain
- ElementsCondition
- FlexDateTime
- Folder
- FolderElement
- GeoPosition
- GeoRange
- GraphConfiguration
- HasAttributeCondition
- HasPropertyCondition
- HasRelationCondition
- Hit
- HttpConnection
- HttpRequest
- HttpResponse
- Instance
- InstanceType
- Interaction
- Interval
- IntervalRange
- JSONRenderContext
- KScriptDocument
- LinkedQueryCondition
- MailMessage
- Mapping
- Mustache
- Mustache
- NetEntity
- NewCookie
- NullDocument
- OAuth
- Operator
- PersistentCollection
- Property
- PropertyFilter
- PropertySourceCondition
- PropertyType
- Query
- QueryParameter
- QueryReference
- Relation
- RelationTargetCondition
- RelationType
- RestInteraction
- ScriptJob
- SemanticCollection
- SemanticElement
- StructuredQuery
- TableConfiguration
- TextDocument
- Time
- Type
- User
- ValueRange
- ValueString
- ViewConfiguration
- XMLWriter
Namespaces
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]
-
static$k.out$k.AbstractTextDocument
-
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.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 }, optional can additionally set the user, e.g. $k.checkAccessRight("read", { "user" : |
Throws:
Type | Description |
---|---|
$k.exception.TypeError | Unknown operation type |
$k.exception.TypeError | Context is missing |
Returns:
Type | Description |
---|---|
Boolean | The decision |
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
Name | Type | Description |
---|---|---|
f |
function |
Function that should be evaluated in a system context |
- Since:
- 4.1.0
Throws:
Type | Description |
---|---|
$k.exception.RuntimeError | 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 functionstatic$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 |
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.getClientContext(key)
Returns an object from the client context. The client context can be used to cache / transfer values across scripts.
Use getTransactionContext(key)
if possible.
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 keystatic$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 keystatic$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 functionstatic$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 functionstatic$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.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 ID 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 valuestatic$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 functionstatic$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:
-
- $k#.transaction
Throws:
Type | Description |
---|---|
$k.exception.TransactionError | If a read-only transaction is already active |
Returns:
The return value of the functionstatic$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 functionstatic$k.rootType() : $k.Type
Returns the root type of the semantic network
Returns:
Type | Description |
---|---|
$k.Type |
static$k.setClientContext(key, value)
Sets an object of the client context. The client context can be used to cache / transfer values across scripts.
Use setTransactionContext(key, value)
if possible.
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
Returns:
Type | Description |
---|---|
$k.Type |
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
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 suppliedExample
$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
Returns:
Type | Description |
---|---|
$k.Type |
static$k.topRelationType() : $k.Type
Returns the parent type of all relation types
Returns:
Type | Description |
---|---|
$k.Type |
static$k.topTypes() : Array.<$k.Type>
Returns all top types except the top attribute and relation types
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:
-
- $k#.optimisticTransaction
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)
andsetTransactionContext(key, value)
- Use
Throws:
Type | Description |
---|---|
$k.exception.TransactionError | If no transaction is active |
Returns:
The context objectstatic$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 semantic network
Returns:
Type | Description |
---|---|
string |