1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.enrollment.lpr.mock; |
17 | |
|
18 | |
import org.kuali.student.common.infc.*; |
19 | |
import org.kuali.student.enrollment.lpr.infc.*; |
20 | |
import org.springframework.beans.BeanUtils; |
21 | |
|
22 | |
import java.util.ArrayList; |
23 | |
import java.util.Date; |
24 | |
import java.util.List; |
25 | |
import org.kuali.student.common.dto.AttributeInfo; |
26 | |
import org.kuali.student.common.dto.MetaInfo; |
27 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationInfo; |
28 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationStateInfo; |
29 | |
import org.kuali.student.enrollment.lpr.dto.LuiPersonRelationTypeInfo; |
30 | |
import org.kuali.student.enrollment.lui.dto.LuiInfo; |
31 | |
import org.kuali.student.enrollment.lui.dto.LuiLuiRelationInfo; |
32 | |
import org.kuali.student.enrollment.lui.infc.LuiInfc; |
33 | |
import org.kuali.student.enrollment.lui.infc.LuiLuiRelationInfc; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 6 | public class CopierHelper { |
40 | |
|
41 | |
public MetaInfc makeCopy(MetaInfc orig) { |
42 | 8 | if (orig == null) { |
43 | 4 | return null; |
44 | |
} |
45 | 4 | MetaInfc copy = new MetaInfo(); |
46 | 4 | BeanUtils.copyProperties(orig, copy); |
47 | 4 | return copy; |
48 | |
} |
49 | |
|
50 | |
public LuiPersonRelationTypeInfc makeCopy(LuiPersonRelationTypeInfc orig) { |
51 | 0 | if (orig == null) { |
52 | 0 | return null; |
53 | |
} |
54 | 0 | LuiPersonRelationTypeInfc copy = new LuiPersonRelationTypeInfo(); |
55 | 0 | BeanUtils.copyProperties(orig, copy); |
56 | 0 | copy.setAttributes(makeCopy(orig.getAttributes())); |
57 | 0 | return copy; |
58 | |
} |
59 | |
|
60 | |
public LuiPersonRelationStateInfc makeCopy(LuiPersonRelationStateInfc orig) { |
61 | 0 | if (orig == null) { |
62 | 0 | return null; |
63 | |
} |
64 | 0 | LuiPersonRelationStateInfc copy = new LuiPersonRelationStateInfo(); |
65 | 0 | BeanUtils.copyProperties(orig, copy); |
66 | 0 | copy.setAttributes(makeCopy(orig.getAttributes())); |
67 | 0 | return copy; |
68 | |
} |
69 | |
|
70 | |
public AttributeInfc makeCopy(AttributeInfc orig) { |
71 | 12 | if (orig == null) { |
72 | 0 | return null; |
73 | |
} |
74 | 12 | AttributeInfc copy = new AttributeInfo(); |
75 | 12 | BeanUtils.copyProperties(orig, copy); |
76 | 12 | return copy; |
77 | |
} |
78 | |
|
79 | |
public List<AttributeInfc> makeCopy(List<? extends AttributeInfc> orig) { |
80 | 7 | if (orig == null) { |
81 | 0 | return null; |
82 | |
} |
83 | 7 | List<AttributeInfc> copy = new ArrayList(); |
84 | 7 | for (AttributeInfc attr : orig) { |
85 | 12 | copy.add(this.makeCopy(attr)); |
86 | |
} |
87 | 7 | return copy; |
88 | |
} |
89 | |
|
90 | |
public LuiPersonRelationInfc makeCopy(LuiPersonRelationInfc orig) { |
91 | 7 | if (orig == null) { |
92 | 0 | return null; |
93 | |
} |
94 | 7 | LuiPersonRelationInfc copy = new LuiPersonRelationInfo(); |
95 | 7 | BeanUtils.copyProperties(orig, copy); |
96 | 7 | copy.setAttributes(this.makeCopy(orig.getAttributes())); |
97 | 7 | copy.setMetaInfo(this.makeCopy(orig.getMetaInfo())); |
98 | 7 | return copy; |
99 | |
} |
100 | |
|
101 | |
public LuiInfc makeCopy(LuiInfc orig) { |
102 | 0 | if (orig == null) { |
103 | 0 | return null; |
104 | |
} |
105 | 0 | LuiInfc copy = new LuiInfo(); |
106 | 0 | BeanUtils.copyProperties(orig, copy); |
107 | 0 | copy.setAttributes(this.makeCopy(orig.getAttributes())); |
108 | 0 | copy.setMetaInfo(this.makeCopy(orig.getMetaInfo())); |
109 | 0 | return copy; |
110 | |
} |
111 | |
|
112 | |
|
113 | |
public LuiLuiRelationInfc makeCopy(LuiLuiRelationInfc orig) { |
114 | 0 | if (orig == null) { |
115 | 0 | return null; |
116 | |
} |
117 | 0 | LuiLuiRelationInfc copy = new LuiLuiRelationInfo(); |
118 | 0 | BeanUtils.copyProperties(orig, copy); |
119 | 0 | copy.setAttributes(this.makeCopy(orig.getAttributes())); |
120 | 0 | copy.setMetaInfo(this.makeCopy(orig.getMetaInfo())); |
121 | 0 | return copy; |
122 | |
} |
123 | |
|
124 | |
public MetaInfc createMeta(ContextInfc context) { |
125 | 4 | MetaInfc meta = new MetaInfo(); |
126 | 4 | Date now = new Date(); |
127 | 4 | meta.setCreateId(context.getPrincipalId()); |
128 | 4 | meta.setCreateTime(now); |
129 | 4 | meta.setUpdateId(context.getPrincipalId()); |
130 | 4 | meta.setUpdateTime(now); |
131 | 4 | meta.setVersionInd("1"); |
132 | 4 | return meta; |
133 | |
} |
134 | |
|
135 | |
public MetaInfc updateMeta(MetaInfc orig, ContextInfc context) { |
136 | 1 | MetaInfc meta = makeCopy(orig); |
137 | 1 | Date now = new Date(); |
138 | 1 | meta.setUpdateId(context.getPrincipalId()); |
139 | 1 | meta.setUpdateTime(now); |
140 | 1 | int oldVersionInd = Integer.parseInt(meta.getVersionInd()); |
141 | 1 | meta.setVersionInd("" + (oldVersionInd + 1)); |
142 | 1 | return meta; |
143 | |
} |
144 | |
} |
145 | |
|