Coverage Report - org.jtheque.primary.services.impl.BorrowersService
 
Classes in this File Line Coverage Branch Coverage Complexity
BorrowersService
0 %
0/24
0 %
0/6
1.091
 
 1  
 package org.jtheque.primary.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.primary.dao.able.IDaoPersons;
 21  
 import org.jtheque.primary.od.able.Person;
 22  
 import org.jtheque.primary.services.able.IBorrowersService;
 23  
 import org.springframework.stereotype.Service;
 24  
 import org.springframework.transaction.annotation.Transactional;
 25  
 
 26  
 import javax.annotation.Resource;
 27  
 import java.util.Collection;
 28  
 
 29  
 /**
 30  
  * A borrowers service implementation.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  0
 @Service
 35  0
 public final class BorrowersService implements IBorrowersService {
 36  
     @Resource
 37  
     private IDaoPersons daoPersons;
 38  
 
 39  
     @Override
 40  
     @Transactional
 41  
     public boolean delete(Person borrower) {
 42  0
         return daoPersons.delete(borrower);
 43  
     }
 44  
 
 45  
     @Override
 46  
     @Transactional
 47  
     public void create(Person borrower) {
 48  0
         assert borrower != null : "Borrower cannot be null";
 49  
 
 50  0
         borrower.setType(PERSON_TYPE);
 51  
 
 52  0
         daoPersons.create(borrower);
 53  0
     }
 54  
 
 55  
     @Override
 56  
     @Transactional
 57  
     public void save(Person borrower) {
 58  0
         borrower.setType(PERSON_TYPE);
 59  
 
 60  0
         daoPersons.save(borrower);
 61  0
     }
 62  
 
 63  
     @Override
 64  
     public Collection<Person> getBorrowers() {
 65  0
         return daoPersons.getPersons(PERSON_TYPE);
 66  
     }
 67  
 
 68  
     @Override
 69  
     public boolean hasNoBorrowers() {
 70  0
         return getBorrowers().isEmpty();
 71  
     }
 72  
 
 73  
     @Override
 74  
     public void createAll(Iterable<Person> borrowers) {
 75  0
         for (Person borrower : borrowers) {
 76  0
             create(borrower);
 77  
         }
 78  0
     }
 79  
 
 80  
     @Override
 81  
     public Collection<Person> getDatas() {
 82  0
         return getBorrowers();
 83  
     }
 84  
 
 85  
     @Override
 86  
     public void addDataListener(DataListener listener) {
 87  0
         daoPersons.addDataListener(listener);
 88  0
     }
 89  
 
 90  
     @Override
 91  
     @Transactional
 92  
     public void clearAll() {
 93  0
         daoPersons.clearAll(PERSON_TYPE);
 94  0
     }
 95  
 
 96  
     @Override
 97  
     public String getDataType() {
 98  0
         return DATA_TYPE;
 99  
     }
 100  
 
 101  
     @Override
 102  
     public Person getEmptyBorrower() {
 103  0
         Person borrower = daoPersons.createPerson();
 104  
 
 105  0
         borrower.setType(PERSON_TYPE);
 106  
 
 107  0
         return borrower;
 108  
     }
 109  
 }