package Ġhu . deep data . tender base . webapp . svc čĊč Ċ import Ġhu . deep data . tender base . webapp . model .* č Ċ import Ġhu . deep data . tender base . webapp . repo .* č Ċ import Ġorg . springframework . beans . factory . annotation .* č Ċ import Ġorg . springframework . data . domain .* č Ċ import Ġorg . springframework . stereotype .* čĊč Ċ /** čĊ Ġ* Ġ@ author ĠZ sol t ĠJ ur Ã¡ny i čĊ Ġ*/ č Ċ @ Service č Ċ class ĠOrganization Service Ġ{ čĊčĊ ĉ @ Autowired čĊ ĉ var Ġw Part icipation Repo : ĠW Part icipation Repo ? Ġ= Ġnull čĊčĊ ĉ @ Autowired čĊ ĉ var Ġw Release Repo : ĠW Release Repo ? Ġ= Ġnull čĊčĊ ĉ fun Ġquery Release sBy Organization And Role ( model : ĠOrganization Model ) Ġ{ čĊĉ ĉ model . apply Ġ{ čĊĉĉ ĉ roles Ġ= Ġw Part icipation Repo ?. find Role Count sBy Organization ( organization . id ) Ġ?: ĠlistOf () čĊĉĉ ĉ val Ġrole Names Ġ= Ġroles . map ( Name And Count :: name ) čĊĉĉ ĉ role Ġ= Ġif Ġ( null Ġ== Ġrole Ġ|| Ġ! role Names . contains ( role !! )) Ġrole Names . first OrNull () Ġ?: Ġ"" Ġelse Ġrole čĊĉĉ ĉ val Ġpage Request Ġ= ĠPage Request ( page able . pageNumber , Ġpage able . pageSize , ĠSort . Direction . DESC , Ġ" published At ", Ġ" id ") čĊĉĉ ĉ releases Ġ= čĊĉĉĉĉ ĉ if Ġ( role . isNull Or Blank ()) Ġnull čĊĉĉĉĉ ĉ else Ġw Release Repo ?. findBy Organization And Role ( organization . id , Ġrole !! , Ġpage Request ) čĊĉ ĉ } čĊ ĉ } č Ċ }