Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
WebGetterManager |
|
| 1.0;1 |
1 | package org.jtheque.films.services.impl.utils.web; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import org.jtheque.films.persistence.od.able.Film; | |
20 | import org.jtheque.films.services.impl.utils.EditArguments; | |
21 | import org.jtheque.films.utils.Constants.Site; | |
22 | ||
23 | import java.util.Collection; | |
24 | ||
25 | /** | |
26 | * Manage the automatic research of informations of a film on the web. | |
27 | * | |
28 | * @author Baptiste Wicht | |
29 | */ | |
30 | public final class WebGetterManager { | |
31 | private final WebGetterFactory factory; | |
32 | ||
33 | /** | |
34 | * Construct a new <code>WebGetterManager</code>. | |
35 | */ | |
36 | public WebGetterManager() { | |
37 | 0 | super(); |
38 | ||
39 | 0 | factory = new WebGetterFactory(); |
40 | 0 | } |
41 | ||
42 | /** | |
43 | * Return all the available films of the website <code>site</code> for <code>search</code>. | |
44 | * | |
45 | * @param site The site on which we must search. | |
46 | * @param search The search of films we search. | |
47 | * @return A list containing all the films found on the site with the search. | |
48 | */ | |
49 | public Collection<FilmResult> getFilms(Site site, String search) { | |
50 | 0 | WebGetter getter = factory.getWebGetter(site); |
51 | ||
52 | 0 | return getter.getFilms(search); |
53 | } | |
54 | ||
55 | /** | |
56 | * Return the film on the site for the result. | |
57 | * | |
58 | * @param search The search of this films. | |
59 | * @return The film with all the informations. | |
60 | */ | |
61 | public Film getFilm(FilmResult search) { | |
62 | 0 | WebGetter getter = factory.getWebGetter(search.getSite()); |
63 | ||
64 | 0 | return getter.getFilm(search, null, null); |
65 | } | |
66 | ||
67 | /** | |
68 | * Modify the film with the informations extracted on internet. We only modify the informations specified by | |
69 | * <code>args</code>. | |
70 | * | |
71 | * @param search The search of the film. | |
72 | * @param film The film we modify. | |
73 | * @param args The arguments who specify the fields we must modify. | |
74 | */ | |
75 | public void modifyFilm(FilmResult search, Film film, EditArguments args) { | |
76 | 0 | WebGetter getter = factory.getWebGetter(search.getSite()); |
77 | ||
78 | 0 | film.saveToMemento(); |
79 | ||
80 | 0 | getter.getFilm(search, film, args); |
81 | 0 | } |
82 | } |