1 | |
package org.kuali.student.enrollment.class2.courseoffering.service.impl; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.kuali.rice.core.api.criteria.PredicateFactory; |
5 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
6 | |
import org.kuali.rice.krad.lookup.LookupableImpl; |
7 | |
import org.kuali.rice.krad.web.form.LookupForm; |
8 | |
|
9 | |
import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader; |
10 | |
import org.kuali.student.enrollment.common.util.ContextBuilder; |
11 | |
import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetService; |
12 | |
import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultInfo; |
13 | |
import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingConstants; |
14 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
15 | |
import org.kuali.student.r2.common.exceptions.*; |
16 | |
|
17 | |
import java.util.List; |
18 | |
import java.util.Map; |
19 | |
import java.util.ArrayList; |
20 | |
|
21 | 0 | public class SocRolloverResultInfoLookupableImpl extends LookupableImpl { |
22 | 0 | private transient CourseOfferingSetService courseOfferingSetService = null; |
23 | 0 | private ContextInfo contextInfo = null; |
24 | |
|
25 | |
protected List<?> getSearchResults(LookupForm lookupForm, Map<String, String> fieldValues, boolean unbounded) { |
26 | 0 | List<SocRolloverResultInfo> socRolloverResultInfos = new ArrayList<SocRolloverResultInfo>(); |
27 | 0 | String sourceTermId = fieldValues.get(CourseOfferingConstants.SOCROLLOVERRESULTINFO_SOURCE_TERM_ID); |
28 | 0 | String targetTermId = fieldValues.get(CourseOfferingConstants.SOCROLLOVERRESULTINFO_TARGET_TERM_ID); |
29 | |
|
30 | |
|
31 | 0 | QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create(); |
32 | 0 | if (StringUtils.isNotBlank(targetTermId) && !targetTermId.isEmpty()) { |
33 | 0 | if (StringUtils.isNotBlank(sourceTermId) && !sourceTermId.isEmpty()){ |
34 | 0 | qbcBuilder.setPredicates(PredicateFactory.and( |
35 | |
PredicateFactory.equal(CourseOfferingConstants.SOCROLLOVERRESULTINFO_SOURCE_TERM_ID, sourceTermId), |
36 | |
PredicateFactory.equal(CourseOfferingConstants.SOCROLLOVERRESULTINFO_TARGET_TERM_ID, targetTermId))); |
37 | |
} |
38 | |
else { |
39 | 0 | qbcBuilder.setPredicates(PredicateFactory.equal(CourseOfferingConstants.SOCROLLOVERRESULTINFO_TARGET_TERM_ID, targetTermId)); |
40 | |
} |
41 | 0 | }else if (StringUtils.isNotBlank(sourceTermId) && !sourceTermId.isEmpty()){ |
42 | 0 | qbcBuilder.setPredicates(PredicateFactory.equal(CourseOfferingConstants.SOCROLLOVERRESULTINFO_SOURCE_TERM_ID, sourceTermId)); |
43 | |
} |
44 | 0 | QueryByCriteria criteria = qbcBuilder.build(); |
45 | |
|
46 | |
|
47 | |
try{ |
48 | 0 | socRolloverResultInfos = getCourseOfferingSetService().searchForSocRolloverResults(criteria, null); |
49 | |
|
50 | 0 | }catch (InvalidParameterException e){ |
51 | 0 | e.printStackTrace(); |
52 | 0 | }catch (MissingParameterException e){ |
53 | 0 | e.printStackTrace(); |
54 | 0 | }catch (OperationFailedException e){ |
55 | 0 | e.printStackTrace(); |
56 | 0 | }catch (PermissionDeniedException e){ |
57 | 0 | e.printStackTrace(); |
58 | 0 | } |
59 | 0 | return socRolloverResultInfos; |
60 | |
|
61 | |
} |
62 | |
|
63 | |
public CourseOfferingSetService getCourseOfferingSetService() { |
64 | 0 | if(courseOfferingSetService == null) |
65 | 0 | courseOfferingSetService= CourseOfferingResourceLoader.loadCourseOfferingSetService(); |
66 | 0 | return courseOfferingSetService; |
67 | |
} |
68 | |
|
69 | |
public ContextInfo getContextInfo() { |
70 | 0 | if (contextInfo == null){ |
71 | 0 | contextInfo = ContextBuilder.loadContextInfo(); |
72 | |
} |
73 | 0 | return contextInfo; |
74 | |
} |
75 | |
} |