Class ClassDefinitionConverter
- All Implemented Interfaces:
IConverter
ClassDefinition
objects.
We need a subclass for ClassDefinition objects because class
definitions purposefully violate the unicity constraint of the
SlotDefinition class. A slot definition is supposed to be a unique
object (only one object with the same name can exist in the global context).
But several classes can have an attribute with the same name, that should not
imply that they share the same attribute! (In fact, one of the reasons for
the concept of attributes is precisely so that classes can have “local slots”
– slots whose definition has no impact outside of the declaring class.
Therefore, within a LinkML schema, there may very well be several
SlotDefinition objects with the same name: one global slot at most,
plus an arbitrary number of class-specific attributes.
In LinkML-Py, this violation of the unicity constraint is apparently managed
by prepending the name of the declaring class to the name of the attribute,
as in class__slotname, so that all slot definitions (including
definitions of class-specific attributes) are globally unique.
The approach adopted here is simply not to put the attribute
definitions in the global context at all, so that they are really specific to
the class in which they are defined. But this requires overriding the default
behaviour of the ObjectConverter, which puts all unique objects (that
is, all instances of classes that have an identifier slot) in the global
context.
Likewise for the SlotDefinition objects found in the
slot_usage section: they are really local to the class and
should not be treated as global objects.
-
Field Summary
Fields inherited from class ObjectConverter
klass -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class ObjectConverter
convert, convert, convert, convertForSlot, convertTo, getGlobalIdentifier, getGlobalIdentifierList, getType, normaliseList, serialise, serialise, serialiseForSlot, toIdentifier, toList, toMap
-
Constructor Details
-
ClassDefinitionConverter
public ClassDefinitionConverter()
-
-
Method Details
-
convertTo
public void convertTo(Map<String, Object> rawMap, Object dest, ConverterContext ctx) throws LinkMLRuntimeExceptionDescription copied from class:ObjectConverterConverts a raw map into an instance of a LinkML object, where the object already exists.- Overrides:
convertToin classObjectConverter- Parameters:
rawMap- The raw map to convert.dest- The instance of the LinkML object whose slots should be filled with values from the raw map.ctx- The global converter context.- Throws:
LinkMLRuntimeException- If a slot of thedestobject cannot be assigned.
-