Coverage Report - org.jtheque.films.persistence.DataProvider
 
Classes in this File Line Coverage Branch Coverage Complexity
DataProvider
0 %
0/12
0 %
0/6
2.5
 
 1  
 package org.jtheque.films.persistence;
 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.controllers.able.IActorController;
 22  
 import org.jtheque.films.controllers.able.IFilmController;
 23  
 import org.jtheque.films.controllers.able.IRealizerController;
 24  
 import org.jtheque.films.services.able.IActorService;
 25  
 import org.jtheque.films.services.able.IFilmsService;
 26  
 import org.jtheque.films.services.able.IRealizersService;
 27  
 import org.jtheque.primary.od.abstraction.Data;
 28  
 
 29  
 import javax.annotation.Resource;
 30  
 
 31  
 import java.util.Collections;
 32  
 import java.util.List;
 33  
 
 34  
 /**
 35  
  * This class give a data access to the sorters. It simplifies the access to the data without know the exact type
 36  
  * of data.
 37  
  *
 38  
  * @author Baptiste Wicht
 39  
  */
 40  
 public final class DataProvider {
 41  
     private final String content;
 42  
 
 43  
     @Resource
 44  
     private IFilmController filmController;
 45  
 
 46  
     @Resource
 47  
     private IActorController actorController;
 48  
 
 49  
     @Resource
 50  
     private IRealizerController realizerController;
 51  
     
 52  
     /**
 53  
      * Construct a new <code>SorterDataProvider</code> with a specific type of content.
 54  
      *
 55  
      * @param content The content to search
 56  
      */
 57  
     public DataProvider(String content) {
 58  0
         super();
 59  
 
 60  0
         Managers.getManager(IBeansManager.class).inject(this);
 61  
 
 62  0
         this.content = content;
 63  0
     }
 64  
 
 65  
     /**
 66  
      * Return all the data of the specified type.
 67  
      *
 68  
      * @return A collection of <code>Data</code>
 69  
      */
 70  
     public List<? extends Data> getDatas() {
 71  
         final List<? extends Data> datas;
 72  
 
 73  0
         if (IFilmsService.DATA_TYPE.equals(content)) {
 74  0
             datas = filmController.getViewModel().getDisplayList();
 75  0
         } else if (IActorService.DATA_TYPE.equals(content)) {
 76  0
             datas = actorController.getViewModel().getDisplayList();
 77  0
         } else if (IRealizersService.DATA_TYPE.equals(content)) {
 78  0
             datas = realizerController.getViewModel().getDisplayList();
 79  
         } else {
 80  0
             datas = Collections.<Data>emptyList();
 81  
         }
 82  
 
 83  0
         return datas;
 84  
     }
 85  
 }