Clover Coverage Report - KS Services 0.0.1-SNAPSHOT (Aggregated)
Coverage timestamp: Mon May 23 2011 04:06:57 EDT
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
25   123   12   2.27
2   72   0.48   11
11     1.09  
1    
 
  MetaEntity       Line # 32 25 0% 12 38 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.r2.common.entity;
17   
18    import java.util.Date;
19   
20    import javax.persistence.Column;
21    import javax.persistence.Embeddable;
22    import javax.persistence.MappedSuperclass;
23    import javax.persistence.Temporal;
24    import javax.persistence.TemporalType;
25   
26    import org.kuali.student.common.dto.MetaInfo;
27    import org.kuali.student.common.util.security.SecurityUtils;
28    import org.kuali.student.core.entity.BaseEntity;
29   
30    @MappedSuperclass
31    @Embeddable
 
32    public abstract class MetaEntity extends BaseEntity{
33   
34    // Hibernate will not allow @Version in @Embeddable for some annoying reason
35    // @Version
36    // private long versionInd;
37   
38    @Temporal(TemporalType.TIMESTAMP)
39    @Column(updatable=false)
40    private Date createTime;
41   
42    @Column(updatable=false)
43    private String createId;
44   
45    @Temporal(TemporalType.TIMESTAMP)
46    private Date updateTime;
47   
48    private String updateId;
49   
50    // public long getVersionInd() {
51    // return versionInd;
52    // }
53   
54    // public void setVersionInd(long versionInd) {
55    // this.versionInd = versionInd;
56    // }
57   
 
58  0 toggle public Date getCreateTime() {
59  0 return createTime;
60    }
61   
 
62  0 toggle public void setCreateTime(Date createTime) {
63  0 this.createTime = createTime;
64    }
65   
 
66  0 toggle public String getCreateId() {
67  0 return createId;
68    }
69   
 
70  0 toggle public void setCreateId(String createId) {
71  0 this.createId = createId;
72    }
73   
 
74  0 toggle public Date getUpdateTime() {
75  0 return updateTime;
76    }
77   
 
78  0 toggle public void setUpdateTime(Date updateTime) {
79  0 this.updateTime = updateTime;
80    }
81   
 
82  0 toggle public String getUpdateId() {
83  0 return updateId;
84    }
85   
 
86  0 toggle public void setUpdateId(String updateId) {
87  0 this.updateId = updateId;
88    }
89   
 
90  0 toggle @Override
91    protected void onPrePersist(){
92  0 super.onPrePersist();
93  0 setCreateTime(new Date());
94  0 setUpdateTime(new Date());
95   
96  0 String user = SecurityUtils.getCurrentUserId();
97  0 setCreateId(user);
98  0 setUpdateId(user);
99   
100    }
101   
 
102  0 toggle @Override
103    protected void onPreUpdate(){
104  0 super.onPreUpdate();
105    //This code should not be here, but hibernate is calling update callback instead of prepersit if the id is not null.
106  0 if(getCreateTime() == null){
107  0 setCreateTime(new Date());
108    }
109   
110  0 String user = SecurityUtils.getCurrentUserId();
111  0 setUpdateId(user);
112    }
113   
 
114  0 toggle public MetaInfo toDTO() {
115  0 MetaInfo.Builder miBuilder = new MetaInfo.Builder();
116  0 miBuilder.setCreateId(getCreateId());
117  0 miBuilder.setCreateTime(getCreateTime());
118  0 miBuilder.setUpdateId(getUpdateId());
119  0 miBuilder.setUpdateTime(getUpdateTime());
120    // TODO: what about versionInd?
121  0 return miBuilder.build();
122    }
123    }