| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.student.enrollment.class2.appointment.service.impl; |
| 18 | |
|
| 19 | |
import org.apache.commons.lang.StringUtils; |
| 20 | |
import org.kuali.rice.core.api.criteria.PredicateFactory; |
| 21 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
| 22 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 23 | |
import org.kuali.rice.krad.uif.container.CollectionGroup; |
| 24 | |
import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl; |
| 25 | |
import org.kuali.rice.krad.uif.view.View; |
| 26 | |
import org.kuali.rice.krad.util.GlobalVariables; |
| 27 | |
import org.kuali.rice.krad.util.KRADConstants; |
| 28 | |
import org.kuali.student.enrollment.acal.constants.AcademicCalendarServiceConstants; |
| 29 | |
import org.kuali.student.enrollment.acal.dto.KeyDateInfo; |
| 30 | |
import org.kuali.student.enrollment.acal.dto.TermInfo; |
| 31 | |
import org.kuali.student.enrollment.acal.service.AcademicCalendarService; |
| 32 | |
import org.kuali.student.enrollment.class2.appointment.dto.AppointmentWindowWrapper; |
| 33 | |
import org.kuali.student.enrollment.class2.appointment.form.RegistrationWindowsManagementForm; |
| 34 | |
import org.kuali.student.enrollment.class2.appointment.service.AppointmentViewHelperService; |
| 35 | |
import org.kuali.student.enrollment.class2.appointment.util.AppointmentConstants; |
| 36 | |
import org.kuali.student.enrollment.class2.appointment.util.AppointmentSlotRuleTypeConversion; |
| 37 | |
import org.kuali.student.mock.utilities.TestHelper; |
| 38 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 39 | |
import org.kuali.student.r2.common.dto.LocaleInfo; |
| 40 | |
import org.kuali.student.r2.common.exceptions.*; |
| 41 | |
import org.kuali.student.r2.common.util.constants.TypeServiceConstants; |
| 42 | |
import org.kuali.student.r2.core.appointment.constants.AppointmentServiceConstants; |
| 43 | |
import org.kuali.student.r2.core.appointment.dto.AppointmentWindowInfo; |
| 44 | |
import org.kuali.student.r2.core.appointment.service.AppointmentService; |
| 45 | |
import org.kuali.student.r2.core.type.dto.TypeTypeRelationInfo; |
| 46 | |
import org.kuali.student.r2.core.type.service.TypeService; |
| 47 | |
|
| 48 | |
import javax.xml.namespace.QName; |
| 49 | |
import java.text.DateFormat; |
| 50 | |
import java.text.SimpleDateFormat; |
| 51 | |
import java.util.*; |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | 0 | public class AppointmentViewHelperServiceImpl extends ViewHelperServiceImpl implements AppointmentViewHelperService { |
| 59 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AppointmentViewHelperServiceImpl.class); |
| 60 | |
|
| 61 | |
@Override |
| 62 | |
public void searchForTerm(String typeKey, String year, RegistrationWindowsManagementForm form) throws Exception { |
| 63 | |
|
| 64 | |
|
| 65 | 0 | DateFormat df = new SimpleDateFormat("yyyy"); |
| 66 | 0 | Date minBoundDate = df.parse(year); |
| 67 | 0 | Date maxBoundDate = df.parse(Integer.toString(Integer.parseInt(year)+1)); |
| 68 | |
|
| 69 | |
|
| 70 | 0 | QueryByCriteria.Builder qbcBuilder = QueryByCriteria.Builder.create(); |
| 71 | 0 | qbcBuilder.setPredicates(PredicateFactory.and( |
| 72 | |
PredicateFactory.equal("atpType", typeKey), |
| 73 | |
PredicateFactory.greaterThanOrEqual("startDate", minBoundDate), |
| 74 | |
PredicateFactory.lessThan("startDate", maxBoundDate))); |
| 75 | |
|
| 76 | 0 | QueryByCriteria criteria = qbcBuilder.build(); |
| 77 | |
|
| 78 | |
|
| 79 | 0 | AcademicCalendarService academicCalendarService = getAcalService(); |
| 80 | 0 | List<TermInfo> terms = academicCalendarService.searchForTerms(criteria, null); |
| 81 | |
|
| 82 | |
|
| 83 | 0 | if(terms == null || terms.isEmpty()){ |
| 84 | 0 | GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, AppointmentConstants.APPOINTMENT_MSG_ERROR_NO_TERMS_FOUND); |
| 85 | 0 | return; |
| 86 | |
} |
| 87 | |
|
| 88 | 0 | if(terms.size()>1){ |
| 89 | 0 | LOG.error("Too many terms!"); |
| 90 | |
} |
| 91 | |
|
| 92 | 0 | TermInfo term = terms.get(0); |
| 93 | |
|
| 94 | |
|
| 95 | 0 | form.setTermInfo(term); |
| 96 | |
|
| 97 | |
|
| 98 | 0 | List<KeyDateInfo> keyDates = academicCalendarService.getKeyDatesForTerm(term.getId(), null); |
| 99 | 0 | if(keyDates != null){ |
| 100 | |
|
| 101 | |
|
| 102 | 0 | List<TypeTypeRelationInfo> milestoneTypeRelations = getTypeService().getTypeTypeRelationsByOwnerAndType("kuali.milestone.type.group.appt.regperiods","kuali.type.type.relation.type.group",new ContextInfo()); |
| 103 | 0 | List<String> validMilestoneTypes = new ArrayList<String>(); |
| 104 | 0 | for(TypeTypeRelationInfo milestoneTypeRelation:milestoneTypeRelations){ |
| 105 | 0 | validMilestoneTypes.add(milestoneTypeRelation.getRelatedTypeKey()); |
| 106 | |
} |
| 107 | |
|
| 108 | |
|
| 109 | 0 | List<KeyDateInfo> periodMilestones = new ArrayList<KeyDateInfo>(); |
| 110 | 0 | for(KeyDateInfo keyDate:keyDates){ |
| 111 | 0 | if(validMilestoneTypes.contains(keyDate.getTypeKey())){ |
| 112 | 0 | periodMilestones.add(keyDate); |
| 113 | |
} |
| 114 | |
} |
| 115 | 0 | form.setPeriodMilestones(periodMilestones); |
| 116 | |
|
| 117 | |
} |
| 118 | |
|
| 119 | |
|
| 120 | 0 | if(form.getPeriodMilestones()==null||form.getPeriodMilestones().isEmpty()){ |
| 121 | 0 | GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, AppointmentConstants.APPOINTMENT_MSG_ERROR_NO_REG_PERIODS_FOR_TERM); |
| 122 | |
} |
| 123 | |
|
| 124 | 0 | } |
| 125 | |
|
| 126 | |
public void loadTermAndPeriods(String termId, RegistrationWindowsManagementForm form) throws Exception { |
| 127 | 0 | ContextInfo context = TestHelper.getContext1(); |
| 128 | 0 | TermInfo term = getAcalService().getTerm(termId, context); |
| 129 | |
|
| 130 | 0 | if (term.getId() != null && !term.getId().isEmpty()) { |
| 131 | 0 | form.setTermInfo(term); |
| 132 | 0 | loadPeriods(termId, form); |
| 133 | |
} |
| 134 | |
|
| 135 | 0 | } |
| 136 | |
|
| 137 | |
public void loadPeriods(String termId, RegistrationWindowsManagementForm form) throws Exception { |
| 138 | 0 | ContextInfo context = TestHelper.getContext1(); |
| 139 | 0 | List<KeyDateInfo> periodMilestones = new ArrayList<KeyDateInfo>(); |
| 140 | 0 | List<KeyDateInfo> keyDateInfoList = getAcalService().getKeyDatesForTerm(termId, context); |
| 141 | 0 | List<TypeTypeRelationInfo> relations = getTypeService().getTypeTypeRelationsByOwnerAndType("kuali.milestone.type.group.appt.regperiods","kuali.type.type.relation.type.group",context); |
| 142 | 0 | for (KeyDateInfo keyDateInfo : keyDateInfoList) { |
| 143 | 0 | for (TypeTypeRelationInfo relationInfo : relations) { |
| 144 | 0 | String relatedTypeKey = relationInfo.getRelatedTypeKey(); |
| 145 | 0 | if (keyDateInfo.getTypeKey().equals(relatedTypeKey)) { |
| 146 | 0 | periodMilestones.add(keyDateInfo); |
| 147 | 0 | break; |
| 148 | |
} |
| 149 | 0 | } |
| 150 | |
} |
| 151 | |
|
| 152 | 0 | form.setPeriodMilestones(periodMilestones); |
| 153 | 0 | } |
| 154 | |
|
| 155 | |
public boolean validateApptWidnow(AppointmentWindowWrapper apptWindow) { |
| 156 | 0 | boolean isValid = true; |
| 157 | |
|
| 158 | |
|
| 159 | 0 | String windowTypeKey = apptWindow.getWindowTypeKey(); |
| 160 | 0 | if (AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_SLOTTED_UNIFORM_KEY.equals(windowTypeKey)){ |
| 161 | 0 | if(apptWindow.getEndDate() == null) { |
| 162 | 0 | GlobalVariables.getMessageMap().putError("newCollectionLines['appointmentWindows'].endDate", |
| 163 | |
AppointmentConstants.APPOINTMENT_MSG_ERROR_END_DATE_REQUIRED_FOR_UNIFORM); |
| 164 | 0 | isValid = false; |
| 165 | |
} |
| 166 | 0 | if(apptWindow.getEndTime() == null){ |
| 167 | 0 | GlobalVariables.getMessageMap().putError( "newCollectionLines['appointmentWindows'].endTime", |
| 168 | |
AppointmentConstants.APPOINTMENT_MSG_ERROR_END_TIME_REQUIRED_FOR_UNIFORM); |
| 169 | 0 | isValid = false; |
| 170 | |
} |
| 171 | 0 | if (apptWindow.getEndTime().isEmpty()){ |
| 172 | 0 | GlobalVariables.getMessageMap().putError( "newCollectionLines['appointmentWindows'].endTimeAmPm", |
| 173 | |
AppointmentConstants.APPOINTMENT_MSG_ERROR_END_TIME_REQUIRED_FOR_UNIFORM); |
| 174 | 0 | isValid = false; |
| 175 | |
} |
| 176 | |
} |
| 177 | |
|
| 178 | 0 | String periodId = apptWindow.getPeriodKey(); |
| 179 | |
try { |
| 180 | 0 | KeyDateInfo period = getAcalService().getKeyDate(periodId,getContextInfo()); |
| 181 | 0 | if (period.getStartDate().after(apptWindow.getStartDate()) || period.getEndDate().before(apptWindow.getStartDate())){ |
| 182 | 0 | GlobalVariables.getMessageMap().putError( "newCollectionLines['appointmentWindows'].startDate", |
| 183 | |
AppointmentConstants.APPOINTMENT_MSG_ERROR_START_DATE_OUT_OF_RANGE); |
| 184 | 0 | isValid = false; |
| 185 | |
} |
| 186 | 0 | if (apptWindow.getEndDate() != null && !apptWindow.getEndDate().toString().isEmpty() ){ |
| 187 | 0 | if (period.getStartDate().after(apptWindow.getEndDate()) || period.getEndDate().before(apptWindow.getEndDate()) ){ |
| 188 | 0 | GlobalVariables.getMessageMap().putError("newCollectionLines['appointmentWindows'].endDate", |
| 189 | |
AppointmentConstants.APPOINTMENT_MSG_ERROR_END_DATE_OUT_OF_RANGE); |
| 190 | 0 | isValid = false; |
| 191 | |
} |
| 192 | |
} |
| 193 | 0 | }catch (Exception e){ |
| 194 | 0 | LOG.error("Fail to find periods for a selected term.",e); |
| 195 | 0 | GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, AppointmentConstants.APPOINTMENT_MSG_ERROR_NO_REG_PERIODS_FOR_TERM); |
| 196 | 0 | isValid = false; |
| 197 | 0 | } |
| 198 | |
|
| 199 | |
|
| 200 | 0 | if (isValid){ |
| 201 | |
try{ |
| 202 | 0 | if (apptWindow.getEndDate() != null && !apptWindow.getEndTime().isEmpty() && !apptWindow.getEndTimeAmPm().isEmpty()){ |
| 203 | 0 | Date startDate = _updateTime(apptWindow.getStartDate(), apptWindow.getStartTime(), apptWindow.getStartTimeAmPm()); |
| 204 | 0 | Date endDate = _updateTime(apptWindow.getEndDate(), apptWindow.getEndTime(), apptWindow.getEndTimeAmPm()); |
| 205 | 0 | if(startDate.after(endDate)){ |
| 206 | 0 | GlobalVariables.getMessageMap().putError( "newCollectionLines['appointmentWindows'].endDate", |
| 207 | |
AppointmentConstants.APPOINTMENT_MSG_ERROR_END_DATE_IS_BEFORE_START_DATE); |
| 208 | |
} |
| 209 | |
} |
| 210 | 0 | } catch (Exception e){ |
| 211 | 0 | LOG.error("Fail to find periods for a selected term.",e); |
| 212 | 0 | GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, AppointmentConstants.APPOINTMENT_MSG_ERROR_END_DATE_IS_BEFORE_START_DATE); |
| 213 | 0 | isValid = false; |
| 214 | 0 | } |
| 215 | |
} |
| 216 | 0 | return isValid; |
| 217 | |
} |
| 218 | |
|
| 219 | |
protected void processAfterAddLine(View view, CollectionGroup collectionGroup, Object model, Object addLine) { |
| 220 | 0 | if (addLine instanceof AppointmentWindowWrapper) { |
| 221 | |
|
| 222 | |
|
| 223 | 0 | RegistrationWindowsManagementForm form = (RegistrationWindowsManagementForm) model; |
| 224 | 0 | AppointmentWindowWrapper newCollectionLine= (AppointmentWindowWrapper)form.getNewCollectionLines().get("appointmentWindows"); |
| 225 | 0 | String periodId = form.getPeriodId(); |
| 226 | 0 | if (periodId != "all" && !periodId.isEmpty()){ |
| 227 | 0 | newCollectionLine.setPeriodName(form.getPeriodName()); |
| 228 | 0 | newCollectionLine.setPeriodKey(form.getPeriodId()); |
| 229 | |
} |
| 230 | |
} |
| 231 | 0 | } |
| 232 | |
|
| 233 | |
public boolean saveApptWindow(AppointmentWindowWrapper appointmentWindowWrapper) throws InvalidParameterException, DataValidationErrorException, MissingParameterException, DoesNotExistException, ReadOnlyException, PermissionDeniedException, OperationFailedException, VersionMismatchException{ |
| 234 | 0 | boolean isSave = true; |
| 235 | |
|
| 236 | 0 | AppointmentWindowInfo appointmentWindowInfo = appointmentWindowWrapper.getAppointmentWindowInfo(); |
| 237 | 0 | appointmentWindowInfo.setTypeKey(appointmentWindowWrapper.getWindowTypeKey()); |
| 238 | 0 | appointmentWindowInfo.setPeriodMilestoneId(appointmentWindowWrapper.getPeriodKey()); |
| 239 | 0 | appointmentWindowInfo.setStartDate(_updateTime(appointmentWindowWrapper.getStartDate(), appointmentWindowWrapper.getStartTime(), appointmentWindowWrapper.getStartTimeAmPm())); |
| 240 | 0 | appointmentWindowInfo.setEndDate(_updateTime(appointmentWindowWrapper.getEndDate(), appointmentWindowWrapper.getEndTime(), appointmentWindowWrapper.getEndTimeAmPm())); |
| 241 | |
|
| 242 | |
|
| 243 | 0 | if(appointmentWindowInfo.getAssignedOrderTypeKey() == null || appointmentWindowInfo.getAssignedOrderTypeKey().isEmpty()){ |
| 244 | 0 | appointmentWindowInfo.setAssignedOrderTypeKey("DUMMY_ID"); |
| 245 | |
} |
| 246 | |
|
| 247 | |
|
| 248 | 0 | if(appointmentWindowInfo.getTypeKey() == null || appointmentWindowInfo.getTypeKey().isEmpty()){ |
| 249 | 0 | appointmentWindowInfo.setTypeKey(AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_ONE_SLOT_KEY); |
| 250 | |
} |
| 251 | |
|
| 252 | 0 | if(appointmentWindowInfo.getId()==null||appointmentWindowInfo.getId().isEmpty()){ |
| 253 | |
|
| 254 | 0 | appointmentWindowInfo.setStateKey(AppointmentServiceConstants.APPOINTMENT_WINDOW_STATE_DRAFT_KEY); |
| 255 | |
|
| 256 | |
|
| 257 | 0 | if(!AppointmentServiceConstants.APPOINTMENT_WINDOW_TYPE_ONE_SLOT_KEY.equals(appointmentWindowInfo.getTypeKey())) { |
| 258 | 0 | appointmentWindowInfo.setSlotRule(AppointmentSlotRuleTypeConversion.convToAppointmentSlotRuleInfo(appointmentWindowWrapper.getSlotRuleEnumType())); |
| 259 | |
} |
| 260 | |
|
| 261 | |
|
| 262 | 0 | appointmentWindowInfo = getAppointmentService().createAppointmentWindow(appointmentWindowInfo.getTypeKey(),appointmentWindowInfo,new ContextInfo()); |
| 263 | |
}else{ |
| 264 | 0 | appointmentWindowInfo = getAppointmentService().updateAppointmentWindow(appointmentWindowInfo.getId(),appointmentWindowInfo,new ContextInfo()); |
| 265 | |
} |
| 266 | |
|
| 267 | |
|
| 268 | 0 | appointmentWindowWrapper.setAppointmentWindowInfo(appointmentWindowInfo); |
| 269 | 0 | appointmentWindowWrapper.setId(appointmentWindowInfo.getId()); |
| 270 | 0 | appointmentWindowWrapper.setWindowName(appointmentWindowInfo.getName()); |
| 271 | |
|
| 272 | 0 | return isSave; |
| 273 | |
|
| 274 | |
} |
| 275 | |
|
| 276 | |
public boolean saveWindows(RegistrationWindowsManagementForm form) throws InvalidParameterException, DataValidationErrorException, MissingParameterException, DoesNotExistException, ReadOnlyException, PermissionDeniedException, OperationFailedException, VersionMismatchException { |
| 277 | 0 | boolean isApptWindowSaved = true; |
| 278 | 0 | boolean allWindowsSaved = true; |
| 279 | 0 | if(form.getAppointmentWindows()!=null){ |
| 280 | |
|
| 281 | 0 | for(AppointmentWindowWrapper appointmentWindowWrapper:form.getAppointmentWindows()){ |
| 282 | 0 | boolean isValid = validateApptWidnow(appointmentWindowWrapper); |
| 283 | 0 | if (isValid) { |
| 284 | 0 | isApptWindowSaved=saveApptWindow(appointmentWindowWrapper); |
| 285 | 0 | if(!isApptWindowSaved) |
| 286 | 0 | allWindowsSaved = isApptWindowSaved; |
| 287 | |
} |
| 288 | 0 | } |
| 289 | |
|
| 290 | 0 | if (isApptWindowSaved) |
| 291 | 0 | GlobalVariables.getMessageMap().putInfo( KRADConstants.GLOBAL_MESSAGES, |
| 292 | |
AppointmentConstants.APPOINTMENT_MSG_INFO_SAVED); |
| 293 | |
} |
| 294 | 0 | return allWindowsSaved; |
| 295 | |
} |
| 296 | |
|
| 297 | |
protected void processBeforeAddLine(View view, CollectionGroup collectionGroup, Object model, Object addLine) { |
| 298 | 0 | if (addLine instanceof AppointmentWindowWrapper){ |
| 299 | 0 | RegistrationWindowsManagementForm form = (RegistrationWindowsManagementForm) model; |
| 300 | 0 | List<KeyDateInfo> periodMilestones = form.getPeriodMilestones(); |
| 301 | 0 | String periodKey = ((AppointmentWindowWrapper) addLine).getPeriodKey(); |
| 302 | 0 | for (KeyDateInfo period : periodMilestones) { |
| 303 | 0 | if (periodKey.equals(period.getId())){ |
| 304 | 0 | if (period.getName() != null && !period.getName().isEmpty()){ |
| 305 | 0 | ((AppointmentWindowWrapper) addLine).setPeriodName(period.getName()); |
| 306 | |
} |
| 307 | |
else{ |
| 308 | 0 | ((AppointmentWindowWrapper) addLine).setPeriodName(periodKey); |
| 309 | |
} |
| 310 | 0 | break; |
| 311 | |
} |
| 312 | |
} |
| 313 | 0 | String windowName = ((AppointmentWindowWrapper) addLine).getAppointmentWindowInfo().getName(); |
| 314 | 0 | ((AppointmentWindowWrapper) addLine).setWindowName(windowName); |
| 315 | |
} |
| 316 | 0 | } |
| 317 | |
|
| 318 | |
protected boolean performAddLineValidation(View view, CollectionGroup collectionGroup, Object model, |
| 319 | |
Object addLine) { |
| 320 | 0 | boolean isValid = true; |
| 321 | 0 | if (addLine instanceof AppointmentWindowWrapper){ |
| 322 | 0 | AppointmentWindowWrapper apptWindow = (AppointmentWindowWrapper) addLine; |
| 323 | 0 | isValid = validateApptWidnow(apptWindow); |
| 324 | 0 | if(isValid) { |
| 325 | |
try { |
| 326 | |
|
| 327 | 0 | saveApptWindow((AppointmentWindowWrapper)addLine); |
| 328 | |
|
| 329 | 0 | GlobalVariables.getMessageMap().putInfo(KRADConstants.GLOBAL_MESSAGES, |
| 330 | |
AppointmentConstants.APPOINTMENT_MSG_INFO_SAVED); |
| 331 | 0 | } catch (Exception e) { |
| 332 | 0 | LOG.error("Fail to create a window.",e); |
| 333 | 0 | GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES, AppointmentConstants.APPOINTMENT_MSG_ERROR_WINDOW_SAVE_FAIL); |
| 334 | 0 | isValid = false; |
| 335 | 0 | } |
| 336 | |
} |
| 337 | |
|
| 338 | 0 | } else { |
| 339 | 0 | super.performAddLineValidation(view, collectionGroup, model, addLine); |
| 340 | |
} |
| 341 | 0 | return isValid; |
| 342 | |
} |
| 343 | |
|
| 344 | |
|
| 345 | |
private Date _updateTime(Date date,String time,String amPm){ |
| 346 | |
|
| 347 | 0 | if(date == null || time == null || amPm == null){ |
| 348 | 0 | return null; |
| 349 | |
} |
| 350 | |
|
| 351 | |
|
| 352 | |
|
| 353 | |
|
| 354 | 0 | Calendar cal = Calendar.getInstance(); |
| 355 | 0 | cal.setTime(date); |
| 356 | |
|
| 357 | |
|
| 358 | 0 | cal.set(Calendar.HOUR, Integer.parseInt(StringUtils.substringBefore(time, ":"))); |
| 359 | 0 | cal.set(Calendar.MINUTE, Integer.parseInt(StringUtils.substringAfter(time,":"))); |
| 360 | 0 | cal.set(Calendar.SECOND, 0); |
| 361 | 0 | cal.set(Calendar.MILLISECOND, 0); |
| 362 | 0 | if (StringUtils.isNotBlank(amPm)){ |
| 363 | 0 | if (StringUtils.equalsIgnoreCase(amPm,"am")){ |
| 364 | 0 | cal.set(Calendar.AM_PM,Calendar.AM); |
| 365 | 0 | }else if(StringUtils.equalsIgnoreCase(amPm,"pm")){ |
| 366 | 0 | cal.set(Calendar.AM_PM,Calendar.PM); |
| 367 | |
}else{ |
| 368 | 0 | throw new RuntimeException("Unknown AM/PM format."); |
| 369 | |
} |
| 370 | |
} |
| 371 | |
|
| 372 | 0 | return cal.getTime(); |
| 373 | |
} |
| 374 | |
|
| 375 | |
public AcademicCalendarService getAcalService() { |
| 376 | 0 | return (AcademicCalendarService) GlobalResourceLoader.getService(new QName(AcademicCalendarServiceConstants.NAMESPACE, AcademicCalendarServiceConstants.SERVICE_NAME_LOCAL_PART)); |
| 377 | |
} |
| 378 | |
|
| 379 | |
public TypeService getTypeService() { |
| 380 | 0 | return (TypeService) GlobalResourceLoader.getService(new QName(TypeServiceConstants.NAMESPACE, TypeService.class.getSimpleName())); |
| 381 | |
} |
| 382 | |
|
| 383 | |
public AppointmentService getAppointmentService() { |
| 384 | 0 | return (AppointmentService) GlobalResourceLoader.getService(new QName(AppointmentServiceConstants.NAMESPACE, AppointmentServiceConstants.SERVICE_NAME_LOCAL_PART)); |
| 385 | |
} |
| 386 | |
|
| 387 | |
public ContextInfo getContextInfo() { |
| 388 | 0 | ContextInfo contextInfo = new ContextInfo(); |
| 389 | 0 | contextInfo.setAuthenticatedPrincipalId(GlobalVariables.getUserSession().getPrincipalId()); |
| 390 | 0 | contextInfo.setPrincipalId(GlobalVariables.getUserSession().getPrincipalId()); |
| 391 | 0 | LocaleInfo localeInfo = new LocaleInfo(); |
| 392 | 0 | localeInfo.setLocaleLanguage(Locale.getDefault().getLanguage()); |
| 393 | 0 | localeInfo.setLocaleRegion(Locale.getDefault().getCountry()); |
| 394 | 0 | contextInfo.setLocale(localeInfo); |
| 395 | 0 | return contextInfo; |
| 396 | |
} |
| 397 | |
|
| 398 | |
|
| 399 | |
} |