Coverage Report - org.jtheque.films.services.impl.RealizersService
 
Classes in this File Line Coverage Branch Coverage Complexity
RealizersService
0 %
0/28
0 %
0/4
1.143
 
 1  
 package org.jtheque.films.services.impl;
 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.persistence.able.DataListener;
 20  
 import org.jtheque.films.services.able.INotesService;
 21  
 import org.jtheque.films.services.able.IRealizersService;
 22  
 import org.jtheque.primary.dao.able.IDaoPersons;
 23  
 import org.jtheque.primary.od.able.Person;
 24  
 import org.jtheque.primary.services.able.ICountriesService;
 25  
 import org.springframework.stereotype.Service;
 26  
 import org.springframework.transaction.annotation.Transactional;
 27  
 
 28  
 import javax.annotation.Resource;
 29  
 import java.util.Collection;
 30  
 
 31  
 /**
 32  
  * The implementation of the realizers service.
 33  
  *
 34  
  * @author Baptiste Wicht
 35  
  */
 36  
 @Service
 37  0
 public final class RealizersService implements IRealizersService {
 38  
     @Resource
 39  
     private IDaoPersons daoPersons;
 40  
 
 41  
     @Resource
 42  
     private INotesService notesService;
 43  
 
 44  
     @Resource
 45  
     private ICountriesService countriesService;
 46  
 
 47  
     private Person defaultRealizer;
 48  
 
 49  
     private static final String DEFAULT_REALIZER = "Unknown";
 50  
 
 51  
     @Override
 52  
     public Collection<Person> getRealizers() {
 53  0
         return daoPersons.getPersons(PERSON_TYPE);
 54  
     }
 55  
 
 56  
     @Override
 57  
     @Transactional
 58  
     public boolean delete(Person realizer) {
 59  0
         return daoPersons.delete(realizer);
 60  
     }
 61  
 
 62  
     @Override
 63  
     public boolean exists(String firstName, String name) {
 64  0
         return daoPersons.exists(firstName, name, PERSON_TYPE);
 65  
     }
 66  
 
 67  
     @Override
 68  
     public Person getRealizer(String firstName, String name) {
 69  0
         return daoPersons.getPerson(firstName, name, PERSON_TYPE);
 70  
     }
 71  
 
 72  
     @Override
 73  
     @Transactional
 74  
     public void create(Person realizer) {
 75  0
         daoPersons.create(realizer);
 76  0
     }
 77  
 
 78  
     @Override
 79  
     public boolean exists(Person realizer) {
 80  0
         return daoPersons.exist(realizer);
 81  
     }
 82  
 
 83  
     @Override
 84  
     public boolean hasNoRealizers() {
 85  0
         return getRealizers().isEmpty();
 86  
     }
 87  
 
 88  
     @Override
 89  
     @Transactional
 90  
     public void save(Person realizer) {
 91  0
         daoPersons.save(realizer);
 92  0
     }
 93  
 
 94  
     @Override
 95  
     public Collection<Person> getDatas() {
 96  0
         return daoPersons.getPersons(PERSON_TYPE);
 97  
     }
 98  
 
 99  
     @Override
 100  
     public void addDataListener(DataListener listener) {
 101  0
         daoPersons.addDataListener(listener);
 102  0
     }
 103  
 
 104  
     @Override
 105  
     public Person getEmptyRealizer() {
 106  0
         return daoPersons.createPerson();
 107  
     }
 108  
 
 109  
     @Override
 110  
     @Transactional
 111  
     public Person getDefaultRealizer() {
 112  0
         if (defaultRealizer == null) {
 113  0
             defaultRealizer = daoPersons.getPerson(DEFAULT_REALIZER, DEFAULT_REALIZER, PERSON_TYPE);
 114  
 
 115  0
             if (defaultRealizer == null) {
 116  0
                 defaultRealizer = getEmptyRealizer();
 117  
 
 118  0
                 defaultRealizer.setName(DEFAULT_REALIZER);
 119  0
                 defaultRealizer.setFirstName(DEFAULT_REALIZER);
 120  0
                 defaultRealizer.setNote(notesService.getDefaultNote());
 121  0
                 defaultRealizer.setTheCountry(countriesService.getDefaultCountry());
 122  0
                 daoPersons.create(defaultRealizer);
 123  
             }
 124  
         }
 125  
 
 126  0
         return defaultRealizer;
 127  
     }
 128  
 
 129  
     @Override
 130  
     @Transactional
 131  
     public void clearAll() {
 132  0
         daoPersons.clearAll();
 133  0
     }
 134  
 
 135  
     @Override
 136  
     public String getDataType() {
 137  0
         return DATA_TYPE;
 138  
     }
 139  
 }