Grouping terms
disl0.120.12Grouping terms
Example definition grouping-terms.dis: Statements about terms, and the terms derived from them through groupBy, used to show the macro and a failing key (DISL 0.9, 12.4).
Views generated from the file
These views are drawn by this site from grouping-terms.dis itself: its metamodel, and the layers it fills. They are not the notation the definition draws; that appears in an IDE that runs it.
grouping-terms.dis at ddb0daaDiagram as text (Mermaid)
classDiagram
accTitle: Metamodel of the Grouping terms example
accDescr: Class diagram of grouping-terms.dis: 3 node types (Statement, Term, Weight) and 0 relation types (none), with their typed attributes, inheritance, containment and relation ends.
class Statement {
+string subject
+string predicate
+string object
}
class Term {
+string name
+string label
}
class Weight {
+int weight
}grouping-terms.dis at ddb0daaDiagram as text (Mermaid)
flowchart LR
accTitle: Layers of grouping-terms.dis
accDescr: The eight DISL layers in order. grouping-terms.dis fills 2 of them: Metamodel (3 items), Constraints (1 items). It leaves Coordinates, Notation, Toolbox, Behavior, Layout, Persistence empty.
L1["1 · Metamodel<br/>3 items"]
L2["2 · Coordinate systems, placement and snapping<br/>not used"]
L3["3 · Notation (visual definition)<br/>not used"]
L4["4 · Toolbox, context tools and forms<br/>not used"]
L5["5 · Constraints<br/>1 items"]
L6["6 · Behavior<br/>not used"]
L7["7 · Layout<br/>not used"]
L8["8 · Persistence<br/>not used"]
L1 --> L2 --> L3 --> L4 --> L5 --> L6 --> L7 --> L8
classDef filled stroke-width:3px
classDef empty stroke-dasharray:4 4
class L1 filled
class L2 empty
class L3 empty
class L4 empty
class L5 filled
class L6 empty
class L7 empty
class L8 empty- Layer 1 — Metamodel: 3 items
- Layer 2 — Coordinate systems, placement and snapping: not used
- Layer 3 — Notation (visual definition): not used
- Layer 4 — Toolbox, context tools and forms: not used
- Layer 5 — Constraints: 1 items
- Layer 6 — Behavior: not used
- Layer 7 — Layout: not used
- Layer 8 — Persistence: not used
The file
Download grouping-terms.dis (2,870 bytes, unchanged from the source).
{
"$schema": "https://etalii.net/adp/disl/schema/0.2/disl.schema.json#/$defs/Specification",
"disl": "0.9",
"language": {
"id": "org.example.grouping-terms",
"version": "1.0.0",
"label": "Grouping terms",
"doc": {
"summary": "Statements about terms, and the terms derived from them through groupBy, used to show the macro and a failing key (DISL 0.9, 12.4).",
"description": "Each statement says one thing about one subject. `Term` derives one node per subject from the keys of the statements grouped by subject, and reads its label from the statements grouped by subject and predicate, so that no rule filters every statement again for each term. `Weight` groups the weight statements by their number; one weight is not a number, so its key fails, the whole grouping fails, and the type has no elements and one `std.derivedFailed` finding (2.5)."
},
"requires": { "features": ["cel.groupBy"] }
},
"metamodel": {
"types": {
"Statement": {
"doc": "One statement: a subject, a predicate and an object, as written.",
"attributes": {
"subject": { "type": "string", "required": true },
"predicate": { "type": "string", "required": true },
"object": { "type": "string", "required": true }
}
},
"Term": {
"doc": "One per subject of the statements, labelled by its `label` statement, else by its name.",
"attributes": {
"name": { "type": "string", "required": true, "key": true },
"label": { "type": "string" }
},
"derived": {
"from": "diagram.nodesOfType('Statement').groupBy(s, s.subject).keys()",
"key": "item",
"id": "item",
"attributes": {
"name": "item",
"label": "cel.bind(l, diagram.nodesOfType('Statement').groupBy(s, s.subject + '|' + s.predicate).get(item + '|label'), l.size() > 0 ? l[0].object : item)"
},
"reason": "A term is derived from its statements; change them instead."
}
},
"Weight": {
"doc": "One per distinct weight the statements give.",
"attributes": {
"weight": { "type": "int", "required": true, "key": true }
},
"derived": {
"from": "diagram.nodesOfType('Statement').groupBy(s, s.predicate == 'weight' ? int(s.object) : -1).keys().filter(w, w >= 0)",
"key": "item",
"id": "'weight-' + string(item)",
"attributes": { "weight": "item" },
"reason": "A weight is derived from the statements that give it."
}
}
}
},
"constraints": {
"rules": [
{
"id": "labelled",
"scope": "Term",
"rule": "self.label != self.name",
"severity": "warning",
"message": { "cel": "self.name + ' has no label.'" }
}
]
}
}In an IDE
No IDE host runs this example yet.