new DBView(logger, database)
GraphDB constructor
Parameters:
Name | Type | Description |
---|---|---|
logger |
olympe.logging.Channel | |
database |
olympe.dc.db.Database |
Members
-
callbackLogs
-
DEVONLY
-
callbackLogsSnapshot
-
DEVONLY
-
logCallbacks
-
DEVONLY
Methods
-
countRelated(tag, type, direction)
-
Gets the amount of related instances at the time of the method call
Parameters:
Name Type Description tag
olympe.dc.InstanceTag Instance tag
type
string Relation type tag
direction
olympe.dc.Direction Relation direction
Returns:
- Type
- number
-
exist(tag)
-
Determines if the instance currently exists in the local DB.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
if the instance is currently marked as exist in the db.
- Type
- boolean
-
extension(tag)
-
Returns the tag of the parent model of the instance given as parameter, if the instance exists and it it has a model. Returns null instead.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance, represented by any of the option offered by InstanceTag
Returns:
the tag of the extended model
- Type
- string
-
findAllRelated(startTag, relations, predicate)
-
Find all the instances matching the provided predicate when following all the given relations (non recursive).
Parameters:
Name Type Description startTag
olympe.dc.InstanceTag Tag of the starting instance
relations
Array.<!olympe.dc.registry.Relation> The relations to follow
predicate
function Anonymous predicate function
Returns:
- Type
- Array.<string>
-
findRecursive(startTag, relation, predicate)
-
Find the first (random) instance matching a predicate when following recursively a given relation, including the start instance.
Parameters:
Name Type Description startTag
olympe.dc.InstanceTag Tag of the starting instance
relation
olympe.dc.registry.Relation The relation to follow recursively
predicate
function Anonymous predicate function
Returns:
null
if no instance matchespredicate
- Type
- string
-
findRelated(startTag, relations, predicate)
-
Find the first instance matching the provided predicate when following all the given relations (non recursive).
Parameters:
Name Type Description startTag
olympe.dc.InstanceTag Tag of the starting instance
relations
Array.<!olympe.dc.registry.Relation> The relations to follow
predicate
function Anonymous predicate function
Returns:
- Type
- string
-
getAnyRelated(tag)
-
Return an iterable object over all instances related to the specified instance, whatever the relation is. For each relation, an array of 3 strings is returned in that format : [relation tag, direction, related instance tag]
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance tag
Returns:
the iterable result
- Type
- Generator.<!Array.<string>>
-
getDefaultProperties(tag [, ownOnly])
-
Gets all default property values defined on this model instance.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag Instance tag
ownOnly
boolean <optional>
false If true, returns only own properties (ie. not inherited)
Returns:
A map of all the default properties values indexed by property tag
- Type
- Map.<string, *>
-
getDefaultProperty(tag, property [, ownOnly])
-
Get the specified default property value of the specified instance.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag Instance tag
property
olympe.dc.InstanceTag The property
ownOnly
boolean <optional>
false If true, returns only own property (ie. not inherited)
Returns:
- Type
- *
-
getExtendedModels(modelTag [, endTag])
-
Get all the models extended by this model (including self). Optionally define an end tag to get a subset of extended models. Will throw an error if the expected end model is not found.
Parameters:
Name Type Argument Default Description modelTag
olympe.dc.InstanceTag Tag of the starting model instance
endTag
olympe.dc.InstanceTag <optional>
olympe.dc.CloudObject Optional end instance tag after which to stop following the extend relations.
Returns:
- Type
- Array.<string>
-
getFollowRule(relation, rule)
-
Return the follow rule associated to the specified rule, for the specified relations. Return 0 if no rule exist for it or if the instance is not a relation.
Parameters:
Name Type Description relation
olympe.dc.InstanceTag rule
olympe.dc.FollowRules Returns:
- Type
- number
-
getId()
-
Return the identifier of the database
Returns:
- Type
- string
-
getImplicitRelated(tag, followRule)
-
Return an iterable object over all instances related to the specified one via relations with specified follow rules. It includes the initial instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The root instance tag
followRule
olympe.dc.FollowRules The rule to apply to follow relations
Returns:
the iterable result
- Type
- Iterable.<string>
-
getIncomingRelations(tag)
-
Gets currently incoming relations: all relation whose the destination is the specified instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance tag
Returns:
An array of incoming relation tags
- Type
- Array.<string>
-
getInstances(modelTag)
-
Get the current instances of a model.
Parameters:
Name Type Description modelTag
olympe.dc.InstanceTag Tag of the model instance
Returns:
- Type
- Array.<string>
-
getMultiRelated(startTag, relations)
-
Get the currently related instances following all the specified relations (non recursive).
Parameters:
Name Type Description startTag
olympe.dc.InstanceTag the instance to start with
relations
Array.<!olympe.dc.registry.Relation> Relations to follow
Returns:
The resulting array
- Type
- Array.<string>
-
getOutgoingRelations(tag)
-
Gets currently incoming relations: all relation whose the destination is the specified instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance tag
Returns:
An array of incoming relation tags
- Type
- Array.<string>
-
getProperties(tag [, ownOnly])
-
Get a map of all property values of the specified instance.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag The instance tag
ownOnly
boolean <optional>
false if true, the result does not include the inherited default properties.
Returns:
A map with all property values indexed by property tag
- Type
- Map.<string, ?*>
-
getProperty(tag, property [, ownOnly])
-
Get the value of an instance's property, or null if the property is not set.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag The instance
property
olympe.dc.InstanceTag The property to retrieve
ownOnly
boolean <optional>
false if true, the result does not include the inherited default properties.
Returns:
the current value or null
- Type
- *
-
getRecursiveRelated(startInstanceTag, relation [, endInstanceTag])
-
Follow the specified relation recursively and return all the instances found along the path(s) (unordered).
Parameters:
Name Type Argument Description startInstanceTag
olympe.dc.InstanceTag Tag of the starting instance
relation
olympe.dc.registry.Relation The relation to follow recursively
endInstanceTag
olympe.dc.InstanceTag <optional>
Optional end instance tag at which to stop following
relation. If provided, only instances lying on a path somewhere between
startTagand
endTag` will be returnedReturns:
All the instances found by following recursively
relation
(unordered)- Type
- Array.<string>
-
getReferencingObject(tag)
-
If
tag
is a complex property, returns the tag of the instance that references it. Return null if not.Parameters:
Name Type Description tag
olympe.dc.InstanceTag Tag of the complex property
Returns:
- Type
- string
-
getRelated(tag, relation)
-
Gets the currently related instances following a specific relation (non recursive).
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
relation
olympe.dc.registry.Relation The relation to follow
Returns:
The resulting array of tags.
- Type
- Array.<string>
-
getUniqueRelated(tag, relation)
-
Gets the currently unique related instance tag (non recursive).
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
relation
olympe.dc.registry.Relation The relation to follow
Returns:
The tag, or
null
if there is no match or more than one match.- Type
- string
-
instanceOf(tag, modelTag)
-
Assess whether the instance
tag
is instanceof the modelmodelTag
. Note: if A is instance of B, and B extends C, A is an instance of both B and C.Parameters:
Name Type Description tag
olympe.dc.InstanceTag Tag of the starting model instance
modelTag
olympe.dc.InstanceTag Tag of the extended model instance
Returns:
- Type
- boolean
-
isExtending(modelTag, extendedTag)
-
Assess whether the model
modelTag
is extending the modelextendedTag
. Returns true if modelTag is equal to extendedTag.Parameters:
Name Type Description modelTag
olympe.dc.InstanceTag Tag of the starting model instance
extendedTag
olympe.dc.InstanceTag Tag of the extended model instance
Returns:
- Type
- boolean
-
isModel(tag)
-
Return whether the specified instance is a model or not
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
is the instance a model
- Type
- boolean
-
isPersisted(tag)
-
Return whether the specified instance is persisted or in memory volatile. By default, if the specified instance is not in the local database, it considers it's a persisted instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
Persistence state of the instance.
- Type
- boolean
-
isRelated(tag, relation, related)
-
Return true if the specified instance is effectively related to the other instance with this relation.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
relation
olympe.dc.registry.Relation The relation to follow
related
olympe.dc.InstanceTag The related instance to look for
Returns:
Whether the instance is effectively related to the other specified instance.
- Type
- boolean
-
model(tag)
-
Return the tag of the model of the specified instance if there is one
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
the model tag
- Type
- string
-
name(tag)
-
Return the name of the specified instance, or an empty string if not found.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
the name of the instance
- Type
- string
-
offAnyProperty(tag, id)
-
Unregisters an anyProperty callback from the specified instance
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
id
string The id of the callback to unregister
-
offAnyRelation(tag, id [, noEvent])
-
Unregisters a callback on all relations of an instance. For each existing relation at the time of hte method call and unless otherwise specified, a REMOVED event will be immediately fired upon unregistration.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag Instance tag
id
string Callback identifier
noEvent
boolean <optional>
false If true, no REMOVED event will be fired upon unregistration
-
offInstance(tag, id [, noEvent])
-
Unregisters a callback on an instance. Unless otherwise specified, calling this method will immediately trigger a REMOVED event.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag Instance tag
id
string Callback identifier
noEvent
boolean <optional>
false If true, no REMOVED event will be fired upon unregistration
-
offProperty(tag, property, id)
-
Unregisters a property update callback from an instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag Instance tag.
property
olympe.dc.InstanceTag The property tag.
id
string Callback identifier.
-
offRelation(tag, relation, id [, noEvent])
-
Unregisters a callback on an instance relation. For each existing relation at the time of the method call and unless otherwise specified, a REMOVED event will be immediately fired upon unregistration.
Parameters:
Name Type Argument Default Description tag
olympe.dc.InstanceTag Instance tag
relation
olympe.dc.registry.Relation The relation to listen to
id
string Callback identifier
noEvent
boolean <optional>
false If true, no REMOVED event will be fired upon unregistration
-
onAnyProperty(tag, callback [, id])
-
Registers a callback to be invoked any time a property of the specified instance gets a value.
Parameters:
Name Type Argument Description tag
olympe.dc.InstanceTag The instance
callback
olympe.dc.DBView.AnyPropertyCallback the callback to register
id
string <optional>
Returns:
- Type
- string
-
onAnyRelation(tag, callback [, id])
-
Register a callback on an instance which is called every time the instance get a new relation. For each existing relation at the time of the method call, an ADDED event will be immediately fired. If two callbacks are registered with the same identifier, the last registered one will simply overwrite the first one.
Parameters:
Name Type Argument Description tag
olympe.dc.InstanceTag Instance tag
callback
olympe.dc.DBView.RelationCallback Function to run when any relation is created or removed on the specified instance
id
string <optional>
Callback identifier
Returns:
Registered callback identifier
- Type
- string
-
onInstance(tag, callback [, id])
-
Register a callback on an instance. If the instance already exists at the time of the method call, an ADDED event will be immediately fired
Parameters:
Name Type Argument Description tag
olympe.dc.InstanceTag Instance tag
callback
olympe.dc.DBView.InstanceCallback Callback function
id
string <optional>
Callback identifier
Returns:
Registered callback identifier
- Type
- string
-
onProperty(tag, property, callback [, id])
-
Registers a callback to be invoked when the specified property of the specified instance is updated.
Parameters:
Name Type Argument Description tag
olympe.dc.InstanceTag Instance tag.
property
olympe.dc.InstanceTag The property tag.
callback
olympe.dc.DBView.PropertyCallback Callback function.
id
string <optional>
Callback identifier.
Returns:
Registered callback identifier.
- Type
- string
-
onRelation(tag, relation, callback [, id])
-
Register a callback on an instance relation. For each existing relation at the time of the method call, an ADDED event will be immediately fired. Also, if two callbacks are registered with the same identifier, the last registered one will simply overwrite the first one.
Parameters:
Name Type Argument Description tag
olympe.dc.InstanceTag Instance tag
relation
olympe.dc.registry.Relation The relation to listen to
callback
olympe.dc.DBView.InstanceCallback Callback function
id
string <optional>
Callback identifier
Returns:
Registered callback identifier
- Type
- string
-
propertyDefinedOnModel(property, model)
-
Tells if the property given as first parameter is defined on the model given as second parameter. In other words, if an instance of the provided model is allowed to carry a value against the given property. Note that properties of possible super-model(s) of the model are considered as well
Parameters:
Name Type Description property
olympe.dc.InstanceTag model
olympe.dc.InstanceTag Returns:
- Type
- boolean
-
source(tag)
-
Return the source of the specified instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
the version, null if the instance does not exists
- Type
- string
-
version(tag)
-
Return the version of the specified instance.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag The instance
Returns:
the version, null if the instance does not exists
- Type
- number
Type Definitions
-
AnyPropertyCallback(name, value, isDefault)
-
Function to be called when any property changes.
Parameters:
Name Type Description name
string Property name that has received a value
value
* Value of the property after the change.
isDefault
boolean true
if this value is meant to become the default value. -
InstanceCallback(added, tag)
-
Function to be called when an instance is added or removed.
Parameters:
Name Type Description added
boolean true
if this instance was added,false
if it was removed.tag
string Instance tag
-
PropertyCallback(value, isDefault)
-
Function to be called when a property changes.
Parameters:
Name Type Description value
* Value of the property after the change.
isDefault
boolean true
if this value is meant to become the default value. -
RelationCallback(type, direction, added, tag)
-
Function to be called when a relation is added ore removed.
Parameters:
Name Type Description type
string Relation type.
direction
olympe.dc.Direction Relation direction.
added
boolean true
if this relation was added,false
if it was removed.tag
string Instance tag.