Skip to content

Commit 082d0b5

Browse files
committed
Add "type_designator_mapping" slot.
Add a new `type_designator_mapping` slot. That slot is intended to be used in a slot_definition for a slot that is set as the type designator slot for the class it belongs to. It allows to define custom mappings to match a type designator value with the type to be designated. Such mappings can be used to provide more ways to reference a given class in a type designator value (beyond the default way of using the class name, URI, or CURIE). It also allows to provide a "fallback" mechanism, by which a loader or validator can be made to accept an otherwise unrecognised designated type, through the use of "wildcards" (shell-like patterns). This implements the idea evoked in linkml/linkml#3701.
1 parent 986c788 commit 082d0b5

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

linkml_model/model/schema/meta.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,39 @@ slots:
19341934
- SpecificationSubset
19351935
see_also:
19361936
- https://linkml.io/linkml/schemas/type-designators.html
1937+
- linkml:type_designator_mapping
1938+
1939+
type_designator_mapping:
1940+
domain: slot_definition
1941+
range: designated_type_mapping
1942+
multivalued: true
1943+
inlined: true
1944+
inlined_as_list: false
1945+
inherited: true
1946+
description: >-
1947+
Additional mappings between type designator values and instantiation types.
1948+
1949+
Mappings defined here are taken into account after a type designator value failed to match the
1950+
name, URI, or CURIE of any known subclass of the class carrying the type designator slot.
1951+
comments:
1952+
- This slot only makes sense for a slot that is a type designator slot.
1953+
examples:
1954+
- object:
1955+
foo: FooClass
1956+
bar: BarClass
1957+
"*": FallbackClass
1958+
description: >-
1959+
Assuming FooClass, BarClass, and FallbackClass all refers to classes that are compatible
1960+
with the base class carrying the type designator slot, this example would allow to use
1961+
'foo' to designate an instance of FooClass and 'bar' to designate an instance of BarClass;
1962+
in addition, any unrecognised type name is to be interpreted as designating an instance of
1963+
FallbackClass.
1964+
in_subset:
1965+
- SpecificationSubset
1966+
see_also:
1967+
- https://linkml.io/linkml/schemas/type-designators.html
1968+
- linkml:designates_type
1969+
- linkml:designated_type_mapping
19371970

19381971
alias:
19391972
rank: 6
@@ -3332,6 +3365,33 @@ classes:
33323365
range_expression:
33333366
range: anonymous_slot_expression
33343367

3368+
designated_type_mapping:
3369+
description: >-
3370+
A custom mapping between a pattern and a class definition.
3371+
attributes:
3372+
pattern:
3373+
description: >-
3374+
The pattern to map to a class definition.
3375+
3376+
This is a shell-like pattern, where '*' represents any substring (including an
3377+
empty string) and '?' represents any character.
3378+
3379+
If the value found in a type designator slot (1) matches the pattern and
3380+
(2) does not match any longer pattern in the same 'type_designator_mapping'
3381+
map, then the object carrying the type designator value is to be treated as
3382+
an instance of the class associated to the pattern.
3383+
range: string
3384+
key: true
3385+
designated_type:
3386+
description: >-
3387+
The class to associate to the pattern.
3388+
3389+
It must be a class that is compatible with the base class that is carrying the
3390+
type designator slot (that is, it must either be that class or a subclass of it).
3391+
range: class_definition
3392+
see_also:
3393+
- linkml:type_designator_mapping
3394+
33353395

33363396
# ==================================
33373397
# Enumerations #

0 commit comments

Comments
 (0)