|
40 | 40 | TypeDefinition, |
41 | 41 | TypeDefinitionName, |
42 | 42 | ) |
| 43 | +from linkml_runtime.processing import inlining |
43 | 44 | from linkml_runtime.utils.context_utils import map_import, parse_import_map |
44 | 45 | from linkml_runtime.utils.formatutils import camelcase, is_empty, sfx, underscore |
45 | 46 | from linkml_runtime.utils.namespaces import Namespaces |
@@ -1491,6 +1492,7 @@ def induced_slot( |
1491 | 1492 | :param imports: include imports closure |
1492 | 1493 | :return: dynamic slot constructed by inference |
1493 | 1494 | """ |
| 1495 | + # print(f"inducing {slot_name}") |
1494 | 1496 | if class_name: |
1495 | 1497 | cls = self.get_class(class_name, imports, strict=True) |
1496 | 1498 | else: |
@@ -1566,8 +1568,7 @@ def induced_slot( |
1566 | 1568 | v = self.schema.default_range |
1567 | 1569 | if v is not None: |
1568 | 1570 | setattr(induced_slot, metaslot_name, v) |
1569 | | - if slot.inlined_as_list: |
1570 | | - slot.inlined = True |
| 1571 | + slot.inlined, slot.inlined_as_list = inlining.process(induced_slot, self.schema_map, logger) |
1571 | 1572 | if slot.identifier or slot.key: |
1572 | 1573 | slot.required = True |
1573 | 1574 | if mangle_name: |
@@ -1696,16 +1697,27 @@ def is_inlined(self, slot: SlotDefinition, imports: bool = True) -> bool: |
1696 | 1697 | range = slot.range |
1697 | 1698 | if range in self.all_classes(): |
1698 | 1699 | if slot.inlined or slot.inlined_as_list: |
| 1700 | + # print(f"is_inlined({slot.name}) -> True") |
1699 | 1701 | return True |
1700 | 1702 |
|
1701 | 1703 | id_slot = self.get_identifier_slot(range, imports=imports) |
1702 | 1704 | if id_slot is None: |
1703 | 1705 | # must be inlined as has no identifier |
| 1706 | + # print(f"is_inlined({slot.name}) -> True") |
1704 | 1707 | return True |
1705 | 1708 | # not explicitly declared inline and has an identifier: assume is ref, not inlined |
| 1709 | + # print(f"is_inlined({slot.name}) -> False") |
1706 | 1710 | return False |
| 1711 | + # print(f"is_inlined({slot.name}) -> False") |
1707 | 1712 | return False |
1708 | 1713 |
|
| 1714 | + result = inlining.is_inlined(slot, self.schema_map, logger) |
| 1715 | + print(f"is_inlined({slot.name}) -> {result}") |
| 1716 | + # if slot.name == "a_thing_without_id": |
| 1717 | + # result = True |
| 1718 | + return result |
| 1719 | + return inlining.is_inlined(slot, self.schema_map, logger) |
| 1720 | + |
1709 | 1721 | def slot_applicable_range_elements(self, slot: SlotDefinition) -> list[ClassDefinitionName]: |
1710 | 1722 | """Retrieve all applicable metamodel elements for a slot range. |
1711 | 1723 |
|
@@ -2060,13 +2072,7 @@ def materialize_derived_schema(self) -> SchemaDefinition: |
2060 | 2072 | if metaslot_val is not None: |
2061 | 2073 | setattr(slot, metaslot, metaslot_val) |
2062 | 2074 | slot_range_pk_slot_name = None |
2063 | | - if isinstance(slot_range_element, ClassDefinition): |
2064 | | - slot_range_pk_slot_name = self.get_identifier_slot(slot_range_element.name, use_key=True) |
2065 | | - if not slot_range_pk_slot_name: |
2066 | | - slot.inlined = True |
2067 | | - slot.inlined_as_list = True |
2068 | | - if slot.inlined_as_list: |
2069 | | - slot.inlined = True |
| 2075 | + slot.inlined, slot.inlined_as_list = inlining.process(slot, self.schema_map, logger) |
2070 | 2076 | if slot.identifier or slot.key: |
2071 | 2077 | slot.required = True |
2072 | 2078 | cls.attributes[slot.name] = slot |
|
0 commit comments