Skip to content

Commit cc376f4

Browse files
committed
feat(schemaview): use inlining processor
Use created module to process object inlining. Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
1 parent f185a7a commit cc376f4

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

linkml_runtime/utils/schemaview.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
TypeDefinition,
4141
TypeDefinitionName,
4242
)
43+
from linkml_runtime.processing import inlining
4344
from linkml_runtime.utils.context_utils import map_import, parse_import_map
4445
from linkml_runtime.utils.formatutils import camelcase, is_empty, sfx, underscore
4546
from linkml_runtime.utils.namespaces import Namespaces
@@ -1491,6 +1492,7 @@ def induced_slot(
14911492
:param imports: include imports closure
14921493
:return: dynamic slot constructed by inference
14931494
"""
1495+
# print(f"inducing {slot_name}")
14941496
if class_name:
14951497
cls = self.get_class(class_name, imports, strict=True)
14961498
else:
@@ -1566,8 +1568,7 @@ def induced_slot(
15661568
v = self.schema.default_range
15671569
if v is not None:
15681570
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)
15711572
if slot.identifier or slot.key:
15721573
slot.required = True
15731574
if mangle_name:
@@ -1696,16 +1697,27 @@ def is_inlined(self, slot: SlotDefinition, imports: bool = True) -> bool:
16961697
range = slot.range
16971698
if range in self.all_classes():
16981699
if slot.inlined or slot.inlined_as_list:
1700+
# print(f"is_inlined({slot.name}) -> True")
16991701
return True
17001702

17011703
id_slot = self.get_identifier_slot(range, imports=imports)
17021704
if id_slot is None:
17031705
# must be inlined as has no identifier
1706+
# print(f"is_inlined({slot.name}) -> True")
17041707
return True
17051708
# not explicitly declared inline and has an identifier: assume is ref, not inlined
1709+
# print(f"is_inlined({slot.name}) -> False")
17061710
return False
1711+
# print(f"is_inlined({slot.name}) -> False")
17071712
return False
17081713

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+
17091721
def slot_applicable_range_elements(self, slot: SlotDefinition) -> list[ClassDefinitionName]:
17101722
"""Retrieve all applicable metamodel elements for a slot range.
17111723
@@ -2060,13 +2072,7 @@ def materialize_derived_schema(self) -> SchemaDefinition:
20602072
if metaslot_val is not None:
20612073
setattr(slot, metaslot, metaslot_val)
20622074
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)
20702076
if slot.identifier or slot.key:
20712077
slot.required = True
20722078
cls.attributes[slot.name] = slot

0 commit comments

Comments
 (0)