Coverage Report - org.jtheque.primary.services.impl.LendingsService
 
Classes in this File Line Coverage Branch Coverage Complexity
LendingsService
0 %
0/19
0 %
0/2
1
 
 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.IDaoLendings;
 21  
 import org.jtheque.primary.od.able.Lending;
 22  
 import org.jtheque.primary.services.able.ILendingsService;
 23  
 import org.jtheque.utils.bean.IntDate;
 24  
 import org.springframework.transaction.annotation.Transactional;
 25  
 
 26  
 import javax.annotation.Resource;
 27  
 import java.util.Collection;
 28  
 
 29  
 /**
 30  
  * A lendings service implementation.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  0
 public final class LendingsService implements ILendingsService {
 35  
         @Resource
 36  
         private IDaoLendings daoLendings;
 37  
 
 38  
         @Override
 39  
         public Lending getLending(int id){
 40  0
                 return daoLendings.getLending(id);
 41  
         }
 42  
 
 43  
         @Override
 44  
         public boolean hasNoLendings(){
 45  0
                 return daoLendings.getLendings().isEmpty();
 46  
         }
 47  
 
 48  
         @Override
 49  
         public Collection<Lending> getLendings(){
 50  0
                 return daoLendings.getLendings();
 51  
         }
 52  
 
 53  
         @Override
 54  
         @Transactional
 55  
         public void save(Lending lending){
 56  0
                 daoLendings.save(lending);
 57  0
         }
 58  
 
 59  
         @Override
 60  
         public Collection<Lending> getDatas(){
 61  0
                 return daoLendings.getLendings();
 62  
         }
 63  
 
 64  
         @Override
 65  
         public void addDataListener(DataListener listener){
 66  0
                 daoLendings.addDataListener(listener);
 67  0
         }
 68  
 
 69  
         @Override
 70  
         @Transactional
 71  
         public void clearAll(){
 72  0
                 daoLendings.clearAll();
 73  0
         }
 74  
 
 75  
         @Override
 76  
         public String getDataType(){
 77  0
                 return DATA_TYPE;
 78  
         }
 79  
 
 80  
         @Override
 81  
         @Transactional
 82  
         public boolean delete(Lending lending){
 83  0
                 return daoLendings.delete(lending);
 84  
         }
 85  
 
 86  
         @Override
 87  
         @Transactional
 88  
         public void create(Lending lending){
 89  0
                 daoLendings.create(lending);
 90  0
         }
 91  
 
 92  
         @Override
 93  
         public boolean isLate(Lending lending, int days){
 94  0
                 IntDate date = lending.getDate();
 95  
 
 96  0
                 date.add(IntDate.Fields.DAY, days);
 97  
 
 98  0
                 return date.intValue() > IntDate.today().intValue();
 99  
         }
 100  
 
 101  
         @Override
 102  
         public Lending getEmptyLending(){
 103  0
                 return daoLendings.createLending();
 104  
         }
 105  
 }