1 | |
package org.jtheque.films.persistence; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.beans.IBeansManager; |
21 | |
import org.jtheque.films.controllers.able.IActorController; |
22 | |
import org.jtheque.films.controllers.able.IFilmController; |
23 | |
import org.jtheque.films.controllers.able.IRealizerController; |
24 | |
import org.jtheque.films.services.able.IActorService; |
25 | |
import org.jtheque.films.services.able.IFilmsService; |
26 | |
import org.jtheque.films.services.able.IRealizersService; |
27 | |
import org.jtheque.primary.od.abstraction.Data; |
28 | |
|
29 | |
import javax.annotation.Resource; |
30 | |
|
31 | |
import java.util.Collections; |
32 | |
import java.util.List; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public final class DataProvider { |
41 | |
private final String content; |
42 | |
|
43 | |
@Resource |
44 | |
private IFilmController filmController; |
45 | |
|
46 | |
@Resource |
47 | |
private IActorController actorController; |
48 | |
|
49 | |
@Resource |
50 | |
private IRealizerController realizerController; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public DataProvider(String content) { |
58 | 0 | super(); |
59 | |
|
60 | 0 | Managers.getManager(IBeansManager.class).inject(this); |
61 | |
|
62 | 0 | this.content = content; |
63 | 0 | } |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
public List<? extends Data> getDatas() { |
71 | |
final List<? extends Data> datas; |
72 | |
|
73 | 0 | if (IFilmsService.DATA_TYPE.equals(content)) { |
74 | 0 | datas = filmController.getViewModel().getDisplayList(); |
75 | 0 | } else if (IActorService.DATA_TYPE.equals(content)) { |
76 | 0 | datas = actorController.getViewModel().getDisplayList(); |
77 | 0 | } else if (IRealizersService.DATA_TYPE.equals(content)) { |
78 | 0 | datas = realizerController.getViewModel().getDisplayList(); |
79 | |
} else { |
80 | 0 | datas = Collections.<Data>emptyList(); |
81 | |
} |
82 | |
|
83 | 0 | return datas; |
84 | |
} |
85 | |
} |