@@ -354,9 +354,10 @@ def get_node_by_uid_weak2(self, uid: str):
354354
355355 def get_linkable_node_by_uid (
356356 self , uid
357- ) -> Union [SDocNode , SDocSection , Anchor ]:
357+ ) -> Union [SDocDocument , SDocNode , SDocSection , Anchor ]:
358358 return assert_cast (
359- self .get_node_by_uid (uid ), (SDocNode , SDocSection , Anchor )
359+ self .get_node_by_uid (uid ),
360+ (SDocDocument , SDocNode , SDocSection , Anchor ),
360361 )
361362
362363 def get_node_by_uid_weak (
@@ -383,16 +384,16 @@ def get_node_by_uid_weak(
383384
384385 def get_linkable_node_by_uid_weak (
385386 self , uid
386- ) -> Union [SDocNode , SDocSection , Anchor , None ]:
387+ ) -> Union [SDocDocument , SDocNode , SDocSection , Anchor , None ]:
387388 return assert_optional_cast (
388389 self .graph_database .get_link_value_weak (
389390 link_type = GraphLinkType .UID_TO_NODE , lhs_node = uid
390391 ),
391- (SDocNode , SDocSection , Anchor ),
392+ (SDocDocument , SDocNode , SDocSection , Anchor ),
392393 )
393394
394395 def get_incoming_links (
395- self , node : Union [SDocNode , SDocSection , Anchor ]
396+ self , node : Union [SDocDocument , SDocNode , SDocSection , Anchor ]
396397 ) -> Optional [List [InlineLink ]]:
397398 incoming_links = self .graph_database .get_link_values_weak (
398399 link_type = GraphLinkType .NODE_TO_INCOMING_LINKS ,
@@ -448,6 +449,20 @@ def create_traceability_info(
448449 source_file_rel_path , traceability_info , traceability_index
449450 )
450451
452+ def create_document (self , document : SDocDocument ) -> None :
453+ assert isinstance (document , SDocDocument )
454+ if document .reserved_uid is not None :
455+ self .graph_database .create_link (
456+ link_type = GraphLinkType .UID_TO_NODE ,
457+ lhs_node = document .reserved_uid ,
458+ rhs_node = document ,
459+ )
460+ self .graph_database .create_link (
461+ link_type = GraphLinkType .MID_TO_NODE ,
462+ lhs_node = document .reserved_mid ,
463+ rhs_node = document ,
464+ )
465+
451466 def create_section (self , section : SDocSection ) -> None :
452467 assert isinstance (section , SDocSection )
453468 if section .reserved_uid is not None :
@@ -469,12 +484,14 @@ def create_inline_link(self, new_link: InlineLink):
469484 if self .graph_database .has_link (
470485 link_type = GraphLinkType .UID_TO_NODE , lhs_node = new_link .link
471486 ):
472- node_or_anchor : Union [SDocNode , SDocSection , Anchor ] = assert_cast (
487+ node_or_anchor : Union [
488+ SDocDocument , SDocNode , SDocSection , Anchor
489+ ] = assert_cast (
473490 self .graph_database .get_link_value (
474491 link_type = GraphLinkType .UID_TO_NODE ,
475492 lhs_node = new_link .link ,
476493 ),
477- (SDocNode , SDocSection , Anchor ),
494+ (SDocDocument , SDocNode , SDocSection , Anchor ),
478495 )
479496 self .graph_database .create_link (
480497 link_type = GraphLinkType .NODE_TO_INCOMING_LINKS ,
@@ -767,6 +784,21 @@ def update_disconnect_two_documents_if_no_links_left(
767784 rhs_node = document .reserved_mid ,
768785 )
769786
787+ def delete_document (self , document : SDocDocument ) -> None :
788+ assert isinstance (document , SDocDocument ), document
789+
790+ self .graph_database .delete_link (
791+ link_type = GraphLinkType .MID_TO_NODE ,
792+ lhs_node = document .reserved_mid ,
793+ rhs_node = document ,
794+ )
795+ if document .reserved_uid is not None :
796+ self .graph_database .delete_link (
797+ link_type = GraphLinkType .UID_TO_NODE ,
798+ lhs_node = document .reserved_uid ,
799+ rhs_node = document ,
800+ )
801+
770802 def delete_section (self , section : SDocSection ) -> None :
771803 assert isinstance (section , SDocSection ), section
772804
0 commit comments