| 1 | |
package org.jtheque.films.services.impl.utils.search; |
| 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.persistence.od.RealizerImpl; |
| 22 | |
import org.jtheque.films.services.able.IRealizersService; |
| 23 | |
|
| 24 | |
import javax.annotation.Resource; |
| 25 | |
import java.util.ArrayList; |
| 26 | |
import java.util.List; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
public final class RealizerSearcher implements Searcher<RealizerImpl> { |
| 34 | |
@Resource |
| 35 | |
private IRealizersService realizersService; |
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
public RealizerSearcher() { |
| 41 | 0 | super(); |
| 42 | |
|
| 43 | 0 | Managers.getManager(IBeansManager.class).inject(this); |
| 44 | 0 | } |
| 45 | |
|
| 46 | |
@Override |
| 47 | |
public List<RealizerImpl> search(Search<RealizerImpl> research) { |
| 48 | 0 | List<RealizerImpl> realizers = realizersService.getRealizers(); |
| 49 | |
|
| 50 | 0 | List<RealizerImpl> list = new ArrayList<RealizerImpl>(realizers.size() / 2); |
| 51 | 0 | RealizerSearch search = (RealizerSearch) research; |
| 52 | |
|
| 53 | 0 | for (RealizerImpl realizer : realizers) { |
| 54 | 0 | boolean correct = true; |
| 55 | |
|
| 56 | 0 | if (search.isMustCheckNote() && !realizer.getNote().equals(search.getNote())) { |
| 57 | 0 | correct = false; |
| 58 | |
} |
| 59 | |
|
| 60 | 0 | if (search.isMustCheckCountry() && !realizer.getTheCountry().equals(search.getCountry())) { |
| 61 | 0 | correct = false; |
| 62 | |
} |
| 63 | |
|
| 64 | 0 | if (correct) { |
| 65 | 0 | list.add(realizer); |
| 66 | |
} |
| 67 | 0 | } |
| 68 | |
|
| 69 | 0 | return list; |
| 70 | |
} |
| 71 | |
} |