new GraphPatch( [id])
Simple constructor
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
id |
string |
<optional> |
- Implements:
Methods
-
<static> fromJSON(json)
-
Deserializes a
GraphPatchfrom a JSON object or string.Parameters:
Name Type Description jsonstring | Object Returns:
-
applyOperationsTo(writable)
-
Updates the specified object (writable) with the operation accumulated in this patch.
Parameters:
Name Type Description writableolympe.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 tagstring The instance to clear
followRuleolympe.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 relationstring the relation tag
originstring the tag of the origin
destinationstring 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 tagstring New instance tag
propertiesMap.<string, ?*> <optional>
Instance's properties (map of properties names to values)
idnumber <optional>
operationId
- Implements:
-
createRelation(relationTag, originTag, destinationTag [, id])
-
Creates a relation between two instances.
Parameters:
Name Type Argument Description relationTagstring Tag of the relation
originTagstring Origin instance tag
destinationTagstring Destination instance tag
idnumber <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 tagstring followRuleolympe.dc.FollowRules <optional>
idnumber <optional>
operationId
- Implements:
-
deleteRelation(relationTag, originTag, destinationTag [, id])
-
Removes a relation between two instances
Parameters:
Name Type Argument Description relationTagstring Tag of the relation
originTagstring Origin instance tag
destinationTagstring Destination instance tag
idnumber <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 tagolympe.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 originolympe.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 tagolympe.dc.InstanceTag relationolympe.dc.registry.Relation formatterfunction 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
GraphPatchinto 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 tagstring Instance tag
propertiesMap.<string, ?*> <optional>
Instance properties
forceUpdateboolean <optional>
false If true, do not do any version check and accepts any update (used by rollbacks)
idnumber <optional>
operationId
- Implements:
Olympe SDK