Class SchemaDefinitionConverter

  • All Implemented Interfaces:
    IConverter

    public class SchemaDefinitionConverter
    extends ObjectConverter
    A converter object specifically intended to convert SchemaDefinition objects.

    A special converter is needed because LinkML’s own meta-schema violates the unicity constraint of the Element class with its schema names.

    The SchemaDefinition class, like all “schema elements” (e.g. SlotDefinition, ClassDefinition, etc.), is a subclass of the Element class, which is the class that carries, among other slots, the identifier slot (name). This means that schema elements share the same identifier namespace.

    This sharing of a single identifier namespace is needed, because that’s what ensures that we cannot have, for example, a ClassDefinition with the same name than a SlotDefinition (if this could happen, then we would have no way of knowing whether the range of a slot refers to the class definition or to the type definition).

    But LinkML’s own meta-schema violates the unicity constraint in several places, seemingly behaving as if the name of a schema was either not an identifier, or at least an identifier that does not live in the same namespace than all the other schema elements. This results in several conflicts where the name of a schema (that is imported by LinkML’s root schema) happens to be the same as the name of another element. For example, the name of the types schema conflicts with the name of the types slot, and the name of the mappings schema conflicts with the name of the mappings slots.

    So here, we work around that issue by basically not treating SchemaDefinition objects as global objects. There should be no cases where we might need to query a schema by its name in the cache, so we can behave as if a schema definition was a non-identifiable object (which seems to be what LinkML-Py is doing).

    • Constructor Detail

      • SchemaDefinitionConverter

        public SchemaDefinitionConverter()
    • Method Detail

      • convert

        public Object convert​(Map<String,​Object> raw,
                              String id,
                              ConverterContext ctx)
                       throws LinkMLRuntimeException
        Description copied from class: ObjectConverter
        Converts a raw map into a new instance of a LinkML object.
        Overrides:
        convert in class ObjectConverter
        Parameters:
        raw - The raw map to convert.
        id - The global identifier of the new object. May be null if the object is not a “ globally identifiable” object (it has no identifier slot).
        ctx - The global converter context.
        Returns:
        The newly created object.
        Throws:
        LinkMLRuntimeException - If the object cannot be created, or one of its slots cannot be assigned.