Coverage Report - org.jtheque.films.view.impl.models.ActorsModel
 
Classes in this File Line Coverage Branch Coverage Complexity
ActorsModel
0 %
0/21
0 %
0/8
1.333
 
 1  
 package org.jtheque.films.view.impl.models;
 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.services.able.IActorService;
 22  
 import org.jtheque.films.view.impl.models.able.IActorsModel;
 23  
 import org.jtheque.primary.od.able.Person;
 24  
 import org.jtheque.primary.view.impl.listeners.ObjectChangedEvent;
 25  
 import org.jtheque.primary.view.impl.models.PrincipalDataModel;
 26  
 
 27  
 import java.util.Collection;
 28  
 
 29  
 /**
 30  
  * A model for the actors view.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  0
 public final class ActorsModel extends PrincipalDataModel<Person> implements IActorsModel {
 35  
     private Collection<Person> displayList;
 36  
 
 37  
     private Person currentActor;
 38  
 
 39  
     private final IActorService actorService;
 40  
 
 41  
     public ActorsModel() {
 42  0
         super();
 43  
         
 44  0
         actorService = Managers.getManager(IBeansManager.class).getBean("actorService");
 45  
         
 46  0
         actorService.addDataListener(this);
 47  0
     }
 48  
 
 49  
     @Override
 50  
     @SuppressWarnings("unchecked")
 51  
     public void updateDisplayList(Collection<Person> actors) {
 52  0
         getDisplayList().clear();
 53  
 
 54  0
         if (actors == null) {
 55  0
             getDisplayList().addAll(actorService.getActors());
 56  
         } else {
 57  0
             getDisplayList().addAll(actors);
 58  
         }
 59  
 
 60  0
         fireDisplayListChanged();
 61  0
     }
 62  
 
 63  
     @Override
 64  
     public void updateDisplayList() {
 65  0
         updateDisplayList(null);
 66  0
     }
 67  
 
 68  
 
 69  
     @Override
 70  
     public Collection<Person> getDisplayList() {
 71  0
         if (displayList == null) {
 72  0
             displayList = actorService.getActors();
 73  
         }
 74  
 
 75  0
         return displayList;
 76  
     }
 77  
 
 78  
     @Override
 79  
     public Person getCurrentActor() {
 80  0
         return currentActor;
 81  
     }
 82  
 
 83  
     @Override
 84  
     public void setCurrentActor(Person actor) {
 85  0
         assert actor.getType().equals(IActorService.PERSON_TYPE) : "The person must of type Actor";
 86  
 
 87  0
         currentActor = actor;
 88  
 
 89  0
         fireCurrentObjectChanged(new ObjectChangedEvent(this, currentActor));
 90  0
     }
 91  
 }