Coverage Report - jp.co.y_net.amm.dao.Grpusr
 
Classes in this File Line Coverage Branch Coverage Complexity
Grpusr
0%
0/47
0%
0/10
0
Grpusr$JoindateComparator
0%
0/17
0%
0/22
0
 
 1  0
 package jp.co.y_net.amm.dao;
 2  
 
 3  
 import java.io.Serializable;
 4  
 import java.util.Comparator;
 5  
 
 6  
 import jp.co.y_net.amm.common.AppUtils;
 7  
 
 8  
 
 9  0
 public class Grpusr extends AppDto implements Serializable {
 10  
     private static final long serialVersionUID = 1L;
 11  
     
 12  0
     public static final Integer STATUS_未設定 = -1;
 13  0
     public static final Integer STATUS_招待中 = 0;
 14  0
     public static final Integer STATUS_参加中 = 1;
 15  0
     public static final Integer STATUS_脱退 = 2;
 16  
     
 17  0
     public static final Integer STATUS_ADMIN_未設定 = -1;
 18  0
     public static final Integer STATUS_ADMIN_移管依頼中 = 0;
 19  0
     public static final Integer STATUS_ADMIN_移管完了 = 1;
 20  
     
 21  
     
 22  
     /* DBMSと連携するメンバ */
 23  
     private Integer grpusrid;
 24  
     private Integer grpid;
 25  
     private Integer usrid;
 26  
     
 27  
     private Long invitationdate;
 28  
     private Long joindate;
 29  
     private Long leavedate;
 30  
     private Long admindate;
 31  
     
 32  
     private Integer statusadmin;
 33  
     private Integer status;
 34  
 
 35  
 
 36  
     
 37  
     /* アプリケーションで設定するメンバ */
 38  
     // なし
 39  
     
 40  
     /* 自動生成のアクセサ */
 41  
     public Integer getGrpusrid() {
 42  0
         return grpusrid;
 43  
     }
 44  
     public void setGrpusrid(Integer grpusrid) {
 45  0
         this.grpusrid = grpusrid;
 46  0
     }
 47  
     public Integer getGrpid() {
 48  0
         return grpid;
 49  
     }
 50  
     public void setGrpid(Integer grpid) {
 51  0
         this.grpid = grpid;
 52  0
     }
 53  
     public Integer getUsrid() {
 54  0
         return usrid;
 55  
     }
 56  
     public void setUsrid(Integer usrid) {
 57  0
         this.usrid = usrid;
 58  0
     }
 59  
     public Long getInvitationdate() {
 60  0
         return invitationdate;
 61  
     }
 62  
     public void setInvitationdate(Long invitationdate) {
 63  0
         this.invitationdate = invitationdate;
 64  0
     }
 65  
     public Long getJoindate() {
 66  0
         return joindate;
 67  
     }
 68  
     public void setJoindate(Long joindate) {
 69  0
         this.joindate = joindate;
 70  0
     }
 71  
     public Long getLeavedate() {
 72  0
         return leavedate;
 73  
     }
 74  
     public void setLeavedate(Long leavedate) {
 75  0
         this.leavedate = leavedate;
 76  0
     }
 77  
     public Long getAdmindate() {
 78  0
         return admindate;
 79  
     }
 80  
     public void setAdmindate(Long admindate) {
 81  0
         this.admindate = admindate;
 82  0
     }
 83  
     public Integer getStatusadmin() {
 84  0
         return statusadmin;
 85  
     }
 86  
     public void setStatusadmin(Integer statusadmin) {
 87  0
         this.statusadmin = statusadmin;
 88  0
     }
 89  
     public Integer getStatus() {
 90  0
         return status;
 91  
     }
 92  
     public void setStatus(Integer status) {
 93  0
         this.status = status;
 94  0
     }
 95  
     /* 自動生成のアクセサ -end */
 96  
 
 97  
     /* 型変換のアクセサ */
 98  
 
 99  
     
 100  
     /* 型変換のアクセサ - end */
 101  
 
 102  
     
 103  
     /**
 104  
      * 参加日時のソートに用いるComparator
 105  
      */
 106  
     public static class JoindateComparator implements Comparator<Grpusr> {
 107  
         /** trueに変更すると新しい順 */
 108  0
         private boolean desc = false; 
 109  
         
 110  0
         public JoindateComparator(boolean desc) {
 111  0
             this.desc = desc;
 112  0
         }
 113  
         
 114  
         @Override
 115  
         public int compare(Grpusr o1, Grpusr o2) {
 116  0
             int reverse = 1;
 117  0
             if(desc) {
 118  0
                 reverse = -1;
 119  
             }
 120  
             
 121  0
             Long n1 = 0L;
 122  0
             Long n2 = 0L;
 123  0
             if(o1 != null && o1.getJoindate() != null) n1 = o1.getJoindate();
 124  0
             if(o2 != null && o2.getJoindate() != null) n2 = o2.getJoindate();
 125  
             
 126  
             /* 参加日が未設定の時は、招待日に置き換える */
 127  0
             if(n1 == 0L) {
 128  0
                 if(o1 != null && o1.getInvitationdate() != null) n1 = o1.getInvitationdate();
 129  
             }
 130  0
             if(n2 == 0L) {
 131  0
                 if(o2 != null && o2.getInvitationdate() != null) n2 = o2.getInvitationdate();
 132  
             }
 133  
             
 134  0
             return Long.compare(n1, n2) * reverse;
 135  
         }
 136  
     }
 137  
 
 138  
     /**
 139  
      * statusadmin と status を合算した結果を表示文字列で返す。
 140  
      * 
 141  
      * 参加状態(status)=「招待中」 ⇒ 招待中
 142  
      * 参加状態(status)=「参加済み」 かつ 移管状態=未設定 ⇒ 参加中
 143  
      * 参加状態(status)=「参加済み」 かつ 移管状態=「移管依頼中」 ⇒ 移管依頼中
 144  
      * 参加状態(status)=「参加済み」 かつ 移管状態=「移管完了」 ⇒ 参加中
 145  
      */
 146  
     public String getStatus合算() {
 147  0
         if(this.status == null || STATUS_未設定.equals(this.status) ) {
 148  0
             return "";
 149  
         }
 150  0
         if(STATUS_招待中.equals(this.status)) {
 151  0
             return "招待中";
 152  
         }
 153  0
         if(STATUS_参加中.equals(this.status)) {
 154  
             
 155  0
             if(STATUS_ADMIN_移管依頼中.equals(this.status)) {
 156  0
                 return "移管依頼中";
 157  
             }
 158  0
             return "参加中";
 159  
         }
 160  0
         return "";
 161  
     }
 162  
     public void set脱退設定() {
 163  0
         this.setLeavedate(AppUtils.createNowLong()); // 脱退日時
 164  0
         this.setStatus(Grpusr.STATUS_脱退);
 165  0
     }
 166  
 
 167  
 
 168  
 }
 169