Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MetaEntity |
|
| 1.5;1.5 |
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.core.entity; | |
17 | ||
18 | import java.util.Date; | |
19 | ||
20 | import javax.persistence.Embedded; | |
21 | import javax.persistence.MappedSuperclass; | |
22 | ||
23 | import org.kuali.student.common.util.security.SecurityUtils; | |
24 | ||
25 | @MappedSuperclass | |
26 | 0 | public abstract class MetaEntity extends BaseEntity{ |
27 | ||
28 | @Embedded | |
29 | private Meta meta; | |
30 | ||
31 | @Override | |
32 | protected void onPrePersist(){ | |
33 | 0 | super.onPrePersist(); |
34 | 0 | if(meta==null){ |
35 | 0 | meta = new Meta(); |
36 | } | |
37 | 0 | meta.setCreateTime(new Date()); |
38 | 0 | meta.setUpdateTime(new Date()); |
39 | ||
40 | 0 | String user = SecurityUtils.getCurrentUserId(); |
41 | 0 | meta.setCreateId(user); |
42 | 0 | meta.setUpdateId(user); |
43 | ||
44 | 0 | } |
45 | ||
46 | @Override | |
47 | protected void onPreUpdate(){ | |
48 | 0 | super.onPreUpdate(); |
49 | //This code should not be here, but hibernate is calling update callback instead of prepersit if the id is not null. | |
50 | 0 | if(meta==null){ |
51 | 0 | meta = new Meta(); |
52 | 0 | meta.setCreateTime(new Date()); |
53 | } | |
54 | ||
55 | 0 | meta.setUpdateTime(new Date()); |
56 | ||
57 | 0 | String user = SecurityUtils.getCurrentUserId(); |
58 | 0 | meta.setUpdateId(user); |
59 | 0 | } |
60 | ||
61 | public Meta getMeta() { | |
62 | 0 | return meta; |
63 | } | |
64 | ||
65 | public void setMeta(Meta meta) { | |
66 | 0 | this.meta = meta; |
67 | 0 | } |
68 | } |