Coverage Report - org.jtheque.primary.services.impl.KindsService
 
Classes in this File Line Coverage Branch Coverage Complexity
KindsService
0 %
0/28
0 %
0/6
1.2
 
 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.IDaoKinds;
 21  
 import org.jtheque.primary.od.able.Kind;
 22  
 import org.jtheque.primary.services.able.IKindsService;
 23  
 import org.springframework.transaction.annotation.Transactional;
 24  
 
 25  
 import javax.annotation.Resource;
 26  
 import java.util.Collection;
 27  
 
 28  
 /**
 29  
  * A kinds service implementation.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  0
 public final class KindsService implements IKindsService {
 34  
     private Kind defaultKind;
 35  
 
 36  
     @Resource
 37  
     private IDaoKinds daoKinds;
 38  
 
 39  
     @Override
 40  
     @Transactional
 41  
     public Kind getDefaultKind() {
 42  0
         if (defaultKind == null) {
 43  0
             defaultKind = daoKinds.getKind("Suspense");
 44  
 
 45  0
             if (defaultKind == null) {
 46  0
                 defaultKind = getEmptyKind();
 47  0
                 defaultKind.setName("Suspense");
 48  0
                 daoKinds.create(defaultKind);
 49  
             }
 50  
         }
 51  
 
 52  0
         return defaultKind;
 53  
     }
 54  
 
 55  
     @Override
 56  
     public Collection<Kind> getKinds() {
 57  0
         return daoKinds.getKinds();
 58  
     }
 59  
 
 60  
     @Override
 61  
     @Transactional
 62  
     public void create(Kind kind) {
 63  0
         daoKinds.create(kind);
 64  0
     }
 65  
 
 66  
     @Override
 67  
     @Transactional
 68  
     public boolean delete(Kind kind) {
 69  0
         return daoKinds.delete(kind);
 70  
     }
 71  
 
 72  
     @Override
 73  
     @Transactional
 74  
     public void save(Kind kind) {
 75  0
         daoKinds.save(kind);
 76  0
     }
 77  
 
 78  
     @Override
 79  
     public Kind getKind(String name) {
 80  0
         return daoKinds.getKind(name);
 81  
     }
 82  
 
 83  
     @Override
 84  
     public boolean exists(String name) {
 85  0
         return daoKinds.exists(name);
 86  
     }
 87  
 
 88  
     @Override
 89  
     public boolean exists(Kind kind) {
 90  0
         return exists(kind.getName());
 91  
     }
 92  
 
 93  
     @Override
 94  
     public boolean hasNoKinds() {
 95  0
         return daoKinds.getKinds().isEmpty();
 96  
     }
 97  
 
 98  
     @Override
 99  
     @Transactional
 100  
     public void createAll(Iterable<Kind> kinds) {
 101  0
         for (Kind kind : kinds) {
 102  0
             daoKinds.create(kind);
 103  
         }
 104  0
     }
 105  
 
 106  
     @Override
 107  
     public Kind getEmptyKind() {
 108  0
         return daoKinds.createKind();
 109  
     }
 110  
 
 111  
     @Override
 112  
     public Collection<Kind> getDatas() {
 113  0
         return daoKinds.getKinds();
 114  
     }
 115  
 
 116  
     @Override
 117  
     public void addDataListener(DataListener listener) {
 118  0
         daoKinds.addDataListener(listener);
 119  0
     }
 120  
 
 121  
     @Override
 122  
     @Transactional
 123  
     public void clearAll() {
 124  0
         daoKinds.clearAll();
 125  0
     }
 126  
 
 127  
     @Override
 128  
     public String getDataType() {
 129  0
         return DATA_TYPE;
 130  
     }
 131  
 }