Working with the repository
Working with the Repository
The LionWebClient Kotlin class provides a convenient high-level interface for interacting with a LionWeb-compliant repository. It allows you to programmatically create, retrieve, store, and manipulate LionWeb nodes using familiar object-oriented patterns.
It is essentially a wrapper around the same class defined in LionWeb Java. However it offers additional methods and an API that is slightly more convenient for Kotlin developers.
Note: Since 1.4.2, the underlying Java class is
LionWebBulkClient(formerlyLionWebClient). The Kotlin wrapper API is unchanged, but if you import the Java class directly, update your imports accordingly.
Repository Setup
-
Create a repository:
client.createRepository("myRepo", LionWebVersion.v2024_1) -
Delete a repository:
client.deleteRepository("myRepo") -
List all repositories:
val repos = client.listRepositories()
Partition Management
-
Create a partition (a root node with no parent):
client.createPartition(myRootNode) -
Delete a partition:
client.deletePartition("partition-id") -
List all partition IDs:
val ids = client.getPartitionIDs()
Node Retrieval
-
Retrieve a node and its entire subtree:
val node = client.retrieve("node-id") -
Retrieve multiple nodes up to a given depth:
val nodes = client.retrieve(listOf("id1", "id2"), limit = 3) -
Check if a node exists:
val exists = client.isNodeExisting("node-id") -
Get the parent ID of a node:
val parentId = client.getParentId("node-id")
Storing Data
-
Store a node and its subtree:
client.storeTree(myNode) -
Store multiple nodes:
client.storeTrees(listOf(node1, node2))
Modifying the Model
These APIs permit individual changes to nodes in the LionWeb Repository. As of 1.4.1, a proper
DeltaClient is available for fine-grained real-time control. For direct delta usage, see the
Delta Protocol Guide.
-
Append a node to a containment:
client.appendTree(child, containerId, "containmentName", containmentIndex) -
Add an annotation:
client.appendAnnotation(annotationInstance, targetId) -
Clear a containment:
client.clearContainment(containerId, "containmentName") -
Set a property value:
client.setProperty(node, "propertyName", "newValue") -
Manage references:
client.setSingleReference(target, container, MyNode::someRef)
client.addReference(target, container, MyNode::someRef)
Advanced Operations
-
Retrieve a tree of nodes starting from a node:
val tree = client.nodeTree("root-id") -
Perform a bulk import:
client.bulkImport(myBulkImport, TransferFormat.FLATBUFFERS) -
Inspect node usage by classifier:
val classifierMap = client.nodesByClassifier() -
List children in a containment:
val childIds = client.childrenInContainment(containerId, "containmentName")
Notes
- Retrieval modes allow control over performance vs completeness:
SINGLE_NODEfetches only the node.ENTIRE_SUBTREEfetches the full structure beneath a node.
- Proxy nodes are placeholders and should be resolved before use.
- The client ensures repository consistency but does not handle concurrent updates atomically.