@linked.archi/kernel 0.0.0-stage → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +11 -0
- package/README.md +102 -2
- package/assets/arch-decision/arch-decision-metamodel.ttl +44 -0
- package/assets/arch-decision/arch-decision-onto.ttl +1566 -0
- package/assets/arch-decision/arch-decision-shapes.ttl +582 -0
- package/assets/arch-decision/arch-decision-tax.ttl +129 -0
- package/assets/arch-processes/arch-processes-metamodel.ttl +42 -0
- package/assets/arch-processes/arch-processes-tax.ttl +136 -0
- package/assets/arch-processes/archProcesses-shapes.ttl +189 -0
- package/assets/arch-processes/archProcesses.ttl +953 -0
- package/assets/archimate3/archimate3.2-element-shapes.ttl +379 -0
- package/assets/archimate3/archimate3.2-metamodel.ttl +205 -0
- package/assets/archimate3/archimate3.2-notation.ttl +1503 -0
- package/assets/archimate3/archimate3.2-onto.ttl +1579 -0
- package/assets/archimate3/archimate3.2-presentation-contexts.ttl +90 -0
- package/assets/archimate3/archimate3.2-principle-shapes.ttl +917 -0
- package/assets/archimate3/archimate3.2-questions.ttl +1125 -0
- package/assets/archimate3/archimate3.2-reference-data.ttl +74 -0
- package/assets/archimate3/archimate3.2-relationship-shapes.ttl +30956 -0
- package/assets/archimate3/archimate3.2-relationship-tables.ttl +5992 -0
- package/assets/archimate3/archimate3.2-tax.ttl +724 -0
- package/assets/archimate3/archimate3.2-viewpoint-shapes.ttl +59 -0
- package/assets/archimate3/archimate3.2-viewpoints.ttl +793 -0
- package/assets/archimate3/icons/and-junction.svg +3 -0
- package/assets/archimate3/icons/application-collaboration.svg +22 -0
- package/assets/archimate3/icons/application-component.svg +18 -0
- package/assets/archimate3/icons/application-event.svg +15 -0
- package/assets/archimate3/icons/application-function.svg +14 -0
- package/assets/archimate3/icons/application-interaction.svg +17 -0
- package/assets/archimate3/icons/application-interface.svg +16 -0
- package/assets/archimate3/icons/application-process.svg +14 -0
- package/assets/archimate3/icons/application-service.svg +14 -0
- package/assets/archimate3/icons/artifact.svg +16 -0
- package/assets/archimate3/icons/assessment.svg +17 -0
- package/assets/archimate3/icons/business-actor.svg +22 -0
- package/assets/archimate3/icons/business-collaboration.svg +21 -0
- package/assets/archimate3/icons/business-event.svg +15 -0
- package/assets/archimate3/icons/business-function.svg +14 -0
- package/assets/archimate3/icons/business-interaction.svg +18 -0
- package/assets/archimate3/icons/business-interface.svg +16 -0
- package/assets/archimate3/icons/business-object.svg +14 -0
- package/assets/archimate3/icons/business-process.svg +15 -0
- package/assets/archimate3/icons/business-role.svg +16 -0
- package/assets/archimate3/icons/business-service.svg +14 -0
- package/assets/archimate3/icons/capability.svg +40 -0
- package/assets/archimate3/icons/communication-network.svg +18 -0
- package/assets/archimate3/icons/constraint.svg +18 -0
- package/assets/archimate3/icons/contract.svg +13 -0
- package/assets/archimate3/icons/course-of-action.svg +20 -0
- package/assets/archimate3/icons/data-object.svg +14 -0
- package/assets/archimate3/icons/deliverable.svg +11 -0
- package/assets/archimate3/icons/device.svg +18 -0
- package/assets/archimate3/icons/distribution-network.svg +19 -0
- package/assets/archimate3/icons/driver.svg +24 -0
- package/assets/archimate3/icons/equipment.svg +31 -0
- package/assets/archimate3/icons/facility.svg +16 -0
- package/assets/archimate3/icons/gap.svg +22 -0
- package/assets/archimate3/icons/glyphs/activity.svg +3 -0
- package/assets/archimate3/icons/glyphs/actor.svg +14 -0
- package/assets/archimate3/icons/glyphs/application-component.svg +12 -0
- package/assets/archimate3/icons/glyphs/artifact.svg +9 -0
- package/assets/archimate3/icons/glyphs/assessment.svg +9 -0
- package/assets/archimate3/icons/glyphs/capability.svg +32 -0
- package/assets/archimate3/icons/glyphs/cloud-gear.svg +3 -0
- package/assets/archimate3/icons/glyphs/collaboration.svg +15 -0
- package/assets/archimate3/icons/glyphs/communication-network.svg +12 -0
- package/assets/archimate3/icons/glyphs/constraint.svg +10 -0
- package/assets/archimate3/icons/glyphs/contract.svg +5 -0
- package/assets/archimate3/icons/glyphs/course-of-action.svg +12 -0
- package/assets/archimate3/icons/glyphs/data-object.svg +4 -0
- package/assets/archimate3/icons/glyphs/deliverable.svg +3 -0
- package/assets/archimate3/icons/glyphs/device.svg +10 -0
- package/assets/archimate3/icons/glyphs/distribution-network.svg +11 -0
- package/assets/archimate3/icons/glyphs/driver.svg +16 -0
- package/assets/archimate3/icons/glyphs/equipment.svg +22 -0
- package/assets/archimate3/icons/glyphs/event.svg +6 -0
- package/assets/archimate3/icons/glyphs/facility.svg +7 -0
- package/assets/archimate3/icons/glyphs/function.svg +6 -0
- package/assets/archimate3/icons/glyphs/gap.svg +14 -0
- package/assets/archimate3/icons/glyphs/goal.svg +10 -0
- package/assets/archimate3/icons/glyphs/grouping.svg +4 -0
- package/assets/archimate3/icons/glyphs/interaction.svg +10 -0
- package/assets/archimate3/icons/glyphs/interface.svg +8 -0
- package/assets/archimate3/icons/glyphs/location.svg +6 -0
- package/assets/archimate3/icons/glyphs/material.svg +12 -0
- package/assets/archimate3/icons/glyphs/meaning.svg +3 -0
- package/assets/archimate3/icons/glyphs/node.svg +8 -0
- package/assets/archimate3/icons/glyphs/object.svg +4 -0
- package/assets/archimate3/icons/glyphs/outcome.svg +16 -0
- package/assets/archimate3/icons/glyphs/path.svg +10 -0
- package/assets/archimate3/icons/glyphs/person-silhouette.svg +3 -0
- package/assets/archimate3/icons/glyphs/plateau.svg +8 -0
- package/assets/archimate3/icons/glyphs/principle.svg +12 -0
- package/assets/archimate3/icons/glyphs/process.svg +6 -0
- package/assets/archimate3/icons/glyphs/product.svg +4 -0
- package/assets/archimate3/icons/glyphs/representation.svg +4 -0
- package/assets/archimate3/icons/glyphs/requirement.svg +6 -0
- package/assets/archimate3/icons/glyphs/resource.svg +14 -0
- package/assets/archimate3/icons/glyphs/role.svg +6 -0
- package/assets/archimate3/icons/glyphs/service.svg +6 -0
- package/assets/archimate3/icons/glyphs/stakeholder.svg +6 -0
- package/assets/archimate3/icons/glyphs/system-software.svg +14 -0
- package/assets/archimate3/icons/glyphs/value-stream.svg +3 -0
- package/assets/archimate3/icons/glyphs/value.svg +3 -0
- package/assets/archimate3/icons/glyphs/work-package.svg +4 -0
- package/assets/archimate3/icons/goal.svg +18 -0
- package/assets/archimate3/icons/grouping.svg +12 -0
- package/assets/archimate3/icons/implementation-event.svg +15 -0
- package/assets/archimate3/icons/location.svg +14 -0
- package/assets/archimate3/icons/material.svg +21 -0
- package/assets/archimate3/icons/meaning.svg +11 -0
- package/assets/archimate3/icons/node.svg +14 -0
- package/assets/archimate3/icons/or-junction.svg +3 -0
- package/assets/archimate3/icons/outcome.svg +25 -0
- package/assets/archimate3/icons/path.svg +18 -0
- package/assets/archimate3/icons/plateau.svg +16 -0
- package/assets/archimate3/icons/principle.svg +21 -0
- package/assets/archimate3/icons/product.svg +12 -0
- package/assets/archimate3/icons/representation.svg +12 -0
- package/assets/archimate3/icons/requirement.svg +14 -0
- package/assets/archimate3/icons/resource.svg +23 -0
- package/assets/archimate3/icons/stakeholder.svg +15 -0
- package/assets/archimate3/icons/system-software.svg +22 -0
- package/assets/archimate3/icons/technology-collaboration.svg +22 -0
- package/assets/archimate3/icons/technology-event.svg +15 -0
- package/assets/archimate3/icons/technology-function.svg +14 -0
- package/assets/archimate3/icons/technology-interaction.svg +18 -0
- package/assets/archimate3/icons/technology-interface.svg +16 -0
- package/assets/archimate3/icons/technology-process.svg +14 -0
- package/assets/archimate3/icons/technology-service.svg +14 -0
- package/assets/archimate3/icons/value-stream.svg +11 -0
- package/assets/archimate3/icons/value.svg +11 -0
- package/assets/archimate3/icons/work-package.svg +12 -0
- package/assets/archimate4/archimate4-element-shapes.ttl +404 -0
- package/assets/archimate4/archimate4-metamodel.ttl +179 -0
- package/assets/archimate4/archimate4-notation.ttl +1147 -0
- package/assets/archimate4/archimate4-onto.ttl +1559 -0
- package/assets/archimate4/archimate4-presentation-contexts.ttl +60 -0
- package/assets/archimate4/archimate4-principle-shapes.ttl +895 -0
- package/assets/archimate4/archimate4-questions.ttl +1224 -0
- package/assets/archimate4/archimate4-reference-data.ttl +56 -0
- package/assets/archimate4/archimate4-relationship-shapes.ttl +16920 -0
- package/assets/archimate4/archimate4-relationship-tables.ttl +3200 -0
- package/assets/archimate4/archimate4-tax.ttl +749 -0
- package/assets/archimate4/archimate4-viewpoint-shapes.ttl +55 -0
- package/assets/archimate4/archimate4-viewpoints.ttl +777 -0
- package/assets/archimate4/icons/and-junction.svg +3 -0
- package/assets/archimate4/icons/application-component.svg +18 -0
- package/assets/archimate4/icons/application-interface.svg +16 -0
- package/assets/archimate4/icons/artifact.svg +16 -0
- package/assets/archimate4/icons/assessment.svg +17 -0
- package/assets/archimate4/icons/business-actor.svg +22 -0
- package/assets/archimate4/icons/business-interface.svg +16 -0
- package/assets/archimate4/icons/business-object.svg +14 -0
- package/assets/archimate4/icons/capability.svg +40 -0
- package/assets/archimate4/icons/collaboration.svg +21 -0
- package/assets/archimate4/icons/communication-network.svg +18 -0
- package/assets/archimate4/icons/course-of-action.svg +20 -0
- package/assets/archimate4/icons/data-object.svg +14 -0
- package/assets/archimate4/icons/deliverable.svg +11 -0
- package/assets/archimate4/icons/device.svg +18 -0
- package/assets/archimate4/icons/distribution-network.svg +19 -0
- package/assets/archimate4/icons/driver.svg +24 -0
- package/assets/archimate4/icons/equipment.svg +31 -0
- package/assets/archimate4/icons/event.svg +15 -0
- package/assets/archimate4/icons/facility.svg +16 -0
- package/assets/archimate4/icons/function.svg +13 -0
- package/assets/archimate4/icons/glyphs/activity.svg +3 -0
- package/assets/archimate4/icons/glyphs/actor.svg +14 -0
- package/assets/archimate4/icons/glyphs/application-component.svg +12 -0
- package/assets/archimate4/icons/glyphs/artifact.svg +9 -0
- package/assets/archimate4/icons/glyphs/assessment.svg +9 -0
- package/assets/archimate4/icons/glyphs/capability.svg +32 -0
- package/assets/archimate4/icons/glyphs/cloud-gear.svg +3 -0
- package/assets/archimate4/icons/glyphs/collaboration.svg +15 -0
- package/assets/archimate4/icons/glyphs/communication-network.svg +12 -0
- package/assets/archimate4/icons/glyphs/constraint.svg +10 -0
- package/assets/archimate4/icons/glyphs/contract.svg +5 -0
- package/assets/archimate4/icons/glyphs/course-of-action.svg +12 -0
- package/assets/archimate4/icons/glyphs/data-object.svg +4 -0
- package/assets/archimate4/icons/glyphs/deliverable.svg +3 -0
- package/assets/archimate4/icons/glyphs/device.svg +10 -0
- package/assets/archimate4/icons/glyphs/distribution-network.svg +11 -0
- package/assets/archimate4/icons/glyphs/driver.svg +16 -0
- package/assets/archimate4/icons/glyphs/equipment.svg +22 -0
- package/assets/archimate4/icons/glyphs/event.svg +6 -0
- package/assets/archimate4/icons/glyphs/facility.svg +7 -0
- package/assets/archimate4/icons/glyphs/function.svg +6 -0
- package/assets/archimate4/icons/glyphs/gap.svg +14 -0
- package/assets/archimate4/icons/glyphs/goal.svg +10 -0
- package/assets/archimate4/icons/glyphs/grouping.svg +4 -0
- package/assets/archimate4/icons/glyphs/interaction.svg +10 -0
- package/assets/archimate4/icons/glyphs/interface.svg +8 -0
- package/assets/archimate4/icons/glyphs/location.svg +6 -0
- package/assets/archimate4/icons/glyphs/material.svg +12 -0
- package/assets/archimate4/icons/glyphs/meaning.svg +3 -0
- package/assets/archimate4/icons/glyphs/node.svg +8 -0
- package/assets/archimate4/icons/glyphs/object.svg +4 -0
- package/assets/archimate4/icons/glyphs/outcome.svg +16 -0
- package/assets/archimate4/icons/glyphs/path.svg +10 -0
- package/assets/archimate4/icons/glyphs/person-silhouette.svg +3 -0
- package/assets/archimate4/icons/glyphs/plateau.svg +8 -0
- package/assets/archimate4/icons/glyphs/principle.svg +12 -0
- package/assets/archimate4/icons/glyphs/process.svg +6 -0
- package/assets/archimate4/icons/glyphs/product.svg +4 -0
- package/assets/archimate4/icons/glyphs/representation.svg +4 -0
- package/assets/archimate4/icons/glyphs/requirement.svg +6 -0
- package/assets/archimate4/icons/glyphs/resource.svg +14 -0
- package/assets/archimate4/icons/glyphs/role.svg +6 -0
- package/assets/archimate4/icons/glyphs/service.svg +6 -0
- package/assets/archimate4/icons/glyphs/stakeholder.svg +6 -0
- package/assets/archimate4/icons/glyphs/system-software.svg +14 -0
- package/assets/archimate4/icons/glyphs/value-stream.svg +3 -0
- package/assets/archimate4/icons/glyphs/value.svg +3 -0
- package/assets/archimate4/icons/glyphs/work-package.svg +4 -0
- package/assets/archimate4/icons/goal.svg +18 -0
- package/assets/archimate4/icons/grouping.svg +12 -0
- package/assets/archimate4/icons/location.svg +14 -0
- package/assets/archimate4/icons/material.svg +21 -0
- package/assets/archimate4/icons/meaning.svg +11 -0
- package/assets/archimate4/icons/node.svg +14 -0
- package/assets/archimate4/icons/or-junction.svg +3 -0
- package/assets/archimate4/icons/outcome.svg +25 -0
- package/assets/archimate4/icons/path.svg +18 -0
- package/assets/archimate4/icons/plateau.svg +16 -0
- package/assets/archimate4/icons/principle.svg +21 -0
- package/assets/archimate4/icons/process.svg +15 -0
- package/assets/archimate4/icons/product.svg +12 -0
- package/assets/archimate4/icons/requirement.svg +14 -0
- package/assets/archimate4/icons/resource.svg +23 -0
- package/assets/archimate4/icons/role.svg +16 -0
- package/assets/archimate4/icons/service.svg +13 -0
- package/assets/archimate4/icons/stakeholder.svg +15 -0
- package/assets/archimate4/icons/system-software.svg +22 -0
- package/assets/archimate4/icons/technology-interface.svg +16 -0
- package/assets/archimate4/icons/value-stream.svg +11 -0
- package/assets/archimate4/icons/value.svg +11 -0
- package/assets/archimate4/icons/work-package.svg +12 -0
- package/assets/basic/basic-metamodel.ttl +100 -0
- package/assets/basic/basic-notation-bubble.ttl +175 -0
- package/assets/basic/basic-notation.ttl +172 -0
- package/assets/basic/basic-onto.ttl +171 -0
- package/assets/basic/basic-presentation-contexts.ttl +70 -0
- package/assets/basic/basic-tax.ttl +130 -0
- package/assets/basic/icons/aggregation.svg +7 -0
- package/assets/basic/icons/association.svg +6 -0
- package/assets/basic/icons/element.svg +5 -0
- package/assets/basic/icons/glyphs/aggregation.svg +6 -0
- package/assets/basic/icons/glyphs/association.svg +5 -0
- package/assets/basic/icons/glyphs/element.svg +5 -0
- package/assets/basic/icons/glyphs/relationship.svg +5 -0
- package/assets/basic/icons/relationship.svg +7 -0
- package/assets/basic/notation-bubble/icons/aggregation.svg +7 -0
- package/assets/basic/notation-bubble/icons/association.svg +6 -0
- package/assets/basic/notation-bubble/icons/element.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/aggregation.svg +6 -0
- package/assets/basic/notation-bubble/icons/glyphs/association.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/element.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/relationship.svg +5 -0
- package/assets/basic/notation-bubble/icons/relationship.svg +7 -0
- package/assets/catalog.ttl +7406 -0
- package/assets/core/core-notation.ttl +131 -0
- package/assets/core/core-onto.ttl +2811 -0
- package/assets/core/core-questions.ttl +957 -0
- package/assets/core/core-shapes.ttl +915 -0
- package/assets/core/core-vis-onto.ttl +1408 -0
- package/assets/core/core-vis-shapes.ttl +851 -0
- package/assets/core-vis/markers/circle-dot.svg +3 -0
- package/assets/core-vis/markers/closed-arrowhead.svg +3 -0
- package/assets/core-vis/markers/filled-diamond.svg +3 -0
- package/assets/core-vis/markers/half-arrowhead.svg +3 -0
- package/assets/core-vis/markers/hollow-arrowhead.svg +3 -0
- package/assets/core-vis/markers/hollow-diamond.svg +3 -0
- package/assets/core-vis/markers/open-arrowhead.svg +3 -0
- package/fixtures/interoperability/archimate4-demo.trig +259 -0
- package/fixtures/interoperability/expected-findings.json +26 -0
- package/fixtures/interoperability/shop-seed.ttl +225 -0
- package/package.json +136 -4
- package/scripts/sync-assets.mjs +252 -0
- package/src/conformance.ts +66 -0
- package/src/import-export/model-io.ts +426 -0
- package/src/index.ts +11 -0
- package/src/metamodel-manager/asset-sources.ts +754 -0
- package/src/metamodel-manager/bundled-assets.ts +599 -0
- package/src/metamodel-manager/catalogue.ts +114 -0
- package/src/metamodel-manager/class-hierarchy.ts +155 -0
- package/src/metamodel-manager/index.ts +65 -0
- package/src/metamodel-manager/interfaces.ts +422 -0
- package/src/metamodel-manager/metamodel-completeness.ts +162 -0
- package/src/metamodel-manager/metamodel-loader.ts +864 -0
- package/src/metamodel-manager/notation-resolver.ts +284 -0
- package/src/metamodel-manager/notation.ts +659 -0
- package/src/metamodel-manager/palette-generator.ts +882 -0
- package/src/metamodel-manager/property-shapes.ts +290 -0
- package/src/metamodel-manager/taxonomy.ts +904 -0
- package/src/metamodel-manager/type-guide.ts +241 -0
- package/src/metamodel-manager/viewpoint-manager.ts +147 -0
- package/src/model-manager/appearance.ts +389 -0
- package/src/model-manager/cascade.ts +246 -0
- package/src/model-manager/clipboard.ts +566 -0
- package/src/model-manager/context-names.ts +108 -0
- package/src/model-manager/custom-properties.ts +549 -0
- package/src/model-manager/derivations.ts +166 -0
- package/src/model-manager/direct-permissions.ts +182 -0
- package/src/model-manager/drawing-order.ts +119 -0
- package/src/model-manager/element-manager.ts +69 -0
- package/src/model-manager/element-pictures.ts +118 -0
- package/src/model-manager/field-names.ts +42 -0
- package/src/model-manager/folders.ts +354 -0
- package/src/model-manager/grid.ts +6 -0
- package/src/model-manager/index.ts +43 -0
- package/src/model-manager/interfaces.ts +417 -0
- package/src/model-manager/iri-conformance.ts +183 -0
- package/src/model-manager/label-expression.ts +233 -0
- package/src/model-manager/legacy-migration.ts +200 -0
- package/src/model-manager/missing-references.ts +86 -0
- package/src/model-manager/model-diff-text.ts +150 -0
- package/src/model-manager/model-diff.ts +534 -0
- package/src/model-manager/model-merge.ts +1160 -0
- package/src/model-manager/model-namespace.ts +199 -0
- package/src/model-manager/model-operations.ts +132 -0
- package/src/model-manager/model-queries.ts +616 -0
- package/src/model-manager/model-session.ts +759 -0
- package/src/model-manager/multiplicity.ts +74 -0
- package/src/model-manager/nested-resources.ts +145 -0
- package/src/model-manager/own-metamodel.ts +157 -0
- package/src/model-manager/placement-copy.ts +116 -0
- package/src/model-manager/property-catalog.ts +787 -0
- package/src/model-manager/proposal-order.ts +203 -0
- package/src/model-manager/provenance.ts +396 -0
- package/src/model-manager/questions.ts +475 -0
- package/src/model-manager/rdf-scope.ts +97 -0
- package/src/model-manager/relationship-graph.ts +462 -0
- package/src/model-manager/relationship-manager.ts +962 -0
- package/src/model-manager/relationship-table.ts +189 -0
- package/src/model-manager/relationship-validity.ts +261 -0
- package/src/model-manager/resource-edits.ts +28 -0
- package/src/model-manager/short-hash.ts +104 -0
- package/src/model-manager/snapshot-lines.ts +88 -0
- package/src/model-manager/version-history.ts +205 -0
- package/src/model-manager/view-from-results.ts +81 -0
- package/src/model-manager/view-manager.ts +1410 -0
- package/src/model-manager/vocabulary.ts +279 -0
- package/src/rdf-engine/finding-shape.ts +23 -0
- package/src/rdf-engine/graph-scope.ts +163 -0
- package/src/rdf-engine/index.ts +7 -0
- package/src/rdf-engine/interfaces.ts +144 -0
- package/src/rdf-engine/iri.ts +203 -0
- package/src/rdf-engine/localized-text.ts +13 -0
- package/src/rdf-engine/namespaces.ts +41 -0
- package/src/rdf-engine/native-load.ts +37 -0
- package/src/rdf-engine/observable-store.ts +609 -0
- package/src/rdf-engine/rdf-store.ts +520 -0
- package/src/rdf-engine/shacl-validator.ts +602 -0
- package/src/rdf-engine/shape-reach.ts +140 -0
- package/src/rdf-engine/shape-switches.ts +165 -0
- package/src/rdf-engine/single-valued.ts +219 -0
- package/src/rdf-engine/sparql-constraints.ts +349 -0
- package/src/rdf-engine/term-codec.ts +51 -0
- package/src/rdf-engine/ttl-parser.ts +51 -0
- package/src/rdf-engine/ttl-serializer.ts +79 -0
- package/src/rdf-engine/turtle-writer.ts +284 -0
- package/src/rdf-engine/validation-engine.ts +747 -0
- package/src/rdf-engine/validation-service.ts +186 -0
- package/src/rdf-engine/validation.worker.ts +47 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Palette Generator implementation.
|
|
3
|
+
*
|
|
4
|
+
* Builds the tool palette out of the three layers a Linked.Archi metamodel
|
|
5
|
+
* publishes, each of which already has a module of its own:
|
|
6
|
+
*
|
|
7
|
+
* - **taxonomy** (`taxonomy.ts`) — which classes are instantiable, and how they
|
|
8
|
+
* group along each classification axis ("Domain", "Aspect"). The axis is
|
|
9
|
+
* what a "Group by" selector switches between.
|
|
10
|
+
* - **notation** (`notation.ts`) — the `arch-vis:` visual style per concept,
|
|
11
|
+
* scoped to a notation set.
|
|
12
|
+
* - **ontology** — `rdfs:subClassOf+ arch:QualifiedRelationship` for the
|
|
13
|
+
* relationship types, with `arch:domainIncludes` / `arch:rangeIncludes`
|
|
14
|
+
* gathered from the class *and* from whatever `arch:unqualifiedForm` names,
|
|
15
|
+
* exactly as `RelationshipManager` does it.
|
|
16
|
+
*
|
|
17
|
+
* ## Notation lookup
|
|
18
|
+
*
|
|
19
|
+
* Each class is styled by `notation-resolver.ts`, in five steps (Req 2.16).
|
|
20
|
+
*
|
|
21
|
+
* For a class C, the active set A is the set that the active presentation
|
|
22
|
+
* context names with `arch:usesNotationSet`, or else the primary metamodel's
|
|
23
|
+
* `arch:notationSet`. The fallback layers F are the default sets
|
|
24
|
+
* (`arch:notationSet`) of all loaded metamodels except A itself, in load order.
|
|
25
|
+
* F includes the default set of A's own metamodel when a presentation context
|
|
26
|
+
* picked an alternative set.
|
|
27
|
+
*
|
|
28
|
+
* 1. A descriptor in A for C.
|
|
29
|
+
* 2. A descriptor for C in F, the first match in load order.
|
|
30
|
+
* 3. C's own `arch:prefVisNotation`.
|
|
31
|
+
* 4. A descriptor for the nearest superclass of C that has one in A or F. The
|
|
32
|
+
* walk goes breadth-first over `rdfs:subClassOf`: by distance first, and
|
|
33
|
+
* superclasses at the same distance in IRI order. It stops at `arch:Element`
|
|
34
|
+
* and `arch:QualifiedRelationship`. For each superclass, A is checked first,
|
|
35
|
+
* then F in load order.
|
|
36
|
+
* 5. Built-in defaults. Elements: a rectangle with a white fill and a black
|
|
37
|
+
* line. Relationships: a solid black line.
|
|
38
|
+
*
|
|
39
|
+
* Anything published for the class itself beats anything inherited; among
|
|
40
|
+
* inherited descriptors the nearest ancestor wins; the active set only breaks
|
|
41
|
+
* ties.
|
|
42
|
+
*
|
|
43
|
+
* Here a set chosen explicitly (`PaletteOptions.notationSetIri`) comes before
|
|
44
|
+
* the context's, and the primary metamodel is the first of
|
|
45
|
+
* `PaletteOptions.defaultNotationSetIris` whose set has descriptors.
|
|
46
|
+
*
|
|
47
|
+
* The palette entries and the `notationIndex` the canvas reads come from the
|
|
48
|
+
* same resolver, so palette and canvas cannot disagree.
|
|
49
|
+
*
|
|
50
|
+
* ## Why this is not SPARQL any more
|
|
51
|
+
*
|
|
52
|
+
* The previous implementation queried `?type rdfs:subClassOf+ arch:Element`,
|
|
53
|
+
* grouped by a single `skos:broader` hop, filtered on `arch:isAbstract`, and
|
|
54
|
+
* looked for `?rel a arch:Relationship`. Against the published ArchiMate 4.0
|
|
55
|
+
* data every one of those is wrong: grouping is multi-axis through
|
|
56
|
+
* `skos:narrower` onto the OWL classes, the abstractness flag is
|
|
57
|
+
* `arch:isAbstractClass`, and `arch:Relationship` does not occur at all —
|
|
58
|
+
* relationship types are `owl:Class`es under `arch:QualifiedRelationship`.
|
|
59
|
+
*
|
|
60
|
+
* `taxonomy.ts` and `notation.ts` encode those rules and operate on an n3
|
|
61
|
+
* `Store`, so this module reads the quads out of the application's `RdfStore`
|
|
62
|
+
* and hands them a snapshot rather than duplicating the logic in SPARQL.
|
|
63
|
+
*
|
|
64
|
+
* ## Icons
|
|
65
|
+
*
|
|
66
|
+
* Icon URIs are published absolute (`https://meta.linked.archi/archimate4/…`).
|
|
67
|
+
* They are passed through {@link resolveIconUri} so the bundled copies load with
|
|
68
|
+
* no network, and the published URI is kept alongside in a {@link ResolvedUri}
|
|
69
|
+
* so a caller with network access can still choose it.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
import { declaredOutside, documentsWithoutTypes, metamodelCompleteness } from './metamodel-completeness.js';
|
|
73
|
+
import { DataFactory, Store } from 'n3';
|
|
74
|
+
import type { Quad as N3Quad } from 'n3';
|
|
75
|
+
import type { Quad } from '@rdfjs/types';
|
|
76
|
+
import type { RdfStore } from '../rdf-engine/interfaces.js';
|
|
77
|
+
import { selectLocalizedLiteral } from '../rdf-engine/localized-text.js';
|
|
78
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
79
|
+
import { resolveIconUri } from './bundled-assets.js';
|
|
80
|
+
import {
|
|
81
|
+
buildClasses,
|
|
82
|
+
buildClassificationAxes,
|
|
83
|
+
paletteGroupingOf,
|
|
84
|
+
type SemanticClass,
|
|
85
|
+
type TaxonomyAxis,
|
|
86
|
+
} from './taxonomy.js';
|
|
87
|
+
import {
|
|
88
|
+
buildDecorationSymbols,
|
|
89
|
+
buildVisualNotations,
|
|
90
|
+
effectiveRenderingMode,
|
|
91
|
+
labelExpressionIn,
|
|
92
|
+
labelExpressionsOf,
|
|
93
|
+
presentationContextLabel,
|
|
94
|
+
resolveNotationSetForContext,
|
|
95
|
+
type Decoration,
|
|
96
|
+
type NotationSet,
|
|
97
|
+
type RelationshipVisualStyle,
|
|
98
|
+
type VisualNotation,
|
|
99
|
+
type VisualStyle,
|
|
100
|
+
} from './notation.js';
|
|
101
|
+
import { NOTATION_ROOTS, buildSuperClassMap, closureOf, compareIris, superClassesNearestFirst } from './class-hierarchy.js';
|
|
102
|
+
import {
|
|
103
|
+
coreNotationSetIris,
|
|
104
|
+
NotationResolver,
|
|
105
|
+
orderedFallbackSets,
|
|
106
|
+
storeDefaultNotationSetIris,
|
|
107
|
+
type NotationIndexEntry,
|
|
108
|
+
type ResolvedNotation,
|
|
109
|
+
} from './notation-resolver.js';
|
|
110
|
+
import type {
|
|
111
|
+
PaletteGenerator,
|
|
112
|
+
PaletteDefinition,
|
|
113
|
+
PaletteOptions,
|
|
114
|
+
PaletteAxis,
|
|
115
|
+
ElementTypeInfo,
|
|
116
|
+
ElementGroup,
|
|
117
|
+
RelationshipTypeInfo,
|
|
118
|
+
ResolvedUri,
|
|
119
|
+
} from './interfaces.js';
|
|
120
|
+
|
|
121
|
+
const { namedNode } = DataFactory;
|
|
122
|
+
|
|
123
|
+
const RDF_TYPE = `${NAMESPACES.rdf}type`;
|
|
124
|
+
const RDFS_LABEL = `${NAMESPACES.rdfs}label`;
|
|
125
|
+
const RDFS_COMMENT = `${NAMESPACES.rdfs}comment`;
|
|
126
|
+
const RDFS_SUBCLASS_OF = `${NAMESPACES.rdfs}subClassOf`;
|
|
127
|
+
const SKOS_PREF_LABEL = `${NAMESPACES.skos}prefLabel`;
|
|
128
|
+
const SKOS_DEFINITION = `${NAMESPACES.skos}definition`;
|
|
129
|
+
|
|
130
|
+
const ARCH_QUALIFIED_RELATIONSHIP = `${NAMESPACES.arch}QualifiedRelationship`;
|
|
131
|
+
const ARCH_RELATIONSHIP_LEGACY = `${NAMESPACES.arch}Relationship`;
|
|
132
|
+
const ARCH_UNQUALIFIED_FORM = `${NAMESPACES.arch}unqualifiedForm`;
|
|
133
|
+
const RDFS_SEE_ALSO = `${NAMESPACES.rdfs}seeAlso`;
|
|
134
|
+
const OWL_SYMMETRIC_PROPERTY = `${NAMESPACES.owl}SymmetricProperty`;
|
|
135
|
+
const ARCH_DOMAIN_INCLUDES = `${NAMESPACES.arch}domainIncludes`;
|
|
136
|
+
const ARCH_RANGE_INCLUDES = `${NAMESPACES.arch}rangeIncludes`;
|
|
137
|
+
const ARCH_IS_ABSTRACT_CLASS = `${NAMESPACES.arch}isAbstractClass`;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* How real viewpoints express membership.
|
|
141
|
+
*
|
|
142
|
+
* Verified against `archimate4-viewpoints.ttl`: every one of the 18 viewpoints
|
|
143
|
+
* uses `arch:includesConcept`, and `arch:permitsElement` /
|
|
144
|
+
* `arch:permitsRelationship` — which the previous implementation assumed —
|
|
145
|
+
* appear nowhere. The core ontology types `arch:includesConcept` with
|
|
146
|
+
* `rdfs:range arch:ModelConcept`, so one predicate covers both elements and
|
|
147
|
+
* relationship types.
|
|
148
|
+
*/
|
|
149
|
+
const ARCH_INCLUDES_CONCEPT = `${NAMESPACES.arch}includesConcept`;
|
|
150
|
+
/** Legacy membership predicates, still honoured for older/hand-written data. */
|
|
151
|
+
const ARCH_PERMITS_ELEMENT = `${NAMESPACES.arch}permitsElement`;
|
|
152
|
+
const ARCH_PERMITS_RELATIONSHIP = `${NAMESPACES.arch}permitsRelationship`;
|
|
153
|
+
|
|
154
|
+
/** Group label used when an element has no group under the active axis. */
|
|
155
|
+
const UNCATEGORIZED = 'Other';
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* PaletteGenerator over the metamodel quads held in an {@link RdfStore}.
|
|
159
|
+
*
|
|
160
|
+
* Each `generatePalette` call takes a fresh snapshot of the store, so a palette
|
|
161
|
+
* generated after loading more of the metamodel reflects the addition.
|
|
162
|
+
*/
|
|
163
|
+
export class SparqlPaletteGenerator implements PaletteGenerator {
|
|
164
|
+
constructor(private store: RdfStore) {}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Build a palette from everything currently in the store.
|
|
168
|
+
*
|
|
169
|
+
* @param metamodelGraph Retained for call-site compatibility and used only to
|
|
170
|
+
* scope the snapshot when that graph exists on its own. A metamodel spans
|
|
171
|
+
* several named graphs (ontology, taxonomy, notation …), and the taxonomy
|
|
172
|
+
* and notation layers must see all of them, so by default the snapshot is
|
|
173
|
+
* the whole store.
|
|
174
|
+
* @param options Which axis to group by and which notation set to style from.
|
|
175
|
+
*/
|
|
176
|
+
generatePalette(metamodelGraph?: string, options?: PaletteOptions): PaletteDefinition {
|
|
177
|
+
const graph = this.snapshot();
|
|
178
|
+
|
|
179
|
+
const preferredLanguage = options?.preferredLanguage ?? 'en';
|
|
180
|
+
const classificationAxes = buildClassificationAxes(graph, options?.metamodelIris, preferredLanguage);
|
|
181
|
+
// Not the classes of a document that gives no loaded metamodel its types: another version's ontology, loaded
|
|
182
|
+
// because the shapes of both import it (LeanIX v3 beside v4, TOGAF 9.2 beside 10).
|
|
183
|
+
const withoutTypes = options?.metamodels ? documentsWithoutTypes(graph, options.metamodels) : new Set<string>();
|
|
184
|
+
const semanticClasses = buildClasses(graph, classificationAxes, preferredLanguage).filter((cls) => declaredOutside(graph, cls.iri, withoutTypes));
|
|
185
|
+
// Only an axis that groups some element type is one to group the palette by. A taxonomy may also
|
|
186
|
+
// classify relationship types — ArchiMate's relationship categories — which are not palette elements.
|
|
187
|
+
// A standalone group (ArchiMate's Junction, under no axis) is no way of grouping either: its members take
|
|
188
|
+
// a section of its name when no grouping axis classifies them.
|
|
189
|
+
const taxonomyAxes = classificationAxes.filter(
|
|
190
|
+
(axis) => !axis.standalone && semanticClasses.some((cls) => cls.groupsByAxis[axis.iri] !== undefined),
|
|
191
|
+
);
|
|
192
|
+
const standaloneAxes = classificationAxes.filter((axis) => axis.standalone).map((axis) => axis.iri);
|
|
193
|
+
|
|
194
|
+
const activeAxis = this.pickAxis(taxonomyAxes, options?.axisIri);
|
|
195
|
+
// The axes the palette is grouped by, the active one first: under an axis the metamodel's palette
|
|
196
|
+
// grouping names (arch:paletteGrouping), the others it names follow, in its order — they place a class
|
|
197
|
+
// the active axis does not classify, and order the classes within a section. Under any other axis, it alone.
|
|
198
|
+
const grouping = paletteGroupingOf(graph, options?.metamodelIris).filter((iri) =>
|
|
199
|
+
taxonomyAxes.some((axis) => axis.iri === iri),
|
|
200
|
+
);
|
|
201
|
+
const groupingAxes = !activeAxis
|
|
202
|
+
? []
|
|
203
|
+
: grouping.includes(activeAxis.iri)
|
|
204
|
+
? [activeAxis.iri, ...grouping.filter((iri) => iri !== activeAxis.iri)]
|
|
205
|
+
: [activeAxis.iri];
|
|
206
|
+
const notationSet = this.resolveNotationSet(graph, options);
|
|
207
|
+
|
|
208
|
+
// One hierarchy map and one resolver per palette: relationship discovery,
|
|
209
|
+
// the palette entries and the canvas index all read the same answers.
|
|
210
|
+
const superClassMap = buildSuperClassMap(graph);
|
|
211
|
+
const fallbackSets = orderedFallbackSets(graph, notationSet?.iri, [
|
|
212
|
+
...(options?.defaultNotationSetIris ?? storeDefaultNotationSetIris(graph)),
|
|
213
|
+
// The core's own relationship types, after every language's; nesting may draw Has Part and Refines (VC-DD-5).
|
|
214
|
+
...coreNotationSetIris(graph),
|
|
215
|
+
]);
|
|
216
|
+
const resolver = new NotationResolver(graph, notationSet, fallbackSets, superClassMap);
|
|
217
|
+
|
|
218
|
+
// The dimensions the grouping does not name place what it leaves out, after its own sections: the types of
|
|
219
|
+
// a metamodel loaded beside the first — the decision extension's records and forces beside ArchiMate's
|
|
220
|
+
// domains — keep their own groups, not "Other".
|
|
221
|
+
const otherAxes = groupingAxes.length > 0 ? taxonomyAxes.map((axis) => axis.iri).filter((iri) => !groupingAxes.includes(iri)) : [];
|
|
222
|
+
const elements = semanticClasses.map((cls) => this.toElementTypeInfo(cls, groupingAxes, standaloneAxes, resolver, otherAxes));
|
|
223
|
+
const elementGroups = this.groupElements(elements, activeAxis, groupingAxes, semanticClasses, otherAxes);
|
|
224
|
+
const relationshipTypes = categoriseRelationships(
|
|
225
|
+
this.discoverRelationships(graph, resolver, superClassMap, preferredLanguage).filter((rel) => declaredOutside(graph, rel.iri, withoutTypes)),
|
|
226
|
+
classificationAxes,
|
|
227
|
+
superClassMap,
|
|
228
|
+
graph,
|
|
229
|
+
);
|
|
230
|
+
const notationIndex = buildNotationIndex(graph, resolver, superClassMap, [
|
|
231
|
+
...(notationSet ? [notationSet] : []),
|
|
232
|
+
...fallbackSets,
|
|
233
|
+
]);
|
|
234
|
+
|
|
235
|
+
const axes: PaletteAxis[] = taxonomyAxes.map((axis) => ({
|
|
236
|
+
iri: axis.iri,
|
|
237
|
+
label: axis.label,
|
|
238
|
+
groups: groupsInOrder(axis),
|
|
239
|
+
}));
|
|
240
|
+
|
|
241
|
+
// `metamodelGraph` is deliberately unused for scoping — see the doc above.
|
|
242
|
+
void metamodelGraph;
|
|
243
|
+
|
|
244
|
+
const groupedByName = taxonomyAxes.length === 0;
|
|
245
|
+
const completeness = options?.metamodels
|
|
246
|
+
? metamodelCompleteness(graph, options.metamodels, semanticClasses, relationshipTypes, groupedByName)
|
|
247
|
+
: [];
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
elementGroups,
|
|
251
|
+
relationshipTypes,
|
|
252
|
+
...(completeness.length > 0 ? { completeness } : {}),
|
|
253
|
+
axes,
|
|
254
|
+
activeAxisIri: activeAxis?.iri,
|
|
255
|
+
// buildClasses walks the OWL classes when there is no axis to group by.
|
|
256
|
+
grouping: taxonomyAxes.length > 0 ? 'taxonomy' : 'owl',
|
|
257
|
+
notationSetIri: notationSet?.iri,
|
|
258
|
+
notationSetLabel: notationSet?.label,
|
|
259
|
+
...this.presentationContextOf(graph, options?.presentationContextIri),
|
|
260
|
+
notationIndex,
|
|
261
|
+
decorationSymbols: resolvedDecorationSymbols(graph),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Restrict a palette to the concepts a viewpoint includes.
|
|
267
|
+
*
|
|
268
|
+
* ArchiMate viewpoints list element types only — `arch:includesConcept` never
|
|
269
|
+
* names a relationship type in the published data. Filtering relationships
|
|
270
|
+
* against an element-only list would empty the relationship section, so
|
|
271
|
+
* relationships are filtered only when the viewpoint actually names at least
|
|
272
|
+
* one of them. A viewpoint that names nothing at all leaves the palette
|
|
273
|
+
* untouched: `arch:includesConcept` is documented as a palette hint, not a
|
|
274
|
+
* restriction.
|
|
275
|
+
*/
|
|
276
|
+
filterByViewpoint(palette: PaletteDefinition, viewpointIri: string): PaletteDefinition {
|
|
277
|
+
const included = this.readViewpointConcepts(viewpointIri);
|
|
278
|
+
if (included.size === 0) return palette;
|
|
279
|
+
|
|
280
|
+
const elementGroups: ElementGroup[] = palette.elementGroups
|
|
281
|
+
.map((group) => ({ ...group, elements: group.elements.filter((e) => included.has(e.iri)) }))
|
|
282
|
+
.filter((group) => group.elements.length > 0);
|
|
283
|
+
|
|
284
|
+
const namedRelationships = palette.relationshipTypes.filter((r) => included.has(r.iri));
|
|
285
|
+
const relationshipTypes =
|
|
286
|
+
namedRelationships.length > 0 ? namedRelationships : palette.relationshipTypes;
|
|
287
|
+
|
|
288
|
+
return { ...palette, elementGroups, relationshipTypes };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ── Snapshot ─────────────────────────────────────────────────────────
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Copy the store's quads into an n3 `Store`.
|
|
295
|
+
*
|
|
296
|
+
* `taxonomy.ts` and `notation.ts` take an n3 `Store` — they are synchronous,
|
|
297
|
+
* unit-testable against hand-written Turtle, and independent of the
|
|
298
|
+
* application's RDF abstraction. Quads keep their graph term; n3 treats a
|
|
299
|
+
* `null` graph argument as a wildcard, which is what both modules pass, so
|
|
300
|
+
* per-document graphs stay visible without special handling.
|
|
301
|
+
*/
|
|
302
|
+
private snapshot(): Store {
|
|
303
|
+
// Over the application's store: the metamodel graphs read into a store, and
|
|
304
|
+
// the model's copy as it is — not copied into it too (Task 22). Not kept
|
|
305
|
+
// between palettes: the metamodels' quads held in JavaScript cost 100 MB.
|
|
306
|
+
const observed = this.store as RdfStore & { modelGraph?(): Store; namedGraphQuads?(): Quad[] };
|
|
307
|
+
if (observed.modelGraph && observed.namedGraphQuads) {
|
|
308
|
+
const named = new Store();
|
|
309
|
+
named.addQuads(observed.namedGraphQuads() as unknown as N3Quad[]);
|
|
310
|
+
return unionOf(named, observed.modelGraph());
|
|
311
|
+
}
|
|
312
|
+
const graph = new Store();
|
|
313
|
+
for (const q of this.store.getQuads()) {
|
|
314
|
+
// The application's Quad is @rdfjs/types-shaped and n3's addQuad wants its
|
|
315
|
+
// own term unions; the terms are the same objects (both come from n3's
|
|
316
|
+
// DataFactory), so the assertion is a typing bridge, not a conversion.
|
|
317
|
+
graph.addQuad(
|
|
318
|
+
q.subject as unknown as N3Quad['subject'],
|
|
319
|
+
q.predicate as unknown as N3Quad['predicate'],
|
|
320
|
+
q.object as unknown as N3Quad['object'],
|
|
321
|
+
q.graph as unknown as N3Quad['graph'],
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
return graph;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// ── Elements ─────────────────────────────────────────────────────────
|
|
328
|
+
|
|
329
|
+
/** The axis to group by: the requested one, else the taxonomy's preferred one. */
|
|
330
|
+
private pickAxis(axes: TaxonomyAxis[], axisIri?: string): TaxonomyAxis | undefined {
|
|
331
|
+
if (axisIri) {
|
|
332
|
+
const requested = axes.find((axis) => axis.iri === axisIri);
|
|
333
|
+
if (requested) return requested;
|
|
334
|
+
}
|
|
335
|
+
return axes[0];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* The active notation set: an explicit IRI, else the set a presentation
|
|
340
|
+
* context asks for, else the first of the loaded metamodels' default sets that
|
|
341
|
+
* has descriptors, else the graph's default (resolved inside
|
|
342
|
+
* `buildVisualNotations`).
|
|
343
|
+
*
|
|
344
|
+
* Taking the primary metamodel's set when the caller gives the load order is
|
|
345
|
+
* what makes the default deterministic with several metamodels loaded: the
|
|
346
|
+
* graph alone yields whichever `arch:notationSet` the store iterates first.
|
|
347
|
+
*/
|
|
348
|
+
/** The presentation context chosen — its name, and what it says every label says (its own label expression). */
|
|
349
|
+
private presentationContextOf(
|
|
350
|
+
graph: Store,
|
|
351
|
+
contextIri: string | undefined,
|
|
352
|
+
): Pick<PaletteDefinition, 'presentationContextIri' | 'presentationContextLabel' | 'presentationContextLabelExpression'> {
|
|
353
|
+
if (!contextIri) return {};
|
|
354
|
+
const expression = labelExpressionIn(labelExpressionsOf(graph, DataFactory.namedNode(contextIri)), contextIri);
|
|
355
|
+
return {
|
|
356
|
+
presentationContextIri: contextIri,
|
|
357
|
+
presentationContextLabel: presentationContextLabel(graph, contextIri),
|
|
358
|
+
...(expression !== undefined ? { presentationContextLabelExpression: expression } : {}),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private resolveNotationSet(graph: Store, options?: PaletteOptions): NotationSet | null {
|
|
363
|
+
if (options?.notationSetIri) return buildVisualNotations(graph, options.notationSetIri);
|
|
364
|
+
if (options?.presentationContextIri) {
|
|
365
|
+
const fromContext = resolveNotationSetForContext(graph, options.presentationContextIri);
|
|
366
|
+
if (fromContext) return buildVisualNotations(graph, fromContext);
|
|
367
|
+
}
|
|
368
|
+
for (const iri of options?.defaultNotationSetIris ?? []) {
|
|
369
|
+
const set = buildVisualNotations(graph, iri);
|
|
370
|
+
if (set) return set;
|
|
371
|
+
}
|
|
372
|
+
return buildVisualNotations(graph);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private toElementTypeInfo(
|
|
376
|
+
cls: SemanticClass,
|
|
377
|
+
groupingAxes: readonly string[],
|
|
378
|
+
standaloneAxes: readonly string[],
|
|
379
|
+
resolver: NotationResolver,
|
|
380
|
+
otherAxes: readonly string[] = [],
|
|
381
|
+
): ElementTypeInfo {
|
|
382
|
+
// The five-step lookup (module doc). Its `prefVisNotation` already applies
|
|
383
|
+
// the guide's fallback to the class's own arch:prefVisNotation.
|
|
384
|
+
const resolved = resolver.resolve(cls.iri);
|
|
385
|
+
const notation = resolved.notation;
|
|
386
|
+
const prefVisNotation = resolveUri(resolved.prefVisNotation);
|
|
387
|
+
const iconSymbol = resolveUri(notation?.style?.iconSymbol);
|
|
388
|
+
const style = styleWithResolvedIcon(notation);
|
|
389
|
+
|
|
390
|
+
// A class's section is its group under the active axis; one that axis does not classify takes its
|
|
391
|
+
// group under the next axis the palette grouping names — never another axis's on a guess — then the
|
|
392
|
+
// standalone group that lists it (Junction), then its group under a dimension the grouping does not name
|
|
393
|
+
// (another loaded metamodel's), else "Other". With no axis at all the taxonomy's own default group (its
|
|
394
|
+
// OWL-only fallback) is used.
|
|
395
|
+
const group =
|
|
396
|
+
groupingAxes.length > 0
|
|
397
|
+
? (sectionOf(cls, groupingAxes)?.group ??
|
|
398
|
+
standaloneAxes.map((iri) => cls.groupsByAxis[iri]).find(Boolean) ??
|
|
399
|
+
sectionOf(cls, otherAxes)?.group)
|
|
400
|
+
: cls.group;
|
|
401
|
+
|
|
402
|
+
return {
|
|
403
|
+
iri: cls.iri,
|
|
404
|
+
label: cls.label,
|
|
405
|
+
definition: cls.definition,
|
|
406
|
+
iconUrl: prefVisNotation?.url ?? iconSymbol?.url,
|
|
407
|
+
prefVisNotation,
|
|
408
|
+
iconSymbol,
|
|
409
|
+
style,
|
|
410
|
+
renderingMode: style ? effectiveRenderingMode(style) : undefined,
|
|
411
|
+
group: group || UNCATEGORIZED,
|
|
412
|
+
groupsByAxis: cls.groupsByAxis,
|
|
413
|
+
isAbstract: cls.isAbstract,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Bucket elements by their section. Sections come in the order of the axis that gave them — the active
|
|
419
|
+
* axis's first, then the next grouping axis's — each in its axis's order (its thesaurus array's), then
|
|
420
|
+
* by label; "Other" last. Within a section, elements follow their groups' order under the other grouping
|
|
421
|
+
* axes, then their labels.
|
|
422
|
+
*/
|
|
423
|
+
private groupElements(
|
|
424
|
+
elements: ElementTypeInfo[],
|
|
425
|
+
activeAxis: TaxonomyAxis | undefined,
|
|
426
|
+
groupingAxes: readonly string[],
|
|
427
|
+
classes: readonly SemanticClass[],
|
|
428
|
+
otherAxes: readonly string[] = [],
|
|
429
|
+
): ElementGroup[] {
|
|
430
|
+
const classOf = new Map(classes.map((cls) => [cls.iri, cls]));
|
|
431
|
+
const buckets = new Map<string, ElementTypeInfo[]>();
|
|
432
|
+
/** A section's place: which grouping axis gave it, and its rank there (the lowest of its classes'). */
|
|
433
|
+
const place = new Map<string, [number, number]>();
|
|
434
|
+
const LAST = Number.MAX_SAFE_INTEGER;
|
|
435
|
+
for (const element of elements) {
|
|
436
|
+
const category = element.group || UNCATEGORIZED;
|
|
437
|
+
const bucket = buckets.get(category);
|
|
438
|
+
if (bucket) bucket.push(element);
|
|
439
|
+
else buckets.set(category, [element]);
|
|
440
|
+
const cls = classOf.get(element.iri);
|
|
441
|
+
const section = cls && groupingAxes.length > 0 ? sectionOf(cls, groupingAxes) : undefined;
|
|
442
|
+
// A section from a dimension the grouping does not name comes after the grouping's, in that dimension's order.
|
|
443
|
+
const other = cls && !section && element.group !== UNCATEGORIZED ? sectionOf(cls, otherAxes) : undefined;
|
|
444
|
+
const here: [number, number] = section
|
|
445
|
+
? [section.axis, section.rank ?? LAST]
|
|
446
|
+
: other && other.group === element.group
|
|
447
|
+
? [groupingAxes.length + other.axis, other.rank ?? LAST]
|
|
448
|
+
: [LAST, LAST];
|
|
449
|
+
const before = place.get(category);
|
|
450
|
+
if (!before || here[0] < before[0] || (here[0] === before[0] && here[1] < before[1])) place.set(category, here);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Within a section: first the order its group gives its own members, where it gives one (an array under
|
|
454
|
+
// the group — ArchiMate 4.0's Common Domain: process, function, service, event…); then the groups' order
|
|
455
|
+
// under the other grouping axes (the aspects); then, after this, the label.
|
|
456
|
+
const withinKey = (element: ElementTypeInfo, sectionAxis: number): number[] => {
|
|
457
|
+
const cls = classOf.get(element.iri);
|
|
458
|
+
const own = groupingAxes[sectionAxis];
|
|
459
|
+
return [
|
|
460
|
+
own !== undefined ? (cls?.memberRanksByAxis?.[own] ?? LAST) : LAST,
|
|
461
|
+
...groupingAxes.filter((_, i) => i !== sectionAxis).map((axis) => cls?.ranksByAxis[axis] ?? LAST),
|
|
462
|
+
];
|
|
463
|
+
};
|
|
464
|
+
const compareKeys = (a: number[], b: number[]): number => {
|
|
465
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return (a[i] ?? LAST) - (b[i] ?? LAST);
|
|
466
|
+
return 0;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
return [...buckets.entries()]
|
|
470
|
+
.map(([category, groupElements]) => {
|
|
471
|
+
const sectionAxis = place.get(category)?.[0] ?? LAST;
|
|
472
|
+
return {
|
|
473
|
+
category,
|
|
474
|
+
axisIri: activeAxis?.iri,
|
|
475
|
+
elements: groupElements.sort(
|
|
476
|
+
(a, b) => compareKeys(withinKey(a, sectionAxis), withinKey(b, sectionAxis)) || a.label.localeCompare(b.label),
|
|
477
|
+
),
|
|
478
|
+
};
|
|
479
|
+
})
|
|
480
|
+
.sort((a, b) => {
|
|
481
|
+
if ((a.category === UNCATEGORIZED) !== (b.category === UNCATEGORIZED)) return a.category === UNCATEGORIZED ? 1 : -1;
|
|
482
|
+
const [axisA, rankA] = place.get(a.category) ?? [LAST, LAST];
|
|
483
|
+
const [axisB, rankB] = place.get(b.category) ?? [LAST, LAST];
|
|
484
|
+
return axisA - axisB || rankA - rankB || a.category.localeCompare(b.category);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// ── Relationships ────────────────────────────────────────────────────
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Relationship types: `owl:Class`es whose `rdfs:subClassOf+` closure reaches
|
|
492
|
+
* `arch:QualifiedRelationship`.
|
|
493
|
+
*
|
|
494
|
+
* `+` rather than `*` because the intermediate steps are real (ArchiMate's
|
|
495
|
+
* `Composition` subclasses `Aggregation`) and `arch:QualifiedRelationship`
|
|
496
|
+
* itself is not a relationship type. A legacy `?rel a arch:Relationship`
|
|
497
|
+
* typing is also accepted so hand-written metamodels keep working, even though
|
|
498
|
+
* the published ArchiMate 4.0 data never uses it.
|
|
499
|
+
*/
|
|
500
|
+
private discoverRelationships(
|
|
501
|
+
graph: Store,
|
|
502
|
+
resolver: NotationResolver,
|
|
503
|
+
superClassMap: Map<string, string[]>,
|
|
504
|
+
preferredLanguage: string,
|
|
505
|
+
): RelationshipTypeInfo[] {
|
|
506
|
+
const candidates = new Set<string>();
|
|
507
|
+
for (const [iri, supers] of superClassMap) {
|
|
508
|
+
if (supers.length === 0) continue;
|
|
509
|
+
if (closureOf(iri, superClassMap).includes(ARCH_QUALIFIED_RELATIONSHIP)) candidates.add(iri);
|
|
510
|
+
}
|
|
511
|
+
for (const subject of graph.getSubjects(
|
|
512
|
+
namedNode(RDF_TYPE),
|
|
513
|
+
namedNode(ARCH_RELATIONSHIP_LEGACY),
|
|
514
|
+
null,
|
|
515
|
+
)) {
|
|
516
|
+
if (subject.termType === 'NamedNode') candidates.add(subject.value);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const relationships: RelationshipTypeInfo[] = [];
|
|
520
|
+
|
|
521
|
+
for (const iri of candidates) {
|
|
522
|
+
if (iri === ARCH_QUALIFIED_RELATIONSHIP) continue;
|
|
523
|
+
if (isAbstractClass(graph, iri)) continue;
|
|
524
|
+
|
|
525
|
+
const unqualifiedPredicateIri = objectValue(graph, iri, ARCH_UNQUALIFIED_FORM);
|
|
526
|
+
|
|
527
|
+
// ArchiMate 4.0 hangs the constraints off the unqualified *property*
|
|
528
|
+
// (am4:serves), C4 repeats them on both; gather from each and dedupe.
|
|
529
|
+
const constraintSubjects = [iri, ...(unqualifiedPredicateIri ? [unqualifiedPredicateIri] : [])];
|
|
530
|
+
const domainTypes = uniqueInOrder(
|
|
531
|
+
constraintSubjects.flatMap((subject) => objectValues(graph, subject, ARCH_DOMAIN_INCLUDES)),
|
|
532
|
+
);
|
|
533
|
+
const rangeTypes = uniqueInOrder(
|
|
534
|
+
constraintSubjects.flatMap((subject) => objectValues(graph, subject, ARCH_RANGE_INCLUDES)),
|
|
535
|
+
);
|
|
536
|
+
|
|
537
|
+
// Same lookup as the elements. A descriptor carries a line colour only
|
|
538
|
+
// when it states one; with none the renderer draws black.
|
|
539
|
+
const resolved = resolver.resolve(iri);
|
|
540
|
+
const prefVisNotation = resolveUri(resolved.prefVisNotation);
|
|
541
|
+
|
|
542
|
+
relationships.push({
|
|
543
|
+
iri,
|
|
544
|
+
label: labelFor(graph, iri, preferredLanguage),
|
|
545
|
+
definition: definitionFor(graph, iri),
|
|
546
|
+
iconUrl: prefVisNotation?.url,
|
|
547
|
+
prefVisNotation,
|
|
548
|
+
relationshipStyle: resolved.notation?.relationshipStyle ?? unstyledRelationship(graph, unqualifiedPredicateIri),
|
|
549
|
+
domainTypes,
|
|
550
|
+
rangeTypes,
|
|
551
|
+
unqualifiedPredicateIri,
|
|
552
|
+
...(iri.startsWith(NAMESPACES.arch) ? { core: true } : {}),
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return relationships.sort((a, b) => a.label.localeCompare(b.label));
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// ── Viewpoints ───────────────────────────────────────────────────────
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* The concept IRIs a viewpoint names, and their subclasses — a viewpoint
|
|
563
|
+
* naming a class includes its subclasses, as `ViewpointManager` reads it.
|
|
564
|
+
*
|
|
565
|
+
* Read straight off the store rather than through SPARQL so the IRI never has
|
|
566
|
+
* to be interpolated into a query string.
|
|
567
|
+
*/
|
|
568
|
+
private readViewpointConcepts(viewpointIri: string): Set<string> {
|
|
569
|
+
const concepts = new Set<string>();
|
|
570
|
+
const subject = namedNode(viewpointIri);
|
|
571
|
+
for (const predicate of [
|
|
572
|
+
ARCH_INCLUDES_CONCEPT,
|
|
573
|
+
ARCH_PERMITS_ELEMENT,
|
|
574
|
+
ARCH_PERMITS_RELATIONSHIP,
|
|
575
|
+
]) {
|
|
576
|
+
for (const q of this.store.getQuads(subject, namedNode(predicate), null, null)) {
|
|
577
|
+
if (q.object.termType === 'NamedNode') concepts.add(q.object.value);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
// A Set visits what is added during iteration, so this walks the closure.
|
|
581
|
+
for (const iri of concepts) {
|
|
582
|
+
for (const q of this.store.getQuads(null, namedNode(RDFS_SUBCLASS_OF), namedNode(iri), null)) {
|
|
583
|
+
if (q.subject.termType === 'NamedNode') concepts.add(q.subject.value);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return concepts;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// ── Module-level graph helpers ──────────────────────────────────────────
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* The canvas's copy of the notation lookup (`PaletteDefinition.notationIndex`).
|
|
594
|
+
*
|
|
595
|
+
* Covers every class the graph declares, every class a consulted set describes
|
|
596
|
+
* (a set may describe a class whose ontology is not loaded) and the two roots;
|
|
597
|
+
* classes that resolve to nothing are left out, so the renderer's defaults
|
|
598
|
+
* apply. Each class's `arch:unqualifiedForm` predicate is added as an alias,
|
|
599
|
+
* because a model triple uses the predicate, never overwriting a class key.
|
|
600
|
+
* A predicate a class shares with its subclasses aliases the class: a bare
|
|
601
|
+
* `am4:accesses` triple is an `am4:Access`, not an `am4:ReadAccess`. Keys are
|
|
602
|
+
* visited in IRI order so a predicate unrelated classes share always aliases
|
|
603
|
+
* the same one.
|
|
604
|
+
*/
|
|
605
|
+
function buildNotationIndex(
|
|
606
|
+
graph: Store,
|
|
607
|
+
resolver: NotationResolver,
|
|
608
|
+
superClassMap: ReadonlyMap<string, readonly string[]>,
|
|
609
|
+
consultedSets: readonly NotationSet[],
|
|
610
|
+
): Record<string, NotationIndexEntry> {
|
|
611
|
+
const classes = new Set<string>([...superClassMap.keys(), ...NOTATION_ROOTS]);
|
|
612
|
+
for (const set of consultedSets) {
|
|
613
|
+
for (const conceptIri of set.notations.keys()) classes.add(conceptIri);
|
|
614
|
+
}
|
|
615
|
+
const ordered = [...classes].sort(compareIris);
|
|
616
|
+
|
|
617
|
+
const index = new Map<string, NotationIndexEntry>();
|
|
618
|
+
for (const iri of ordered) {
|
|
619
|
+
const entry = indexEntryFor(resolver.resolve(iri));
|
|
620
|
+
if (entry) index.set(iri, entry);
|
|
621
|
+
}
|
|
622
|
+
for (const iri of ordered) {
|
|
623
|
+
const entry = index.get(iri);
|
|
624
|
+
if (!entry) continue;
|
|
625
|
+
const predicate = objectValue(graph, iri, ARCH_UNQUALIFIED_FORM);
|
|
626
|
+
if (!predicate || index.has(predicate)) continue;
|
|
627
|
+
const inherited = closureOf(iri, superClassMap).some(
|
|
628
|
+
(superClass) => objectValue(graph, superClass, ARCH_UNQUALIFIED_FORM) === predicate,
|
|
629
|
+
);
|
|
630
|
+
if (!inherited) index.set(predicate, entry);
|
|
631
|
+
}
|
|
632
|
+
return Object.fromEntries(index);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** A resolved notation as index data, or `undefined` when nothing applies. */
|
|
636
|
+
function indexEntryFor(resolved: ResolvedNotation): NotationIndexEntry | undefined {
|
|
637
|
+
if (resolved.source === 'default') return undefined;
|
|
638
|
+
const style = styleWithResolvedIcon(resolved.notation);
|
|
639
|
+
const relationshipStyle = resolved.notation?.relationshipStyle;
|
|
640
|
+
return {
|
|
641
|
+
source: resolved.source,
|
|
642
|
+
...(resolved.notationSetIri ? { notationSetIri: resolved.notationSetIri } : {}),
|
|
643
|
+
...(resolved.matchedClassIri ? { matchedClassIri: resolved.matchedClassIri } : {}),
|
|
644
|
+
// The same derivation as a palette entry's `renderingMode`.
|
|
645
|
+
...(style ? { style, renderingMode: effectiveRenderingMode(style) } : {}),
|
|
646
|
+
...(relationshipStyle ? { relationshipStyle } : {}),
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* A descriptor's element style as renderers take it: the icon URL resolved to
|
|
652
|
+
* the bundled copy when there is one. The published URI stays available on the
|
|
653
|
+
* palette entry's `iconSymbol`.
|
|
654
|
+
*/
|
|
655
|
+
function styleWithResolvedIcon(notation: VisualNotation | undefined): VisualStyle | undefined {
|
|
656
|
+
if (!notation?.style) return undefined;
|
|
657
|
+
const iconSymbol = resolveUri(notation.style.iconSymbol);
|
|
658
|
+
return { ...notation.style, iconSymbol: iconSymbol?.url ?? notation.style.iconSymbol };
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* How a relationship type no notation describes is drawn (Req 2.25): it leads from its source to its target, so
|
|
663
|
+
* with an open arrowhead at the target — the links of an extension that publishes no notation (a decision's, a
|
|
664
|
+
* process's, an evaluation's) read by their direction. One whose direct predicate is symmetric
|
|
665
|
+
* (`owl:SymmetricProperty`: core's Association) has no direction, and is a plain line.
|
|
666
|
+
*/
|
|
667
|
+
function unstyledRelationship(graph: Store, unqualifiedPredicateIri: string | undefined): RelationshipVisualStyle | undefined {
|
|
668
|
+
const symmetric =
|
|
669
|
+
unqualifiedPredicateIri !== undefined &&
|
|
670
|
+
graph.getQuads(namedNode(unqualifiedPredicateIri), namedNode(RDF_TYPE), namedNode(OWL_SYMMETRIC_PROPERTY), null).length > 0;
|
|
671
|
+
return symmetric ? undefined : { lineStyle: 'SolidLine', targetDecor: 'OpenArrowhead' };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/** True when the class carries `arch:isAbstractClass true`. */
|
|
675
|
+
function isAbstractClass(graph: Store, iri: string): boolean {
|
|
676
|
+
return graph
|
|
677
|
+
.getObjects(namedNode(iri), namedNode(ARCH_IS_ABSTRACT_CLASS), null)
|
|
678
|
+
.some((term) => term.value === 'true');
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/** First object value for subject + predicate, whatever the term type. */
|
|
682
|
+
function objectValue(graph: Store, subjectIri: string, predicate: string): string | undefined {
|
|
683
|
+
for (const object of graph.getObjects(namedNode(subjectIri), namedNode(predicate), null)) {
|
|
684
|
+
return object.value;
|
|
685
|
+
}
|
|
686
|
+
return undefined;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/** All named-node object values for subject + predicate. */
|
|
690
|
+
function objectValues(graph: Store, subjectIri: string, predicate: string): string[] {
|
|
691
|
+
return graph
|
|
692
|
+
.getObjects(namedNode(subjectIri), namedNode(predicate), null)
|
|
693
|
+
.filter((term) => term.termType === 'NamedNode')
|
|
694
|
+
.map((term) => term.value);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Preferred RDF label, or the IRI fragment if the asset provides none. */
|
|
698
|
+
function labelFor(graph: Store, iri: string, preferredLanguage: string): string {
|
|
699
|
+
for (const predicate of [SKOS_PREF_LABEL, RDFS_LABEL]) {
|
|
700
|
+
const literal = selectLocalizedLiteral(graph.getObjects(namedNode(iri), namedNode(predicate), null), preferredLanguage);
|
|
701
|
+
if (literal) return literal.value;
|
|
702
|
+
}
|
|
703
|
+
return fragmentToLabel(iriFragment(iri));
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/** Definition: `skos:definition`, then `rdfs:comment`. */
|
|
707
|
+
function definitionFor(graph: Store, iri: string): string | undefined {
|
|
708
|
+
return objectValue(graph, iri, SKOS_DEFINITION) ?? objectValue(graph, iri, RDFS_COMMENT);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/** Pair a published URI with its bundled path, when this bundle ships one. */
|
|
712
|
+
/** {@link buildDecorationSymbols}, each symbol resolved to its bundled copy where there is one. */
|
|
713
|
+
function resolvedDecorationSymbols(graph: Store): Partial<Record<Decoration, ResolvedUri>> {
|
|
714
|
+
const resolved: Partial<Record<Decoration, ResolvedUri>> = {};
|
|
715
|
+
for (const [decoration, uri] of Object.entries(buildDecorationSymbols(graph)) as Array<[Decoration, string]>) {
|
|
716
|
+
const symbol = resolveUri(uri);
|
|
717
|
+
if (symbol) resolved[decoration] = symbol;
|
|
718
|
+
}
|
|
719
|
+
return resolved;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function resolveUri(sourceUri: string | undefined): ResolvedUri | undefined {
|
|
723
|
+
if (!sourceUri) return undefined;
|
|
724
|
+
const bundledPath = resolveIconUri(sourceUri) ?? undefined;
|
|
725
|
+
return { sourceUri, bundledPath, url: bundledPath ?? sourceUri };
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** Local name of an IRI: after the last `#`, or after the last `/`. */
|
|
729
|
+
function iriFragment(iri: string): string {
|
|
730
|
+
return iri.includes('#') ? iri.slice(iri.lastIndexOf('#') + 1) : iri.slice(iri.lastIndexOf('/') + 1);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/** Humanises a local name: `BusinessActor` becomes `Business Actor`. */
|
|
734
|
+
function fragmentToLabel(fragment: string): string {
|
|
735
|
+
return fragment
|
|
736
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
737
|
+
.replace(/[-_]/g, ' ')
|
|
738
|
+
.replace(/\s+/g, ' ')
|
|
739
|
+
.trim();
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function uniqueInOrder(items: string[]): string[] {
|
|
743
|
+
return [...new Set(items)];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Two stores read as one — what the palette's builders ask of a store
|
|
748
|
+
* (`getQuads`, `getObjects`, `getSubjects`) — without copying either.
|
|
749
|
+
*/
|
|
750
|
+
function unionOf(a: Store, b: Store): Store {
|
|
751
|
+
const distinct = <T extends { termType: string; value: string }>(terms: T[]): T[] => {
|
|
752
|
+
const seen = new Set<string>();
|
|
753
|
+
return terms.filter((t) => {
|
|
754
|
+
const key = `${t.termType}:${t.value}`;
|
|
755
|
+
if (seen.has(key)) return false;
|
|
756
|
+
seen.add(key);
|
|
757
|
+
return true;
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
type Args<K extends 'getQuads' | 'getObjects' | 'getSubjects'> = Parameters<Store[K]>;
|
|
761
|
+
return {
|
|
762
|
+
getQuads: (...args: Args<'getQuads'>) => [...a.getQuads(...args), ...b.getQuads(...args)],
|
|
763
|
+
getObjects: (...args: Args<'getObjects'>) => distinct([...a.getObjects(...args), ...b.getObjects(...args)]),
|
|
764
|
+
getSubjects: (...args: Args<'getSubjects'>) => distinct([...a.getSubjects(...args), ...b.getSubjects(...args)]),
|
|
765
|
+
} as unknown as Store;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Each relationship type's category: its group under a dimension that classifies relationship types — ArchiMate's
|
|
770
|
+
* Relationship, its groups Structural, Dependency, Dynamic and Other; the decision extension's Relationship Kind —
|
|
771
|
+
* or, for a kind of relationship the taxonomy does not list (ArchiMate 4.0's Read Access), its nearest superclass's.
|
|
772
|
+
* A dimension lists a type by its class, or by a concept that stands for it (`rdfs:seeAlso`: LeanIX's, BPMN's).
|
|
773
|
+
*
|
|
774
|
+
* Several metamodels are loaded, each with its own: a type takes its category from the dimension that lists it —
|
|
775
|
+
* of several, the one that lists the most relationship types: a dimension of element types may list one too (UML's
|
|
776
|
+
* state machine diagram lists Transition), and is not their classification. A group under no dimension (LeanIX's
|
|
777
|
+
* Relationship Type, BPMN's Connecting Objects) gives a category only beside a dimension that does: alone, the list
|
|
778
|
+
* stays as it is.
|
|
779
|
+
*
|
|
780
|
+
* The types come dimension by dimension — the one that lists the most first — in the order of each one's groups
|
|
781
|
+
* (its thesaurus array, ArchiMate's
|
|
782
|
+
* `:RelationshipOrder`), then by name; a type of no category after them. Within a category, the order of the array
|
|
783
|
+
* under it (ArchiMate's order of strength, weakest first), a kind just after the relationship it is a kind of, then
|
|
784
|
+
* by name. With no dimension classifying a relationship type, the list is as it was.
|
|
785
|
+
*/
|
|
786
|
+
function categoriseRelationships(
|
|
787
|
+
relationships: RelationshipTypeInfo[],
|
|
788
|
+
axes: readonly TaxonomyAxis[],
|
|
789
|
+
superClassMap: ReadonlyMap<string, readonly string[]>,
|
|
790
|
+
graph: Store,
|
|
791
|
+
): RelationshipTypeInfo[] {
|
|
792
|
+
const types = new Set(relationships.map((rel) => rel.iri));
|
|
793
|
+
/** The relationship type a member of a dimension is, or stands for. */
|
|
794
|
+
const typeOf = (member: string): string | undefined => {
|
|
795
|
+
if (types.has(member)) return member;
|
|
796
|
+
const linked = [
|
|
797
|
+
...graph.getObjects(namedNode(member), namedNode(RDFS_SEE_ALSO), null),
|
|
798
|
+
...graph.getSubjects(namedNode(RDFS_SEE_ALSO), namedNode(member), null),
|
|
799
|
+
];
|
|
800
|
+
return linked.find((term) => types.has(term.value))?.value;
|
|
801
|
+
};
|
|
802
|
+
/** Per dimension that lists a relationship type: the member that lists each type. */
|
|
803
|
+
const listing = axes
|
|
804
|
+
.map((axis) => {
|
|
805
|
+
const members = new Map<string, string>();
|
|
806
|
+
for (const member of axis.groups.keys()) {
|
|
807
|
+
const type = typeOf(member);
|
|
808
|
+
if (type !== undefined && !members.has(type)) members.set(type, member);
|
|
809
|
+
}
|
|
810
|
+
return { axis, members };
|
|
811
|
+
})
|
|
812
|
+
.filter(({ members }) => members.size > 0)
|
|
813
|
+
// The dimension that lists the most first: a metamodel's own relationship types before those of one it
|
|
814
|
+
// imports (LeanIX's before the processes extension's).
|
|
815
|
+
.sort((a, b) => b.members.size - a.members.size);
|
|
816
|
+
const dimensions = listing.some(({ axis }) => !axis.standalone) ? listing : [];
|
|
817
|
+
if (dimensions.length === 0) return relationships;
|
|
818
|
+
|
|
819
|
+
const LAST = Number.MAX_SAFE_INTEGER;
|
|
820
|
+
const placed = relationships.map((rel) => {
|
|
821
|
+
const chain = [rel.iri, ...superClassesNearestFirst(rel.iri, superClassMap)];
|
|
822
|
+
let best: { at: number; listed: string; member: string; size: number } | undefined;
|
|
823
|
+
dimensions.forEach(({ members }, at) => {
|
|
824
|
+
const listed = chain.find((iri) => members.has(iri));
|
|
825
|
+
if (listed !== undefined && (!best || members.size > best.size)) {
|
|
826
|
+
best = { at, listed, member: members.get(listed) as string, size: members.size };
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
if (!best) return { rel, at: LAST, rank: LAST, memberRank: LAST, isKind: 0 };
|
|
830
|
+
const { axis } = dimensions[best.at]!;
|
|
831
|
+
const category = axis.groups.get(best.member);
|
|
832
|
+
return {
|
|
833
|
+
rel: category ? { ...rel, category } : rel,
|
|
834
|
+
at: best.at,
|
|
835
|
+
rank: axis.ranks.get(best.member) ?? LAST - 1,
|
|
836
|
+
// Within its category: the category's own array (ArchiMate's order of strength), a kind just after the
|
|
837
|
+
// relationship it is a kind of, then by name.
|
|
838
|
+
memberRank: axis.memberRanks?.get(best.member) ?? LAST,
|
|
839
|
+
isKind: best.listed !== rel.iri ? 1 : 0,
|
|
840
|
+
};
|
|
841
|
+
});
|
|
842
|
+
return placed
|
|
843
|
+
.sort(
|
|
844
|
+
(a, b) =>
|
|
845
|
+
a.at - b.at ||
|
|
846
|
+
a.rank - b.rank ||
|
|
847
|
+
(a.rel.category ?? '').localeCompare(b.rel.category ?? '') ||
|
|
848
|
+
a.memberRank - b.memberRank ||
|
|
849
|
+
a.isKind - b.isKind ||
|
|
850
|
+
a.rel.label.localeCompare(b.rel.label),
|
|
851
|
+
)
|
|
852
|
+
.map(({ rel }) => rel);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* A class's palette section under the grouping axes, the active one first: its group under the first of them
|
|
857
|
+
* that classifies it, which axis that is (its index) and its rank there; none when none does.
|
|
858
|
+
*/
|
|
859
|
+
function sectionOf(
|
|
860
|
+
cls: SemanticClass,
|
|
861
|
+
groupingAxes: readonly string[],
|
|
862
|
+
): { group: string; axis: number; rank?: number } | undefined {
|
|
863
|
+
for (let axis = 0; axis < groupingAxes.length; axis++) {
|
|
864
|
+
const iri = groupingAxes[axis]!;
|
|
865
|
+
const group = cls.groupsByAxis[iri];
|
|
866
|
+
if (group) return { group, axis, ...(cls.ranksByAxis[iri] !== undefined ? { rank: cls.ranksByAxis[iri] } : {}) };
|
|
867
|
+
}
|
|
868
|
+
return undefined;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** An axis's group labels: in the axis's order where it has one (by the lowest rank of their members), then by label. */
|
|
872
|
+
function groupsInOrder(axis: TaxonomyAxis): string[] {
|
|
873
|
+
const rank = new Map<string, number>();
|
|
874
|
+
for (const [member, label] of axis.groups) {
|
|
875
|
+
const r = axis.ranks.get(member);
|
|
876
|
+
if (r !== undefined) rank.set(label, Math.min(rank.get(label) ?? r, r));
|
|
877
|
+
}
|
|
878
|
+
const LAST = Number.MAX_SAFE_INTEGER;
|
|
879
|
+
return uniqueInOrder([...axis.groups.values()]).sort(
|
|
880
|
+
(a, b) => (rank.get(a) ?? LAST) - (rank.get(b) ?? LAST) || a.localeCompare(b),
|
|
881
|
+
);
|
|
882
|
+
}
|