Coverage Report - jp.co.y_net.amm.dao.GrpusrDao
 
Classes in this File Line Coverage Branch Coverage Complexity
GrpusrDao
0%
0/32
0%
0/4
1.375
 
 1  0
 package jp.co.y_net.amm.dao;
 2  
 import java.util.List;
 3  
 
 4  
 import org.hibernate.criterion.DetachedCriteria;
 5  
 import org.hibernate.criterion.Example;
 6  
 import org.springframework.orm.hibernate3.HibernateTemplate;
 7  
 import org.springframework.stereotype.Component;
 8  
 
 9  
 
 10  
 @Component("grpusrDao")
 11  0
 public class GrpusrDao extends AbstractDao {
 12  
     
 13  
     /* 参照形処理 ------------------------------------------------------------------------------------------------ */
 14  
     /** ユニークキーを使用した取得 */
 15  
     public Grpusr getByGrpusrid(Integer grpusrid) {
 16  0
         Grpusr cnd = new Grpusr();
 17  0
         cnd.setGrpusrid(grpusrid);
 18  0
         List<Grpusr> list = get(cnd);
 19  0
         if(list.size() == 1) {
 20  0
             return list.get(0);
 21  
         }
 22  0
         return null;
 23  
     }
 24  
     /** 全件取得(論理削除除外) */
 25  
     public List<Grpusr> get() {
 26  0
         Grpusr cnd = new Grpusr();
 27  0
         cnd.setDeleted(AppDef.FLASE); // 論理削除考慮
 28  0
         return get(cnd);
 29  
     }
 30  
     /** 条件付き取得(論理削除除外) */
 31  
     public List<Grpusr> get(Grpusr cnd) {
 32  0
         if(cnd != null) {
 33  0
             cnd.setDeleted(AppDef.FLASE); // 論理削除考慮
 34  
         }
 35  0
         HibernateTemplate hibernateTemplate = getHibernateTemplate();
 36  0
         DetachedCriteria dc = DetachedCriteria.forClass(Grpusr.class);
 37  0
         dc.add(Example.create(cnd));
 38  
         @SuppressWarnings("unchecked")
 39  0
         List<Grpusr> list = (List<Grpusr>) hibernateTemplate.findByCriteria(dc);
 40  0
         hibernateTemplate.clear();
 41  0
         return list;
 42  
     }
 43  
 
 44  
     /* 更新系処理 ------------------------------------------------------------------------------------------------ */
 45  
     private static final String ENTITYNAME = "Grpusr";
 46  
     private static final String PKEYNAME = "grpusrid";
 47  
     /**
 48  
      * 登録処理
 49  
      * ・必要なカラムを自動採番する
 50  
      * ・共通処理を実施する。
 51  
      * @see AbstractDao#add(AppDto, Integer)
 52  
      * @param item 追加対象オブジェクト
 53  
      * @param updateusrid 更新者ID
 54  
      */
 55  
     public void add(Grpusr item, Integer updateusrid) {
 56  
         /* 自動採番 */
 57  0
         item.setGrpusrid(getNextId(ENTITYNAME, PKEYNAME));
 58  
         /* Insert実施 */
 59  0
         super.add(item, updateusrid);
 60  0
     }
 61  
     public void update(Grpusr item, Integer updateusrid) {
 62  0
         super.update(item, updateusrid);
 63  0
     }
 64  
     public void removeLogical(Grpusr item, Integer updateusrid) {
 65  0
         super.removeLogical(item, updateusrid);
 66  0
     }
 67  
     
 68  
     /* entity固有のユーティリティ ----------------------------------------------------------------------------------- */
 69  
     /**
 70  
      * 所属メンバー数
 71  
      * @param grpid 
 72  
      * @return
 73  
      */
 74  
     public String getMembercount参加中AsString(Integer grpid) {
 75  0
         return String.valueOf(getMembercount参加中(grpid));
 76  
     }
 77  
     /**
 78  
      * 所属メンバー数
 79  
      * @param grpid 
 80  
      * @return
 81  
      */
 82  
     public Integer getMembercount参加中(Integer grpid) {
 83  0
         Grpusr cndGu = new Grpusr();
 84  0
         cndGu.setGrpid(grpid);
 85  0
         cndGu.setStatus(Grpusr.STATUS_参加中);
 86  0
         List<Grpusr> member = this.get(cndGu);
 87  0
         return member.size();
 88  
     }
 89  
 
 90  
 
 91  
 
 92  
 
 93  
 }