Skip to content

Commit 66b7217

Browse files
committed
Add new documentation: storage options, validations, annotations, and nodes comparison; adjust sidebar positions
1 parent 106d7ad commit 66b7217

File tree

5 files changed

+214
-1
lines changed

5 files changed

+214
-1
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Nodes Comparison
3+
sidebar_position: 46
4+
---
5+
6+
# Nodes Comparison
7+
8+
The lionweb-java project provides comprehensive model comparison capabilities through the `io.lionweb.utils.ModelComparator` class.
9+
10+
The `ModelComparator` enables detailed comparison of models, nodes, and classifier instances to identify structural and semantic differences between them.
11+
12+
## Comparison Methods
13+
14+
The `ModelComparator` provides several overloaded `compare()` methods for different types of elements:
15+
16+
- **Node Comparison**: Compare two `Node` objects
17+
- **AnnotationInstance Comparison**: Compare two `AnnotationInstance` objects
18+
- **ClassifierInstance Comparison**: Compare two `ClassifierInstance` objects (polymorphic)
19+
20+
## Static Equivalence Checking
21+
22+
Convenience methods for quick equivalence checks:
23+
24+
- `areEquivalent(ClassifierInstance<?> a, ClassifierInstance<?> b)`: Check if two classifier instances are equivalent
25+
- `areEquivalent(List<A> as, List<B> bs)`: Check if two lists of classifier instances are equivalent
26+
27+
## ComparisonResult
28+
29+
The `ComparisonResult` class encapsulates the outcome of a comparison operation:
30+
31+
### Key Features
32+
33+
- **Difference Tracking**: Maintains a list of all detected differences
34+
- **Equivalence Check**: Provides `areEquivalent()` method that returns `true` when no differences exist
35+
- **Detailed Reporting**: Contains methods to mark specific types of differences
36+
37+
### Types of Differences Detected
38+
39+
1. **ID Differences**: Different node IDs
40+
2. **Concept Differences**: Different concept/classifier assignments
41+
3. **Property Value Differences**: Different values for properties
42+
4. **Containment Differences**: Different numbers or values of child nodes
43+
5. **Reference Differences**: Different reference targets or resolve information
44+
6. **Annotation Differences**: Different numbers or values of annotations
45+
7. **Incompatibility**: When instances cannot be compared (different types)
46+
47+
## Comparison Aspects
48+
49+
The `ModelComparator` performs deep comparison across multiple dimensions:
50+
51+
### 1. **Properties**
52+
Compares all property values defined by the classifier, identifying any discrepancies in property data.
53+
54+
### 2. **References**
55+
Compares reference values including:
56+
- Number of references
57+
- Referenced node IDs
58+
- Resolve information for each reference
59+
60+
### 3. **Containments**
61+
Compares child nodes including:
62+
- Number of children in each containment
63+
- Recursive comparison of child node structures
64+
65+
### 4. **Annotations**
66+
Compares annotations including:
67+
- Number of annotations
68+
- Annotation IDs and structures
69+
70+
### 5. **Structure**
71+
Validates structural consistency including:
72+
- Parent-child relationships
73+
- Concept/classifier assignments
74+
- Node hierarchy
75+
76+
## Use Cases
77+
78+
- **Testing**: Verify that model transformations produce expected results
79+
- **Validation**: Ensure model consistency across operations
80+
- **Debugging**: Identify unexpected changes in models
81+
- **Serialization/Deserialization**: Verify round-trip integrity
82+
- **Version Control**: Compare model versions to detect changes
83+
84+
## Context Information
85+
86+
All differences are reported with contextual information including:
87+
- Location in the model hierarchy
88+
- Node IDs involved
89+
- Specific feature or property names
90+
- Index positions for list elements
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Validation
3+
sidebar_position: 45
4+
---
5+
6+
# Validation
7+
8+
The lionweb-java project includes a comprehensive validation framework located in the `io.lionweb.utils` package. Here's an overview of all validation-related features:
9+
10+
## Introduction
11+
12+
### **ValidationResult**
13+
Represents the outcome of validation operations, containing information about any issues found during validation.
14+
15+
### **Issue**
16+
Represents individual validation problems or concerns detected during the validation process.
17+
18+
Each issue has an _Issue Severity_. The severity levels are error, warning, and info.
19+
20+
## Specific Validators
21+
22+
### **ChunkValidator**
23+
Validates `SerializationChunks` of data, ensuring they meet structural and semantic requirements.
24+
25+
### **NodeTreeValidator**
26+
Validates the structure and integrity of node trees within the model hierarchy.
27+
28+
### **PartitionChunkValidator**
29+
Specialized validator for validating `SerializationChunks` supposed to contain a single partition.
30+
31+
### **LanguageValidator**
32+
Validates language definitions, checking that language structures conform to expected patterns and rules.
33+
34+
## Validation Utilities
35+
36+
Notable mention for **CommonChecks**: it provides a collection of common validation checks that can be reused across different validation scenarios.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Annotations
3+
sidebar_position: 34
4+
---
5+
6+
# Annotations
7+
8+
Annotations provide a generic mechanism for extending languages without modifying them. They are useful for:
9+
10+
- cross-cutting concerns that apply across many languages or many kinds of nodes.
11+
- extending a language we do not own
12+
13+
An annotation definition can be reused with instances of different languages, even if the original language designer never anticipated that extension. This is a key aspect that provides extensibility.
14+
15+
## Generic and Reusable Extensions
16+
A common example for using annotation is adding comments. You can define a comment annotation once and apply it to any node of any language. Tools that understand this annotation can use it; tools that don’t need it are free to ignore it. This enables optional, non-intrusive extensions.
17+
18+
This example shows also how annotations are sort of metadata: they are relevant to some users and can be ignored by others. Let's imagine a node with a comment:
19+
20+
- A process generating documentation for a partition may benefit from the comment.
21+
- At the same time a process executing the partition may ignore the annotation containing the comment, as it is irrelevant for it
22+
23+
Annotations may also be constrained. For instance, you could define a “synonym” annotation that applies only to nodes that provide a name (i.e., implementing the interface `INamed`, part of _LionCore Builtins_). The annotation system supports this level of restriction.
24+
25+
Of course we may also have annotations restricted to specific concepts. Let's imagine we are using a valuable language provided by someone else. We may want to add an extra field to a a certain concept, however we may not control the language and we may not change freely if other tools we use rely on the language being defined in a certain way. We can still add an annotation that, let's say, can be applied to instances of the concept `Car` and could specify a `Color` field. We may then have an editor that is aware of such annotation and can display the node using the color specified in the annotation.
26+
27+
## How Annotations Relate to Nodes
28+
Annotations behave much like ordinary nodes:
29+
- both are classifier instances,
30+
- both carry structured data.
31+
32+
The difference is in their attachment:
33+
- regular nodes participate in containment trees,
34+
- annotations are not children of the nodes they describe,
35+
- instead, they act as metadata associated with nodes.
36+
37+
This avoids mixing cross-cutting information with the primary structure of the model.
38+
39+
Note also that annotations can be attached to nodes but not to other annotations.
40+
41+
Annotations may contain nodes.

website/docs/Introduction/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Features
3-
sidebar_position: 33
3+
sidebar_position: 35
44
---
55

66
# LionWeb Feature Matrix
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Where LionWeb Nodes and Languages Live?
3+
sidebar_position: 33
4+
---
5+
6+
# Where LionWeb Nodes and Languages Live?
7+
8+
## In-Memory Only
9+
Nodes can exist purely in memory. This is typical for short-lived operations:
10+
- a batch process creates some nodes,
11+
- performs analysis or transformation,
12+
- produces an artifact (e.g., a report),
13+
- discards the nodes when the operation ends.
14+
15+
In this scenario, nodes are regular in-memory objects created through any LionWeb library, without persistence.
16+
17+
## Persistent Repository
18+
The most common setup is to store nodes in a persistent repository.
19+
A repository:
20+
- keeps nodes and partitions over time,
21+
- offers services for accessing, querying, and modifying data,
22+
- acts as the authoritative storage for tools that rely on shared models.
23+
24+
This is the scenario most LionWeb-based systems eventually adopt.
25+
26+
## Files on Disk (JSON or Protobuf)
27+
Nodes can also be persisted as files:
28+
- JSON is supported by all LionWeb libraries.
29+
- Protobuf is supported by most libraries.
30+
31+
You can:
32+
- store each partition in its own file, or
33+
- use the archive format (a ZIP container holding multiple encoded partitions).
34+
35+
The archive format is currently available in the Java and Python implementations.
36+
It groups multiple partitions and languages into a single compressed file containing protobuf-encoded data.
37+
38+
## Storing Languages
39+
Languages are nodes too. All storage mechanisms described above apply to languages the same way they apply to regular nodes.
40+
41+
Some considerations:
42+
- A specialized editor might embed a language definition directly.
43+
- A language might be shipped as a file alongside the tool.
44+
- A language may also be constructed programmatically when the editor starts.
45+
46+
These choices depend on how dynamic the language needs to be and how the tool is distributed.

0 commit comments

Comments
 (0)