new GraphPatch( [id])
Simple constructor
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
id |
string |
<optional> |
- Implements:
Methods
-
<static> fromJSON(json)
-
Deserializes a
GraphPatch
from a JSON object or string.Parameters:
Name Type Description json
string | Object Returns:
-
applyOperationsTo(writable)
-
Updates the specified object (writable) with the operation accumulated in this patch.
Parameters:
Name Type Description writable
olympe.dc.Writable the writable on which apply the operations contained in this patch.
- Implements:
Returns:
By convention, the writable given as parameter is returned to ease chaining.
- Type
- olympe.dc.Writable
-
clearInstance(tag [, followRule])
-
Remove all operations contained in this patch related to the specified instance.
Parameters:
Name Type Argument Default Description tag
string The instance to clear
followRule
olympe.dc.FollowRules <optional>
olympe.dc.FollowRules.NONE Returns:
whether the clear had an impact on the patch or not
- Type
- boolean
-
clearRelation(relation, origin, destination)
-
Remove any operation related to the specified relation.
Parameters:
Name Type Description relation
string the relation tag
origin
string the tag of the origin
destination
string the tag of the destination
Returns:
Whether the clear had an impact on the patch
- Type
- boolean
-
clone()
-
Create a clone of this graph patch and all its instances patches
Returns:
the newly cloned patch
-
createInstance(tag [, properties] [, id])
-
Creates an instance and returns it's tag
Parameters:
Name Type Argument Description tag
string New instance tag
properties
Map.<string, ?*> <optional>
Instance's properties (map of properties names to values)
id
number <optional>
operationId
- Implements:
-
createRelation(relationTag, originTag, destinationTag [, id])
-
Creates a relation between two instances.
Parameters:
Name Type Argument Description relationTag
string Tag of the relation
originTag
string Origin instance tag
destinationTag
string Destination instance tag
id
number <optional>
operationId
- Implements:
-
deleteInstance(tag [, followRule] [, id])
-
Deletes the specified instance. If specified, apply the follow rules to make a clean delete.
Parameters:
Name Type Argument Description tag
string followRule
olympe.dc.FollowRules <optional>
id
number <optional>
operationId
- Implements:
-
deleteRelation(relationTag, originTag, destinationTag [, id])
-
Removes a relation between two instances
Parameters:
Name Type Argument Description relationTag
string Tag of the relation
originTag
string Origin instance tag
destinationTag
string Destination instance tag
id
number <optional>
operationId
- Implements:
-
getAllInstances()
-
Return a map with all the instance patches of this graph patch.
Returns:
- Type
- Map.<string, !olympe.dc.db.InstancePatch>
-
getId()
-
Return the patch id
- Implements:
Returns:
- Type
- string
-
getInstance(tag)
-
Return the instance patch associated to this tag, if exist in this graph patch.
Parameters:
Name Type Description tag
olympe.dc.InstanceTag Returns:
-
getInstanceRelations(origin)
-
Returns an iterator over all new relations going out of the specified instance created by this commit. A relation is represented by an array of 2 strings and a boolean in the following format: [relation tag, destination tag, added]
Parameters:
Name Type Description origin
olympe.dc.InstanceTag origin instance of relations
Returns:
the iterator
- Type
- Generator.<!Array.<(string|boolean)>>
-
getInstances()
-
Return an iterable over all instances that are edited in this patch. It excludes instances that get relation updates only.
Returns:
- Type
- Generator.<!olympe.dc.db.InstancePatch>
-
getRecursiveRelated(tag, relation, formatter)
-
Returns an iterator over all instances recursively related to a specific instance through a specific relation. The order in which the instances are yielded may be random on non linear graphs (e.g. a graph containing cycles or multiple arms).
Parameters:
Name Type Description tag
olympe.dc.InstanceTag relation
olympe.dc.registry.Relation formatter
function Returns:
- Type
- Generator.<T>
-
getRelations()
-
Returns an iterator over all new relations created by this graph patch. A relation is represented by an array of 3 strings and a boolean value in the following format: [relation tag, origin tag, destination tag, added]
Returns:
the iterator
- Type
- Generator.<!Array.<(string|boolean)>>
-
getSize()
-
Return the number of primitive operation this patch is made from
- Implements:
Returns:
- Type
- number
-
toJSON()
-
Serializes a
GraphPatch
into a JSON string.Returns:
- Type
- string
-
updateInstance(tag [, properties] [, forceUpdate] [, id])
-
Updates an instance.
- If the instance does not exist, it will be automatically created
- Depending on the implementation, updates will be rejected if the provided "new" version is lower than the stored one
Parameters:
Name Type Argument Default Description tag
string Instance tag
properties
Map.<string, ?*> <optional>
Instance properties
forceUpdate
boolean <optional>
false If true, do not do any version check and accepts any update (used by rollbacks)
id
number <optional>
operationId
- Implements: