|
39 | 39 | TypeDefinition, |
40 | 40 | TypeDefinitionName, |
41 | 41 | ) |
| 42 | +from linkml_runtime.processing import inlining |
42 | 43 | from linkml_runtime.utils.context_utils import map_import, parse_import_map |
43 | 44 | from linkml_runtime.utils.formatutils import camelcase, is_empty, sfx, underscore |
44 | 45 | from linkml_runtime.utils.namespaces import Namespaces |
@@ -1474,6 +1475,7 @@ def induced_slot( |
1474 | 1475 | :param imports: include imports closure |
1475 | 1476 | :return: dynamic slot constructed by inference |
1476 | 1477 | """ |
| 1478 | + # print(f"inducing {slot_name}") |
1477 | 1479 | if class_name: |
1478 | 1480 | cls = self.get_class(class_name, imports, strict=True) |
1479 | 1481 | else: |
@@ -1549,8 +1551,7 @@ def induced_slot( |
1549 | 1551 | v = self.schema.default_range |
1550 | 1552 | if v is not None: |
1551 | 1553 | setattr(induced_slot, metaslot_name, v) |
1552 | | - if slot.inlined_as_list: |
1553 | | - slot.inlined = True |
| 1554 | + slot.inlined, slot.inlined_as_list = inlining.process(induced_slot, self.schema_map, logger) |
1554 | 1555 | if slot.identifier or slot.key: |
1555 | 1556 | slot.required = True |
1556 | 1557 | if mangle_name: |
@@ -1679,16 +1680,27 @@ def is_inlined(self, slot: SlotDefinition, imports: bool = True) -> bool: |
1679 | 1680 | range = slot.range |
1680 | 1681 | if range in self.all_classes(): |
1681 | 1682 | if slot.inlined or slot.inlined_as_list: |
| 1683 | + # print(f"is_inlined({slot.name}) -> True") |
1682 | 1684 | return True |
1683 | 1685 |
|
1684 | 1686 | id_slot = self.get_identifier_slot(range, imports=imports) |
1685 | 1687 | if id_slot is None: |
1686 | 1688 | # must be inlined as has no identifier |
| 1689 | + # print(f"is_inlined({slot.name}) -> True") |
1687 | 1690 | return True |
1688 | 1691 | # not explicitly declared inline and has an identifier: assume is ref, not inlined |
| 1692 | + # print(f"is_inlined({slot.name}) -> False") |
1689 | 1693 | return False |
| 1694 | + # print(f"is_inlined({slot.name}) -> False") |
1690 | 1695 | return False |
1691 | 1696 |
|
| 1697 | + result = inlining.is_inlined(slot, self.schema_map, logger) |
| 1698 | + print(f"is_inlined({slot.name}) -> {result}") |
| 1699 | + # if slot.name == "a_thing_without_id": |
| 1700 | + # result = True |
| 1701 | + return result |
| 1702 | + return inlining.is_inlined(slot, self.schema_map, logger) |
| 1703 | + |
1692 | 1704 | def slot_applicable_range_elements(self, slot: SlotDefinition) -> list[ClassDefinitionName]: |
1693 | 1705 | """Retrieve all applicable metamodel elements for a slot range. |
1694 | 1706 |
|
@@ -2043,13 +2055,7 @@ def materialize_derived_schema(self) -> SchemaDefinition: |
2043 | 2055 | if metaslot_val is not None: |
2044 | 2056 | setattr(slot, metaslot, metaslot_val) |
2045 | 2057 | slot_range_pk_slot_name = None |
2046 | | - if isinstance(slot_range_element, ClassDefinition): |
2047 | | - slot_range_pk_slot_name = self.get_identifier_slot(slot_range_element.name, use_key=True) |
2048 | | - if not slot_range_pk_slot_name: |
2049 | | - slot.inlined = True |
2050 | | - slot.inlined_as_list = True |
2051 | | - if slot.inlined_as_list: |
2052 | | - slot.inlined = True |
| 2058 | + slot.inlined, slot.inlined_as_list = inlining.process(slot, self.schema_map, logger) |
2053 | 2059 | if slot.identifier or slot.key: |
2054 | 2060 | slot.required = True |
2055 | 2061 | cls.attributes[slot.name] = slot |
|
0 commit comments