package Ġcom . so yle . stories . use case . location . rename Location Ċ Ċ import Ġcom . so yle . stories . domain . location . Location Ċ import Ġcom . so yle . stories . domain . location . events . Location Rename d Ċ import Ġcom . so yle . stories . domain . pro se . events . Mention Text Re placed Ċ import Ġcom . so yle . stories . domain . pro se . mention ed Ċ import Ġcom . so yle . stories . domain . scene . Updated Ċ import Ġcom . so yle . stories . domain . scene . events . Scene Setting Location Rename d Ċ import Ġcom . so yle . stories . domain . validation . Single Non Blank Line Ċ import Ġcom . so yle . stories . use case . location . Location Repository Ċ import Ġcom . so yle . stories . use case . pro se . Pro se Repository Ċ import Ġcom . so yle . stories . use case . scene . Scene Repository Ċ Ċ class ĠRename Location UseCase ( ĊĠ Ġprivate Ġval Ġlocation Repository : ĠLocation Repository , ĊĠ Ġprivate Ġval Ġpro se Repository : ĠPro se Repository , ĊĠ Ġprivate Ġval Ġscene Repository : ĠScene Repository Ċ ) Ġ: ĠRename Location Ġ{ ĊĊ ĉ override Ġsuspend Ġfun Ġinvoke ( id : ĠLocation . Id , Ġname : ĠSingle Non Blank Line , Ġoutput : ĠRename Location . Output Port ) Ġ{ Ċĉ ĉ val Ġlocation Ġ= Ġlocation Repository . getLocation Or Error ( id ) Ċĉ ĉ val Ġresponse Model Ġ= Ġupdate If Names Are Different ( name , Ġlocation ) Ġ?: Ġreturn Ċĉ ĉ output . receive Rename Location Response ( response Model ) Ċ ĉ } ĊĊ ĉ private Ġsuspend Ġfun Ġupdate If Names Are Different ( Ċĉ ĉ name : ĠSingle Non Blank Line , Ċĉ ĉ location : ĠLocation Ċ ĉ ): ĠRename Location . Response Model ? Ġ{ Ċĉ ĉ return Ġif Ġ( name Ġ!= Ġlocation . name ) Ġ{ Ċĉĉ ĉ Rename Location . Response Model ( Ċĉĉĉ ĉ update Location Name ( location , Ġname ), Ċĉĉĉ ĉ update Pro se That Mention Location ( location , Ġname ), Ċĉĉĉ ĉ update Sc enes That Use Location ( location , Ġname ) Ċĉĉ ĉ ) Ċĉ ĉ } Ċĉ ĉ else Ġnull Ċ ĉ } ĊĊ ĉ private Ġsuspend Ġfun Ġupdate Location Name ( location : ĠLocation , Ġname : ĠSingle Non Blank Line ): ĠLocation Rename d Ġ{ Ċĉ ĉ location Repository . update Location ( location . with Name ( name ). location ) Ċĉ ĉ return ĠLocation Rename d ( location . id , Ġname . value ) Ċ ĉ } ĊĊ ĉ private Ġsuspend Ġfun Ġupdate Pro se That Mention Location ( Ċĉ ĉ location : ĠLocation , Ċĉ ĉ new Name : ĠSingle Non Blank Line Ċ ĉ ): ĠList < Mention Text Re placed > Ġ{ Ċĉ ĉ val Ġlocation EntityId Ġ= Ġlocation . id . mention ed () Ċĉ ĉ val Ġupdated Pro se Ġ= Ġpro se Repository . get Pro se That Mention Entity ( location EntityId ). map Ġ{ Ċĉĉ ĉ it . with Mention Text Re placed ( location EntityId , Ġlocation . name . value Ġto ĠnewName . value ) Ċĉ ĉ } Ċĉ ĉ pro se Repository . replace Pro se ( updated Pro se . map Ġ{ Ġit . pro se Ġ}) Ċĉ ĉ return Ġupdated Pro se . map NotNull Ġ{ Ġit . event Ġ} Ċ ĉ } ĊĊ ĉ private Ġsuspend Ġfun Ġupdate Sc enes That Use Location ( Ċĉ ĉ location : ĠLocation , Ċĉ ĉ new Name : ĠSingle Non Blank Line Ċ ĉ ): ĠList < Scene Setting Location Rename d > Ġ{ Ċĉ ĉ val Ġ( re named Location ) Ġ= Ġlocation . with Name ( new Name ) Ċĉ ĉ val Ġscene Updates Ġ= Ġscene Repository . get Sc enes Using Location ( location . id ). map NotNull Ġ{ Ċĉĉ ĉ it . with Location Rename d ( re named Location ) Ġas ? ĠUpdated Ċĉ ĉ } Ċĉ ĉ scene Repository . update Sc enes ( scene Updates . map Ġ{ Ġit . scene Ġ}) Ċĉ ĉ return Ġscene Updates . map Ġ{ Ġit . event Ġ} Ċ ĉ } Ċ } Ċ