1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
package org.kuali.student.enrollment.class1.lui.service.impl; |
6 | |
|
7 | |
import java.util.ArrayList; |
8 | |
import java.util.HashMap; |
9 | |
import java.util.List; |
10 | |
import java.util.Map; |
11 | |
import java.util.Map.Entry; |
12 | |
|
13 | |
|
14 | |
import java.util.logging.Level; |
15 | |
import java.util.logging.Logger; |
16 | |
import org.kuali.student.common.entity.Amount; |
17 | |
import org.kuali.student.common.entity.CurrencyAmount; |
18 | |
import org.kuali.student.common.entity.TimeAmount; |
19 | |
import org.kuali.student.r2.common.dto.AmountInfo; |
20 | |
import org.kuali.student.r2.common.dto.CurrencyAmountInfo; |
21 | |
import org.kuali.student.r2.common.dto.TimeAmountInfo; |
22 | |
|
23 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
24 | |
import org.kuali.student.r2.lum.clu.dto.AccreditationInfo; |
25 | |
import org.kuali.student.r2.lum.clu.dto.AdminOrgInfo; |
26 | |
import org.kuali.student.r2.lum.clu.dto.AffiliatedOrgInfo; |
27 | |
import org.kuali.student.r2.lum.clu.dto.CluAccountingInfo; |
28 | |
import org.kuali.student.r2.lum.clu.dto.CluCluRelationInfo; |
29 | |
import org.kuali.student.r2.lum.clu.dto.CluCreditInfo; |
30 | |
import org.kuali.student.r2.lum.clu.dto.CluFeeInfo; |
31 | |
import org.kuali.student.r2.lum.clu.dto.CluFeeRecordInfo; |
32 | |
import org.kuali.student.r2.lum.clu.dto.CluIdentifierInfo; |
33 | |
import org.kuali.student.r2.lum.clu.dto.CluInfo; |
34 | |
import org.kuali.student.r2.lum.clu.dto.CluInstructorInfo; |
35 | |
import org.kuali.student.r2.lum.clu.dto.CluLoRelationInfo; |
36 | |
import org.kuali.student.r2.lum.clu.dto.CluPublicationInfo; |
37 | |
import org.kuali.student.r2.lum.clu.dto.CluResultInfo; |
38 | |
import org.kuali.student.r2.lum.clu.dto.CluSetInfo; |
39 | |
import org.kuali.student.r2.lum.clu.dto.FieldInfo; |
40 | |
import org.kuali.student.r2.lum.clu.dto.LuCodeInfo; |
41 | |
import org.kuali.student.r2.lum.clu.dto.MembershipQueryInfo; |
42 | |
import org.kuali.student.r2.lum.clu.dto.ResultOptionInfo; |
43 | |
|
44 | |
|
45 | |
import org.kuali.student.enrollment.lui.dto.LuiInfo; |
46 | |
import org.kuali.student.enrollment.lui.dto.LuiLuiRelationInfo; |
47 | |
import org.kuali.student.lum.lu.dao.LuDao; |
48 | |
import org.kuali.student.lum.lu.entity.AffiliatedOrg; |
49 | |
import org.kuali.student.lum.lu.entity.Clu; |
50 | |
import org.kuali.student.lum.lu.entity.CluAccounting; |
51 | |
import org.kuali.student.lum.lu.entity.CluAccreditation; |
52 | |
import org.kuali.student.lum.lu.entity.CluAdminOrg; |
53 | |
import org.kuali.student.lum.lu.entity.CluAtpTypeKey; |
54 | |
import org.kuali.student.lum.lu.entity.CluCampusLocation; |
55 | |
import org.kuali.student.lum.lu.entity.CluCluRelation; |
56 | |
import org.kuali.student.lum.lu.entity.CluCredit; |
57 | |
import org.kuali.student.lum.lu.entity.CluFee; |
58 | |
import org.kuali.student.lum.lu.entity.CluFeeAmount; |
59 | |
import org.kuali.student.lum.lu.entity.CluFeeAttribute; |
60 | |
import org.kuali.student.lum.lu.entity.CluFeeRecord; |
61 | |
import org.kuali.student.lum.lu.entity.CluFeeRecordAttribute; |
62 | |
import org.kuali.student.lum.lu.entity.CluIdentifier; |
63 | |
import org.kuali.student.lum.lu.entity.CluIdentifierAttribute; |
64 | |
import org.kuali.student.lum.lu.entity.CluInstructor; |
65 | |
import org.kuali.student.lum.lu.entity.CluLoRelation; |
66 | |
import org.kuali.student.lum.lu.entity.CluLoRelationType; |
67 | |
import org.kuali.student.lum.lu.entity.CluPublication; |
68 | |
import org.kuali.student.lum.lu.entity.CluPublicationVariant; |
69 | |
import org.kuali.student.lum.lu.entity.CluResult; |
70 | |
import org.kuali.student.lum.lu.entity.CluResultType; |
71 | |
import org.kuali.student.lum.lu.entity.CluSet; |
72 | |
import org.kuali.student.lum.lu.entity.CluSetAttribute; |
73 | |
import org.kuali.student.lum.lu.entity.CluSetJoinVersionIndClu; |
74 | |
import org.kuali.student.lum.lu.entity.CluSetType; |
75 | |
import org.kuali.student.lum.lu.entity.DeliveryMethodType; |
76 | |
import org.kuali.student.lum.lu.entity.InstructionalFormatType; |
77 | |
import org.kuali.student.lum.lu.entity.LuCode; |
78 | |
import org.kuali.student.lum.lu.entity.LuCodeType; |
79 | |
import org.kuali.student.lum.lu.entity.LuLuRelationType; |
80 | |
import org.kuali.student.lum.lu.entity.LuPublicationType; |
81 | |
import org.kuali.student.lum.lu.entity.LuRichText; |
82 | |
import org.kuali.student.lum.lu.entity.LuType; |
83 | |
import org.kuali.student.lum.lu.entity.Lui; |
84 | |
import org.kuali.student.lum.lu.entity.LuiAttribute; |
85 | |
import org.kuali.student.lum.lu.entity.LuiLuiRelation; |
86 | |
import org.kuali.student.lum.lu.entity.MembershipQuery; |
87 | |
import org.kuali.student.lum.lu.entity.ResultOption; |
88 | |
import org.kuali.student.lum.lu.entity.ResultUsageType; |
89 | |
import org.kuali.student.lum.lu.entity.SearchParameter; |
90 | |
import org.kuali.student.lum.lu.entity.SearchParameterValue; |
91 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
92 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
93 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
94 | |
import org.kuali.student.r2.common.service.impl.BaseAssembler; |
95 | |
import org.kuali.student.r2.core.search.dto.SearchParamInfo; |
96 | |
import org.kuali.student.r2.core.search.infc.SearchParam; |
97 | |
import org.springframework.beans.BeanUtils; |
98 | |
|
99 | 0 | public class LuServiceAssembler extends BaseAssembler { |
100 | |
|
101 | |
public static List<TypeInfo> toCluLoRelationTypeInfos( |
102 | |
List<CluLoRelationType> entities) { |
103 | 0 | return toGenericTypeInfoList(CluLoRelationInfo.class, entities); |
104 | |
} |
105 | |
|
106 | |
public static TypeInfo toCluLoRelationTypeInfo( |
107 | |
CluLoRelationType entity) { |
108 | 0 | return toGenericTypeInfo(CluLoRelationInfo.class, entity); |
109 | |
} |
110 | |
|
111 | |
public static List<CluCluRelationInfo> toCluCluRelationInfos( |
112 | |
List<CluCluRelation> entities) { |
113 | 0 | List<CluCluRelationInfo> dtos = new ArrayList<CluCluRelationInfo>( |
114 | |
entities.size()); |
115 | 0 | if (entities != null) { |
116 | 0 | for (CluCluRelation entity : entities) { |
117 | 0 | dtos.add(toCluCluRelationInfo(entity)); |
118 | |
} |
119 | |
} |
120 | 0 | return dtos; |
121 | |
|
122 | |
} |
123 | |
|
124 | |
public static CluCluRelationInfo toCluCluRelationInfo(CluCluRelation entity) { |
125 | 0 | if (entity == null) { |
126 | 0 | return null; |
127 | |
} |
128 | 0 | CluCluRelationInfo dto = new CluCluRelationInfo(); |
129 | 0 | BeanUtils.copyProperties(entity, dto, |
130 | |
new String[]{"cluId", "relatedCluId", "cluRelationRequired", |
131 | |
"attributes", "meta"}); |
132 | |
|
133 | 0 | dto.setIsCluRelationRequired(entity.isCluRelationRequired()); |
134 | 0 | dto.setCluId(entity.getClu().getId()); |
135 | 0 | dto.setRelatedCluId(entity.getRelatedClu().getId()); |
136 | 0 | dto.setTypeKey(entity.getLuLuRelationType().getId()); |
137 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
138 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
139 | |
|
140 | 0 | return dto; |
141 | |
|
142 | |
} |
143 | |
|
144 | |
public static List<CluLoRelationInfo> toCluLoRelationInfos( |
145 | |
List<CluLoRelation> entities) { |
146 | |
|
147 | 0 | List<CluLoRelationInfo> dtos = new ArrayList<CluLoRelationInfo>( |
148 | |
entities.size()); |
149 | 0 | if (entities != null) { |
150 | 0 | for (CluLoRelation entity : entities) { |
151 | 0 | dtos.add(toCluLoRelationInfo(entity)); |
152 | |
} |
153 | |
} |
154 | 0 | return dtos; |
155 | |
} |
156 | |
|
157 | |
public static CluLoRelationInfo toCluLoRelationInfo(CluLoRelation entity) { |
158 | 0 | if (entity == null) { |
159 | 0 | return null; |
160 | |
} |
161 | 0 | CluLoRelationInfo dto = new CluLoRelationInfo(); |
162 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"cluId", |
163 | |
"attributes", "meta", "type"}); |
164 | |
|
165 | 0 | dto.setCluId(entity.getClu().getId()); |
166 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
167 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
168 | 0 | dto.setTypeKey(entity.getType().getId()); |
169 | |
|
170 | 0 | return dto; |
171 | |
} |
172 | |
|
173 | |
public static List<CluInfo> toCluInfos(List<Clu> entities) { |
174 | |
|
175 | |
|
176 | 0 | if (entities == null) { |
177 | 0 | return new ArrayList<CluInfo>(0); |
178 | |
} |
179 | |
|
180 | 0 | List<CluInfo> dtos = new ArrayList<CluInfo>(entities.size()); |
181 | 0 | for (Clu entity : entities) { |
182 | 0 | dtos.add(toCluInfo(entity)); |
183 | |
} |
184 | 0 | return dtos; |
185 | |
|
186 | |
} |
187 | |
|
188 | |
public static CluInfo toCluInfo(Clu entity) { |
189 | 0 | if (entity == null) { |
190 | 0 | return null; |
191 | |
} |
192 | 0 | CluInfo dto = new CluInfo(); |
193 | |
|
194 | |
|
195 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{ |
196 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
197 | |
"participatingOrgs", "primaryInstructor", "instructors", |
198 | |
"stdDuration", "luCodes", "credit", "offeredAtpTypes", "fee", |
199 | |
"accounting", "intensity", |
200 | |
"campusLocationList", "accreditationList", |
201 | |
"adminOrgs", "attributes", "meta", "versionInfo"}); |
202 | 0 | dto.setOfficialIdentifier(toCluIdentifierInfo(entity.getOfficialIdentifier())); |
203 | 0 | dto.setAlternateIdentifiers(toCluIdentifierInfos(entity.getAlternateIdentifiers())); |
204 | 0 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
205 | |
|
206 | |
|
207 | |
|
208 | 0 | dto.setAccreditations(toAccreditationInfos(entity.getAccreditations())); |
209 | |
|
210 | 0 | dto.setAdminOrgs(toCluAdminOrgInfos(entity.getAdminOrgs())); |
211 | |
|
212 | 0 | dto.setPrimaryInstructor(toCluInstructorInfo(entity.getPrimaryInstructor())); |
213 | 0 | dto.setInstructors(toCluInstructorInfos(entity.getInstructors())); |
214 | 0 | dto.setStdDuration(toTimeAmountInfo(entity.getStdDuration())); |
215 | 0 | dto.setLuCodes(toLuCodeInfos(entity.getLuCodes())); |
216 | |
|
217 | 0 | if (entity.getOfferedAtpTypes() != null) { |
218 | 0 | List<String> offeredAtpTypes = new ArrayList<String>(entity.getOfferedAtpTypes().size()); |
219 | 0 | for (CluAtpTypeKey key : entity.getOfferedAtpTypes()) { |
220 | 0 | offeredAtpTypes.add(key.getAtpTypeKey()); |
221 | |
} |
222 | 0 | dto.setOfferedAtpTypes(offeredAtpTypes); |
223 | |
} |
224 | |
|
225 | 0 | dto.setFeeInfo(toCluFeeInfo(entity.getFee())); |
226 | 0 | dto.setAccountingInfo(toCluAccountingInfo(entity.getAccounting())); |
227 | |
|
228 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
229 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
230 | |
|
231 | 0 | dto.setType(entity.getLuType().getId()); |
232 | |
|
233 | 0 | if (entity.getCampusLocations() != null) { |
234 | 0 | List<String> campusLocations = new ArrayList<String>(entity.getCampusLocations().size()); |
235 | 0 | for (CluCampusLocation cluCamp : entity.getCampusLocations()) { |
236 | 0 | campusLocations.add(cluCamp.getCampusLocation()); |
237 | |
} |
238 | 0 | dto.setCampusLocations(campusLocations); |
239 | |
} |
240 | |
|
241 | 0 | dto.setIntensity(toAmountInfo(entity.getIntensity())); |
242 | |
|
243 | 0 | dto.setVersionInfo(toVersionInfo(entity.getVersion())); |
244 | |
|
245 | 0 | return dto; |
246 | |
|
247 | |
} |
248 | |
|
249 | |
public static List<CluSetInfo> toCluSetInfos(List<CluSet> entities) { |
250 | 0 | List<CluSetInfo> dtos = new ArrayList<CluSetInfo>(entities.size()); |
251 | 0 | if (entities != null) { |
252 | 0 | for (CluSet entity : entities) { |
253 | 0 | dtos.add(toCluSetInfo(entity)); |
254 | |
} |
255 | |
} |
256 | 0 | return dtos; |
257 | |
} |
258 | |
|
259 | |
public static CluSet toCluSetEntity(CluSetInfo cluSetInfo, LuDao luDao) throws InvalidParameterException, DoesNotExistException { |
260 | 0 | CluSet cluSet = new CluSet(); |
261 | |
|
262 | 0 | BeanUtils.copyProperties(cluSetInfo, cluSet, new String[]{"id", |
263 | |
"descr", "attributes", "meta", "membershipQuery"}); |
264 | 0 | cluSet.setAttributes(toGenericAttributes( |
265 | |
CluSetAttribute.class, cluSetInfo.getAttributes(), cluSet, luDao)); |
266 | 0 | cluSet.setType(cluSetInfo.getTypeKey()); |
267 | 0 | cluSet.setDescr(toRichText(LuRichText.class, cluSetInfo.getDescr())); |
268 | |
|
269 | 0 | for (String cluId : cluSetInfo.getCluIds()) { |
270 | 0 | CluSetJoinVersionIndClu join = new CluSetJoinVersionIndClu(); |
271 | 0 | join.setCluSet(cluSet); |
272 | 0 | join.setCluVersionIndId(cluId); |
273 | 0 | cluSet.getCluVerIndIds().add(join); |
274 | 0 | } |
275 | 0 | for (String cluSetId : cluSetInfo.getCluSetIds()) { |
276 | |
CluSet c; |
277 | |
try { |
278 | 0 | c = luDao.fetch(CluSet.class, cluSetId); |
279 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
280 | 0 | throw new DoesNotExistException(cluSetId); |
281 | 0 | } |
282 | 0 | if (cluSet.getCluSets() == null) { |
283 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
284 | |
} |
285 | 0 | cluSet.getCluSets().add(c); |
286 | 0 | } |
287 | 0 | cluSet.setMembershipQuery(toMembershipQueryEntity(cluSetInfo.getMembershipQuery())); |
288 | |
|
289 | 0 | return cluSet; |
290 | |
} |
291 | |
|
292 | |
public static CluSetInfo toCluSetInfo(CluSet entity) { |
293 | 0 | if (entity == null) { |
294 | 0 | return null; |
295 | |
} |
296 | 0 | CluSetInfo dto = new CluSetInfo(); |
297 | |
|
298 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"descr", |
299 | |
"cluCriteria", "cluSets", "clus", "attributes", "meta", "membershipQuery"}); |
300 | |
|
301 | 0 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
302 | |
|
303 | 0 | if (entity.getCluSets() != null) { |
304 | 0 | List<String> cluSetIds = new ArrayList<String>(entity.getCluSets().size()); |
305 | 0 | for (CluSet id : entity.getCluSets()) { |
306 | 0 | cluSetIds.add(id.getId()); |
307 | |
} |
308 | 0 | dto.setCluSetIds(cluSetIds); |
309 | |
} |
310 | |
|
311 | 0 | List<String> cluIds = new ArrayList<String>(entity.getCluVerIndIds().size()); |
312 | 0 | for (CluSetJoinVersionIndClu join : entity.getCluVerIndIds()) { |
313 | 0 | cluIds.add(join.getCluVersionIndId()); |
314 | |
} |
315 | 0 | dto.setCluIds(cluIds); |
316 | |
|
317 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
318 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
319 | |
|
320 | 0 | MembershipQueryInfo mqInfo = toMembershipQueryInfo(entity.getMembershipQuery()); |
321 | 0 | dto.setMembershipQuery(mqInfo); |
322 | 0 | dto.setIsReusable(entity.getIsReusable()); |
323 | 0 | dto.setIsReferenceable(entity.getIsReferenceable()); |
324 | |
|
325 | 0 | return dto; |
326 | |
} |
327 | |
|
328 | |
public static MembershipQueryInfo toMembershipQueryInfo(MembershipQuery entity) { |
329 | 0 | if (entity == null) { |
330 | 0 | return null; |
331 | |
} |
332 | 0 | MembershipQueryInfo dto = new MembershipQueryInfo(); |
333 | 0 | dto.setId(entity.getId()); |
334 | 0 | dto.setSearchTypeKey(entity.getSearchTypeKey()); |
335 | 0 | List<SearchParamInfo> list = new ArrayList<SearchParamInfo>(); |
336 | 0 | for (SearchParameter param : entity.getSearchParameters()) { |
337 | 0 | SearchParamInfo sp = toSearchParam(param); |
338 | 0 | list.add(sp); |
339 | 0 | } |
340 | 0 | dto.setQueryParamValues(list); |
341 | |
|
342 | 0 | return dto; |
343 | |
} |
344 | |
|
345 | |
public static SearchParamInfo toSearchParam(SearchParameter entity) { |
346 | 0 | SearchParamInfo dto = new SearchParamInfo(); |
347 | 0 | dto.setKey(entity.getKey()); |
348 | 0 | List<String> values = new ArrayList<String>(); |
349 | 0 | for (SearchParameterValue value : entity.getValues()) { |
350 | 0 | values.add(value.getValue()); |
351 | |
} |
352 | 0 | dto.setValue(values); |
353 | 0 | if (entity.getValues().size() == 1) { |
354 | 0 | dto.setValue(entity.getValues().get(0).getValue()); |
355 | |
} |
356 | 0 | return dto; |
357 | |
} |
358 | |
|
359 | |
public static MembershipQuery toMembershipQueryEntity(MembershipQueryInfo dto) { |
360 | 0 | if (dto == null) { |
361 | 0 | return null; |
362 | |
} |
363 | 0 | MembershipQuery entity = new MembershipQuery(); |
364 | 0 | entity.setSearchTypeKey(dto.getSearchTypeKey()); |
365 | 0 | List<SearchParameter> list = new ArrayList<SearchParameter>(); |
366 | 0 | for (SearchParam param : dto.getQueryParamValues()) { |
367 | 0 | SearchParameter sp = toSearchParameterEntity(param); |
368 | 0 | list.add(sp); |
369 | 0 | } |
370 | 0 | entity.setSearchParameters(list); |
371 | |
|
372 | 0 | return entity; |
373 | |
} |
374 | |
|
375 | |
public static SearchParameter toSearchParameterEntity(SearchParam dto) { |
376 | 0 | if (dto == null) { |
377 | 0 | return null; |
378 | |
} |
379 | 0 | SearchParameter entity = new SearchParameter(); |
380 | 0 | entity.setKey(dto.getKey()); |
381 | 0 | List<SearchParameterValue> values = new ArrayList<SearchParameterValue>(); |
382 | 0 | for (String s : dto.getValues()) { |
383 | 0 | SearchParameterValue value = new SearchParameterValue(); |
384 | 0 | value.setValue(s); |
385 | 0 | values.add(value); |
386 | 0 | } |
387 | 0 | entity.setValues(values); |
388 | 0 | return entity; |
389 | |
} |
390 | |
|
391 | |
public static List<TypeInfo> toResultUsageTypeInfos( |
392 | |
List<ResultUsageType> entities) { |
393 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
394 | |
} |
395 | |
|
396 | |
public static TypeInfo toResultUsageTypeInfo( |
397 | |
ResultUsageType entity) { |
398 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
399 | |
} |
400 | |
|
401 | |
public static List<TypeInfo> toDeliveryMethodTypeInfos( |
402 | |
List<DeliveryMethodType> entities) { |
403 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
404 | |
} |
405 | |
|
406 | |
public static TypeInfo toDeliveryMethodTypeInfo( |
407 | |
DeliveryMethodType entity) { |
408 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
409 | |
} |
410 | |
|
411 | |
public static List<TypeInfo> toInstructionalFormatTypeInfos( |
412 | |
List<InstructionalFormatType> entities) { |
413 | 0 | return toGenericTypeInfoList(TypeInfo.class, |
414 | |
entities); |
415 | |
} |
416 | |
|
417 | |
public static TypeInfo toInstructionalFormatTypeInfo( |
418 | |
InstructionalFormatType entity) { |
419 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
420 | |
} |
421 | |
|
422 | |
public static List<TypeInfo> toLuCodeTypeInfos( |
423 | |
List<LuCodeType> entities) { |
424 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
425 | |
} |
426 | |
|
427 | |
public static TypeInfo toLuCodeTypeInfo(LuCodeType entity) { |
428 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
429 | |
} |
430 | |
|
431 | |
public static List<TypeInfo> toCluResultTypeInfos( |
432 | |
List<CluResultType> entities) { |
433 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
434 | |
} |
435 | |
|
436 | |
public static TypeInfo toCluResultTypeInfo(CluResultType entity) { |
437 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
438 | |
} |
439 | |
|
440 | |
public static TypeInfo toCluSetTypeInfo(CluSetType entity) { |
441 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
442 | |
} |
443 | |
|
444 | |
public static List<TypeInfo> toCluSetTypeInfos( |
445 | |
List<CluSetType> entities) { |
446 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
447 | |
} |
448 | |
|
449 | |
public static CluResultInfo toCluResultInfo(CluResult entity) { |
450 | 0 | if (entity == null) { |
451 | 0 | return null; |
452 | |
} |
453 | |
|
454 | 0 | CluResultInfo dto = new CluResultInfo(); |
455 | |
|
456 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"resultOptions", "desc"}); |
457 | |
|
458 | 0 | List<ResultOptionInfo> resultOptions = toResultOptionInfos(entity.getResultOptions()); |
459 | 0 | dto.setResultOptions(resultOptions); |
460 | 0 | dto.setDescr(toRichTextInfo(entity.getDesc())); |
461 | 0 | dto.setCluId(entity.getClu().getId()); |
462 | 0 | TypeInfo type = toCluResultTypeInfo(entity.getCluResultType()); |
463 | 0 | if (type != null) { |
464 | 0 | dto.setTypeKey(type.getKey()); |
465 | |
} |
466 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
467 | |
|
468 | 0 | return dto; |
469 | |
} |
470 | |
|
471 | |
public static List<CluResultInfo> toCluResultInfos(List<CluResult> entities) { |
472 | 0 | List<CluResultInfo> dtos = new ArrayList<CluResultInfo>(); |
473 | 0 | if (entities != null) { |
474 | 0 | for (CluResult entity : entities) { |
475 | 0 | dtos.add(toCluResultInfo(entity)); |
476 | |
} |
477 | |
} |
478 | 0 | return dtos; |
479 | |
} |
480 | |
|
481 | |
public static List<ResultOptionInfo> toResultOptionInfos( |
482 | |
List<ResultOption> entities) { |
483 | 0 | List<ResultOptionInfo> dtos = new ArrayList<ResultOptionInfo>(); |
484 | 0 | if (entities != null) { |
485 | 0 | for (ResultOption entity : entities) { |
486 | 0 | dtos.add(toResultOptionInfo(entity)); |
487 | |
} |
488 | |
} |
489 | 0 | return dtos; |
490 | |
} |
491 | |
|
492 | |
public static ResultOptionInfo toResultOptionInfo(ResultOption entity) { |
493 | 0 | if (entity == null) { |
494 | 0 | return null; |
495 | |
} |
496 | |
|
497 | 0 | ResultOptionInfo dto = new ResultOptionInfo(); |
498 | |
|
499 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"resultUsageType", "desc"}); |
500 | 0 | if (entity.getResultUsageType() != null) { |
501 | 0 | dto.setResultUsageTypeKey(entity.getResultUsageType().getId()); |
502 | |
} |
503 | 0 | dto.setDescr(toRichTextInfo(entity.getDesc())); |
504 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
505 | |
|
506 | 0 | return dto; |
507 | |
} |
508 | |
|
509 | |
public static List<TypeInfo> toLuLuRelationTypeInfos( |
510 | |
List<LuLuRelationType> entities) { |
511 | 0 | List<TypeInfo> dtos = new ArrayList<TypeInfo>( |
512 | |
entities.size()); |
513 | 0 | if (entities != null) { |
514 | 0 | for (LuLuRelationType entity : entities) { |
515 | 0 | dtos.add(toLuLuRelationTypeInfo(entity)); |
516 | |
} |
517 | |
} |
518 | 0 | return dtos; |
519 | |
|
520 | |
} |
521 | |
|
522 | |
public static TypeInfo toLuLuRelationTypeInfo( |
523 | |
LuLuRelationType entity) { |
524 | 0 | if (entity == null) { |
525 | 0 | return null; |
526 | |
} |
527 | 0 | TypeInfo dto = new TypeInfo(); |
528 | |
|
529 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"attributes"}); |
530 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
531 | |
|
532 | 0 | return dto; |
533 | |
} |
534 | |
|
535 | |
public static List<TypeInfo> toLuTypeInfos(List<LuType> entities) { |
536 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
537 | |
} |
538 | |
|
539 | |
public static TypeInfo toLuTypeInfo(LuType entity) { |
540 | 0 | TypeInfo typeInfo = toGenericTypeInfo(TypeInfo.class, entity); |
541 | |
|
542 | |
|
543 | |
|
544 | 0 | return typeInfo; |
545 | |
} |
546 | |
|
547 | |
public static List<LuiInfo> toLuiInfos(List<Lui> entities) { |
548 | 0 | List<LuiInfo> dtos = new ArrayList<LuiInfo>(entities.size()); |
549 | 0 | if (entities != null) { |
550 | 0 | for (Lui entity : entities) { |
551 | 0 | dtos.add(toLuiInfo(entity)); |
552 | |
} |
553 | |
} |
554 | 0 | return dtos; |
555 | |
|
556 | |
} |
557 | |
|
558 | |
public static LuiInfo toLuiInfo(Lui entity) { |
559 | 0 | if (entity == null) { |
560 | 0 | return null; |
561 | |
} |
562 | 0 | LuiInfo luiInfo = new LuiInfo(); |
563 | |
|
564 | 0 | BeanUtils.copyProperties(entity, luiInfo, new String[]{"clu", |
565 | |
"meta", "attributes"}); |
566 | |
|
567 | 0 | luiInfo.setCluId(entity.getClu().getId()); |
568 | |
|
569 | 0 | luiInfo.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
570 | |
|
571 | 0 | luiInfo.setAttributes(toAttributeMap(entity.getAttributes())); |
572 | |
|
573 | 0 | return luiInfo; |
574 | |
} |
575 | |
|
576 | |
public static Lui toLui(boolean isUpdate, LuiInfo luiInfo, LuDao dao) |
577 | |
throws DoesNotExistException, VersionMismatchException, |
578 | |
InvalidParameterException { |
579 | 0 | if (luiInfo == null) { |
580 | 0 | return null; |
581 | |
} |
582 | |
Lui lui; |
583 | |
|
584 | 0 | if (isUpdate) { |
585 | |
try { |
586 | 0 | lui = dao.fetch(Lui.class, luiInfo.getId()); |
587 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
588 | 0 | throw new DoesNotExistException (luiInfo.getId()); |
589 | 0 | } |
590 | 0 | if (null == lui) { |
591 | 0 | throw new DoesNotExistException((new StringBuilder()).append( |
592 | |
"Lui does not exist for id: ").append(luiInfo.getId()).toString()); |
593 | |
} |
594 | 0 | if (!String.valueOf(lui.getVersionNumber()).equals( |
595 | |
luiInfo.getMeta().getVersionInd())) { |
596 | 0 | throw new VersionMismatchException( |
597 | |
"Lui to be updated is not the current version"); |
598 | |
} |
599 | |
} else { |
600 | 0 | lui = new Lui(); |
601 | |
} |
602 | |
|
603 | 0 | BeanUtils.copyProperties(luiInfo, lui, new String[]{"cluId", |
604 | |
"attributes", "meta"}); |
605 | |
|
606 | 0 | lui.setAttributes(toGenericAttributes(LuiAttribute.class, luiInfo.getAttributes(), lui, dao)); |
607 | |
|
608 | |
Clu clu; |
609 | |
try { |
610 | 0 | clu = dao.fetch(Clu.class, luiInfo.getCluId()); |
611 | 0 | } catch (org.kuali.student.common.exceptions.DoesNotExistException ex) { |
612 | 0 | throw new DoesNotExistException (luiInfo.getCluId()); |
613 | 0 | } |
614 | 0 | if (null == clu) { |
615 | 0 | throw new InvalidParameterException((new StringBuilder()).append( |
616 | |
"Clu does not exist for id: ").append(luiInfo.getCluId()).toString()); |
617 | |
} |
618 | 0 | lui.setClu(clu); |
619 | 0 | return lui; |
620 | |
} |
621 | |
|
622 | |
public static List<LuiLuiRelationInfo> toLuiLuiRelationInfos( |
623 | |
List<LuiLuiRelation> entities) { |
624 | 0 | List<LuiLuiRelationInfo> dtos = new ArrayList<LuiLuiRelationInfo>( |
625 | |
entities.size()); |
626 | 0 | if (entities != null) { |
627 | 0 | for (LuiLuiRelation entity : entities) { |
628 | 0 | dtos.add(toLuiLuiRelationInfo(entity)); |
629 | |
} |
630 | |
} |
631 | 0 | return dtos; |
632 | |
} |
633 | |
|
634 | |
public static LuiLuiRelationInfo toLuiLuiRelationInfo(LuiLuiRelation entity) { |
635 | 0 | if (entity == null) { |
636 | 0 | return null; |
637 | |
} |
638 | 0 | LuiLuiRelationInfo dto = new LuiLuiRelationInfo(); |
639 | |
|
640 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"lui", |
641 | |
"relatedLui", "attributes"}); |
642 | |
|
643 | 0 | dto.setLuiId(entity.getLui().getId()); |
644 | 0 | dto.setRelatedLuiId(entity.getRelatedLui().getId()); |
645 | 0 | dto.setType(entity.getLuLuRelationType().getId()); |
646 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
647 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
648 | 0 | return dto; |
649 | |
} |
650 | |
|
651 | |
public static List<CluIdentifierInfo> toCluIdentifierInfos( |
652 | |
List<CluIdentifier> entities) { |
653 | 0 | List<CluIdentifierInfo> dtos = new ArrayList<CluIdentifierInfo>( |
654 | |
entities.size()); |
655 | 0 | if (entities != null) { |
656 | 0 | for (CluIdentifier entity : entities) { |
657 | 0 | dtos.add(toCluIdentifierInfo(entity)); |
658 | |
} |
659 | |
} |
660 | 0 | return dtos; |
661 | |
} |
662 | |
|
663 | |
public static CluIdentifierInfo toCluIdentifierInfo(CluIdentifier entity) { |
664 | 0 | if (entity == null) { |
665 | 0 | return null; |
666 | |
} |
667 | |
|
668 | 0 | CluIdentifierInfo dto = new CluIdentifierInfo(); |
669 | |
|
670 | 0 | BeanUtils.copyProperties(entity, dto, |
671 | |
new String[]{"attributes"}); |
672 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
673 | 0 | return dto; |
674 | |
} |
675 | |
|
676 | |
public static List<CluInstructorInfo> toCluInstructorInfos( |
677 | |
List<CluInstructor> entities) { |
678 | 0 | List<CluInstructorInfo> dtos = new ArrayList<CluInstructorInfo>( |
679 | |
entities.size()); |
680 | 0 | if (entities != null) { |
681 | 0 | for (CluInstructor entity : entities) { |
682 | 0 | dtos.add(toCluInstructorInfo(entity)); |
683 | |
} |
684 | |
} |
685 | 0 | return dtos; |
686 | |
} |
687 | |
|
688 | |
public static CluInstructorInfo toCluInstructorInfo(CluInstructor entity) { |
689 | 0 | if (entity == null) { |
690 | 0 | return null; |
691 | |
} |
692 | 0 | CluInstructorInfo dto = new CluInstructorInfo(); |
693 | |
|
694 | 0 | BeanUtils.copyProperties(entity, dto, |
695 | |
new String[]{"id", "attributes"}); |
696 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
697 | |
|
698 | 0 | return dto; |
699 | |
} |
700 | |
|
701 | |
public static AmountInfo toAmountInfo(Amount entity) { |
702 | 0 | if (entity == null) { |
703 | 0 | return null; |
704 | |
} |
705 | 0 | AmountInfo dto = new AmountInfo(); |
706 | |
|
707 | 0 | BeanUtils.copyProperties(entity, dto); |
708 | |
|
709 | 0 | return dto; |
710 | |
} |
711 | |
|
712 | |
public static TimeAmountInfo toTimeAmountInfo(TimeAmount entity) { |
713 | 0 | if (entity == null) { |
714 | 0 | return null; |
715 | |
} |
716 | 0 | TimeAmountInfo dto = new TimeAmountInfo(); |
717 | |
|
718 | 0 | BeanUtils.copyProperties(entity, dto); |
719 | |
|
720 | 0 | return dto; |
721 | |
} |
722 | |
|
723 | |
public static List<LuCodeInfo> toLuCodeInfos(List<LuCode> entities) { |
724 | 0 | List<LuCodeInfo> dtos = new ArrayList<LuCodeInfo>(entities.size()); |
725 | 0 | if (entities != null) { |
726 | 0 | for (LuCode entity : entities) { |
727 | 0 | dtos.add(toLuCodeInfo(entity)); |
728 | |
} |
729 | |
} |
730 | 0 | return dtos; |
731 | |
} |
732 | |
|
733 | |
public static LuCodeInfo toLuCodeInfo(LuCode entity) { |
734 | 0 | if (entity == null) { |
735 | 0 | return null; |
736 | |
} |
737 | 0 | LuCodeInfo dto = new LuCodeInfo(); |
738 | |
|
739 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"attributes", |
740 | |
"metInfo"}); |
741 | |
|
742 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
743 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
744 | |
|
745 | 0 | return dto; |
746 | |
} |
747 | |
|
748 | |
public static CluCreditInfo toCluCreditInfos(CluCredit entity) { |
749 | 0 | if (entity == null) { |
750 | 0 | return null; |
751 | |
} |
752 | 0 | CluCreditInfo dto = new CluCreditInfo(); |
753 | |
|
754 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"id", |
755 | |
"repeatTime", "minTimeToComplete", "maxTimeToComplete", |
756 | |
"maxAllowableInactivity", "maxTimeResultsRecognized"}); |
757 | 0 | dto.setRepeatTime(toTimeAmountInfo(entity.getRepeatTime())); |
758 | 0 | dto.setMinTimeToComplete(toTimeAmountInfo(entity.getMinTimeToComplete())); |
759 | 0 | dto.setMaxTimeToComplete(toTimeAmountInfo(entity.getMaxTimeToComplete())); |
760 | 0 | dto.setMaxAllowableInactivity(toTimeAmountInfo(entity.getMaxAllowableInactivity())); |
761 | 0 | dto.setMaxTimeResultsRecognized(toTimeAmountInfo(entity.getMaxTimeResultsRecognized())); |
762 | |
|
763 | 0 | return dto; |
764 | |
} |
765 | |
|
766 | |
public static List<TypeInfo> toResultComponentTypeInfo( |
767 | |
List<String> componentIds) { |
768 | 0 | List<TypeInfo> dtos = new ArrayList<TypeInfo>(); |
769 | 0 | if (componentIds != null) { |
770 | 0 | for (String id : componentIds) { |
771 | 0 | TypeInfo comp = new TypeInfo(); |
772 | 0 | comp.setKey(id); |
773 | 0 | dtos.add(comp); |
774 | 0 | } |
775 | |
} |
776 | 0 | return dtos; |
777 | |
} |
778 | |
|
779 | |
public static CluFeeInfo toCluFeeInfo(CluFee entity) { |
780 | 0 | if (entity == null) { |
781 | 0 | return null; |
782 | |
} |
783 | 0 | CluFeeInfo dto = new CluFeeInfo(); |
784 | |
|
785 | 0 | dto.setCluFeeRecords(toCluFeeRecordInfos(entity.getCluFeeRecords())); |
786 | 0 | dto.setId(entity.getId()); |
787 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
788 | 0 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
789 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
790 | |
|
791 | 0 | return dto; |
792 | |
} |
793 | |
|
794 | |
private static List<CluFeeRecordInfo> toCluFeeRecordInfos( |
795 | |
List<CluFeeRecord> entities) { |
796 | 0 | List<CluFeeRecordInfo> dtos = new ArrayList<CluFeeRecordInfo>(); |
797 | 0 | if (entities != null) { |
798 | 0 | for (CluFeeRecord record : entities) { |
799 | 0 | dtos.add(toCluFeeRecordInfo(record)); |
800 | |
} |
801 | |
} |
802 | 0 | return dtos; |
803 | |
} |
804 | |
|
805 | |
private static CluFeeRecordInfo toCluFeeRecordInfo(CluFeeRecord entity) { |
806 | 0 | if (entity == null) { |
807 | 0 | return null; |
808 | |
} |
809 | |
|
810 | 0 | CluFeeRecordInfo dto = new CluFeeRecordInfo(); |
811 | |
|
812 | 0 | BeanUtils.copyProperties(entity, dto, |
813 | |
new String[]{"affiliatedOrgs", "currencyAmount", "attributes", "descr"}); |
814 | |
|
815 | 0 | dto.setAffiliatedOrgs(toAffiliatedOrgInfos(entity.getAffiliatedOrgs())); |
816 | 0 | dto.setFeeAmounts(toFeeAmounts(entity.getFeeAmounts())); |
817 | 0 | dto.setDescr(toRichTextInfo(entity.getDescr())); |
818 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
819 | 0 | dto.setMeta(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
820 | |
|
821 | 0 | return dto; |
822 | |
} |
823 | |
|
824 | |
private static List<CurrencyAmountInfo> toFeeAmounts(List<CluFeeAmount> cluFees) { |
825 | 0 | List<CurrencyAmountInfo> feeAmounts = new ArrayList<CurrencyAmountInfo>(); |
826 | |
|
827 | 0 | if (cluFees != null) { |
828 | 0 | for (CluFeeAmount cluFeeAmount : cluFees) { |
829 | 0 | CurrencyAmountInfo dto = new CurrencyAmountInfo(); |
830 | 0 | CurrencyAmount ca = cluFeeAmount.getCurrencyAmount(); |
831 | 0 | if (ca != null) { |
832 | 0 | dto.setCurrencyQuantity(ca.getCurrencyQuantity()); |
833 | 0 | dto.setCurrencyTypeKey(ca.getCurrencyTypeKey()); |
834 | |
} |
835 | 0 | feeAmounts.add(dto); |
836 | 0 | } |
837 | |
} |
838 | |
|
839 | 0 | return feeAmounts; |
840 | |
} |
841 | |
|
842 | |
private static List<AffiliatedOrgInfo> toAffiliatedOrgInfos( |
843 | |
List<AffiliatedOrg> entities) { |
844 | 0 | List<AffiliatedOrgInfo> dtos = new ArrayList<AffiliatedOrgInfo>(); |
845 | 0 | if (entities != null) { |
846 | 0 | for (AffiliatedOrg record : entities) { |
847 | 0 | dtos.add(toAffiliatedOrgInfo(record)); |
848 | |
} |
849 | |
} |
850 | 0 | return dtos; |
851 | |
} |
852 | |
|
853 | |
private static AffiliatedOrgInfo toAffiliatedOrgInfo(AffiliatedOrg entity) { |
854 | 0 | if (entity == null) { |
855 | 0 | return null; |
856 | |
} |
857 | |
|
858 | 0 | AffiliatedOrgInfo dto = new AffiliatedOrgInfo(); |
859 | |
|
860 | 0 | BeanUtils.copyProperties(entity, dto); |
861 | 0 | return dto; |
862 | |
} |
863 | |
|
864 | |
public static CluAccountingInfo toCluAccountingInfo(CluAccounting entity) { |
865 | 0 | if (entity == null) { |
866 | 0 | return null; |
867 | |
} |
868 | 0 | CluAccountingInfo dto = new CluAccountingInfo(); |
869 | 0 | dto.setId(entity.getId()); |
870 | 0 | dto.setAffiliatedOrgs(toAffiliatedOrgInfos(entity.getAffiliatedOrgs())); |
871 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
872 | 0 | return dto; |
873 | |
} |
874 | |
|
875 | |
public static Amount toAmount(AmountInfo amountInfo) { |
876 | 0 | if (amountInfo == null) { |
877 | 0 | return null; |
878 | |
} |
879 | 0 | Amount amount = new Amount(); |
880 | 0 | BeanUtils.copyProperties(amountInfo, amount); |
881 | 0 | return amount; |
882 | |
} |
883 | |
|
884 | |
public static TimeAmount toTimeAmount(TimeAmountInfo timeAmountInfo) { |
885 | 0 | if (timeAmountInfo == null) { |
886 | 0 | return null; |
887 | |
} |
888 | 0 | TimeAmount timeAmount = new TimeAmount(); |
889 | 0 | BeanUtils.copyProperties(timeAmountInfo, timeAmount); |
890 | 0 | return timeAmount; |
891 | |
} |
892 | |
|
893 | |
public static CluCredit toCluCredit(CluCreditInfo cluCreditInfo) { |
894 | 0 | if (cluCreditInfo == null) { |
895 | 0 | return null; |
896 | |
} |
897 | 0 | CluCredit cluCredit = new CluCredit(); |
898 | |
|
899 | 0 | cluCredit.setMaxAllowableInactivity(LuServiceAssembler.toTimeAmount(cluCreditInfo.getMaxAllowableInactivity())); |
900 | 0 | cluCredit.setMaxTimeResultsRecognized(LuServiceAssembler.toTimeAmount(cluCreditInfo.getMaxTimeResultsRecognized())); |
901 | 0 | cluCredit.setMaxTimeToComplete(LuServiceAssembler.toTimeAmount(cluCreditInfo.getMaxTimeToComplete())); |
902 | 0 | cluCredit.setMinTimeToComplete(LuServiceAssembler.toTimeAmount(cluCreditInfo.getMinTimeToComplete())); |
903 | 0 | cluCredit.setRepeatTime(LuServiceAssembler.toTimeAmount(cluCreditInfo.getRepeatTime())); |
904 | |
|
905 | 0 | BeanUtils.copyProperties(cluCreditInfo, cluCredit, new String[]{ |
906 | |
"repeatTime", "minTimeToComplete", "maxTimeToComplete", |
907 | |
"maxAllowableInactivity", "maxTimeResultsRecognized"}); |
908 | |
|
909 | 0 | return cluCredit; |
910 | |
} |
911 | |
|
912 | |
public static void copyCluCredit(CluCreditInfo cluCreditInfo, |
913 | |
CluCredit entity) { |
914 | 0 | if (entity == null) { |
915 | 0 | return; |
916 | |
} |
917 | 0 | if (entity.getMaxAllowableInactivity() == null) { |
918 | 0 | entity.setMaxAllowableInactivity(new TimeAmount()); |
919 | |
} |
920 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMaxAllowableInactivity(), |
921 | |
entity.getMaxAllowableInactivity()); |
922 | |
|
923 | 0 | if (entity.getMaxTimeResultsRecognized() == null) { |
924 | 0 | entity.setMaxTimeResultsRecognized(new TimeAmount()); |
925 | |
} |
926 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMaxTimeResultsRecognized(), |
927 | |
entity.getMaxTimeResultsRecognized()); |
928 | |
|
929 | 0 | if (entity.getMaxTimeToComplete() == null) { |
930 | 0 | entity.setMaxTimeToComplete(new TimeAmount()); |
931 | |
} |
932 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMaxTimeToComplete(), entity.getMaxTimeToComplete()); |
933 | |
|
934 | 0 | if (entity.getMinTimeToComplete() == null) { |
935 | 0 | entity.setMinTimeToComplete(new TimeAmount()); |
936 | |
} |
937 | 0 | BeanUtils.copyProperties(cluCreditInfo.getMinTimeToComplete(), entity.getMinTimeToComplete()); |
938 | |
|
939 | 0 | if (entity.getRepeatTime() == null) { |
940 | 0 | entity.setRepeatTime(new TimeAmount()); |
941 | |
} |
942 | 0 | BeanUtils.copyProperties(cluCreditInfo.getRepeatTime(), entity.getRepeatTime()); |
943 | |
|
944 | 0 | BeanUtils.copyProperties(cluCreditInfo, entity, new String[]{ |
945 | |
"repeatTime", "minTimeToComplete", "maxTimeToComplete", |
946 | |
"maxAllowableInactivity", "maxTimeResultsRecognized"}); |
947 | |
|
948 | 0 | } |
949 | |
|
950 | |
public static List<AccreditationInfo> toAccreditationInfos( |
951 | |
List<CluAccreditation> entities) { |
952 | 0 | List<AccreditationInfo> dtos = new ArrayList<AccreditationInfo>(entities.size()); |
953 | |
|
954 | 0 | if (entities != null) { |
955 | 0 | for (CluAccreditation entity : entities) { |
956 | 0 | dtos.add(toAccreditationInfo(entity)); |
957 | |
} |
958 | |
} |
959 | 0 | return dtos; |
960 | |
} |
961 | |
|
962 | |
public static AccreditationInfo toAccreditationInfo(CluAccreditation entity) { |
963 | 0 | if (entity == null) { |
964 | 0 | return null; |
965 | |
} |
966 | 0 | AccreditationInfo dto = new AccreditationInfo(); |
967 | |
|
968 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"attributes"}); |
969 | |
|
970 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
971 | |
|
972 | 0 | return dto; |
973 | |
|
974 | |
} |
975 | |
|
976 | |
public static List<AdminOrgInfo> toCluAdminOrgInfos( |
977 | |
List<CluAdminOrg> entities) { |
978 | 0 | List<AdminOrgInfo> dtos = new ArrayList<AdminOrgInfo>(entities.size()); |
979 | 0 | if (entities != null) { |
980 | 0 | for (CluAdminOrg entity : entities) { |
981 | 0 | dtos.add(toAdminOrgInfo(entity)); |
982 | |
} |
983 | |
} |
984 | 0 | return dtos; |
985 | |
} |
986 | |
|
987 | |
public static AdminOrgInfo toAdminOrgInfo(CluAdminOrg entity) { |
988 | 0 | if (entity == null) { |
989 | 0 | return null; |
990 | |
} |
991 | 0 | AdminOrgInfo dto = new AdminOrgInfo(); |
992 | 0 | BeanUtils.copyProperties(entity, dto, new String[]{"attributes"}); |
993 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
994 | |
|
995 | 0 | return dto; |
996 | |
} |
997 | |
|
998 | |
public static List<TypeInfo> toLuPublicationTypeInfos( |
999 | |
List<LuPublicationType> entities) { |
1000 | 0 | return toGenericTypeInfoList(TypeInfo.class, entities); |
1001 | |
} |
1002 | |
|
1003 | |
public static TypeInfo toLuPublicationTypeInfo( |
1004 | |
LuPublicationType entity) { |
1005 | 0 | return toGenericTypeInfo(TypeInfo.class, entity); |
1006 | |
} |
1007 | |
|
1008 | |
public static CluFee toCluFee(Clu clu, boolean isUpdate, CluFeeInfo feeInfo, |
1009 | |
LuDao dao) throws DoesNotExistException, VersionMismatchException, |
1010 | |
InvalidParameterException { |
1011 | 0 | if (feeInfo == null) { |
1012 | 0 | return null; |
1013 | |
} |
1014 | |
|
1015 | 0 | CluFee fee = null; |
1016 | |
|
1017 | 0 | if (isUpdate) { |
1018 | 0 | fee = clu.getFee(); |
1019 | 0 | if (!String.valueOf(fee.getVersionNumber()).equals( |
1020 | |
feeInfo.getMeta().getVersionInd())) { |
1021 | 0 | throw new VersionMismatchException( |
1022 | |
"CluFee to be updated is not the current version"); |
1023 | |
} |
1024 | |
} |
1025 | 0 | if (fee == null) { |
1026 | 0 | fee = new CluFee(); |
1027 | |
} |
1028 | |
|
1029 | 0 | if (feeInfo.getDescr() != null && (feeInfo.getDescr().getPlain() != null || feeInfo.getDescr().getFormatted() != null)) { |
1030 | 0 | if (fee.getDescr() == null) { |
1031 | 0 | fee.setDescr(new LuRichText()); |
1032 | |
} |
1033 | 0 | BeanUtils.copyProperties(feeInfo.getDescr(), fee.getDescr()); |
1034 | 0 | } else if (isUpdate && fee.getDescr() != null) { |
1035 | 0 | dao.delete(fee.getDescr()); |
1036 | 0 | fee.setDescr(null); |
1037 | |
} |
1038 | |
|
1039 | 0 | fee.setAttributes(LuServiceAssembler.toGenericAttributes( |
1040 | |
CluFeeAttribute.class, feeInfo.getAttributes(), fee, dao)); |
1041 | 0 | toCluFeeRecords(isUpdate, fee, feeInfo.getCluFeeRecords(), dao); |
1042 | |
|
1043 | 0 | return fee; |
1044 | |
} |
1045 | |
|
1046 | |
public static void toCluFeeRecords(boolean isUpdate, |
1047 | |
CluFee cluFee, List<CluFeeRecordInfo> cluFeeRecords, LuDao dao) throws InvalidParameterException { |
1048 | |
|
1049 | 0 | if (cluFeeRecords == null) { |
1050 | 0 | return; |
1051 | |
} |
1052 | |
|
1053 | 0 | if (!isUpdate) { |
1054 | |
|
1055 | 0 | for (CluFeeRecordInfo feeRecordInfo : cluFeeRecords) { |
1056 | 0 | CluFeeRecord feeRec = new CluFeeRecord(); |
1057 | 0 | feeRec.setAffiliatedOrgs(toAffiliatedOrgs(isUpdate, feeRec.getAffiliatedOrgs(), feeRecordInfo.getAffiliatedOrgs(), dao)); |
1058 | 0 | feeRec.setFeeType(feeRecordInfo.getFeeType()); |
1059 | 0 | feeRec.setRateType(feeRecordInfo.getRateType()); |
1060 | 0 | feeRec.setDescr(toRichText(LuRichText.class, feeRecordInfo.getDescr())); |
1061 | 0 | feeRec.setFeeAmounts(toFeeAmounts(isUpdate, feeRec.getFeeAmounts(), feeRecordInfo.getFeeAmounts(), dao)); |
1062 | 0 | feeRec.setAttributes(LuServiceAssembler.toGenericAttributes( |
1063 | |
CluFeeRecordAttribute.class, feeRecordInfo.getAttributes(), feeRec, dao)); |
1064 | 0 | if (cluFee.getCluFeeRecords() == null) { |
1065 | 0 | cluFee.setCluFeeRecords(new ArrayList<CluFeeRecord>()); |
1066 | |
} |
1067 | 0 | cluFee.getCluFeeRecords().add(feeRec); |
1068 | 0 | } |
1069 | |
} else { |
1070 | 0 | Map<String, CluFeeRecord> oldFeeRecMap = new HashMap<String, CluFeeRecord>(); |
1071 | 0 | if (cluFee.getCluFeeRecords() != null) { |
1072 | 0 | for (CluFeeRecord feeRec : cluFee.getCluFeeRecords()) { |
1073 | 0 | oldFeeRecMap.put(feeRec.getId(), feeRec); |
1074 | |
} |
1075 | 0 | cluFee.getCluFeeRecords().clear(); |
1076 | |
} |
1077 | |
|
1078 | |
|
1079 | |
|
1080 | |
|
1081 | 0 | for (CluFeeRecordInfo feeRecordInfo : cluFeeRecords) { |
1082 | 0 | CluFeeRecord feeRec = oldFeeRecMap.remove(feeRecordInfo.getId()); |
1083 | 0 | if (feeRec == null) { |
1084 | 0 | feeRec = new CluFeeRecord(); |
1085 | |
} |
1086 | |
|
1087 | 0 | feeRec.setAffiliatedOrgs(toAffiliatedOrgs(isUpdate, feeRec.getAffiliatedOrgs(), feeRecordInfo.getAffiliatedOrgs(), dao)); |
1088 | 0 | feeRec.setFeeType(feeRecordInfo.getFeeType()); |
1089 | 0 | feeRec.setRateType(feeRecordInfo.getRateType()); |
1090 | 0 | feeRec.setDescr(toRichText(LuRichText.class, feeRecordInfo.getDescr())); |
1091 | 0 | feeRec.setFeeAmounts(toFeeAmounts(isUpdate, feeRec.getFeeAmounts(), feeRecordInfo.getFeeAmounts(), dao)); |
1092 | 0 | feeRec.setAttributes(LuServiceAssembler.toGenericAttributes( |
1093 | |
CluFeeRecordAttribute.class, feeRecordInfo.getAttributes(), feeRec, dao)); |
1094 | 0 | if (cluFee.getCluFeeRecords() == null) { |
1095 | 0 | cluFee.setCluFeeRecords(new ArrayList<CluFeeRecord>()); |
1096 | |
} |
1097 | 0 | cluFee.getCluFeeRecords().add(feeRec); |
1098 | 0 | } |
1099 | |
|
1100 | |
|
1101 | 0 | for (Entry<String, CluFeeRecord> entry : oldFeeRecMap.entrySet()) { |
1102 | 0 | dao.delete(entry.getValue()); |
1103 | |
} |
1104 | |
} |
1105 | 0 | } |
1106 | |
|
1107 | |
public static List<AffiliatedOrg> toAffiliatedOrgs(boolean isUpdate, List<AffiliatedOrg> orgList, List<AffiliatedOrgInfo> affiliatedOrgInfoList, LuDao dao) { |
1108 | 0 | if (null == affiliatedOrgInfoList) { |
1109 | 0 | return orgList; |
1110 | |
} |
1111 | 0 | if (orgList == null) { |
1112 | 0 | orgList = new ArrayList<AffiliatedOrg>(); |
1113 | |
} |
1114 | |
|
1115 | 0 | if (!isUpdate) { |
1116 | |
|
1117 | 0 | for (AffiliatedOrgInfo orgInfo : affiliatedOrgInfoList) { |
1118 | 0 | AffiliatedOrg org = new AffiliatedOrg(); |
1119 | 0 | BeanUtils.copyProperties(orgInfo, org); |
1120 | 0 | orgList.add(org); |
1121 | 0 | } |
1122 | |
} else { |
1123 | 0 | Map<String, AffiliatedOrg> oldOrgMap = new HashMap<String, AffiliatedOrg>(); |
1124 | 0 | for (AffiliatedOrg org : orgList) { |
1125 | 0 | oldOrgMap.put(org.getId(), org); |
1126 | |
} |
1127 | 0 | orgList.clear(); |
1128 | |
|
1129 | 0 | for (AffiliatedOrgInfo orgInfo : affiliatedOrgInfoList) { |
1130 | 0 | AffiliatedOrg org = oldOrgMap.remove(orgInfo.getId()); |
1131 | 0 | if (org == null) { |
1132 | 0 | org = new AffiliatedOrg(); |
1133 | |
} |
1134 | |
|
1135 | 0 | BeanUtils.copyProperties(orgInfo, org); |
1136 | |
|
1137 | 0 | orgList.add(org); |
1138 | 0 | } |
1139 | |
|
1140 | |
|
1141 | 0 | for (Entry<String, AffiliatedOrg> entry : oldOrgMap.entrySet()) { |
1142 | 0 | dao.delete(entry.getValue()); |
1143 | |
} |
1144 | |
} |
1145 | |
|
1146 | 0 | return orgList; |
1147 | |
} |
1148 | |
|
1149 | |
public static List<CluFeeAmount> toFeeAmounts(boolean isUpdate, List<CluFeeAmount> caList, List<CurrencyAmountInfo> caInfoList, LuDao dao) { |
1150 | 0 | if (null == caInfoList) { |
1151 | 0 | return caList; |
1152 | |
} |
1153 | 0 | if (caList == null) { |
1154 | 0 | caList = new ArrayList<CluFeeAmount>(caInfoList.size()); |
1155 | |
} |
1156 | |
|
1157 | 0 | if (!isUpdate) { |
1158 | 0 | for (CurrencyAmountInfo caInfo : caInfoList) { |
1159 | 0 | CurrencyAmount ca = new CurrencyAmount(); |
1160 | 0 | ca.setCurrencyQuantity(caInfo.getCurrencyQuantity()); |
1161 | 0 | ca.setCurrencyTypeKey(caInfo.getCurrencyTypeKey()); |
1162 | 0 | CluFeeAmount cluFeeAmount = new CluFeeAmount(); |
1163 | 0 | cluFeeAmount.setCurrencyAmount(ca); |
1164 | 0 | caList.add(cluFeeAmount); |
1165 | 0 | } |
1166 | |
} else { |
1167 | |
|
1168 | 0 | for (CluFeeAmount cluFeeAmount : caList) { |
1169 | 0 | dao.delete(cluFeeAmount); |
1170 | |
} |
1171 | 0 | caList.clear(); |
1172 | |
|
1173 | 0 | for (CurrencyAmountInfo caInfo : caInfoList) { |
1174 | 0 | CurrencyAmount ca = new CurrencyAmount(); |
1175 | |
|
1176 | 0 | ca.setCurrencyQuantity(caInfo.getCurrencyQuantity()); |
1177 | 0 | ca.setCurrencyTypeKey(caInfo.getCurrencyTypeKey()); |
1178 | 0 | CluFeeAmount cluFeeAmount = new CluFeeAmount(); |
1179 | 0 | cluFeeAmount.setCurrencyAmount(ca); |
1180 | 0 | caList.add(cluFeeAmount); |
1181 | 0 | } |
1182 | |
} |
1183 | |
|
1184 | 0 | return caList; |
1185 | |
} |
1186 | |
|
1187 | |
public static CluIdentifier createOfficialIdentifier(CluInfo cluInfo, LuDao dao) throws InvalidParameterException { |
1188 | 0 | CluIdentifier officialIdentifier = new CluIdentifier(); |
1189 | 0 | BeanUtils.copyProperties(cluInfo.getOfficialIdentifier(), |
1190 | |
officialIdentifier, new String[]{"attributes"}); |
1191 | 0 | officialIdentifier.setAttributes(LuServiceAssembler.toGenericAttributes( |
1192 | |
CluIdentifierAttribute.class, cluInfo.getOfficialIdentifier().getAttributes(), officialIdentifier, dao)); |
1193 | |
|
1194 | 0 | return officialIdentifier; |
1195 | |
} |
1196 | |
|
1197 | |
public static void updateOfficialIdentifier(Clu clu, CluInfo cluInfo, LuDao dao) throws InvalidParameterException { |
1198 | 0 | if (clu.getOfficialIdentifier() == null) { |
1199 | 0 | clu.setOfficialIdentifier(new CluIdentifier()); |
1200 | |
} |
1201 | 0 | BeanUtils.copyProperties(cluInfo.getOfficialIdentifier(), clu.getOfficialIdentifier(), new String[]{"id", "attributes"}); |
1202 | |
|
1203 | 0 | clu.getOfficialIdentifier().setAttributes(LuServiceAssembler.toGenericAttributes( |
1204 | |
CluIdentifierAttribute.class, cluInfo.getOfficialIdentifier().getAttributes(), clu.getOfficialIdentifier(), dao)); |
1205 | |
|
1206 | 0 | } |
1207 | |
|
1208 | |
public static List<CluIdentifier> createAlternateIdentifiers(CluInfo cluInfo, LuDao dao) throws InvalidParameterException { |
1209 | 0 | List<CluIdentifier> alternateIdentifiers = new ArrayList<CluIdentifier>(0); |
1210 | 0 | for (CluIdentifierInfo cluIdInfo : cluInfo.getAlternateIdentifiers()) { |
1211 | 0 | CluIdentifier identifier = new CluIdentifier(); |
1212 | 0 | BeanUtils.copyProperties(cluIdInfo, identifier, new String[]{"attributes"}); |
1213 | |
|
1214 | 0 | identifier.setAttributes(LuServiceAssembler.toGenericAttributes( |
1215 | |
CluIdentifierAttribute.class, cluIdInfo.getAttributes(), identifier, dao)); |
1216 | |
|
1217 | 0 | alternateIdentifiers.add(identifier); |
1218 | 0 | } |
1219 | 0 | return alternateIdentifiers; |
1220 | |
} |
1221 | |
|
1222 | |
public static void updateAlternateIdentifier(Map<String, CluIdentifier> oldAltIdMap, Clu clu, CluInfo cluInfo, LuDao dao) throws InvalidParameterException { |
1223 | 0 | for (CluIdentifier altIdentifier : clu.getAlternateIdentifiers()) { |
1224 | 0 | oldAltIdMap.put(altIdentifier.getId(), altIdentifier); |
1225 | |
} |
1226 | 0 | clu.getAlternateIdentifiers().clear(); |
1227 | |
|
1228 | |
|
1229 | |
|
1230 | |
|
1231 | 0 | for (CluIdentifierInfo cluIdInfo : cluInfo.getAlternateIdentifiers()) { |
1232 | 0 | CluIdentifier identifier = oldAltIdMap.remove(cluIdInfo.getId()); |
1233 | 0 | if (identifier == null) { |
1234 | 0 | identifier = new CluIdentifier(); |
1235 | |
} |
1236 | |
|
1237 | 0 | BeanUtils.copyProperties(cluIdInfo, identifier, new String[]{"attributes"}); |
1238 | |
|
1239 | 0 | identifier.setAttributes(LuServiceAssembler.toGenericAttributes( |
1240 | |
CluIdentifierAttribute.class, cluIdInfo.getAttributes(), identifier, dao)); |
1241 | |
|
1242 | 0 | clu.getAlternateIdentifiers().add(identifier); |
1243 | 0 | } |
1244 | 0 | } |
1245 | |
|
1246 | |
public static List<CluPublicationVariant> toCluPublicationVariants( |
1247 | |
List<FieldInfo> variantInfos, CluPublication cluPub, LuDao luDao) { |
1248 | 0 | List<CluPublicationVariant> variants = new ArrayList<CluPublicationVariant>(); |
1249 | |
|
1250 | 0 | if (cluPub.getVariants() == null) { |
1251 | 0 | cluPub.setVariants(new ArrayList<CluPublicationVariant>()); |
1252 | |
} |
1253 | |
|
1254 | |
|
1255 | 0 | for (CluPublicationVariant variant : cluPub.getVariants()) { |
1256 | 0 | luDao.delete(variant); |
1257 | |
} |
1258 | 0 | cluPub.getVariants().clear(); |
1259 | |
|
1260 | 0 | for (FieldInfo variantInfo : variantInfos) { |
1261 | 0 | CluPublicationVariant variant = new CluPublicationVariant(); |
1262 | 0 | variant.setKey(variantInfo.getId()); |
1263 | 0 | variant.setValue(variantInfo.getValue()); |
1264 | 0 | variant.setOwner(cluPub); |
1265 | 0 | variants.add(variant); |
1266 | 0 | } |
1267 | |
|
1268 | 0 | return variants; |
1269 | |
} |
1270 | |
|
1271 | |
public static CluPublicationInfo toCluPublicationInfo(CluPublication cluPub) { |
1272 | 0 | if (cluPub == null) { |
1273 | 0 | return null; |
1274 | |
} |
1275 | 0 | CluPublicationInfo cluPubInfo = new CluPublicationInfo(); |
1276 | 0 | cluPubInfo.setCluId(cluPub.getClu().getId()); |
1277 | 0 | cluPubInfo.setId(cluPub.getId()); |
1278 | 0 | cluPubInfo.setEndCycle(cluPub.getEndCycle()); |
1279 | 0 | cluPubInfo.setStartCycle(cluPub.getStartCycle()); |
1280 | 0 | cluPubInfo.setEffectiveDate(cluPub.getEffectiveDate()); |
1281 | 0 | cluPubInfo.setExpirationDate(cluPub.getExpirationDate()); |
1282 | 0 | cluPubInfo.setStateKey(cluPub.getState()); |
1283 | 0 | cluPubInfo.setTypeKey(cluPub.getType().getId()); |
1284 | 0 | cluPubInfo.setMeta(toMetaInfo(cluPub.getMeta(), cluPub.getVersionNumber())); |
1285 | 0 | cluPubInfo.setAttributes(LuServiceAssembler.toAttributeMap(cluPub.getAttributes())); |
1286 | 0 | cluPubInfo.setVariants(LuServiceAssembler.toCluPublicationVariantInfos(cluPub.getVariants())); |
1287 | |
|
1288 | 0 | return cluPubInfo; |
1289 | |
} |
1290 | |
|
1291 | |
private static List<FieldInfo> toCluPublicationVariantInfos( |
1292 | |
List<CluPublicationVariant> variants) { |
1293 | 0 | if (variants == null) { |
1294 | 0 | return new ArrayList<FieldInfo>(0); |
1295 | |
} |
1296 | 0 | List<FieldInfo> fields = new ArrayList<FieldInfo>(); |
1297 | 0 | for (CluPublicationVariant variant : variants) { |
1298 | 0 | FieldInfo field = new FieldInfo(); |
1299 | 0 | field.setId(variant.getKey()); |
1300 | 0 | field.setValue(variant.getValue()); |
1301 | 0 | fields.add(field); |
1302 | 0 | } |
1303 | 0 | return fields; |
1304 | |
} |
1305 | |
|
1306 | |
public static List<CluPublicationInfo> toCluPublicationInfos( |
1307 | |
List<CluPublication> cluPublications) { |
1308 | 0 | if (cluPublications == null) { |
1309 | 0 | return new ArrayList<CluPublicationInfo>(0); |
1310 | |
} |
1311 | 0 | List<CluPublicationInfo> cluPublicationInfos = new ArrayList<CluPublicationInfo>(cluPublications.size()); |
1312 | 0 | for (CluPublication cluPublication : cluPublications) { |
1313 | 0 | cluPublicationInfos.add(toCluPublicationInfo(cluPublication)); |
1314 | |
} |
1315 | 0 | return cluPublicationInfos; |
1316 | |
} |
1317 | |
} |