/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 6 - 2 0 1 8 Ġay atk . Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . ay atk . bib lio . data . repository Ċ Ċ import Ġcom . ay atk . bib lio . data . remote . N ar ou DataStore Ċ import Ġcom . ay atk . bib lio . data . remote . entity . mapper . to Entity Ċ import Ġcom . ay atk . bib lio . data . remote . util . QueryBuilder Ċ import Ġcom . ay atk . bib lio . di . scope . N ar ou Ċ import Ġcom . ay atk . bib lio . di . scope . No ct urne Ċ import Ġcom . ay atk . bib lio . infrastructure . database . dao . No vel Dao Ċ import Ġcom . ay atk . bib lio . infrastructure . database . entity . No vel Entity Ċ import Ġcom . ay atk . bib lio . infrastructure . database . entity . enums . Publisher Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . Flow able Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Singleton Ċ class ĠNo vel Repository Impl Ġ@ Inject Ġconstructor ( ĊĠ Ġprivate Ġval Ġdao : ĠNo vel Dao , ĊĠ Ġ@ N ar ou Ġprivate Ġval Ġn ar ou DataStore : ĠN ar ou DataStore , ĊĠ Ġ@ No ct urne Ġprivate Ġval Ġn oc DataStore : ĠN ar ou DataStore Ċ ) Ġ: ĠNo vel Repository Ġ{ ĊĊĠ Ġoverride Ġval Ġsaved No vel s : ĠFlow able < List < No vel Entity >> Ġ= Ġdao . getAll No vel () ĊĊĠ Ġoverride Ġfun Ġnovel s ( publisher : ĠPublisher , Ġvar arg Ġcodes : ĠString ): ĠFlow able < List < No vel Entity >> Ġ{ ĊĠĠĠ Ġ// ĠTODO Ġãĥĩãĥ¼ãĤ¿ ãĥĻãĥ¼ãĤ¹ ãģĭãĤī ãģ¨ ãģ£ãģ¦ ãģı ãĤĭ åĩ¦çĲĨ ãĤĴ ãģĭ ãģı ĊĠĠĠ Ġval Ġquery Ġ= ĠQuery Builder (). n code (* codes ). build () ĊĠĠĠ Ġreturn Ġwhen Ġ( publisher ) Ġ{ ĊĠĠĠĠĠ ĠPublisher . N AR OU Ġ-> Ġn ar ou DataStore . get No vel ( query ) ĊĠĠĠĠĠ ĠPublisher . NO CT UR NE _ MO ON LIGHT Ġ-> Ġn oc DataStore . get No vel ( query ) ĊĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ. map Ġ{ Ġit . to Entity ( publisher ) Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġnovel sBy Query ( raw Query : ĠString , Ġpublisher : ĠPublisher ): ĠFlow able < List < No vel Entity >> Ġ{ ĊĠĠĠ Ġ// ĠTODO : Ġãĥķ ãĤ£ ãĥ« ãĤ¿ ãĥª ãĥ³ãĤ° ãģª ãĤĵ ãģĭ ãģ® æĿ¡ä»¶ ãĤĴ ãģ© ãģĨ ãģĻãĤĭ ãģĭ å¾Į ãģ§ èĢĥ ãģĪãĤĭ ĊĠĠĠ Ġval Ġquery Ġ= ĠQuery Builder (). search Words ( raw Query ). build () ĊĠĠĠ Ġreturn Ġwhen Ġ( publisher ) Ġ{ ĊĠĠĠĠĠ ĠPublisher . N AR OU Ġ-> Ġn ar ou DataStore . get No vel ( query ) ĊĠĠĠĠĠ ĠPublisher . NO CT UR NE _ MO ON LIGHT Ġ-> Ġn oc DataStore . get No vel ( query ) ĊĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ. map Ġ{ Ġit . to Entity ( publisher ) Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġsave ( no vel : ĠNo vel Entity ): ĠComp letable Ġ= ĊĠĠĠ ĠComp letable . from Runnable Ġ{ ĊĠĠĠĠĠ ĠTim ber . d (" save Ġ${ no vel . title }") ĊĠĠĠĠĠ Ġdao . insert ( no vel ) ĊĠĠĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġdelete ( no vel : ĠNo vel Entity ): ĠComp letable Ġ= ĊĠĠĠ ĠComp letable . from Runnable Ġ{ ĊĠĠĠĠĠ Ġdao . delete ( no vel ) ĊĠĠĠ Ġ} Ċ } Ċ