Coverage Report - org.jtheque.films.view.impl.models.RealizersModel
 
Classes in this File Line Coverage Branch Coverage Complexity
RealizersModel
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.IRealizersService;
 22  
 import org.jtheque.films.view.impl.models.able.IRealizersModel;
 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 realizers view.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  0
 public final class RealizersModel extends PrincipalDataModel<Person> implements IRealizersModel {
 35  
     private Collection<Person> displayList;
 36  
 
 37  
     private Person currentRealizer;
 38  
     
 39  
     private final IRealizersService realizersService;
 40  
 
 41  
     public RealizersModel() {
 42  0
         super();
 43  
         
 44  0
         realizersService = Managers.getManager(IBeansManager.class).getBean("realizersService");
 45  
                 
 46  0
         realizersService.addDataListener(this);
 47  0
     }
 48  
 
 49  
     @Override
 50  
     @SuppressWarnings("unchecked")
 51  
     public void updateDisplayList(Collection<Person> realizers) {
 52  0
         getDisplayList().clear();
 53  
 
 54  0
         if (realizers != null) {
 55  0
             getDisplayList().addAll(realizers);
 56  
         } else {
 57  0
             getDisplayList().addAll(realizersService.getRealizers());
 58  
         }
 59  
 
 60  0
         fireDisplayListChanged();
 61  0
     }
 62  
 
 63  
     @Override
 64  
     public void updateDisplayList() {
 65  0
         updateDisplayList(null);
 66  0
     }
 67  
 
 68  
     @Override
 69  
     public Collection<Person> getDisplayList() {
 70  0
         if (displayList == null) {
 71  0
             displayList = realizersService.getRealizers();
 72  
         }
 73  
 
 74  0
         return displayList;
 75  
     }
 76  
 
 77  
     @Override
 78  
     public Person getCurrentRealizer() {
 79  0
         return currentRealizer;
 80  
     }
 81  
 
 82  
     @Override
 83  
     public void setCurrentRealizer(Person realizer) {
 84  0
         assert realizer.getType().equals(IRealizersService.PERSON_TYPE) : "The person must of type Actor";
 85  
 
 86  0
         currentRealizer = realizer;
 87  
 
 88  0
         fireCurrentObjectChanged(new ObjectChangedEvent(this, currentRealizer));
 89  0
     }
 90  
 }