1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.scheduleofclasses.service.impl;
18
19 import org.apache.commons.lang.BooleanUtils;
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.rice.core.api.config.property.ConfigContext;
22 import org.kuali.rice.core.api.criteria.PredicateFactory;
23 import org.kuali.rice.core.api.criteria.QueryByCriteria;
24 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
25 import org.kuali.rice.core.api.util.RiceKeyConstants;
26 import org.kuali.rice.kim.api.identity.Person;
27 import org.kuali.rice.kim.api.identity.PersonService;
28 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
29 import org.kuali.rice.kim.impl.KIMPropertyConstants;
30 import org.kuali.rice.krad.uif.component.ReferenceCopy;
31 import org.kuali.rice.krad.util.GlobalVariables;
32 import org.kuali.rice.krad.util.KRADConstants;
33 import org.kuali.rice.krms.api.KrmsConstants;
34 import org.kuali.rice.krms.api.repository.RuleManagementService;
35 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
36 import org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition;
37 import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBinding;
38 import org.kuali.student.common.UUIDHelper;
39 import org.kuali.student.common.util.KSCollectionUtils;
40 import org.kuali.student.enrollment.class2.courseoffering.dto.ActivityOfferingClusterWrapper;
41 import org.kuali.student.enrollment.class2.courseoffering.dto.ActivityOfferingWrapper;
42 import org.kuali.student.enrollment.class2.courseoffering.dto.RegistrationGroupWrapper;
43 import org.kuali.student.enrollment.class2.courseoffering.service.decorators.PermissionServiceConstants;
44 import org.kuali.student.enrollment.class2.courseoffering.service.impl.CourseOfferingManagementViewHelperServiceImpl;
45 import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingConstants;
46 import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader;
47 import org.kuali.student.enrollment.class2.scheduleofclasses.dto.CourseOfferingDisplayWrapper;
48 import org.kuali.student.enrollment.class2.scheduleofclasses.form.ScheduleOfClassesSearchForm;
49 import org.kuali.student.enrollment.class2.scheduleofclasses.service.ScheduleOfClassesViewHelperService;
50 import org.kuali.student.enrollment.class2.scheduleofclasses.sort.KSComparator;
51 import org.kuali.student.enrollment.class2.scheduleofclasses.sort.KSComparatorChain;
52 import org.kuali.student.enrollment.class2.scheduleofclasses.sort.impl.ActivityOfferingCodeComparator;
53 import org.kuali.student.enrollment.class2.scheduleofclasses.sort.impl.ActivityOfferingTypeComparator;
54 import org.kuali.student.enrollment.class2.scheduleofclasses.util.SOCRequisiteHelper;
55 import org.kuali.student.enrollment.class2.scheduleofclasses.util.SOCRequisiteWrapper;
56 import org.kuali.student.enrollment.class2.scheduleofclasses.util.ScheduleOfClassesConstants;
57 import org.kuali.student.r2.common.constants.CommonServiceConstants;
58 import org.kuali.student.r2.common.dto.ContextInfo;
59 import org.kuali.student.r2.common.util.ContextUtils;
60 import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
61 import org.kuali.student.r2.common.util.constants.LprServiceConstants;
62 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
63 import org.kuali.student.r2.common.util.date.DateFormatters;
64 import org.kuali.student.r2.core.acal.dto.TermInfo;
65 import org.kuali.student.r2.core.class1.search.CourseOfferingManagementSearchImpl;
66 import org.kuali.student.r2.core.class1.type.service.TypeService;
67 import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
68 import org.kuali.student.r2.core.organization.service.OrganizationService;
69 import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
70 import org.kuali.student.r2.lum.util.constants.LrcServiceConstants;
71
72 import javax.xml.namespace.QName;
73 import java.util.ArrayList;
74 import java.util.Arrays;
75 import java.util.Formatter;
76 import java.util.HashMap;
77 import java.util.List;
78 import java.util.Locale;
79 import java.util.Map;
80 import java.util.Set;
81
82
83
84
85
86
87 public class ScheduleOfClassesViewHelperServiceImpl extends CourseOfferingManagementViewHelperServiceImpl implements ScheduleOfClassesViewHelperService {
88
89 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ScheduleOfClassesViewHelperServiceImpl.class);
90
91 private OrganizationService organizationService;
92 private TypeService typeService;
93 private RuleManagementService ruleManagementService;
94
95 @ReferenceCopy
96 private KSComparatorChain activityComparatorChain;
97 @ReferenceCopy
98 private KSComparatorChain regGroupComparatorChain;
99
100
101
102
103
104
105 private final static String TOOLTIP_CREATE_SCRIPT
106 = "<input type='hidden' data-role='script' data-for='$ID' value=\"createTooltip('$ID', '$TEXT', " +
107 "{position:'bottom',alwaysVisible:false,themeName:'black',themePath:'$APPLICATION_URL/plugins/tooltip/jquerybubblepopup-theme/',selectable:true,align:'left',tail:{ align:'left', hidden: false }}, true, false);\" script='soc_run'>";
108
109 private final static String TOOLTIP_ADD_ATTRIBUTE
110 = "<input type='hidden' data-role='script' data-for='$ID' " +
111 "value=\"addAttribute('$ID', 'class', 'uif-tooltip', true);\" script='soc_run'>";
112
113 private final static String IMG = "<img id='$ID' src='$SRC'/>";
114
115
116
117
118
119
120
121
122
123 public void loadCourseOfferingsByTermAndCourseCode(String termId, String courseCode, ScheduleOfClassesSearchForm form) throws Exception {
124
125 Map additionalParams = new HashMap();
126 additionalParams.put(CourseOfferingManagementSearchImpl.SearchParameters.COURSE_CODE, courseCode);
127
128 buildCOResultsDisplay(form, termId, additionalParams);
129
130 }
131
132
133
134
135
136
137
138
139
140 public void loadCourseOfferingsByTitleAndDescription(String termId, String titleOrDescription, ScheduleOfClassesSearchForm form) throws Exception {
141
142 Map additionalParams = new HashMap();
143 additionalParams.put(CourseOfferingManagementSearchImpl.SearchParameters.DESCRIPTION, titleOrDescription);
144
145 buildCOResultsDisplay(form, termId, additionalParams);
146
147 }
148
149
150
151
152
153
154
155
156
157
158
159 public void loadCourseOfferingsByTermAndInstructor(String termId, String instructorId, String instructorName, ScheduleOfClassesSearchForm form) throws Exception {
160
161
162 if (StringUtils.isBlank(instructorId)) {
163
164 Map<String, String> searchCriteria = new HashMap<String, String>();
165 searchCriteria.put(KIMPropertyConstants.Person.PRINCIPAL_NAME, instructorName);
166
167 List<Person> instructors = getPersonService().findPeople(searchCriteria);
168
169
170 int firstInstructor = 0;
171
172 if (instructors == null || instructors.isEmpty()) {
173 LOG.error("Error: Can't find any instructor for selected instructor in term: " + termId);
174 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, RiceKeyConstants.ERROR_CUSTOM, "Invalid Principal Id/Name.");
175 return;
176 } else if (instructors.size() > 1) {
177 LOG.error("Error: There is more than one instructor with the same name in term: " + termId);
178 GlobalVariables.getMessageMap().putError("Term & Instructor", ScheduleOfClassesConstants.SOC_MSG_ERROR_MULTIPLE_INSTRUCTOR_IS_FOUND, instructorName);
179 return;
180 } else {
181 instructorId = instructors.get(firstInstructor).getPrincipalId();
182 }
183 }
184
185 if (StringUtils.isNotBlank(instructorId)) {
186
187 ContextInfo context = ContextUtils.createDefaultContextInfo();
188
189
190
191
192 List<String> luiIds = getLprService().getLuiIdsByPersonAndTypeAndState(instructorId, LprServiceConstants.INSTRUCTOR_MAIN_TYPE_KEY, LprServiceConstants.ACTIVE_STATE_KEY, context);
193
194 List<String> courseOfferingIds = null;
195
196 if (!luiIds.isEmpty()) {
197
198
199 QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create();
200 qbcBuilder.setPredicates(PredicateFactory.and(
201 PredicateFactory.in("aoid", luiIds.toArray()),
202 PredicateFactory.equalIgnoreCase("atpId", termId)),
203 PredicateFactory.equal("luiState", LuiServiceConstants.LUI_CO_STATE_OFFERED_KEY));
204 QueryByCriteria criteria = qbcBuilder.build();
205 courseOfferingIds = getCourseOfferingService().searchForCourseOfferingIds(criteria, context);
206 }
207
208
209 if (courseOfferingIds.isEmpty()) {
210 LOG.error("Error: Can't find any Course Offering for selected Instructor in term: " + termId);
211 GlobalVariables.getMessageMap().putError("Term & Instructor", ScheduleOfClassesConstants.SOC_MSG_ERROR_NO_COURSE_OFFERING_IS_FOUND, "instructor", instructorId, termId);
212 form.getCoDisplayWrapperList().clear();
213 return;
214 }
215
216 Map additionalParams = new HashMap();
217 additionalParams.put(CourseOfferingManagementSearchImpl.SearchParameters.CO_IDS, courseOfferingIds);
218
219 buildCOResultsDisplay(form, termId, additionalParams);
220 }
221
222 }
223
224
225
226
227
228
229
230
231
232
233 public void loadCourseOfferingsByTermAndDepartment(String termId, String organizationId, String organizationName, ScheduleOfClassesSearchForm form) throws Exception {
234
235
236 if (StringUtils.isBlank(organizationId)) {
237
238 QueryByCriteria.Builder qBuilder = QueryByCriteria.Builder.create();
239 qBuilder.setPredicates(PredicateFactory.equalIgnoreCase("longName", organizationName));
240 QueryByCriteria query = qBuilder.build();
241 OrganizationService organizationService = getOrganizationService();
242
243 List<String> orgIDs = organizationService.searchForOrgIds(query, ContextUtils.createDefaultContextInfo());
244
245 if (orgIDs.isEmpty()) {
246 LOG.error("Error: Can't find any Department for selected Department in term: " + termId);
247 GlobalVariables.getMessageMap().putError("Term & Department", ScheduleOfClassesConstants.SOC_MSG_ERROR_NO_COURSE_OFFERING_IS_FOUND, "department", organizationName, termId);
248 return;
249 } else if (orgIDs.size() > 1) {
250 LOG.error("Error: There is more than one departments with the same long name in term: " + termId);
251 GlobalVariables.getMessageMap().putError("Term & Department", ScheduleOfClassesConstants.SOC_MSG_ERROR_MULTIPLE_DEPARTMENT_IS_FOUND, organizationName);
252 return;
253 } else {
254 organizationId = KSCollectionUtils.getRequiredZeroElement(orgIDs);
255 }
256 }
257
258 Map additionalParams = new HashMap();
259 additionalParams.put(CourseOfferingManagementSearchImpl.SearchParameters.DEPARTMENT_ID, organizationId);
260
261 buildCOResultsDisplay(form, termId, additionalParams);
262
263 }
264
265
266
267
268
269
270
271
272
273 protected void buildCOResultsDisplay(ScheduleOfClassesSearchForm form, String termId, Map<String, Object> searchParameters) throws Exception {
274
275 form.getCoDisplayWrapperList().clear();
276
277 SearchRequestInfo searchRequest = new SearchRequestInfo(CourseOfferingManagementSearchImpl.CO_MANAGEMENT_SEARCH.getKey());
278
279 for (Map.Entry< String, Object > entry : searchParameters.entrySet()){
280 if (entry.getValue() instanceof String) {
281 searchRequest.addParam(entry.getKey(), (String)entry.getValue());
282 } else if (entry.getValue() instanceof List) {
283 searchRequest.addParam(entry.getKey(), (List)entry.getValue());
284 } else {
285 throw new RuntimeException("Invalid Search Parameter type. Only String and List are allowed.");
286 }
287 }
288
289 List<String> filterCOStates = new ArrayList<String>(1);
290 filterCOStates.add(LuiServiceConstants.LUI_CO_STATE_OFFERED_KEY);
291
292 searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.FILTER_CO_STATES, filterCOStates);
293 searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.ATP_ID, termId);
294 searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.CROSS_LIST_SEARCH_ENABLED, BooleanUtils.toStringTrueFalse(true));
295 searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.IS_EXACT_MATCH_CO_CODE_SEARCH, BooleanUtils.toStringTrueFalse(false));
296 searchRequest.addParam(CourseOfferingManagementSearchImpl.SearchParameters.INCLUDE_PASSFAIL_AUDIT_HONORS_RESULTS, BooleanUtils.toStringTrueFalse(true));
297
298 loadCourseOfferings(searchRequest, form);
299
300 if (form.getCoDisplayWrapperList() == null || form.getCoDisplayWrapperList().isEmpty()) {
301 LOG.error("Error: Can't find any Course Offering for the selected search");
302 GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, RiceKeyConstants.ERROR_CUSTOM, "Can't find any Course Offering for the selected search");
303 return;
304 }
305
306 for (CourseOfferingDisplayWrapper coDisplayWrapper : form.getCoDisplayWrapperList()) {
307
308
309 StringBuilder information = new StringBuilder();
310 if (coDisplayWrapper.isHonorsCourse()) {
311 information.append(makeInfoIconWithTooltip(ScheduleOfClassesConstants.SOC_RESULT_PAGE_HONORS_COURSE_IMG,ScheduleOfClassesConstants.SOC_RESULT_PAGE_HELP_HONORS_COURSE));
312 }
313
314 if (StringUtils.equals(coDisplayWrapper.getCourseOfferingGradingOptionKey(),LrcServiceConstants.RESULT_GROUP_KEY_GRADE_SATISFACTORY)) {
315 information.append(makeInfoIconWithTooltip(ScheduleOfClassesConstants.SOC_RESULT_PAGE_GRADING_SATISFACTORY_IMG, ScheduleOfClassesConstants.SOC_RESULT_PAGE_HELP_GRADING_SATISFACTORY));
316 } else if (StringUtils.equals(coDisplayWrapper.getCourseOfferingGradingOptionKey(),LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PERCENTAGE)) {
317 information.append(makeInfoIconWithTooltip(ScheduleOfClassesConstants.SOC_RESULT_PAGE_GRADING_PERCENT_IMG, ScheduleOfClassesConstants.SOC_RESULT_PAGE_HELP_GRADING_PERCENT));
318 }
319
320 if (coDisplayWrapper.isAuditCourse()){
321 information.append(makeInfoIconWithTooltip(ScheduleOfClassesConstants.SOC_RESULT_PAGE_STUREG_AUDIT_IMG, ScheduleOfClassesConstants.SOC_RESULT_PAGE_HELP_STUREG_AUDIT));
322 }
323
324 if (coDisplayWrapper.isStudentSelectablePassFail()) {
325 information.append(makeInfoIconWithTooltip(ScheduleOfClassesConstants.SOC_RESULT_PAGE_STUREG_PASSFAIL_IMG, ScheduleOfClassesConstants.SOC_RESULT_PAGE_HELP_STUREG_PASSFAIL));
326 }
327
328 coDisplayWrapper.setInformation(information.toString());
329
330 }
331 }
332
333
334
335
336
337
338
339 private String makeInfoIconWithTooltip(String src, String text) {
340 String id = UUIDHelper.genStringUUID();
341 String tt = IMG + TOOLTIP_CREATE_SCRIPT + TOOLTIP_ADD_ATTRIBUTE;
342 tt = tt.replace("$APPLICATION_URL", ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.ConfigParameters.APPLICATION_URL));
343 tt = tt.replace("$ID", id);
344 tt = tt.replace("$SRC", src);
345 tt = tt.replace("$TEXT", text);
346 return tt;
347 }
348
349
350
351
352
353
354
355 public SOCRequisiteHelper retrieveRequisites(String courseOfferingId, List<ActivityOfferingWrapper> activityOfferingWrapperList) {
356
357 SOCRequisiteHelper reqHelper = new SOCRequisiteHelper();
358
359 String catalogUsageId = getRuleManagementService().getNaturalLanguageUsageByNameAndNamespace(KSKRMSServiceConstants.KRMS_NL_TYPE_CATALOG, PermissionServiceConstants.KS_SYS_NAMESPACE).getId();
360
361
362 List<ReferenceObjectBinding> coRefObjectsBindingList = ruleManagementService.findReferenceObjectBindingsByReferenceObject(
363 CourseOfferingServiceConstants.REF_OBJECT_URI_COURSE_OFFERING, courseOfferingId);
364
365
366 for(ReferenceObjectBinding coReferenceObjectBinding : coRefObjectsBindingList) {
367 AgendaDefinition agendaDefinition = ruleManagementService.getAgenda(coReferenceObjectBinding.getKrmsObjectId());
368 AgendaItemDefinition agendaItem = ruleManagementService.getAgendaItem(agendaDefinition.getFirstItemId());
369 loadNaturalLanguageForRuleTypes(reqHelper.getReqWrapper().getCoRequisiteTypeMap(), agendaItem, catalogUsageId, reqHelper.getReqWrapper().getRuleTypes());
370 }
371
372 Map<String, List<ReferenceObjectBinding>> aoRefObjectsBindingMap = new HashMap<String, List<ReferenceObjectBinding>>();
373
374 for(ActivityOfferingWrapper activityOfferingWrapper : activityOfferingWrapperList) {
375 List<ReferenceObjectBinding> aoRefObjectBindingList = ruleManagementService.findReferenceObjectBindingsByReferenceObject(
376 CourseOfferingServiceConstants.REF_OBJECT_URI_ACTIVITY_OFFERING, activityOfferingWrapper.getAoInfo().getId());
377 if(aoRefObjectBindingList != null && !aoRefObjectBindingList.isEmpty()) {
378 aoRefObjectsBindingMap.put(activityOfferingWrapper.getActivityCode(), aoRefObjectBindingList);
379 }
380 }
381
382 StringBuilder aoRequisite = new StringBuilder();
383
384 for(Map.Entry<String, List<ReferenceObjectBinding>> aoEntry : aoRefObjectsBindingMap.entrySet()) {
385 Map<String, String> typeRequisites = new HashMap<String, String>();
386 for(ReferenceObjectBinding aoReferenceObjectBinding : aoEntry.getValue()) {
387 AgendaDefinition agendaDefinition = ruleManagementService.getAgenda(aoReferenceObjectBinding.getKrmsObjectId());
388 AgendaItemDefinition agendaItemDefinition = ruleManagementService.getAgendaItem(agendaDefinition.getFirstItemId());
389 this.loadNaturalLanguageForRuleTypes(typeRequisites, agendaItemDefinition, catalogUsageId, reqHelper.getReqWrapper().getRuleTypes());
390 }
391 reqHelper.getReqWrapper().getAoRequisiteTypeMap().put(aoEntry.getKey(), typeRequisites);
392 }
393 reqHelper.loadRequisites(activityOfferingWrapperList);
394 return reqHelper;
395 }
396
397 protected void loadNaturalLanguageForRuleTypes(Map<String, String> typeRequisites, AgendaItemDefinition agendaItem, String catalogUsageId, Set<String> ruleTypes) {
398
399 if(agendaItem.getRuleId() != null) {
400 String ruleRequisite = ruleManagementService.translateNaturalLanguageForObject(catalogUsageId, "rule", agendaItem.getRuleId(), "en");
401 typeRequisites.put(agendaItem.getRule().getTypeId(), ruleRequisite);
402 if(!ruleTypes.contains(agendaItem.getRule().getTypeId())) {
403 ruleTypes.add(agendaItem.getRule().getTypeId());
404 }
405 }
406
407 if(agendaItem.getWhenTrue() != null) {
408 this.loadNaturalLanguageForRuleTypes(typeRequisites, agendaItem.getWhenTrue(), catalogUsageId, ruleTypes);
409 }
410 }
411
412 public String getTermStartEndDate(TermInfo term) {
413
414 StringBuilder stringBuilder = new StringBuilder();
415 Formatter formatter = new Formatter(stringBuilder, Locale.US);
416 String displayString = "";
417 if (term != null) {
418 String startDate = DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(term.getStartDate());
419 String endDate = DateFormatters.MONTH_DAY_YEAR_DATE_FORMATTER.format(term.getEndDate());
420 formatter.format("%s - %s", startDate, endDate);
421 displayString = stringBuilder.toString();
422 }
423 return displayString;
424 }
425
426
427
428
429
430
431 public void setActivityComparatorChain(KSComparatorChain activityComparatorChain) {
432 this.activityComparatorChain = activityComparatorChain;
433 }
434
435
436
437
438
439
440 public KSComparatorChain getActivityComparatorChain() {
441 return activityComparatorChain;
442 }
443
444
445
446
447
448
449 public void sortRegGroups(List<RegistrationGroupWrapper> regGroupWrappers){
450 if (regGroupComparatorChain != null){
451 regGroupComparatorChain.sort(regGroupWrappers);
452 }
453 }
454
455
456
457
458
459
460 public void setRegGroupComparatorChain(KSComparatorChain regGroupComparatorChain) {
461 this.regGroupComparatorChain = regGroupComparatorChain;
462 }
463
464
465
466
467
468
469
470 public void sortActivityOfferings(ScheduleOfClassesSearchForm form,CourseOfferingDisplayWrapper coWrapper){
471 if (form.getAoDisplayFormat() == ScheduleOfClassesSearchForm.AoDisplayFormat.FLAT){
472 KSComparatorChain defaultComparator = new KSComparatorChain();
473 List<KSComparator> comparators = new ArrayList<KSComparator>(2);
474 comparators.add(new ActivityOfferingTypeComparator());
475 comparators.add(new ActivityOfferingCodeComparator());
476 defaultComparator.setComparators(comparators);
477 defaultComparator.sort(coWrapper.getActivityWrapperList());
478 } else if (form.getAoDisplayFormat() == ScheduleOfClassesSearchForm.AoDisplayFormat.CLUSTER){
479
480
481
482 for (ActivityOfferingClusterWrapper clusterWrapper : form.getClusterResultList()){
483 if(clusterWrapper.getAoWrapperList().size() >1){
484
485 getActivityComparatorChain().addComparator(0,new ActivityOfferingTypeComparator());
486 activityComparatorChain.sort(clusterWrapper.getAoWrapperList());
487 }
488 }
489 }
490 }
491
492
493
494
495
496
497
498
499 public List<String> getAOStateFilter(){
500
501 String allowedAOStates = ConfigContext.getCurrentContextConfig().getProperty(CourseOfferingConstants.CONFIG_PARAM_KEY_SCHOC_AO_STATES);
502 List<String> aoStates;
503
504 if ((allowedAOStates != null) && (!allowedAOStates.isEmpty())) {
505
506 aoStates = Arrays.asList(allowedAOStates.split("\\s*,\\s*"));
507
508 if (!Arrays.asList(LuiServiceConstants.ACTIVITY_OFFERING_LIFECYCLE_STATE_KEYS).containsAll(aoStates)) {
509 String errorMessage = String.format("Error: invalid value for configuration parameter: %s Value: %s",
510 CourseOfferingConstants.CONFIG_PARAM_KEY_SCHOC_AO_STATES, aoStates.toString());
511 throw new RuntimeException(errorMessage);
512 }
513
514 } else {
515
516 aoStates = new ArrayList<String>();
517 aoStates.add(LuiServiceConstants.LUI_AO_STATE_OFFERED_KEY);
518 }
519
520 return aoStates;
521 }
522
523
524
525
526
527
528
529
530 public List<String> getRegGroupStateFilter(){
531
532 String allowedRegGroupStates = ConfigContext.getCurrentContextConfig().getProperty(CourseOfferingConstants.CONFIG_PARAM_KEY_SCHOC_REG_GROUP_STATES);
533 List<String> regGroupStates;
534
535 if ((allowedRegGroupStates != null) && (!allowedRegGroupStates.isEmpty())) {
536 regGroupStates = Arrays.asList(allowedRegGroupStates.split("\\s*,\\s*"));
537 if (!Arrays.asList(LuiServiceConstants.REGISTRATION_GROUP_LIFECYCLE_KEY_STATES).containsAll(regGroupStates)) {
538 String errorMessage = String.format("Error: invalid value for configuration parameter: %s Value: %s",
539 CourseOfferingConstants.CONFIG_PARAM_KEY_SCHOC_REG_GROUP_STATES, regGroupStates.toString());
540 throw new RuntimeException(errorMessage);
541 }
542 } else {
543
544
545
546
547 regGroupStates = new ArrayList<String>(2);
548 regGroupStates.add(LuiServiceConstants.REGISTRATION_GROUP_OFFERED_STATE_KEY);
549 regGroupStates.add(LuiServiceConstants.REGISTRATION_GROUP_INVALID_STATE_KEY);
550 }
551
552 return regGroupStates;
553 }
554
555 private OrganizationService getOrganizationService() {
556 if (organizationService == null) {
557 organizationService = (OrganizationService) GlobalResourceLoader.getService(new QName(CommonServiceConstants.REF_OBJECT_URI_GLOBAL_PREFIX + "organization", "OrganizationService"));
558 }
559 return organizationService;
560 }
561
562 public PersonService getPersonService() {
563 return KimApiServiceLocator.getPersonService();
564 }
565
566 public TypeService getTypeService() {
567 if (typeService == null) {
568 typeService = CourseOfferingResourceLoader.loadTypeService();
569 }
570 return this.typeService;
571 }
572
573 public RuleManagementService getRuleManagementService() {
574 if (ruleManagementService == null) {
575 ruleManagementService = (RuleManagementService) GlobalResourceLoader.getService(new QName(KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0, "ruleManagementService"));
576 }
577 return ruleManagementService;
578 }
579 }