1

やあ!ダウンロード リンクの重要な情報 (完全なフロー) だけを取得したい。

私は自分のドメインを次のように設計しました:

Serie { hasMany[Season] }
Season { hasMany[Episode] and belongsTo[Serie] }
Episode { hasMany[DownloadInfo] and belongsTo[Season] }
DownloadInfo { link nullable:true //among other data }

そして、私はDBにおよそこの数のレコードを持っています:

serie:4500
season:500
episode:6500
download_info:10000

他の情報がないシリーズがたくさんあることがわかります。

シリーズ>シーズン>エピソード>downloadInfoのデータだけを取得するにはどうすればよいですか?

たとえば、次のようになります。

Serie "A"
  Season "sA1"
Serie "B"
  Season "sB1"
    Episode "eB1"
      Link "b1.1"
      Link "b1.2"
    Episode "eB2"
    Episode "eB3"
      Link "b3.1"
Serie "C"
  Season "sC1"
    Episode "eC1"
Serie "D"
Serie "E"
  Season "sE1"
    Episode "eE1"
      Link "e1.1"
  Season "sE2"
    Episode "eE2"
      Link "e2.1"

私はこれを取得したい:

def model = [series:[
  name:'B',
  seasons:[
    name:'sB1',
    episodes:[
      name:'eB1',
      links:['b1.1','b1.2']
    ],[
      name:'eB3',
      links:['b3.1']
    ]
  ]
],[
  name:'E'
  seasons:[
    name:'sE1',
    episodes:[
      name:'eE1',
      links:['e1.1']
    ]
  ],[
    name:'sE2'
    episodes:[
      name:'eE2',
      links:['e2.1']
    ]
  ]
]

リンクのないすべてのシリーズ、シーズン エピソード、および DownloadInfo を破棄します。

ところで、link プロパティが null でない DownloadInfo だけが必要です。私はから始めました:

DownloadInfo.where { link!= null }.list().each {
  // ...
}

しかし、すべてのフローを実行するエレガントな方法がわかりません。どんな手掛かり?

前もって感謝します!

更新しました

これは、各エンティティの名前でグループ化された、次の SQL に相当する Groovy になります。

select * from serie s
inner join season ss on s.id = ss.serie_id
inner join episode e on ss.id = e.season_id
inner join download_info di on e.id = di.episode_id
where di.link is not null
4

0 に答える 0