Class $k.SemanticElement
Represents an element of the semantic network.
- Defined in: SemanticElement.js Extended by: $k.Property, $k.Type, $k.Instance
Constructor Attributes | Constructor Name and Description |
---|---|
Method Summary
Class Detail
$k.SemanticElement()
Method Detail
-
Returns the attribute of the type (including sub-attributes), or undefined if no attribute exists
- Parameters:
- type
- AttributeType or internal name
- Throws:
- {$k.exception.NotUnique}
- If there is more than one attribute of this type
- Returns:
- {$k.Attribute}
-
Returns all attributes of the type (including sub-attributes). Returns all attributes if the type is undefined
- Parameters:
- type
- AttributeType or internal name or undefined
- Throws:
- {$k.exception.SchemaError}
- If type is not an attribute
- Returns:
- {$k.Attribute[]}
-
attributeValue(type, language)Returns the value of the attribute, or undefined if there is no such attribute
- Parameters:
- type
- AttributeType or internal name
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.NotUnique}
- If there is more than one attribute of this type
- Returns:
- The value of the attribute
-
callBehaviour(method, args)Calls an internal behavior method
- Parameters:
- {string} method
- Name of the method
- {object[]} args Optional
- Arguments of the call
- Throws:
- {$k.exception.RuntimeError}
- When the behavior method raises an exception
-
Returns the extended element, if this is an extension. Returns the element itself otherwise
- Returns:
- {$k.SemanticElement}
-
Creates a new attribute with the given value
person.createAttribute("alias", "Tester");
- Parameters:
- type
- AttributeType or internal name
- value
- Value of the attribute. Pass undefined for attribute types without value.
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidValue}
- If the value is not in the range of allowed values of the attribute
- {$k.exception.SchemaError}
- If type is not a possible attribute of the element, or if no additional attributes can be created.
- {$k.exception.NotUnique}
- If there is more than one attribute of this type
- {$k.exception.AccessDenied}
- If creating an attribute is not allowed
- {$k.exception.TransactionError}
- If no write transaction is active
- Returns:
- {$k.Attribute}
-
Creates a new attribute and set the value from the string representation
- Deprecated:
-
Use
setAttributeValue($k.ValueString(valueString), language)
instead
person.createAttributeFromString("dateOfBirth", "2.3.1968", "de");
- Parameters:
- type
- AttributeType or internal name
- {string} valueString
- String represantation of the value
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidValue}
- If the value is not in the range of allowed values of the attribute
- {$k.exception.SchemaError}
- If type is not a possible attribute of the element, or if no additional attributes can be created.
- {$k.exception.NotUnique}
- If there is more than one attribute of this type
- {$k.exception.AccessDenied}
- If creating an attribute is not allowed
- {$k.exception.TransactionError}
- If no write transaction is active
- Returns:
- {$k.Attribute}
-
Creates a new relation
- Parameters:
- type
- RelationType or internal name
- {$k.SemanticElement} target
- 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:
- {$k.exception.SchemaError}
- If type is not a possible relation of the element, or if no additional relations can be created.
- {$k.exception.AccessDenied}
- If creating a relation is not allowed
- {$k.exception.TransactionError}
- If no write transaction is active
- Returns:
- {$k.Relation}
-
{boolean} hasPossibleAttribute(type)Returns true if the type is a possible attribute of this element
- Parameters:
- type
- AttributeType or internal name
- Returns:
- {boolean}
-
{boolean} hasPossibleRelation(type)Returns true if the type is a possible relation of this element
- Parameters:
- type
- RelationType or internal name
- Returns:
- {boolean}
-
{number} idNumber()Returns the element ID as 64 bit integer. Returns undefined for non-persistent topics (system relations etc.)
- Returns:
- {number}
-
{string} idString()Returns the element ID as string, e.g. 'ID123_456'. Returns undefined for non-persistent topics (system relations etc.)
- Returns:
- {string}
-
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:
- type
- AttributeType or internal name
- Throws:
- {$k.exception.NotUnique}
- If there is more than one value of this type
- Returns:
- {$k.Attribute} The inherited attribute, or undefined if there is no attribute
-
inheritedAttributeValue(type, language)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:
- type
- AttributeType or internal name
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.NotUnique}
- If there is more than one value of this type
- Returns:
- The inherited value, or undefined if there is no attribute
-
{number} modificationNumber()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:
- {number}
-
{string} name(language)Returns the name of the element
- Parameters:
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Returns:
- {string}
-
Returns the possible properties of this element.
// 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 });
- Parameters:
- {$k.PropertyFilter} filter Optional
- Optional filter that defines which properties are returned
- Returns:
- {$k.PropertyType[]}
- See:
- $k.PropertyFilter
-
Returns all properties of the property type
// All properties properties();
// All relations with internal name "contains", including sub-relations properties($k.PropertyFilter.setType("contains"));
// All relations with internal name "contains", without sub-relations properties($k.PropertyFilter.setExact().setType("contains"));
// Same as above, using a literal object to define the filter properties({ exact: true, type: "contains" });
- Parameters:
- {$k.PropertyFilter} filter Optional
- Filter that defines which properties are returned
- Returns:
- {$k.Property[]}
-
Returns the relation of the type (including sub-relations), or undefined if no relation exists
- Parameters:
- type
- RelationType or internal name
- Throws:
- {$k.exception.SchemaError}
- If type is not a possible relation of the topic
- {$k.exception.TypeError}
- If type is not a relation type
- {$k.exception.NotUnique}
- If there is more than one relation of this type
- Returns:
- {$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:
- type
- RelationType or internal name or undefined
- Throws:
- {$k.exception.TypeError}
- If type is not a relation type
- Returns:
- {$k.Relation[]}
-
Returns the target of the relation of the relation type, or undefined if there is no such relation
- Parameters:
- type
- RelationType or internal name
- Throws:
- {$k.exception.NotUnique}
- If there is more than one relation of this type
- {$k.exception.TypeError}
- If type is not a relation type
- Returns:
- {$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:
- type
- RelationType or internal name or undefined
- Throws:
- {$k.exception.NotUnique}
- If there is more than one relation of this type
- {$k.exception.TypeError}
- If type is not a relation type
- Returns:
- {$k.SemanticElement[]}
-
remove()Deletes the element and all attached properties
- Throws:
- {$k.exception.AccessDenied}
- If deleting the element or any property not allowed
- {$k.exception.RemoveNotPossible}
- If deleting the element is not possible, e.g. when trying to delete a system element
-
{object} render(context, keyFilter)Renders the element as a literal object using the associated view configuration. Uses the optional context topic to detect a suitable configuration
- Parameters:
- {$k.SemanticElement} context Optional
- Element that defines the context.
- {object} keyFilter Optional
- A filter that defines which property names that are included.
{"exclude": ["key1", ...]}
includes all but the listed properties, while{"include": ["key1", ...]}
or["key1", ...]
includes only the listed properties.
Non-optional properties are always included
- Returns:
- {object} The rendered object
-
{object} renderJSON(context, excludedKeys)Render the element as a JavaScript object using the associated view configuration. Uses the optional context topic to detect a suitable configuration
- Deprecated:
-
Use
render(context, {"exclude": excludedKeys})
instead
- Parameters:
- {$k.SemanticElement} context Optional
- Element that defines the context.
- {string[]} excludedKeys Optional
- Collection of property names that are excluded
- Returns:
- {object} The rendered JSON object
-
selfDestruct()für Test für Bug 2638
-
setAttributeFromString(type, valueString, language)Sets the value of the attribute from the string representation. Creates a new attribute if no such attribute exists
- Deprecated:
-
Use
setAttributeValue($k.ValueString(valueString), language)
instead
- Parameters:
- type
- AttributeType or internal name
- {string} valueString
- String represantation of the value
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidValue}
- If the value is not in the range of allowed values of the attribute
- {$k.exception.SchemaError}
- If type is not a possible attribute of the element
- {$k.exception.NotUnique}
- If there is more than one attribute of this type
- {$k.exception.AccessDenied}
- If modifying is not allowed
- {$k.exception.TransactionError}
- If no write transaction is active
-
setAttributeValue(type, value, language)Sets the value of the attribute. Creates a new attribute if no such attribute exists
- Parameters:
- type
- AttributeType or internal name
- value
- The value that should be set.
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.InvalidValue}
- If the value is not in the range of allowed values of the attribute
- {$k.exception.SchemaError}
- If type is not a possible attribute of the element
- {$k.exception.NotUnique}
- If there is more than one attribute of this type
- {$k.exception.AccessDenied}
- If modifying is not allowed
- {$k.exception.TransactionError}
- If no write transaction is active
-
setName(name, language)Sets the name of the element
- Parameters:
- {string} name
- The name
- {string} language Optional
- Language of the value. If not defined, the current language will be used. Ignored if the attribute is not translated
- Throws:
- {$k.exception.TypeError}
- If the name is not a string
- {$k.exception.TransactionError}
- If no write transaction is active
-
Returns the type of the element. If the topic is a type, the type itself is returned
- Returns:
- {$k.Type}