Coverage Report - org.jtheque.films.services.impl.utils.search.ActorSearcher
 
Classes in this File Line Coverage Branch Coverage Complexity
ActorSearcher
0 %
0/16
0 %
0/12
4
 
 1  
 package org.jtheque.films.services.impl.utils.search;
 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.core.managers.Managers;
 20  
 import org.jtheque.core.managers.beans.IBeansManager;
 21  
 import org.jtheque.films.persistence.od.ActorImpl;
 22  
 import org.jtheque.films.services.able.IActorService;
 23  
 
 24  
 import javax.annotation.Resource;
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 
 28  
 /**
 29  
  * A searcher for the actors. This classe permit a search of actors with an objet Search.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  
 public final class ActorSearcher implements Searcher<ActorImpl> {
 34  
     @Resource
 35  
     private IActorService actorService;
 36  
 
 37  
     /**
 38  
      * Construct a new ActorSearcher.
 39  
      */
 40  
     public ActorSearcher() {
 41  0
         super();
 42  
 
 43  0
         Managers.getManager(IBeansManager.class).inject(this);
 44  0
     }
 45  
 
 46  
     @Override
 47  
     public List<ActorImpl> search(Search<ActorImpl> research) {
 48  0
         List<ActorImpl> actors = actorService.getActors();
 49  
 
 50  0
         List<ActorImpl> list = new ArrayList<ActorImpl>(actors.size() / 2);
 51  0
         ActorSearch search = (ActorSearch) research;
 52  
 
 53  0
         for (ActorImpl actor : actors) {
 54  0
             boolean correct = true;
 55  
 
 56  0
             if (search.isMustCheckNote() && !actor.getNote().equals(search.getNote())) {
 57  0
                 correct = false;
 58  
             }
 59  
 
 60  0
             if (search.isMustCheckCountry() && !actor.getTheCountry().equals(search.getCountry())) {
 61  0
                 correct = false;
 62  
             }
 63  
 
 64  0
             if (correct) {
 65  0
                 list.add(actor);
 66  
             }
 67  0
         }
 68  
 
 69  0
         return list;
 70  
     }
 71  
 }