| 1 | |
package org.kuali.student.enrollment.class2.acal.service.impl; |
| 2 | |
|
| 3 | |
|
| 4 | |
import org.apache.commons.lang.StringUtils; |
| 5 | |
import org.joda.time.DateTime; |
| 6 | |
import org.joda.time.Days; |
| 7 | |
import org.joda.time.Period; |
| 8 | |
import org.joda.time.Weeks; |
| 9 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
| 10 | |
import org.kuali.student.enrollment.acal.dto.*; |
| 11 | |
import org.kuali.student.enrollment.acal.service.AcademicCalendarService; |
| 12 | |
import org.kuali.student.enrollment.class2.acal.service.assembler.*; |
| 13 | |
import org.kuali.student.r2.common.assembler.AssemblyException; |
| 14 | |
import org.kuali.student.r2.common.datadictionary.service.DataDictionaryService; |
| 15 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 16 | |
import org.kuali.student.r2.common.dto.DateRangeInfo; |
| 17 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
| 18 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 19 | |
import org.kuali.student.r2.common.exceptions.*; |
| 20 | |
import org.kuali.student.r2.common.util.constants.AtpServiceConstants; |
| 21 | |
import org.kuali.student.r2.common.util.constants.TypeServiceConstants; |
| 22 | |
import org.kuali.student.r2.core.atp.dto.AtpAtpRelationInfo; |
| 23 | |
import org.kuali.student.r2.core.atp.dto.AtpInfo; |
| 24 | |
import org.kuali.student.r2.core.atp.dto.MilestoneInfo; |
| 25 | |
import org.kuali.student.r2.core.atp.service.AtpService; |
| 26 | |
import org.kuali.student.r2.core.state.dto.StateInfo; |
| 27 | |
import org.kuali.student.r2.core.state.service.StateService; |
| 28 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
| 29 | |
import org.kuali.student.r2.core.type.dto.TypeTypeRelationInfo; |
| 30 | |
import org.kuali.student.r2.core.type.service.TypeService; |
| 31 | |
import org.springframework.transaction.annotation.Transactional; |
| 32 | |
|
| 33 | |
import java.util.*; |
| 34 | |
|
| 35 | |
@Transactional(readOnly = true, noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 36 | 0 | public class AcademicCalendarServiceImpl implements AcademicCalendarService { |
| 37 | |
|
| 38 | |
private AtpService atpService; |
| 39 | |
private StateService stateService; |
| 40 | |
private TypeService typeService; |
| 41 | |
private AcademicCalendarAssembler acalAssembler; |
| 42 | |
private TermAssembler termAssembler; |
| 43 | |
private DataDictionaryService dataDictionaryService; |
| 44 | |
private HolidayCalendarAssembler holidayCalendarAssembler; |
| 45 | |
private HolidayAssembler holidayAssembler; |
| 46 | |
private KeyDateAssembler keyDateAssembler; |
| 47 | |
private AcalEventAssembler acalEventAssembler; |
| 48 | |
|
| 49 | |
public AcalEventAssembler getAcalEventAssembler() { |
| 50 | 0 | return acalEventAssembler; |
| 51 | |
} |
| 52 | |
|
| 53 | |
public void setAcalEventAssembler(AcalEventAssembler acalEventAssembler) { |
| 54 | 0 | this.acalEventAssembler = acalEventAssembler; |
| 55 | 0 | } |
| 56 | |
|
| 57 | |
public KeyDateAssembler getKeyDateAssembler() { |
| 58 | 0 | return keyDateAssembler; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public void setKeyDateAssembler(KeyDateAssembler keyDateAssembler) { |
| 62 | 0 | this.keyDateAssembler = keyDateAssembler; |
| 63 | 0 | } |
| 64 | |
|
| 65 | |
public HolidayAssembler getHolidayAssembler() { |
| 66 | 0 | return holidayAssembler; |
| 67 | |
} |
| 68 | |
|
| 69 | |
public void setHolidayAssembler(HolidayAssembler holidayAssembler) { |
| 70 | 0 | this.holidayAssembler = holidayAssembler; |
| 71 | 0 | } |
| 72 | |
|
| 73 | |
public HolidayCalendarAssembler getHolidayCalendarAssembler() { |
| 74 | 0 | return holidayCalendarAssembler; |
| 75 | |
} |
| 76 | |
|
| 77 | |
public void setHolidayCalendarAssembler(HolidayCalendarAssembler holidayCalendarAssembler) { |
| 78 | 0 | this.holidayCalendarAssembler = holidayCalendarAssembler; |
| 79 | 0 | } |
| 80 | |
|
| 81 | |
public DataDictionaryService getDataDictionaryService() { |
| 82 | 0 | return dataDictionaryService; |
| 83 | |
} |
| 84 | |
|
| 85 | |
public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { |
| 86 | 0 | this.dataDictionaryService = dataDictionaryService; |
| 87 | 0 | } |
| 88 | |
|
| 89 | |
public TypeService getTypeService() { |
| 90 | 0 | return typeService; |
| 91 | |
} |
| 92 | |
|
| 93 | |
public void setTypeService(TypeService typeService) { |
| 94 | 0 | this.typeService = typeService; |
| 95 | 0 | } |
| 96 | |
|
| 97 | |
public StateService getStateService() { |
| 98 | 0 | return stateService; |
| 99 | |
} |
| 100 | |
|
| 101 | |
public void setStateService(StateService stateService) { |
| 102 | 0 | this.stateService = stateService; |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
@Override |
| 106 | |
public TypeInfo getAcademicCalendarType(String academicCalendarTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 107 | |
OperationFailedException { |
| 108 | |
|
| 109 | 0 | return null; |
| 110 | |
} |
| 111 | |
|
| 112 | |
@Override |
| 113 | |
public List<TypeInfo> getAcademicCalendarTypes(ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
| 114 | |
|
| 115 | 0 | return new ArrayList<TypeInfo>(); |
| 116 | |
} |
| 117 | |
|
| 118 | |
@Override |
| 119 | |
public StateInfo getAcademicCalendarState(String academicCalendarStateKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 120 | |
OperationFailedException { |
| 121 | |
|
| 122 | 0 | return null; |
| 123 | |
} |
| 124 | |
|
| 125 | |
private List<StateInfo> getAtpStates(ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 126 | |
List<StateInfo> results; |
| 127 | |
try { |
| 128 | 0 | results = stateService.getStatesByLifecycle(AtpServiceConstants.ATP_LIFECYCLE_KEY, context); |
| 129 | 0 | } catch (DoesNotExistException ex) { |
| 130 | 0 | throw new OperationFailedException(AtpServiceConstants.ATP_LIFECYCLE_KEY, ex); |
| 131 | 0 | } |
| 132 | |
|
| 133 | 0 | return results; |
| 134 | |
} |
| 135 | |
|
| 136 | |
@Override |
| 137 | |
public List<StateInfo> getAcademicCalendarStates(ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 138 | 0 | return getAtpStates(context); |
| 139 | |
} |
| 140 | |
|
| 141 | |
@Override |
| 142 | |
public AcademicCalendarInfo getAcademicCalendar(String academicCalendarKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 143 | |
OperationFailedException, PermissionDeniedException { |
| 144 | 0 | AtpInfo atp = atpService.getAtp(academicCalendarKey, context); |
| 145 | |
AcademicCalendarInfo acal; |
| 146 | |
|
| 147 | |
try { |
| 148 | 0 | acal = acalAssembler.assemble(atp, context); |
| 149 | 0 | } catch (AssemblyException e) { |
| 150 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 151 | 0 | } |
| 152 | |
|
| 153 | 0 | return acal; |
| 154 | |
} |
| 155 | |
|
| 156 | |
@Override |
| 157 | |
public List<AcademicCalendarInfo> getAcademicCalendarsByIds(List<String> academicCalendarKeyList, ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 158 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 159 | 0 | List<AcademicCalendarInfo> academicCalendars = new ArrayList<AcademicCalendarInfo>(); |
| 160 | 0 | List<AtpInfo> atps = atpService.getAtpsByIds(academicCalendarKeyList, context); |
| 161 | 0 | for (AtpInfo atp : atps) { |
| 162 | |
try { |
| 163 | 0 | academicCalendars.add(acalAssembler.assemble(atp, context)); |
| 164 | 0 | } catch (AssemblyException e) { |
| 165 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 166 | 0 | } |
| 167 | |
} |
| 168 | 0 | return academicCalendars; |
| 169 | |
} |
| 170 | |
|
| 171 | |
@Override |
| 172 | |
public List<String> getAcademicCalendarIdsByType(String academicCalendarTypeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 173 | |
PermissionDeniedException { |
| 174 | |
|
| 175 | 0 | return new ArrayList<String>(); |
| 176 | |
} |
| 177 | |
|
| 178 | |
@Override |
| 179 | |
public List<AcademicCalendarInfo> getAcademicCalendarsByStartYear(Integer year, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 180 | |
PermissionDeniedException { |
| 181 | |
final Date yearBegin, yearEnd; |
| 182 | |
|
| 183 | 0 | Calendar cal = Calendar.getInstance(); |
| 184 | 0 | cal.clear(); |
| 185 | 0 | cal.set(year, 0, 1); |
| 186 | 0 | yearBegin = cal.getTime(); |
| 187 | 0 | cal.add(Calendar.YEAR, 1); |
| 188 | 0 | cal.add(Calendar.MILLISECOND, -1); |
| 189 | 0 | yearEnd = cal.getTime(); |
| 190 | |
|
| 191 | 0 | Set<AtpInfo> atpInfos = new TreeSet<AtpInfo>(new Comparator<AtpInfo>() { |
| 192 | |
|
| 193 | |
@Override |
| 194 | |
public int compare(AtpInfo atpInfo1, AtpInfo atpInfo2) { |
| 195 | 0 | return atpInfo1.getId().compareTo(atpInfo2.getId()); |
| 196 | |
} |
| 197 | |
}); |
| 198 | |
|
| 199 | 0 | atpInfos.addAll(atpService.getAtpsByStartDateRangeAndType(yearBegin, yearEnd, AtpServiceConstants.ATP_ACADEMIC_CALENDAR_TYPE_KEY, context)); |
| 200 | |
|
| 201 | 0 | List<AcademicCalendarInfo> acalInfos = new ArrayList<AcademicCalendarInfo>(); |
| 202 | 0 | for (AtpInfo atpInfo : atpInfos) { |
| 203 | |
try { |
| 204 | 0 | acalInfos.add(acalAssembler.assemble(atpInfo, context)); |
| 205 | 0 | } catch (AssemblyException e) { |
| 206 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 207 | 0 | } |
| 208 | |
} |
| 209 | 0 | return acalInfos; |
| 210 | |
} |
| 211 | |
|
| 212 | |
@Override |
| 213 | |
@Transactional(readOnly = false) |
| 214 | |
public AcademicCalendarInfo createAcademicCalendar(String academicCalendarTypeKey, AcademicCalendarInfo academicCalendarInfo, ContextInfo context) throws DataValidationErrorException, |
| 215 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 216 | |
|
| 217 | |
|
| 218 | |
try { |
| 219 | 0 | AtpInfo toCreate = acalAssembler.disassemble(academicCalendarInfo, context); |
| 220 | 0 | AtpInfo createdAtp = atpService.createAtp(toCreate.getTypeKey(), toCreate, context); |
| 221 | |
try { |
| 222 | 0 | createDeleteAtpAtpRelations(createdAtp.getId(), |
| 223 | |
academicCalendarInfo.getHolidayCalendarIds(), |
| 224 | |
AtpServiceConstants.ATP_HOLIDAY_CALENDAR_TYPE_KEY, |
| 225 | |
context); |
| 226 | 0 | } catch (VersionMismatchException e) { |
| 227 | 0 | throw new OperationFailedException(); |
| 228 | 0 | } |
| 229 | 0 | return acalAssembler.assemble(createdAtp, context); |
| 230 | 0 | } catch (AlreadyExistsException e) { |
| 231 | 0 | throw new OperationFailedException("Unexpected", e); |
| 232 | 0 | } catch (AssemblyException e) { |
| 233 | 0 | throw new OperationFailedException("Unexpected", e); |
| 234 | 0 | } catch (ReadOnlyException e) { |
| 235 | 0 | throw new OperationFailedException("Unexpected", e); |
| 236 | |
} |
| 237 | |
|
| 238 | |
} |
| 239 | |
|
| 240 | |
@Override |
| 241 | |
@Transactional(readOnly = false) |
| 242 | |
public AcademicCalendarInfo updateAcademicCalendar(String academicCalendarId, AcademicCalendarInfo academicCalendarInfo, ContextInfo context) throws DataValidationErrorException, |
| 243 | |
DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 244 | |
|
| 245 | |
|
| 246 | |
try { |
| 247 | 0 | AtpInfo toUpdate = acalAssembler.disassemble(academicCalendarInfo, context); |
| 248 | 0 | AtpInfo updated = atpService.updateAtp(academicCalendarId, toUpdate, context); |
| 249 | |
try { |
| 250 | 0 | createDeleteAtpAtpRelations(academicCalendarId, |
| 251 | |
academicCalendarInfo.getHolidayCalendarIds(), |
| 252 | |
AtpServiceConstants.ATP_HOLIDAY_CALENDAR_TYPE_KEY, |
| 253 | |
context); |
| 254 | 0 | } catch (VersionMismatchException e) { |
| 255 | 0 | throw new OperationFailedException(); |
| 256 | 0 | } |
| 257 | 0 | return acalAssembler.assemble(updated, context); |
| 258 | 0 | } catch (Exception e) { |
| 259 | 0 | throw new OperationFailedException("Unexpected", e); |
| 260 | |
} |
| 261 | |
} |
| 262 | |
|
| 263 | |
|
| 264 | |
@Override |
| 265 | |
@Transactional(readOnly = false) |
| 266 | |
public StatusInfo deleteAcademicCalendar(String academicCalendarKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 267 | |
OperationFailedException, PermissionDeniedException { |
| 268 | |
|
| 269 | 0 | StatusInfo status = new StatusInfo(); |
| 270 | 0 | status.setSuccess(Boolean.TRUE); |
| 271 | |
|
| 272 | 0 | AtpInfo atp = atpService.getAtp(academicCalendarKey, context); |
| 273 | |
|
| 274 | 0 | if (atp != null) { |
| 275 | |
|
| 276 | 0 | atpService.deleteAtp(academicCalendarKey, context); |
| 277 | |
} |
| 278 | |
|
| 279 | 0 | return status; |
| 280 | |
} |
| 281 | |
|
| 282 | |
@Override |
| 283 | |
public AcademicCalendarInfo copyAcademicCalendar(String academicCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
| 284 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 285 | 0 | throw new OperationFailedException("Method implemented in calculation decorator."); |
| 286 | |
} |
| 287 | |
|
| 288 | |
@Override |
| 289 | |
@Transactional(readOnly = true) |
| 290 | |
public HolidayCalendarInfo getHolidayCalendar(String holidayCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 291 | |
OperationFailedException, PermissionDeniedException { |
| 292 | 0 | AtpInfo atp = atpService.getAtp(holidayCalendarId, contextInfo); |
| 293 | |
HolidayCalendarInfo ccal; |
| 294 | |
try { |
| 295 | 0 | ccal = holidayCalendarAssembler.assemble(atp, contextInfo); |
| 296 | 0 | } catch (AssemblyException e) { |
| 297 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 298 | 0 | } |
| 299 | |
|
| 300 | 0 | return ccal; |
| 301 | |
} |
| 302 | |
|
| 303 | |
@Override |
| 304 | |
public List<HolidayCalendarInfo> getHolidayCalendarsByIds(List<String> holidayCalendarIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 305 | |
OperationFailedException, PermissionDeniedException { |
| 306 | 0 | List<AtpInfo> atps = atpService.getAtpsByIds(holidayCalendarIds, context); |
| 307 | 0 | List<HolidayCalendarInfo> holidayCalendarInfos = new ArrayList<HolidayCalendarInfo>(); |
| 308 | 0 | for (AtpInfo atp : atps) { |
| 309 | |
try { |
| 310 | 0 | holidayCalendarInfos.add(holidayCalendarAssembler.assemble(atp, context)); |
| 311 | 0 | } catch (AssemblyException e) { |
| 312 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 313 | 0 | } |
| 314 | |
} |
| 315 | 0 | return holidayCalendarInfos; |
| 316 | |
} |
| 317 | |
|
| 318 | |
@Override |
| 319 | |
@Transactional(readOnly = false) |
| 320 | |
public HolidayCalendarInfo createHolidayCalendar(String holidayCalendarTypeKey, HolidayCalendarInfo holidayCalendarInfo, ContextInfo context) throws DataValidationErrorException, |
| 321 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 322 | |
|
| 323 | |
AtpInfo atpInfo; |
| 324 | |
try { |
| 325 | 0 | atpInfo = holidayCalendarAssembler.disassemble(holidayCalendarInfo, context); |
| 326 | 0 | } catch (AssemblyException ex) { |
| 327 | 0 | throw new OperationFailedException("Unexpected", ex); |
| 328 | 0 | } |
| 329 | |
try { |
| 330 | 0 | System.out.println("AcademicCalendarServiceImp: creating atp for holiday calendar "); |
| 331 | 0 | atpInfo = atpService.createAtp(atpInfo.getTypeKey(), atpInfo, context); |
| 332 | 0 | System.out.println("atp created for holiday calendar " + atpInfo.getId()); |
| 333 | 0 | } catch (ReadOnlyException ex) { |
| 334 | 0 | throw new OperationFailedException("Unexpected", ex); |
| 335 | 0 | } |
| 336 | |
HolidayCalendarInfo newHolidayCalendar; |
| 337 | |
try { |
| 338 | 0 | newHolidayCalendar = holidayCalendarAssembler.assemble(atpInfo, context); |
| 339 | 0 | } catch (AssemblyException ex) { |
| 340 | 0 | throw new OperationFailedException("unexpected", ex); |
| 341 | 0 | } |
| 342 | |
|
| 343 | 0 | return newHolidayCalendar; |
| 344 | |
} |
| 345 | |
|
| 346 | |
@Override |
| 347 | |
@Transactional(readOnly = false) |
| 348 | |
public HolidayCalendarInfo copyHolidayCalendar(String holidayCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 349 | 0 | throw new OperationFailedException("Method implemented in calculation decorator."); |
| 350 | |
} |
| 351 | |
|
| 352 | |
@Override |
| 353 | |
@Transactional(readOnly = false) |
| 354 | |
public HolidayCalendarInfo updateHolidayCalendar(String holidayCalendarId, HolidayCalendarInfo holidayCalendarInfo, ContextInfo contextInfo) throws DataValidationErrorException, |
| 355 | |
DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
| 356 | |
|
| 357 | |
try { |
| 358 | 0 | AtpInfo toUpdate = holidayCalendarAssembler.disassemble(holidayCalendarInfo, contextInfo); |
| 359 | 0 | AtpInfo updated = atpService.updateAtp(holidayCalendarId, toUpdate, contextInfo); |
| 360 | 0 | return holidayCalendarAssembler.assemble(updated, contextInfo); |
| 361 | 0 | } catch (AssemblyException e) { |
| 362 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 363 | 0 | } catch (DoesNotExistException e) { |
| 364 | 0 | throw new OperationFailedException("Failed to update ATP - " + e.getMessage(), e); |
| 365 | 0 | } catch (ReadOnlyException e) { |
| 366 | 0 | throw new OperationFailedException("Failed to update ATP - " + e.getMessage(), e); |
| 367 | |
} |
| 368 | |
} |
| 369 | |
|
| 370 | |
@Override |
| 371 | |
@Transactional(readOnly = false) |
| 372 | |
public StatusInfo deleteHolidayCalendar(String holidayCalendarId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 373 | |
OperationFailedException, PermissionDeniedException { |
| 374 | 0 | return atpService.deleteAtp(holidayCalendarId, context); |
| 375 | |
} |
| 376 | |
|
| 377 | |
@Override |
| 378 | |
public TypeInfo getTermType(String termTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 379 | |
PermissionDeniedException { |
| 380 | 0 | TypeInfo type = typeService.getType(termTypeKey, context); |
| 381 | |
|
| 382 | 0 | if (!checkTypeForTermType(termTypeKey, context)) { |
| 383 | 0 | throw new InvalidParameterException(termTypeKey + " is not a Term type"); |
| 384 | |
} |
| 385 | |
|
| 386 | 0 | return type; |
| 387 | |
} |
| 388 | |
|
| 389 | |
@Override |
| 390 | |
public List<TypeInfo> getTermTypes(ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 391 | |
|
| 392 | 0 | List<TypeTypeRelationInfo> relations = null; |
| 393 | |
try { |
| 394 | 0 | relations = typeService.getTypeTypeRelationsByOwnerAndType(AtpServiceConstants.ATP_TERM_GROUPING_TYPE_KEY, TypeServiceConstants.TYPE_TYPE_RELATION_GROUP_TYPE_KEY, context); |
| 395 | 0 | } catch (DoesNotExistException e) { |
| 396 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 397 | 0 | } |
| 398 | |
|
| 399 | 0 | if (relations != null) { |
| 400 | 0 | List<TypeInfo> results = new ArrayList<TypeInfo>(relations.size()); |
| 401 | 0 | for (TypeTypeRelationInfo rel : relations) { |
| 402 | |
try { |
| 403 | 0 | results.add(typeService.getType(rel.getRelatedTypeKey(), context)); |
| 404 | 0 | } catch (DoesNotExistException e) { |
| 405 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 406 | 0 | } |
| 407 | |
} |
| 408 | |
|
| 409 | 0 | return results; |
| 410 | |
} |
| 411 | |
|
| 412 | 0 | return null; |
| 413 | |
} |
| 414 | |
|
| 415 | |
@Override |
| 416 | |
public List<TypeInfo> getTermTypesForAcademicCalendarType(String academicCalendarTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 417 | |
OperationFailedException, PermissionDeniedException { |
| 418 | |
|
| 419 | 0 | TypeInfo acalType = typeService.getType(academicCalendarTypeKey, context); |
| 420 | |
|
| 421 | 0 | return typeService.getAllowedTypesForType(acalType.getKey(), context); |
| 422 | |
} |
| 423 | |
|
| 424 | |
@Override |
| 425 | |
public List<TypeInfo> getTermTypesForTermType(String termTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 426 | |
OperationFailedException, PermissionDeniedException { |
| 427 | 0 | TypeInfo termType = getTermType(termTypeKey, context); |
| 428 | |
|
| 429 | 0 | return typeService.getAllowedTypesForType(termType.getKey(), context); |
| 430 | |
} |
| 431 | |
|
| 432 | |
@Override |
| 433 | |
public StateInfo getTermState(String termStateKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 434 | |
PermissionDeniedException { |
| 435 | |
|
| 436 | 0 | StateInfo termState = stateService.getState(termStateKey, context); |
| 437 | |
|
| 438 | 0 | return termState; |
| 439 | |
} |
| 440 | |
|
| 441 | |
@Override |
| 442 | |
public List<StateInfo> getTermStates(ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 443 | |
|
| 444 | |
List<StateInfo> results; |
| 445 | |
try { |
| 446 | 0 | results = stateService.getStatesByLifecycle(AtpServiceConstants.ATP_LIFECYCLE_KEY, context); |
| 447 | 0 | } catch (DoesNotExistException ex) { |
| 448 | 0 | throw new OperationFailedException(AtpServiceConstants.ATP_LIFECYCLE_KEY, ex); |
| 449 | 0 | } |
| 450 | |
|
| 451 | 0 | return results; |
| 452 | |
} |
| 453 | |
|
| 454 | |
@Override |
| 455 | |
public TermInfo getTerm(String termId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 456 | 0 | AtpInfo atp = atpService.getAtp(termId, context); |
| 457 | 0 | TermInfo term = null; |
| 458 | |
|
| 459 | 0 | if (atp != null && checkTypeForTermType(atp.getTypeKey(), context)) { |
| 460 | |
try { |
| 461 | 0 | term = termAssembler.assemble(atp, context); |
| 462 | 0 | } catch (AssemblyException e) { |
| 463 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 464 | 0 | } |
| 465 | |
} else { |
| 466 | 0 | throw new DoesNotExistException("This is either not valid Atp or not valid Term. " + termId); |
| 467 | |
} |
| 468 | |
|
| 469 | 0 | return term; |
| 470 | |
} |
| 471 | |
|
| 472 | |
@Override |
| 473 | |
public List<TermInfo> getTermsByIds(List<String> termIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 474 | |
PermissionDeniedException { |
| 475 | |
|
| 476 | 0 | List<AtpInfo> results = atpService.getAtpsByIds(termIds, context); |
| 477 | |
|
| 478 | 0 | List<TermInfo> terms = new ArrayList<TermInfo>(); |
| 479 | |
|
| 480 | 0 | for (AtpInfo atp : results) { |
| 481 | |
try { |
| 482 | 0 | terms.add(termAssembler.assemble(atp, context)); |
| 483 | 0 | } catch (AssemblyException e) { |
| 484 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 485 | 0 | } |
| 486 | |
} |
| 487 | |
|
| 488 | 0 | return terms; |
| 489 | |
} |
| 490 | |
|
| 491 | |
@Override |
| 492 | |
public List<TermInfo> getTermsForAcademicCalendar(String academicCalendarId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 493 | |
OperationFailedException, PermissionDeniedException { |
| 494 | |
|
| 495 | 0 | List<AtpAtpRelationInfo> results = atpService.getAtpAtpRelationsByTypeAndAtp(academicCalendarId, |
| 496 | |
AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, |
| 497 | |
context); |
| 498 | 0 | List<TermInfo> terms = new ArrayList<TermInfo>(results.size()); |
| 499 | 0 | for (AtpAtpRelationInfo atpRelation : results) { |
| 500 | 0 | if (atpRelation.getAtpId().equals(academicCalendarId)) { |
| 501 | 0 | AtpInfo possibleTerm = atpService.getAtp(atpRelation.getRelatedAtpId(), context); |
| 502 | 0 | if (checkTypeForTermType(possibleTerm.getTypeKey(), context)) { |
| 503 | |
try { |
| 504 | 0 | terms.add(termAssembler.assemble(possibleTerm, context)); |
| 505 | 0 | } catch (AssemblyException e) { |
| 506 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 507 | 0 | } |
| 508 | |
} |
| 509 | 0 | } |
| 510 | |
} |
| 511 | 0 | return terms; |
| 512 | |
} |
| 513 | |
|
| 514 | |
@Override |
| 515 | |
public List<TermInfo> getCurrentTerms(String processKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 516 | |
PermissionDeniedException { |
| 517 | |
|
| 518 | 0 | List<AcademicCalendarInfo> currentACInfos = getAcademicCalendarsByStartYear(new Integer(Calendar.getInstance().get(Calendar.YEAR)), context); |
| 519 | 0 | List<TermInfo> terms = getTermsForAcademicCalendar(currentACInfos.get(0).getId(), context); |
| 520 | 0 | if (terms == null || terms.size() == 0) { |
| 521 | 0 | throw new DoesNotExistException("This academic calendar doesn't contain any terms : " + currentACInfos.get(0).getId()); |
| 522 | |
} |
| 523 | 0 | return terms; |
| 524 | |
} |
| 525 | |
|
| 526 | |
@Override |
| 527 | |
public List<TermInfo> getIncludedTermsInTerm(String termId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 528 | |
PermissionDeniedException { |
| 529 | |
|
| 530 | |
|
| 531 | 0 | TermInfo parentTerm = getTerm(termId, context); |
| 532 | |
|
| 533 | 0 | List<AtpAtpRelationInfo> results = atpService.getAtpAtpRelationsByTypeAndAtp(parentTerm.getId(), AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, context); |
| 534 | |
|
| 535 | 0 | List<TermInfo> terms = new ArrayList<TermInfo>(results.size()); |
| 536 | |
|
| 537 | 0 | for (AtpAtpRelationInfo atpRelation : results) { |
| 538 | 0 | if (atpRelation.getAtpId().equals(termId)) { |
| 539 | 0 | AtpInfo possibleTerm = atpService.getAtp(atpRelation.getRelatedAtpId(), context); |
| 540 | |
|
| 541 | 0 | if (checkTypeForTermType(possibleTerm.getTypeKey(), context)) { |
| 542 | |
try { |
| 543 | 0 | terms.add(termAssembler.assemble(possibleTerm, context)); |
| 544 | 0 | } catch (AssemblyException e) { |
| 545 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 546 | 0 | } |
| 547 | |
} |
| 548 | 0 | } |
| 549 | |
|
| 550 | |
} |
| 551 | |
|
| 552 | 0 | return terms; |
| 553 | |
} |
| 554 | |
|
| 555 | |
@Override |
| 556 | |
public List<TermInfo> getContainingTerms(String termId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 557 | |
PermissionDeniedException { |
| 558 | |
|
| 559 | |
|
| 560 | 0 | TermInfo term = getTerm(termId, context); |
| 561 | |
|
| 562 | 0 | List<AtpAtpRelationInfo> results = atpService.getAtpAtpRelationsByAtp(term.getId(), context); |
| 563 | |
|
| 564 | 0 | List<TermInfo> terms = new ArrayList<TermInfo>(results.size()); |
| 565 | |
|
| 566 | |
|
| 567 | |
|
| 568 | 0 | for (AtpAtpRelationInfo atpRelation : results) { |
| 569 | 0 | if (atpRelation.getRelatedAtpId().equals(termId)) { |
| 570 | 0 | AtpInfo possibleTerm = atpService.getAtp(atpRelation.getAtpId(), context); |
| 571 | |
|
| 572 | 0 | if (checkTypeForTermType(possibleTerm.getTypeKey(), context)) { |
| 573 | |
try { |
| 574 | 0 | terms.add(termAssembler.assemble(possibleTerm, context)); |
| 575 | 0 | } catch (AssemblyException e) { |
| 576 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 577 | 0 | } |
| 578 | |
} |
| 579 | 0 | } |
| 580 | |
|
| 581 | |
} |
| 582 | |
|
| 583 | 0 | return terms; |
| 584 | |
} |
| 585 | |
|
| 586 | |
@Override |
| 587 | |
public List<ValidationResultInfo> validateTerm(String validationTypeKey, String termTypeKey, TermInfo termInfo, ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 588 | |
MissingParameterException, OperationFailedException { |
| 589 | |
|
| 590 | 0 | return new ArrayList<ValidationResultInfo>(); |
| 591 | |
} |
| 592 | |
|
| 593 | |
@Override |
| 594 | |
@Transactional(readOnly = false) |
| 595 | |
public TermInfo createTerm(String termTypeKey, TermInfo termInfo, ContextInfo context) throws DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 596 | |
OperationFailedException, PermissionDeniedException { |
| 597 | |
AtpInfo atp; |
| 598 | |
|
| 599 | 0 | if (checkTypeForTermType(termTypeKey, context)) { |
| 600 | |
try { |
| 601 | 0 | atp = termAssembler.disassemble(termInfo, context); |
| 602 | 0 | } catch (AssemblyException e) { |
| 603 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 604 | 0 | } |
| 605 | |
|
| 606 | |
try { |
| 607 | 0 | AtpInfo newAtp = atpService.createAtp(atp.getTypeKey(), atp, context); |
| 608 | 0 | termInfo = termAssembler.assemble(newAtp, context); |
| 609 | 0 | } catch (AssemblyException e) { |
| 610 | 0 | throw new OperationFailedException("Error assembling term", e); |
| 611 | 0 | } catch (ReadOnlyException e) { |
| 612 | 0 | throw new OperationFailedException("Error assembling term", e); |
| 613 | 0 | } |
| 614 | |
} else { |
| 615 | 0 | throw new InvalidParameterException("Term type not found: '" + termTypeKey + "'"); |
| 616 | |
} |
| 617 | |
|
| 618 | 0 | return termInfo; |
| 619 | |
} |
| 620 | |
|
| 621 | |
@Override |
| 622 | |
@Transactional(readOnly = false) |
| 623 | |
public TermInfo updateTerm(String termId, TermInfo termInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 624 | |
OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 625 | |
|
| 626 | |
|
| 627 | |
TermInfo updatedTerm; |
| 628 | |
|
| 629 | |
try { |
| 630 | 0 | AtpInfo toUpdate = termAssembler.disassemble(termInfo, context); |
| 631 | |
|
| 632 | 0 | AtpInfo updated = atpService.updateAtp(termId, toUpdate, context); |
| 633 | |
|
| 634 | 0 | updatedTerm = termAssembler.assemble(updated, context); |
| 635 | 0 | } catch (AssemblyException e) { |
| 636 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 637 | 0 | } catch (ReadOnlyException e) { |
| 638 | 0 | throw new OperationFailedException("Error updating ATP - " + e.getMessage(), e); |
| 639 | 0 | } |
| 640 | |
|
| 641 | 0 | return updatedTerm; |
| 642 | |
} |
| 643 | |
|
| 644 | |
@Override |
| 645 | |
@Transactional(readOnly = false) |
| 646 | |
public StatusInfo deleteTerm(String termId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 647 | |
PermissionDeniedException { |
| 648 | |
|
| 649 | 0 | AtpInfo atp = atpService.getAtp(termId, context); |
| 650 | |
|
| 651 | 0 | if (atp == null) { |
| 652 | 0 | throw new DoesNotExistException(termId); |
| 653 | |
} |
| 654 | |
|
| 655 | 0 | if (!checkTypeForTermType(atp.getTypeKey(), context)) { |
| 656 | 0 | throw new InvalidParameterException("Invalid termId: " + termId + " Given key does not map to a Term"); |
| 657 | |
} |
| 658 | |
|
| 659 | 0 | StatusInfo result = atpService.deleteAtp(termId, context); |
| 660 | |
|
| 661 | 0 | return result; |
| 662 | |
} |
| 663 | |
|
| 664 | |
@Override |
| 665 | |
@Transactional(readOnly = false) |
| 666 | |
public StatusInfo addTermToAcademicCalendar(String academicCalendarId, |
| 667 | |
String termId, ContextInfo context) throws DoesNotExistException, |
| 668 | |
InvalidParameterException, |
| 669 | |
MissingParameterException, |
| 670 | |
OperationFailedException, PermissionDeniedException, |
| 671 | |
AlreadyExistsException { |
| 672 | |
|
| 673 | 0 | AtpInfo acal = atpService.getAtp(academicCalendarId, context); |
| 674 | 0 | if (!isAcademicCalendar(acal.getTypeKey())) { |
| 675 | 0 | throw new DoesNotExistException("AcademicCalendar with id = " + academicCalendarId + " is not an academic calendar " + acal.getTypeKey()); |
| 676 | |
} |
| 677 | |
|
| 678 | 0 | AtpInfo term = atpService.getAtp(termId, context); |
| 679 | 0 | if (!checkTypeForTermType(term.getTypeKey(), context)) { |
| 680 | 0 | throw new DoesNotExistException("ter with id = " + termId + " is not an academic calendar " + term.getTypeKey()); |
| 681 | |
} |
| 682 | |
|
| 683 | 0 | if (termAlreadyExists(academicCalendarId, termId, context)) { |
| 684 | 0 | throw new AlreadyExistsException("Term with id = " + termId + " is already associated with academic calendar " + academicCalendarId); |
| 685 | |
} |
| 686 | |
|
| 687 | |
try { |
| 688 | 0 | createAtpAtpRelation(academicCalendarId, termId, AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, context); |
| 689 | 0 | } catch (DataValidationErrorException ex) { |
| 690 | 0 | throw new OperationFailedException("unexpected", ex); |
| 691 | 0 | } |
| 692 | 0 | StatusInfo status = new StatusInfo(); |
| 693 | 0 | status.setSuccess(Boolean.TRUE); |
| 694 | 0 | return status; |
| 695 | |
} |
| 696 | |
|
| 697 | |
private boolean isAcademicCalendar(String acalType) { |
| 698 | 0 | return acalType.equals(AtpServiceConstants.ATP_ACADEMIC_CALENDAR_TYPE_KEY); |
| 699 | |
} |
| 700 | |
|
| 701 | |
private boolean termAlreadyExists(String parentTermOrAcalId, String termId, ContextInfo context) |
| 702 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 703 | |
PermissionDeniedException { |
| 704 | 0 | List<AtpAtpRelationInfo> atpRels = atpService.getAtpAtpRelationsByTypeAndAtp(parentTermOrAcalId, AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, context); |
| 705 | 0 | for (AtpAtpRelationInfo atpRelInfo : atpRels) { |
| 706 | 0 | if (atpRelInfo.getAtpId().equals(parentTermOrAcalId)) { |
| 707 | 0 | if (atpRelInfo.getRelatedAtpId().equals(termId)) { |
| 708 | 0 | return true; |
| 709 | |
} |
| 710 | |
} |
| 711 | |
} |
| 712 | 0 | return false; |
| 713 | |
} |
| 714 | |
|
| 715 | |
@Override |
| 716 | |
@Transactional(readOnly = false) |
| 717 | |
public StatusInfo removeTermFromAcademicCalendar(String academicCalendarKey, String termId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 718 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 719 | |
|
| 720 | 0 | AtpInfo acal = atpService.getAtp(academicCalendarKey, context); |
| 721 | |
|
| 722 | 0 | if (acal == null) { |
| 723 | 0 | throw new InvalidParameterException("Invalid academicCalendarKey: " + academicCalendarKey); |
| 724 | |
} |
| 725 | |
|
| 726 | 0 | AtpInfo term = atpService.getAtp(termId, context); |
| 727 | |
|
| 728 | 0 | if (term == null) { |
| 729 | 0 | throw new InvalidParameterException("Invalid termId: " + termId); |
| 730 | |
} |
| 731 | |
|
| 732 | 0 | List<AtpAtpRelationInfo> relations = atpService.getAtpAtpRelationsByTypeAndAtp(academicCalendarKey, AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, context); |
| 733 | 0 | if (relations == null || relations.isEmpty()) { |
| 734 | 0 | throw new DoesNotExistException("No relationship exists between academic calendar: " + academicCalendarKey + " and term: " + termId); |
| 735 | |
} |
| 736 | |
|
| 737 | 0 | AtpAtpRelationInfo relationToRemove = null; |
| 738 | |
|
| 739 | 0 | for (AtpAtpRelationInfo rel : relations) { |
| 740 | 0 | if (rel.getAtpId().equals(academicCalendarKey)) { |
| 741 | 0 | if (rel.getRelatedAtpId().equals(termId)) { |
| 742 | |
|
| 743 | |
|
| 744 | |
|
| 745 | 0 | relationToRemove = rel; |
| 746 | 0 | break; |
| 747 | |
} |
| 748 | |
} |
| 749 | |
} |
| 750 | |
|
| 751 | 0 | if (relationToRemove == null) { |
| 752 | 0 | throw new DoesNotExistException("No relationship exists between academic calendar: " + academicCalendarKey + " and term: " + termId); |
| 753 | |
} |
| 754 | |
|
| 755 | 0 | StatusInfo resultStatus = atpService.deleteAtpAtpRelation(relationToRemove.getId(), context); |
| 756 | |
|
| 757 | 0 | return resultStatus; |
| 758 | |
} |
| 759 | |
|
| 760 | |
@Override |
| 761 | |
@Transactional(readOnly = false) |
| 762 | |
public StatusInfo addTermToTerm(String termId, String includedTermId, ContextInfo context) throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, |
| 763 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 764 | |
|
| 765 | 0 | TermInfo term = getTerm(termId, context); |
| 766 | |
|
| 767 | 0 | TermInfo includedTerm = getTerm(includedTermId, context); |
| 768 | |
|
| 769 | |
|
| 770 | 0 | List<TermInfo> terms = getIncludedTermsInTerm(term.getId(), context); |
| 771 | 0 | for (TermInfo t : terms) { |
| 772 | 0 | if (t.getId().equals(includedTerm.getId())) { |
| 773 | 0 | throw new AlreadyExistsException("A relationship already exists exists between term: " + termId + " and included term: " + includedTermId); |
| 774 | |
} |
| 775 | |
} |
| 776 | |
|
| 777 | 0 | StatusInfo resultStatus = new StatusInfo(); |
| 778 | |
|
| 779 | |
try { |
| 780 | 0 | createAtpAtpRelation(termId, includedTermId, AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, context); |
| 781 | 0 | } catch (DataValidationErrorException e) { |
| 782 | 0 | resultStatus.setSuccess(false); |
| 783 | 0 | resultStatus.setMessage("Creation of AtpAtpRelation failed due to DataValidationErrorExecption: " + e.getMessage()); |
| 784 | 0 | } |
| 785 | |
|
| 786 | 0 | return resultStatus; |
| 787 | |
} |
| 788 | |
|
| 789 | |
@Override |
| 790 | |
@Transactional(readOnly = false) |
| 791 | |
public StatusInfo removeTermFromTerm(String termId, String includedTermId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 792 | |
OperationFailedException, PermissionDeniedException { |
| 793 | |
|
| 794 | |
try { |
| 795 | 0 | atpService.getAtp(termId, context); |
| 796 | 0 | } catch (DoesNotExistException e) { |
| 797 | 0 | throw new InvalidParameterException("Invalid termId: " + termId); |
| 798 | 0 | } |
| 799 | |
|
| 800 | |
try { |
| 801 | 0 | atpService.getAtp(includedTermId, context); |
| 802 | 0 | } catch (DoesNotExistException e) { |
| 803 | 0 | throw new InvalidParameterException("Invalid includedTermId: " + includedTermId); |
| 804 | 0 | } |
| 805 | |
|
| 806 | 0 | List<AtpAtpRelationInfo> relations = atpService.getAtpAtpRelationsByTypeAndAtp(termId, AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY, context); |
| 807 | 0 | if (relations == null || relations.isEmpty()) { |
| 808 | 0 | throw new DoesNotExistException("No relationship exists between term: " + termId + " and included term: " + includedTermId); |
| 809 | |
} |
| 810 | |
|
| 811 | 0 | AtpAtpRelationInfo relationToRemove = null; |
| 812 | |
|
| 813 | 0 | for (AtpAtpRelationInfo rel : relations) { |
| 814 | 0 | if (rel.getAtpId().equals(termId)) { |
| 815 | 0 | if (rel.getRelatedAtpId().equals(includedTermId)) { |
| 816 | |
|
| 817 | |
|
| 818 | |
|
| 819 | 0 | relationToRemove = rel; |
| 820 | 0 | break; |
| 821 | |
} |
| 822 | |
} |
| 823 | |
} |
| 824 | |
|
| 825 | 0 | if (relationToRemove == null) { |
| 826 | 0 | throw new DoesNotExistException("No relationship exists between term: " + termId + " and included term: " + includedTermId); |
| 827 | |
} |
| 828 | |
|
| 829 | 0 | StatusInfo resultStatus = atpService.deleteAtpAtpRelation(relationToRemove.getId(), context); |
| 830 | |
|
| 831 | 0 | return resultStatus; |
| 832 | |
} |
| 833 | |
|
| 834 | |
@Override |
| 835 | |
public TypeInfo getKeyDateType(String keyDateTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 836 | |
|
| 837 | 0 | return null; |
| 838 | |
} |
| 839 | |
|
| 840 | |
@Override |
| 841 | |
public List<TypeInfo> getKeyDateTypesForTermType(String termTypeKey, ContextInfo context) |
| 842 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 843 | |
OperationFailedException { |
| 844 | 0 | List<TypeInfo> types = null; |
| 845 | |
try { |
| 846 | |
|
| 847 | 0 | types = this.typeService.getAllowedTypesForType(termTypeKey, context); |
| 848 | 0 | } catch (PermissionDeniedException ex) { |
| 849 | 0 | throw new OperationFailedException("TODO: change the contract to allow this method, getKeyDateTypesForTermType, to throw the PermissionDeniedException", ex); |
| 850 | 0 | } |
| 851 | |
|
| 852 | 0 | List<TypeInfo> list = new ArrayList<TypeInfo>(types.size()); |
| 853 | 0 | for (TypeInfo type : types) { |
| 854 | 0 | if (type.getRefObjectUri() == null) { |
| 855 | 0 | throw new NullPointerException(type.getKey()); |
| 856 | |
} |
| 857 | 0 | if (type.getRefObjectUri().equals(AtpServiceConstants.REF_OBJECT_URI_MILESTONE)) { |
| 858 | 0 | list.add(type); |
| 859 | |
} |
| 860 | |
} |
| 861 | 0 | return list; |
| 862 | |
} |
| 863 | |
|
| 864 | |
@Override |
| 865 | |
public KeyDateInfo getKeyDate(String keyDateId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 866 | |
PermissionDeniedException { |
| 867 | 0 | MilestoneInfo ms = atpService.getMilestone(keyDateId, context); |
| 868 | 0 | return (null != ms) ? fromMilestoneInfo(ms) : null; |
| 869 | |
} |
| 870 | |
|
| 871 | |
@Override |
| 872 | |
public List<KeyDateInfo> getKeyDatesByIds(List<String> keyDateIds, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 873 | |
OperationFailedException, PermissionDeniedException { |
| 874 | 0 | return new ArrayList<KeyDateInfo>(); |
| 875 | |
} |
| 876 | |
|
| 877 | |
@Override |
| 878 | |
public List<KeyDateInfo> getKeyDatesForTerm(String termId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 879 | |
PermissionDeniedException { |
| 880 | |
|
| 881 | 0 | AtpInfo termAtp = atpService.getAtp(termId, context); |
| 882 | 0 | if (termAtp == null) { |
| 883 | 0 | throw new DoesNotExistException(termId); |
| 884 | |
} |
| 885 | |
|
| 886 | 0 | List<MilestoneInfo> milestones = atpService.getMilestonesForAtp(termId, context); |
| 887 | |
|
| 888 | 0 | if (milestones == null || milestones.isEmpty()) { |
| 889 | 0 | return Collections.emptyList(); |
| 890 | |
} |
| 891 | |
|
| 892 | 0 | List<KeyDateInfo> keyDates = new ArrayList<KeyDateInfo>(milestones.size()); |
| 893 | |
|
| 894 | 0 | for (MilestoneInfo milestone : milestones) { |
| 895 | 0 | keyDates.add(fromMilestoneInfo(milestone)); |
| 896 | |
} |
| 897 | |
|
| 898 | 0 | return keyDates; |
| 899 | |
} |
| 900 | |
|
| 901 | |
@Override |
| 902 | |
public List<KeyDateInfo> getKeyDatesForTermByDate(String termId, Date startDate, Date endDate, ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 903 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 904 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesByDatesForAtp(termId, startDate, endDate, context); |
| 905 | 0 | List<KeyDateInfo> keyDates = new ArrayList<KeyDateInfo>(); |
| 906 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 907 | 0 | keyDates.add(fromMilestoneInfo(milestoneInfo)); |
| 908 | |
} |
| 909 | 0 | return keyDates; |
| 910 | |
} |
| 911 | |
|
| 912 | |
@Override |
| 913 | |
public List<KeyDateInfo> getImpactedKeyDates(String keyDateId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 914 | |
OperationFailedException, PermissionDeniedException { |
| 915 | 0 | List<KeyDateInfo> impactedKeyDates = new ArrayList<KeyDateInfo>(); |
| 916 | 0 | List<MilestoneInfo> impactedMilestones = atpService.getImpactedMilestones(keyDateId, contextInfo); |
| 917 | 0 | for (MilestoneInfo impactedMilestone : impactedMilestones) { |
| 918 | 0 | impactedKeyDates.add(fromMilestoneInfo(impactedMilestone)); |
| 919 | |
} |
| 920 | 0 | return impactedKeyDates; |
| 921 | |
} |
| 922 | |
|
| 923 | |
private MilestoneInfo toMilestoneInfo(KeyDateInfo keyDateInfo) { |
| 924 | 0 | if (keyDateInfo != null) { |
| 925 | 0 | MilestoneInfo msInfo = new MilestoneInfo(); |
| 926 | 0 | msInfo.setIsAllDay(keyDateInfo.getIsAllDay()); |
| 927 | 0 | msInfo.setAttributes(keyDateInfo.getAttributes()); |
| 928 | 0 | msInfo.setIsDateRange(keyDateInfo.getIsDateRange()); |
| 929 | 0 | msInfo.setDescr(keyDateInfo.getDescr()); |
| 930 | 0 | msInfo.setId(keyDateInfo.getId()); |
| 931 | 0 | msInfo.setMeta(keyDateInfo.getMeta()); |
| 932 | 0 | msInfo.setName(keyDateInfo.getName()); |
| 933 | 0 | msInfo.setStartDate(keyDateInfo.getStartDate()); |
| 934 | 0 | msInfo.setEndDate(keyDateInfo.getEndDate()); |
| 935 | 0 | msInfo.setStateKey(keyDateInfo.getStateKey()); |
| 936 | 0 | msInfo.setTypeKey(keyDateInfo.getTypeKey()); |
| 937 | |
|
| 938 | 0 | return msInfo; |
| 939 | |
} else { |
| 940 | 0 | return null; |
| 941 | |
} |
| 942 | |
} |
| 943 | |
|
| 944 | |
private KeyDateInfo fromMilestoneInfo(MilestoneInfo milestoneInfo) { |
| 945 | 0 | if (milestoneInfo != null) { |
| 946 | 0 | KeyDateInfo keyInfo = new KeyDateInfo(); |
| 947 | 0 | keyInfo.setIsAllDay(milestoneInfo.getIsAllDay()); |
| 948 | 0 | keyInfo.setAttributes(milestoneInfo.getAttributes()); |
| 949 | 0 | keyInfo.setIsDateRange(milestoneInfo.getIsDateRange()); |
| 950 | 0 | keyInfo.setDescr(milestoneInfo.getDescr()); |
| 951 | 0 | keyInfo.setId(milestoneInfo.getId()); |
| 952 | 0 | keyInfo.setMeta(milestoneInfo.getMeta()); |
| 953 | 0 | keyInfo.setName(milestoneInfo.getName()); |
| 954 | 0 | keyInfo.setStartDate(milestoneInfo.getStartDate()); |
| 955 | 0 | keyInfo.setEndDate(milestoneInfo.getEndDate()); |
| 956 | 0 | keyInfo.setStateKey(milestoneInfo.getStateKey()); |
| 957 | 0 | keyInfo.setTypeKey(milestoneInfo.getTypeKey()); |
| 958 | 0 | keyInfo.setIsRelativeToKeyDate(milestoneInfo.getIsRelative()); |
| 959 | 0 | keyInfo.setRelativeAnchorKeyDateId(milestoneInfo.getRelativeAnchorMilestoneId()); |
| 960 | |
|
| 961 | 0 | return keyInfo; |
| 962 | |
} else { |
| 963 | 0 | return null; |
| 964 | |
} |
| 965 | |
} |
| 966 | |
|
| 967 | |
@Override |
| 968 | |
@Transactional(readOnly = false) |
| 969 | |
public KeyDateInfo updateKeyDate(String keyDateId, KeyDateInfo keyDateInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
| 970 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 971 | |
|
| 972 | 0 | MilestoneInfo toUpdate = toMilestoneInfo(keyDateInfo); |
| 973 | 0 | MilestoneInfo newMilestone = null; |
| 974 | |
try { |
| 975 | 0 | newMilestone = atpService.updateMilestone(keyDateId, toUpdate, context); |
| 976 | 0 | } catch (ReadOnlyException e) { |
| 977 | 0 | throw new OperationFailedException("Error updating milestone", e); |
| 978 | 0 | } |
| 979 | |
|
| 980 | 0 | return fromMilestoneInfo(newMilestone); |
| 981 | |
} |
| 982 | |
|
| 983 | |
@Override |
| 984 | |
@Transactional(readOnly = false) |
| 985 | |
public StatusInfo deleteKeyDate(String keyDateId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 986 | |
PermissionDeniedException { |
| 987 | 0 | return atpService.deleteMilestone(keyDateId, context); |
| 988 | |
} |
| 989 | |
|
| 990 | |
@Override |
| 991 | |
@Transactional(readOnly = false) |
| 992 | |
public KeyDateInfo calculateKeyDate(String keyDateId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 993 | |
PermissionDeniedException { |
| 994 | 0 | MilestoneInfo milestone = atpService.calculateMilestone(keyDateId, contextInfo); |
| 995 | 0 | return fromMilestoneInfo(milestone); |
| 996 | |
} |
| 997 | |
|
| 998 | |
@Override |
| 999 | |
public TypeInfo getHolidayType(String holidayTypeKey, ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 1000 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1001 | 0 | TypeInfo type = typeService.getType(holidayTypeKey, context); |
| 1002 | |
|
| 1003 | |
|
| 1004 | 0 | if (!checkTypeForHolidayType(holidayTypeKey, context)) { |
| 1005 | 0 | throw new InvalidParameterException(holidayTypeKey + " is not a Holiday type"); |
| 1006 | |
} |
| 1007 | |
|
| 1008 | 0 | return type; |
| 1009 | |
} |
| 1010 | |
|
| 1011 | |
@Override |
| 1012 | |
@Transactional(readOnly = false) |
| 1013 | |
public HolidayInfo updateHoliday(String holidayId, HolidayInfo holidayInfo, ContextInfo context) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
| 1014 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 1015 | |
|
| 1016 | |
try { |
| 1017 | 0 | MilestoneInfo toUpdate = holidayAssembler.disassemble(holidayInfo, context); |
| 1018 | 0 | MilestoneInfo updated = null; |
| 1019 | |
try { |
| 1020 | 0 | updated = atpService.updateMilestone(holidayId, toUpdate, context); |
| 1021 | 0 | } catch (ReadOnlyException e) { |
| 1022 | 0 | throw new OperationFailedException("Error updating milestone", e); |
| 1023 | 0 | } |
| 1024 | |
|
| 1025 | 0 | return holidayAssembler.assemble(updated, context); |
| 1026 | 0 | } catch (AssemblyException e) { |
| 1027 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 1028 | |
} |
| 1029 | |
} |
| 1030 | |
|
| 1031 | |
@Override |
| 1032 | |
@Transactional(readOnly = false) |
| 1033 | |
public StatusInfo deleteHoliday(String holidayId, ContextInfo context) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1034 | |
PermissionDeniedException { |
| 1035 | 0 | return atpService.deleteMilestone(holidayId, context); |
| 1036 | |
} |
| 1037 | |
|
| 1038 | |
@Override |
| 1039 | |
@Transactional(readOnly = false) |
| 1040 | |
public HolidayInfo calculateHoliday(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1041 | |
PermissionDeniedException { |
| 1042 | 0 | return getHoliday(holidayId, contextInfo); |
| 1043 | |
} |
| 1044 | |
|
| 1045 | |
|
| 1046 | |
private DateRangeInfo getDateRangeFromKeyDate(KeyDateInfo keyDate) { |
| 1047 | 0 | DateRangeInfo dateRange = null; |
| 1048 | 0 | if (keyDate != null) { |
| 1049 | 0 | dateRange = new DateRangeInfo(); |
| 1050 | 0 | dateRange.setStartDate(keyDate.getStartDate()); |
| 1051 | 0 | dateRange.setEndDate(keyDate.getEndDate()); |
| 1052 | |
} |
| 1053 | 0 | return dateRange; |
| 1054 | |
} |
| 1055 | |
|
| 1056 | |
private KeyDateInfo getKeyDatePrepairedFromDateRange(KeyDateInfo keyDate, DateRangeInfo dateRange) { |
| 1057 | 0 | if (null == dateRange) { |
| 1058 | 0 | return null; |
| 1059 | |
} |
| 1060 | 0 | if (keyDate == null) { |
| 1061 | 0 | keyDate = new KeyDateInfo(); |
| 1062 | |
} |
| 1063 | 0 | keyDate.setStartDate(dateRange.getStartDate()); |
| 1064 | 0 | keyDate.setEndDate(dateRange.getEndDate()); |
| 1065 | 0 | keyDate.setIsDateRange(Boolean.TRUE); |
| 1066 | 0 | return keyDate; |
| 1067 | |
} |
| 1068 | |
|
| 1069 | |
private KeyDateInfo getKeyDatePrepairedFromDate(KeyDateInfo keyDate, Date date) { |
| 1070 | 0 | if (null == date) { |
| 1071 | 0 | return null; |
| 1072 | |
} |
| 1073 | 0 | if (keyDate == null) { |
| 1074 | 0 | keyDate = new KeyDateInfo(); |
| 1075 | |
} |
| 1076 | 0 | keyDate.setStartDate(date); |
| 1077 | 0 | keyDate.setEndDate(date); |
| 1078 | 0 | keyDate.setIsAllDay(Boolean.FALSE); |
| 1079 | 0 | keyDate.setIsDateRange(Boolean.FALSE); |
| 1080 | 0 | return keyDate; |
| 1081 | |
} |
| 1082 | |
|
| 1083 | |
|
| 1084 | |
public AtpService getAtpService() { |
| 1085 | 0 | return atpService; |
| 1086 | |
} |
| 1087 | |
|
| 1088 | |
public void setAtpService(AtpService atpService) { |
| 1089 | 0 | this.atpService = atpService; |
| 1090 | 0 | } |
| 1091 | |
|
| 1092 | |
public AcademicCalendarAssembler getAcalAssembler() { |
| 1093 | 0 | return acalAssembler; |
| 1094 | |
} |
| 1095 | |
|
| 1096 | |
public void setAcalAssembler(AcademicCalendarAssembler acalAssembler) { |
| 1097 | 0 | this.acalAssembler = acalAssembler; |
| 1098 | 0 | } |
| 1099 | |
|
| 1100 | |
public TermAssembler getTermAssembler() { |
| 1101 | 0 | return termAssembler; |
| 1102 | |
} |
| 1103 | |
|
| 1104 | |
public void setTermAssembler(TermAssembler termAssembler) { |
| 1105 | 0 | this.termAssembler = termAssembler; |
| 1106 | 0 | } |
| 1107 | |
|
| 1108 | |
@Override |
| 1109 | |
public List<AcademicCalendarInfo> searchForAcademicCalendars(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1110 | |
PermissionDeniedException { |
| 1111 | |
|
| 1112 | 0 | List<AcademicCalendarInfo> academicCalendars = new ArrayList<AcademicCalendarInfo>(); |
| 1113 | 0 | List<AtpInfo> atps = atpService.searchForAtps(criteria, context); |
| 1114 | |
|
| 1115 | 0 | for (AtpInfo atp : atps) { |
| 1116 | |
try { |
| 1117 | 0 | academicCalendars.add(acalAssembler.assemble(atp, context)); |
| 1118 | 0 | } catch (AssemblyException e) { |
| 1119 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 1120 | 0 | } |
| 1121 | |
} |
| 1122 | |
|
| 1123 | 0 | return academicCalendars; |
| 1124 | |
} |
| 1125 | |
|
| 1126 | |
@Override |
| 1127 | |
public List<TermInfo> searchForTerms(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1128 | |
PermissionDeniedException { |
| 1129 | |
|
| 1130 | 0 | List<AtpInfo> results = atpService.searchForAtps(criteria, context); |
| 1131 | 0 | List<TermInfo> terms = new ArrayList<TermInfo>(results.size()); |
| 1132 | |
|
| 1133 | 0 | for (AtpInfo atp : results) { |
| 1134 | |
try { |
| 1135 | 0 | terms.add(termAssembler.assemble(atp, context)); |
| 1136 | 0 | } catch (AssemblyException e) { |
| 1137 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 1138 | 0 | } |
| 1139 | |
} |
| 1140 | |
|
| 1141 | 0 | return terms; |
| 1142 | |
} |
| 1143 | |
|
| 1144 | |
@Override |
| 1145 | |
public List<KeyDateInfo> searchForKeyDates(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1146 | |
PermissionDeniedException { |
| 1147 | |
|
| 1148 | 0 | return new ArrayList<KeyDateInfo>(); |
| 1149 | |
} |
| 1150 | |
|
| 1151 | |
@Override |
| 1152 | |
public List<HolidayInfo> searchForHolidays(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1153 | |
PermissionDeniedException { |
| 1154 | |
|
| 1155 | 0 | List<MilestoneInfo> milestoneInfos = atpService.searchForMilestones(criteria, context); |
| 1156 | 0 | List<HolidayInfo> holidayInfos = new ArrayList<HolidayInfo>(); |
| 1157 | |
|
| 1158 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1159 | |
try { |
| 1160 | 0 | holidayInfos.add(holidayAssembler.assemble(milestoneInfo, context)); |
| 1161 | 0 | } catch (AssemblyException e) { |
| 1162 | 0 | throw new OperationFailedException("Error assembling holiday with Id " + milestoneInfo.getId(), e); |
| 1163 | 0 | } |
| 1164 | |
} |
| 1165 | |
|
| 1166 | 0 | return holidayInfos; |
| 1167 | |
} |
| 1168 | |
|
| 1169 | |
private boolean checkTypeForTermType(String typeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1170 | 0 | List<TypeInfo> types = getTermTypes(context); |
| 1171 | 0 | return checkTypeInTypes(typeKey, types); |
| 1172 | |
} |
| 1173 | |
|
| 1174 | |
private boolean checkTypeForHolidayType(String typeKey, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1175 | 0 | List<TypeInfo> types = getHolidayTypes(context); |
| 1176 | 0 | return checkTypeInTypes(typeKey, types); |
| 1177 | |
} |
| 1178 | |
|
| 1179 | |
private boolean checkTypeInTypes(String typeKey, List<TypeInfo> types) { |
| 1180 | 0 | if (types != null && !types.isEmpty()) { |
| 1181 | 0 | for (TypeInfo type : types) { |
| 1182 | 0 | if (type.getKey().equals(typeKey)) { |
| 1183 | 0 | return true; |
| 1184 | |
} |
| 1185 | |
} |
| 1186 | |
} |
| 1187 | |
|
| 1188 | 0 | return false; |
| 1189 | |
} |
| 1190 | |
|
| 1191 | |
private void createDeleteAtpAtpRelations(String fromAtpId, |
| 1192 | |
List<String> newRelatedAtpIds, |
| 1193 | |
String relatedAtpType, |
| 1194 | |
ContextInfo context) |
| 1195 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 1196 | |
InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1197 | |
PermissionDeniedException, VersionMismatchException { |
| 1198 | |
|
| 1199 | 0 | List<AtpAtpRelationInfo> atpRels = atpService.getAtpAtpRelationsByAtp(fromAtpId, context); |
| 1200 | 0 | Map<String, String> existing = new HashMap<String, String>(); |
| 1201 | 0 | for (AtpAtpRelationInfo atpRelInfo : atpRels) { |
| 1202 | 0 | if (AtpServiceConstants.ATP_ATP_RELATION_ASSOCIATED_TYPE_KEY.equals(atpRelInfo.getTypeKey())) { |
| 1203 | 0 | AtpInfo atp = null; |
| 1204 | |
try { |
| 1205 | 0 | atp = atpService.getAtp(atpRelInfo.getRelatedAtpId(), context); |
| 1206 | 0 | } catch (DoesNotExistException ex) { |
| 1207 | 0 | throw new OperationFailedException(atpRelInfo.getRelatedAtpId(), ex); |
| 1208 | 0 | } |
| 1209 | 0 | if (atp.getTypeKey().equals(relatedAtpType)) { |
| 1210 | 0 | existing.put(atpRelInfo.getRelatedAtpId(), atpRelInfo.getId()); |
| 1211 | |
} |
| 1212 | 0 | } |
| 1213 | |
} |
| 1214 | |
|
| 1215 | 0 | for (String relatedAtpId : newRelatedAtpIds) { |
| 1216 | 0 | if (!existing.containsKey(relatedAtpId)) { |
| 1217 | 0 | createAtpAtpRelation(fromAtpId, relatedAtpId, AtpServiceConstants.ATP_ATP_RELATION_ASSOCIATED_TYPE_KEY, context); |
| 1218 | |
} |
| 1219 | |
} |
| 1220 | |
|
| 1221 | 0 | for (String existingAtpId : existing.keySet()) { |
| 1222 | 0 | if (!newRelatedAtpIds.contains(existingAtpId)) { |
| 1223 | 0 | String atpAtpRelationId = existing.get(existingAtpId); |
| 1224 | |
try { |
| 1225 | 0 | StatusInfo status = atpService.deleteAtpAtpRelation(atpAtpRelationId, context); |
| 1226 | 0 | } catch (DoesNotExistException ex) { |
| 1227 | 0 | throw new OperationFailedException("Unexpected", ex); |
| 1228 | 0 | } |
| 1229 | 0 | } |
| 1230 | |
} |
| 1231 | 0 | } |
| 1232 | |
|
| 1233 | |
private AtpAtpRelationInfo createAtpAtpRelation(String atpId, |
| 1234 | |
String relatedAtpId, |
| 1235 | |
String relationType, |
| 1236 | |
ContextInfo context) |
| 1237 | |
throws AlreadyExistsException, DataValidationErrorException, |
| 1238 | |
InvalidParameterException, MissingParameterException, |
| 1239 | |
OperationFailedException, PermissionDeniedException { |
| 1240 | 0 | AtpAtpRelationInfo atpRel = new AtpAtpRelationInfo(); |
| 1241 | 0 | atpRel.setAtpId(atpId); |
| 1242 | 0 | atpRel.setRelatedAtpId(relatedAtpId); |
| 1243 | 0 | atpRel.setTypeKey(relationType); |
| 1244 | 0 | atpRel.setStateKey(AtpServiceConstants.ATP_ATP_RELATION_ACTIVE_STATE_KEY); |
| 1245 | 0 | atpRel.setEffectiveDate(new Date()); |
| 1246 | |
try { |
| 1247 | 0 | atpRel = atpService.createAtpAtpRelation(atpRel.getAtpId(), atpRel.getRelatedAtpId(), atpRel.getTypeKey(), atpRel, context); |
| 1248 | 0 | } catch (DoesNotExistException e) { |
| 1249 | 0 | throw new OperationFailedException("Error creating atp-atp relation", e); |
| 1250 | 0 | } catch (ReadOnlyException e) { |
| 1251 | 0 | throw new OperationFailedException("Error creating atp-atp relation", e); |
| 1252 | 0 | } |
| 1253 | 0 | return atpRel; |
| 1254 | |
} |
| 1255 | |
|
| 1256 | |
@Override |
| 1257 | |
public List<String> searchForAcademicCalendarIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1258 | |
PermissionDeniedException { |
| 1259 | |
|
| 1260 | 0 | return null; |
| 1261 | |
} |
| 1262 | |
|
| 1263 | |
@Override |
| 1264 | |
public List<ValidationResultInfo> validateAcademicCalendar(String validationTypeKey, String academicCalendarTypeKey, AcademicCalendarInfo academicCalendarInfo, ContextInfo contextInfo) |
| 1265 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1266 | |
|
| 1267 | 0 | return null; |
| 1268 | |
} |
| 1269 | |
|
| 1270 | |
@Override |
| 1271 | |
public TypeInfo getHolidayCalendarType(String holidayCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1272 | |
OperationFailedException { |
| 1273 | |
TypeInfo type; |
| 1274 | |
try { |
| 1275 | 0 | type = typeService.getType(holidayCalendarTypeKey, contextInfo); |
| 1276 | 0 | } catch (PermissionDeniedException ex) { |
| 1277 | 0 | throw new OperationFailedException("Permission Denied"); |
| 1278 | 0 | } |
| 1279 | |
|
| 1280 | 0 | return type; |
| 1281 | |
|
| 1282 | |
} |
| 1283 | |
|
| 1284 | |
@Override |
| 1285 | |
public List<TypeInfo> getHolidayCalendarTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1286 | |
|
| 1287 | 0 | return null; |
| 1288 | |
} |
| 1289 | |
|
| 1290 | |
@Override |
| 1291 | |
public StateInfo getHolidayCalendarState(String holidayCalendarStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, PermissionDeniedException, |
| 1292 | |
OperationFailedException { |
| 1293 | 0 | StateInfo hcState = stateService.getState(holidayCalendarStateKey, contextInfo); |
| 1294 | |
|
| 1295 | 0 | return hcState; |
| 1296 | |
} |
| 1297 | |
|
| 1298 | |
@Override |
| 1299 | |
public List<StateInfo> getHolidayCalendarStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1300 | 0 | return getAtpStates(contextInfo); |
| 1301 | |
} |
| 1302 | |
|
| 1303 | |
@Override |
| 1304 | |
public List<String> getHolidayCalendarIdsByType(String holidayCalendarTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1305 | |
PermissionDeniedException { |
| 1306 | |
|
| 1307 | 0 | return null; |
| 1308 | |
} |
| 1309 | |
|
| 1310 | |
@Override |
| 1311 | |
public List<HolidayCalendarInfo> getHolidayCalendarsByStartYear(Integer year, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1312 | |
PermissionDeniedException { |
| 1313 | |
|
| 1314 | |
|
| 1315 | |
final Date yearBegin, yearEnd; |
| 1316 | |
|
| 1317 | 0 | Calendar cal = Calendar.getInstance(); |
| 1318 | 0 | cal.clear(); |
| 1319 | 0 | cal.set(year, 0, 1); |
| 1320 | 0 | yearBegin = cal.getTime(); |
| 1321 | 0 | cal.add(Calendar.YEAR, 1); |
| 1322 | 0 | cal.add(Calendar.MILLISECOND, -1); |
| 1323 | 0 | yearEnd = cal.getTime(); |
| 1324 | |
|
| 1325 | 0 | Set<AtpInfo> atpInfos = new TreeSet<AtpInfo>(new Comparator<AtpInfo>() { |
| 1326 | |
|
| 1327 | |
@Override |
| 1328 | |
public int compare(AtpInfo atpInfo1, AtpInfo atpInfo2) { |
| 1329 | 0 | return atpInfo1.getId().compareTo(atpInfo2.getId()); |
| 1330 | |
} |
| 1331 | |
}); |
| 1332 | |
|
| 1333 | 0 | atpInfos.addAll(atpService.getAtpsByStartDateRangeAndType(yearBegin, yearEnd, AtpServiceConstants.ATP_HOLIDAY_CALENDAR_TYPE_KEY, contextInfo)); |
| 1334 | |
|
| 1335 | 0 | List<HolidayCalendarInfo> hcalInfos = new ArrayList<HolidayCalendarInfo>(); |
| 1336 | 0 | for (AtpInfo atpInfo : atpInfos) { |
| 1337 | |
try { |
| 1338 | 0 | hcalInfos.add(holidayCalendarAssembler.assemble(atpInfo, contextInfo)); |
| 1339 | 0 | } catch (AssemblyException e) { |
| 1340 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 1341 | 0 | } |
| 1342 | |
} |
| 1343 | 0 | return hcalInfos; |
| 1344 | |
} |
| 1345 | |
|
| 1346 | |
@Override |
| 1347 | |
public List<String> searchForHolidayCalendarIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1348 | |
PermissionDeniedException { |
| 1349 | |
|
| 1350 | 0 | return null; |
| 1351 | |
} |
| 1352 | |
|
| 1353 | |
@Override |
| 1354 | |
public List<HolidayCalendarInfo> searchForHolidayCalendars(QueryByCriteria criteria, ContextInfo contextInfo) |
| 1355 | |
throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1356 | 0 | List<HolidayCalendarInfo> holidayCalendars = new ArrayList<HolidayCalendarInfo>(); |
| 1357 | 0 | List<AtpInfo> atps = atpService.searchForAtps(criteria, contextInfo); |
| 1358 | |
|
| 1359 | 0 | for (AtpInfo atp : atps) { |
| 1360 | |
try { |
| 1361 | 0 | holidayCalendars.add(holidayCalendarAssembler.assemble(atp, contextInfo)); |
| 1362 | 0 | } catch (AssemblyException e) { |
| 1363 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 1364 | 0 | } |
| 1365 | |
} |
| 1366 | |
|
| 1367 | 0 | return holidayCalendars; |
| 1368 | |
} |
| 1369 | |
|
| 1370 | |
@Override |
| 1371 | |
public List<ValidationResultInfo> validateHolidayCalendar(String validationTypeKey, String holidayCalendarTypeKey, HolidayCalendarInfo holidayCalendarInfo, ContextInfo contextInfo) |
| 1372 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1373 | |
|
| 1374 | 0 | return null; |
| 1375 | |
} |
| 1376 | |
|
| 1377 | |
@Override |
| 1378 | |
public List<String> getTermIdsByType(String termTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1379 | |
|
| 1380 | 0 | return atpService.getAtpIdsByType(termTypeKey, contextInfo); |
| 1381 | |
} |
| 1382 | |
|
| 1383 | |
@Override |
| 1384 | |
public List<TermInfo> getTermsByCode(String code, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1385 | |
|
| 1386 | 0 | return null; |
| 1387 | |
} |
| 1388 | |
|
| 1389 | |
@Override |
| 1390 | |
public List<String> searchForTermIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1391 | |
PermissionDeniedException { |
| 1392 | |
|
| 1393 | 0 | return null; |
| 1394 | |
} |
| 1395 | |
|
| 1396 | |
@Override |
| 1397 | |
public List<TypeInfo> getKeyDateTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1398 | |
|
| 1399 | 0 | return null; |
| 1400 | |
} |
| 1401 | |
|
| 1402 | |
@Override |
| 1403 | |
public StateInfo getKeyDateState(String keyDateStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1404 | |
|
| 1405 | 0 | return null; |
| 1406 | |
} |
| 1407 | |
|
| 1408 | |
@Override |
| 1409 | |
public List<StateInfo> getKeyDateStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1410 | |
|
| 1411 | 0 | return null; |
| 1412 | |
} |
| 1413 | |
|
| 1414 | |
@Override |
| 1415 | |
public List<String> getKeyDateIdsByType(String keyDateTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1416 | |
PermissionDeniedException { |
| 1417 | |
|
| 1418 | 0 | return null; |
| 1419 | |
} |
| 1420 | |
|
| 1421 | |
@Override |
| 1422 | |
public List<String> getKeyDateIdsByTypeForTerm(String keyDateTypeKey, String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1423 | |
|
| 1424 | 0 | return null; |
| 1425 | |
} |
| 1426 | |
|
| 1427 | |
@Override |
| 1428 | |
public List<String> searchForKeyDateIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1429 | |
PermissionDeniedException { |
| 1430 | |
|
| 1431 | 0 | return null; |
| 1432 | |
} |
| 1433 | |
|
| 1434 | |
@Override |
| 1435 | |
public List<ValidationResultInfo> validateKeyDate(String validationTypeKey, String termId, String keyDateTypeKey, KeyDateInfo keyDateInfo, ContextInfo contextInfo) throws DoesNotExistException, |
| 1436 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1437 | |
|
| 1438 | 0 | return null; |
| 1439 | |
} |
| 1440 | |
|
| 1441 | |
@Override |
| 1442 | |
@Transactional(readOnly = false) |
| 1443 | |
public KeyDateInfo createKeyDate(String termId, String keyDateTypeKey, KeyDateInfo keyDateInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, |
| 1444 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 1445 | 0 | KeyDateInfo newKeyDateInfo = null; |
| 1446 | 0 | MilestoneInfo milestoneInfo = null; |
| 1447 | |
|
| 1448 | |
try { |
| 1449 | 0 | milestoneInfo = keyDateAssembler.disassemble(keyDateInfo, contextInfo); |
| 1450 | 0 | } catch (AssemblyException e) { |
| 1451 | 0 | throw new OperationFailedException("AssemblyException in disassembling: " + e.getMessage()); |
| 1452 | 0 | } |
| 1453 | |
|
| 1454 | 0 | if (milestoneInfo != null) { |
| 1455 | 0 | if (StringUtils.isBlank(milestoneInfo.getTypeKey())) { |
| 1456 | 0 | milestoneInfo.setTypeKey(keyDateTypeKey); |
| 1457 | |
} |
| 1458 | 0 | MilestoneInfo newMilestone = null; |
| 1459 | |
try { |
| 1460 | 0 | newMilestone = atpService.createMilestone(keyDateTypeKey, milestoneInfo, contextInfo); |
| 1461 | 0 | newKeyDateInfo = keyDateAssembler.assemble(newMilestone, contextInfo); |
| 1462 | 0 | } catch (ReadOnlyException e) { |
| 1463 | 0 | throw new OperationFailedException("Error creating milestone", e); |
| 1464 | 0 | } catch (AssemblyException e) { |
| 1465 | 0 | throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage()); |
| 1466 | 0 | } |
| 1467 | |
|
| 1468 | |
try { |
| 1469 | 0 | atpService.addMilestoneToAtp(newMilestone.getId(), termId, contextInfo); |
| 1470 | 0 | } catch (AlreadyExistsException e) { |
| 1471 | 0 | throw new OperationFailedException("Error creating ATP-Milestone relation", e); |
| 1472 | 0 | } |
| 1473 | |
|
| 1474 | |
} |
| 1475 | |
|
| 1476 | 0 | return newKeyDateInfo; |
| 1477 | |
} |
| 1478 | |
|
| 1479 | |
@Override |
| 1480 | |
public TypeInfo getAcalEventType(String acalEventTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1481 | |
|
| 1482 | 0 | return null; |
| 1483 | |
} |
| 1484 | |
|
| 1485 | |
@Override |
| 1486 | |
public List<TypeInfo> getAcalEventTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1487 | |
|
| 1488 | 0 | List<TypeTypeRelationInfo> relations = null; |
| 1489 | |
|
| 1490 | |
try { |
| 1491 | |
|
| 1492 | |
|
| 1493 | 0 | relations = typeService.getTypeTypeRelationsByOwnerAndType(AtpServiceConstants.MILESTONE_EVENT_GROUPING_TYPE_KEY, |
| 1494 | |
TypeServiceConstants.TYPE_TYPE_RELATION_GROUP_TYPE_KEY, contextInfo); |
| 1495 | 0 | } catch (DoesNotExistException e) { |
| 1496 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 1497 | 0 | } |
| 1498 | |
|
| 1499 | 0 | if (relations != null) { |
| 1500 | 0 | List<TypeInfo> results = new ArrayList<TypeInfo>(relations.size()); |
| 1501 | 0 | for (TypeTypeRelationInfo rel : relations) { |
| 1502 | |
try { |
| 1503 | 0 | results.add(typeService.getType(rel.getRelatedTypeKey(), contextInfo)); |
| 1504 | 0 | } catch (DoesNotExistException e) { |
| 1505 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 1506 | 0 | } |
| 1507 | |
} |
| 1508 | |
|
| 1509 | 0 | return results; |
| 1510 | |
} |
| 1511 | |
|
| 1512 | 0 | return null; |
| 1513 | |
} |
| 1514 | |
|
| 1515 | |
@Override |
| 1516 | |
public List<TypeInfo> getAcalEventTypesForAcademicCalendarType(String academicCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
| 1517 | |
MissingParameterException, OperationFailedException { |
| 1518 | |
|
| 1519 | 0 | return null; |
| 1520 | |
} |
| 1521 | |
|
| 1522 | |
@Override |
| 1523 | |
public StateInfo getAcalEventState(String acalEventStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1524 | |
|
| 1525 | 0 | return null; |
| 1526 | |
} |
| 1527 | |
|
| 1528 | |
@Override |
| 1529 | |
public List<StateInfo> getAcalEventStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
| 1530 | |
|
| 1531 | 0 | return null; |
| 1532 | |
} |
| 1533 | |
|
| 1534 | |
@Override |
| 1535 | |
public AcalEventInfo getAcalEvent(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1536 | |
PermissionDeniedException { |
| 1537 | 0 | MilestoneInfo milestoneInfo = atpService.getMilestone(acalEventId, contextInfo); |
| 1538 | |
|
| 1539 | 0 | if (milestoneInfo == null) { |
| 1540 | 0 | throw new DoesNotExistException(acalEventId); |
| 1541 | |
} |
| 1542 | |
|
| 1543 | |
try { |
| 1544 | 0 | return acalEventAssembler.assemble(milestoneInfo, contextInfo); |
| 1545 | 0 | } catch (AssemblyException e) { |
| 1546 | 0 | throw new OperationFailedException("Error assembling AcalEvent", e); |
| 1547 | |
} |
| 1548 | |
} |
| 1549 | |
|
| 1550 | |
@Override |
| 1551 | |
public List<AcalEventInfo> getAcalEventsByIds(List<String> acalEventIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1552 | |
OperationFailedException, PermissionDeniedException { |
| 1553 | |
|
| 1554 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesByIds(acalEventIds, contextInfo); |
| 1555 | 0 | List<AcalEventInfo> acalEventInfos = new ArrayList<AcalEventInfo>(); |
| 1556 | |
|
| 1557 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1558 | |
try { |
| 1559 | 0 | acalEventInfos.add(acalEventAssembler.assemble(milestoneInfo, contextInfo)); |
| 1560 | 0 | } catch (AssemblyException e) { |
| 1561 | 0 | throw new OperationFailedException("Error assembling AcalEvent", e); |
| 1562 | 0 | } |
| 1563 | |
} |
| 1564 | |
|
| 1565 | 0 | return acalEventInfos; |
| 1566 | |
} |
| 1567 | |
|
| 1568 | |
@Override |
| 1569 | |
public List<String> getAcalEventIdsByType(String acalEventTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1570 | |
PermissionDeniedException { |
| 1571 | 0 | return atpService.getMilestoneIdsByType(acalEventTypeKey, contextInfo); |
| 1572 | |
} |
| 1573 | |
|
| 1574 | |
@Override |
| 1575 | |
public List<AcalEventInfo> getAcalEventsForAcademicCalendar(String academicCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1576 | |
OperationFailedException, PermissionDeniedException { |
| 1577 | |
|
| 1578 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesForAtp(academicCalendarId, contextInfo); |
| 1579 | 0 | List<AcalEventInfo> acalEventInfos = new ArrayList<AcalEventInfo>(); |
| 1580 | |
|
| 1581 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1582 | |
try { |
| 1583 | 0 | acalEventInfos.add(acalEventAssembler.assemble(milestoneInfo, contextInfo)); |
| 1584 | 0 | } catch (AssemblyException e) { |
| 1585 | 0 | throw new OperationFailedException("Error assembling AcalEvent", e); |
| 1586 | 0 | } |
| 1587 | |
} |
| 1588 | |
|
| 1589 | 0 | return acalEventInfos; |
| 1590 | |
} |
| 1591 | |
|
| 1592 | |
@Override |
| 1593 | |
public List<AcalEventInfo> getAcalEventsForAcademicCalendarByDate(String academicCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, |
| 1594 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1595 | |
|
| 1596 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesByDatesForAtp(academicCalendarId, startDate, endDate, contextInfo); |
| 1597 | 0 | List<AcalEventInfo> acalEventInfos = new ArrayList<AcalEventInfo>(); |
| 1598 | |
|
| 1599 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1600 | |
try { |
| 1601 | 0 | acalEventInfos.add(acalEventAssembler.assemble(milestoneInfo, contextInfo)); |
| 1602 | 0 | } catch (AssemblyException e) { |
| 1603 | 0 | throw new OperationFailedException("Error assembling AcalEvent", e); |
| 1604 | 0 | } |
| 1605 | |
} |
| 1606 | |
|
| 1607 | 0 | return acalEventInfos; |
| 1608 | |
} |
| 1609 | |
|
| 1610 | |
@Override |
| 1611 | |
public List<AcalEventInfo> getImpactedAcalEvents(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1612 | |
OperationFailedException, PermissionDeniedException { |
| 1613 | |
|
| 1614 | 0 | return new ArrayList<AcalEventInfo>(); |
| 1615 | |
} |
| 1616 | |
|
| 1617 | |
@Override |
| 1618 | |
public List<String> searchForAcalEventIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1619 | |
PermissionDeniedException { |
| 1620 | |
|
| 1621 | 0 | return null; |
| 1622 | |
} |
| 1623 | |
|
| 1624 | |
@Override |
| 1625 | |
public List<AcalEventInfo> searchForAcalEvents(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1626 | |
PermissionDeniedException { |
| 1627 | |
|
| 1628 | 0 | List<MilestoneInfo> milestoneInfos = atpService.searchForMilestones(criteria, contextInfo); |
| 1629 | 0 | List<AcalEventInfo> acalEventInfos = new ArrayList<AcalEventInfo>(); |
| 1630 | |
|
| 1631 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1632 | |
try { |
| 1633 | 0 | acalEventInfos.add(acalEventAssembler.assemble(milestoneInfo, contextInfo)); |
| 1634 | 0 | } catch (AssemblyException e) { |
| 1635 | 0 | throw new OperationFailedException("Error assembling AcalEvent", e); |
| 1636 | 0 | } |
| 1637 | |
} |
| 1638 | |
|
| 1639 | 0 | return acalEventInfos; |
| 1640 | |
} |
| 1641 | |
|
| 1642 | |
@Override |
| 1643 | |
public List<ValidationResultInfo> validateAcalEvent(String validationTypeKey, String termId, String acalEventTypeKey, AcalEventInfo acalEventInfo, ContextInfo contextInfo) |
| 1644 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1645 | |
|
| 1646 | 0 | return null; |
| 1647 | |
} |
| 1648 | |
|
| 1649 | |
@Override |
| 1650 | |
@Transactional(readOnly = false) |
| 1651 | |
public AcalEventInfo createAcalEvent(String academicCalendarId, String acalEventTypeKey, AcalEventInfo acalEventInfo, ContextInfo contextInfo) throws DataValidationErrorException, |
| 1652 | |
DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 1653 | |
|
| 1654 | |
try { |
| 1655 | 0 | MilestoneInfo milestoneInfo = acalEventAssembler.disassemble(acalEventInfo, contextInfo); |
| 1656 | 0 | if (StringUtils.isBlank(milestoneInfo.getTypeKey())) { |
| 1657 | 0 | milestoneInfo.setTypeKey(acalEventTypeKey); |
| 1658 | |
} |
| 1659 | |
|
| 1660 | 0 | MilestoneInfo newMilestone = atpService.createMilestone(acalEventTypeKey, milestoneInfo, contextInfo); |
| 1661 | |
|
| 1662 | 0 | atpService.addMilestoneToAtp(newMilestone.getId(), academicCalendarId, contextInfo); |
| 1663 | 0 | return acalEventAssembler.assemble(newMilestone, contextInfo); |
| 1664 | |
|
| 1665 | 0 | } catch (AssemblyException e) { |
| 1666 | 0 | throw new OperationFailedException("Error disassembling AcalEvent", e); |
| 1667 | 0 | } catch (AlreadyExistsException e) { |
| 1668 | 0 | throw new OperationFailedException("Error associating AcalEvent with AcademicCalendar", e); |
| 1669 | |
} |
| 1670 | |
|
| 1671 | |
} |
| 1672 | |
|
| 1673 | |
@Override |
| 1674 | |
@Transactional(readOnly = false) |
| 1675 | |
public AcalEventInfo updateAcalEvent(String acalEventId, AcalEventInfo acalEventInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, |
| 1676 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
| 1677 | |
|
| 1678 | |
|
| 1679 | |
try { |
| 1680 | 0 | MilestoneInfo milestoneInfo = acalEventAssembler.disassemble(acalEventInfo, contextInfo); |
| 1681 | 0 | MilestoneInfo newMilestone = atpService.updateMilestone(acalEventId, milestoneInfo, contextInfo); |
| 1682 | 0 | return acalEventAssembler.assemble(newMilestone, contextInfo); |
| 1683 | 0 | } catch (AssemblyException e) { |
| 1684 | 0 | throw new OperationFailedException("Error assembling AcalEvent", e); |
| 1685 | |
} |
| 1686 | |
|
| 1687 | |
} |
| 1688 | |
|
| 1689 | |
@Override |
| 1690 | |
@Transactional(readOnly = false) |
| 1691 | |
public StatusInfo deleteAcalEvent(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1692 | |
PermissionDeniedException { |
| 1693 | 0 | MilestoneInfo existingMilestone = atpService.getMilestone(acalEventId, contextInfo); |
| 1694 | |
|
| 1695 | 0 | if (existingMilestone == null) { |
| 1696 | 0 | throw new DoesNotExistException("AcalEvent doesnt exists " + acalEventId); |
| 1697 | |
} |
| 1698 | |
|
| 1699 | 0 | StatusInfo status = atpService.deleteMilestone(acalEventId, contextInfo); |
| 1700 | 0 | return status; |
| 1701 | |
|
| 1702 | |
} |
| 1703 | |
|
| 1704 | |
@Override |
| 1705 | |
@Transactional(readOnly = false) |
| 1706 | |
public AcalEventInfo calculateAcalEvent(String acalEventId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1707 | |
PermissionDeniedException { |
| 1708 | |
|
| 1709 | 0 | return getAcalEvent(acalEventId, contextInfo); |
| 1710 | |
} |
| 1711 | |
|
| 1712 | |
@Override |
| 1713 | |
public List<TypeInfo> getHolidayTypes(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, |
| 1714 | |
OperationFailedException, PermissionDeniedException { |
| 1715 | 0 | List<TypeTypeRelationInfo> relations = null; |
| 1716 | |
|
| 1717 | |
try { |
| 1718 | 0 | relations = typeService.getTypeTypeRelationsByOwnerAndType(AtpServiceConstants.MILESTONE_HOLIDAY_GROUPING_TYPE_KEY, |
| 1719 | |
TypeServiceConstants.TYPE_TYPE_RELATION_GROUP_TYPE_KEY, contextInfo); |
| 1720 | 0 | } catch (DoesNotExistException e) { |
| 1721 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 1722 | 0 | } |
| 1723 | |
|
| 1724 | 0 | if (relations != null) { |
| 1725 | 0 | List<TypeInfo> results = new ArrayList<TypeInfo>(relations.size()); |
| 1726 | 0 | for (TypeTypeRelationInfo rel : relations) { |
| 1727 | |
try { |
| 1728 | 0 | results.add(typeService.getType(rel.getRelatedTypeKey(), contextInfo)); |
| 1729 | 0 | } catch (DoesNotExistException e) { |
| 1730 | 0 | throw new OperationFailedException(e.getMessage(), e); |
| 1731 | 0 | } |
| 1732 | |
} |
| 1733 | |
|
| 1734 | 0 | return results; |
| 1735 | |
} |
| 1736 | |
|
| 1737 | 0 | return null; |
| 1738 | |
} |
| 1739 | |
|
| 1740 | |
@Override |
| 1741 | |
public List<TypeInfo> getHolidayTypesForHolidayCalendarType(String holidayCalendarTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
| 1742 | |
MissingParameterException, OperationFailedException { |
| 1743 | |
|
| 1744 | 0 | return null; |
| 1745 | |
} |
| 1746 | |
|
| 1747 | |
@Override |
| 1748 | |
public StateInfo getHolidayState(String holidayStateKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1749 | 0 | StateInfo holidayState = stateService.getState(holidayStateKey, contextInfo); |
| 1750 | |
|
| 1751 | 0 | return holidayState; |
| 1752 | |
} |
| 1753 | |
|
| 1754 | |
@Override |
| 1755 | |
public List<StateInfo> getHolidayStates(ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1756 | |
List<StateInfo> results; |
| 1757 | |
try { |
| 1758 | 0 | results = stateService.getStatesByLifecycle(AtpServiceConstants.MILESTONE_PROCESS_KEY, contextInfo); |
| 1759 | 0 | } catch (DoesNotExistException ex) { |
| 1760 | 0 | throw new OperationFailedException(AtpServiceConstants.MILESTONE_PROCESS_KEY, ex); |
| 1761 | 0 | } |
| 1762 | |
|
| 1763 | 0 | return results; |
| 1764 | |
|
| 1765 | |
} |
| 1766 | |
|
| 1767 | |
@Override |
| 1768 | |
public HolidayInfo getHoliday(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1769 | |
PermissionDeniedException { |
| 1770 | |
|
| 1771 | 0 | MilestoneInfo milestoneInfo = atpService.getMilestone(holidayId, contextInfo); |
| 1772 | |
|
| 1773 | 0 | if (milestoneInfo == null) { |
| 1774 | 0 | throw new DoesNotExistException(holidayId); |
| 1775 | |
} |
| 1776 | |
|
| 1777 | |
try { |
| 1778 | 0 | return holidayAssembler.assemble(milestoneInfo, contextInfo); |
| 1779 | 0 | } catch (AssemblyException e) { |
| 1780 | 0 | throw new OperationFailedException("Error assembling Holiday", e); |
| 1781 | |
} |
| 1782 | |
} |
| 1783 | |
|
| 1784 | |
@Override |
| 1785 | |
public List<HolidayInfo> getHolidaysByIds(List<String> holidayIds, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1786 | |
OperationFailedException, PermissionDeniedException { |
| 1787 | |
|
| 1788 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesByIds(holidayIds, contextInfo); |
| 1789 | |
|
| 1790 | 0 | List<HolidayInfo> holidayInfos = new ArrayList<HolidayInfo>(); |
| 1791 | |
|
| 1792 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1793 | |
try { |
| 1794 | 0 | holidayInfos.add(holidayAssembler.assemble(milestoneInfo, contextInfo)); |
| 1795 | 0 | } catch (AssemblyException e) { |
| 1796 | 0 | throw new OperationFailedException("Error assembling holiday with Id " + milestoneInfo.getId(), e); |
| 1797 | 0 | } |
| 1798 | |
} |
| 1799 | |
|
| 1800 | 0 | return holidayInfos; |
| 1801 | |
} |
| 1802 | |
|
| 1803 | |
@Override |
| 1804 | |
public List<String> getHolidayIdsByType(String holidayTypeKey, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1805 | |
PermissionDeniedException { |
| 1806 | 0 | return atpService.getMilestoneIdsByType(holidayTypeKey, contextInfo); |
| 1807 | |
} |
| 1808 | |
|
| 1809 | |
@Override |
| 1810 | |
public List<HolidayInfo> getHolidaysForHolidayCalendar(String holidayCalendarId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1811 | |
OperationFailedException, PermissionDeniedException { |
| 1812 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesForAtp(holidayCalendarId, contextInfo); |
| 1813 | 0 | List<HolidayInfo> holidayInfos = new ArrayList<HolidayInfo>(); |
| 1814 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1815 | |
try { |
| 1816 | 0 | holidayInfos.add(holidayAssembler.assemble(milestoneInfo, contextInfo)); |
| 1817 | 0 | } catch (AssemblyException e) { |
| 1818 | 0 | throw new OperationFailedException("Error assembling holiday" + milestoneInfo.getId(), e); |
| 1819 | 0 | } |
| 1820 | |
} |
| 1821 | |
|
| 1822 | 0 | return holidayInfos; |
| 1823 | |
} |
| 1824 | |
|
| 1825 | |
@Override |
| 1826 | |
public List<HolidayInfo> getHolidaysForHolidayCalendarByDate(String holidayCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, |
| 1827 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1828 | 0 | List<MilestoneInfo> milestoneInfos = atpService.getMilestonesByDatesForAtp(holidayCalendarId, startDate, endDate, contextInfo); |
| 1829 | 0 | List<HolidayInfo> holidayInfos = new ArrayList<HolidayInfo>(); |
| 1830 | 0 | for (MilestoneInfo milestoneInfo : milestoneInfos) { |
| 1831 | |
try { |
| 1832 | 0 | holidayInfos.add(holidayAssembler.assemble(milestoneInfo, contextInfo)); |
| 1833 | 0 | } catch (AssemblyException e) { |
| 1834 | 0 | throw new OperationFailedException("Error assembling holiday" + milestoneInfo.getId(), e); |
| 1835 | 0 | } |
| 1836 | |
} |
| 1837 | |
|
| 1838 | 0 | return holidayInfos; |
| 1839 | |
} |
| 1840 | |
|
| 1841 | |
@Override |
| 1842 | |
public List<HolidayInfo> getImpactedHolidays(String holidayId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 1843 | |
OperationFailedException, PermissionDeniedException { |
| 1844 | |
|
| 1845 | 0 | return new ArrayList<HolidayInfo>(); |
| 1846 | |
} |
| 1847 | |
|
| 1848 | |
@Override |
| 1849 | |
public List<String> searchForHolidayIds(QueryByCriteria criteria, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1850 | |
PermissionDeniedException { |
| 1851 | |
|
| 1852 | 0 | return null; |
| 1853 | |
} |
| 1854 | |
|
| 1855 | |
@Override |
| 1856 | |
public List<ValidationResultInfo> validateHoliday(String validationTypeKey, String holidayCalendarId, String holidayTypeKey, HolidayInfo holidayInfo, ContextInfo contextInfo) |
| 1857 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1858 | |
|
| 1859 | 0 | return null; |
| 1860 | |
} |
| 1861 | |
|
| 1862 | |
@Override |
| 1863 | |
@Transactional(readOnly = false) |
| 1864 | |
public HolidayInfo createHoliday(String holidayCalendarId, String holidayTypeKey, HolidayInfo holidayInfo, ContextInfo contextInfo) throws DataValidationErrorException, DoesNotExistException, |
| 1865 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 1866 | 0 | HolidayInfo newHolidayInfo = null; |
| 1867 | 0 | MilestoneInfo milestoneInfo = null; |
| 1868 | |
|
| 1869 | |
try { |
| 1870 | 0 | milestoneInfo = holidayAssembler.disassemble(holidayInfo, contextInfo); |
| 1871 | 0 | } catch (AssemblyException e) { |
| 1872 | 0 | throw new OperationFailedException("AssemblyException in disassembling: " + e.getMessage()); |
| 1873 | 0 | } |
| 1874 | |
|
| 1875 | 0 | if (milestoneInfo != null) { |
| 1876 | 0 | if (StringUtils.isBlank(milestoneInfo.getTypeKey())) { |
| 1877 | 0 | milestoneInfo.setTypeKey(holidayTypeKey); |
| 1878 | |
} |
| 1879 | 0 | MilestoneInfo newMilestone = null; |
| 1880 | |
try { |
| 1881 | 0 | newMilestone = atpService.createMilestone(holidayTypeKey, milestoneInfo, contextInfo); |
| 1882 | 0 | newHolidayInfo = holidayAssembler.assemble(newMilestone, contextInfo); |
| 1883 | 0 | } catch (ReadOnlyException e) { |
| 1884 | 0 | throw new OperationFailedException("Error creating milestone", e); |
| 1885 | 0 | } catch (AssemblyException e) { |
| 1886 | 0 | throw new OperationFailedException("AssemblyException in assembling: " + e.getMessage()); |
| 1887 | 0 | } |
| 1888 | |
|
| 1889 | |
try { |
| 1890 | 0 | atpService.addMilestoneToAtp(newMilestone.getId(), holidayCalendarId, contextInfo); |
| 1891 | 0 | } catch (AlreadyExistsException e) { |
| 1892 | 0 | throw new OperationFailedException("Error creating ATP-Milestone relation", e); |
| 1893 | 0 | } |
| 1894 | |
|
| 1895 | |
} |
| 1896 | |
|
| 1897 | 0 | return newHolidayInfo; |
| 1898 | |
} |
| 1899 | |
|
| 1900 | |
@Override |
| 1901 | |
public String getAcademicCalendarData(String academicCalendarId, String calendarDataFormatTypeKey, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
| 1902 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1903 | |
|
| 1904 | 0 | return null; |
| 1905 | |
} |
| 1906 | |
|
| 1907 | |
@Override |
| 1908 | |
public Integer getInstructionalDaysForTerm(String termId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1909 | |
PermissionDeniedException { |
| 1910 | |
|
| 1911 | 0 | KeyDateInfo instructionalPeriodKeyDate = null; |
| 1912 | |
|
| 1913 | 0 | List<KeyDateInfo> keyDates = getKeyDatesForTerm(termId, contextInfo); |
| 1914 | |
|
| 1915 | 0 | for (KeyDateInfo keyDate : keyDates) { |
| 1916 | 0 | if (keyDate.getTypeKey().equals(AtpServiceConstants.MILESTONE_INSTRUCTIONAL_PERIOD_TYPE_KEY)) { |
| 1917 | |
|
| 1918 | 0 | instructionalPeriodKeyDate = new KeyDateInfo(keyDate); |
| 1919 | |
|
| 1920 | |
} |
| 1921 | |
|
| 1922 | |
} |
| 1923 | |
|
| 1924 | 0 | DateTime instructionalStart = new DateTime(instructionalPeriodKeyDate.getStartDate().getTime()); |
| 1925 | 0 | DateTime instructionalEnd = new DateTime(instructionalPeriodKeyDate.getEndDate().getTime()); |
| 1926 | |
|
| 1927 | 0 | Days totalDays = Days.daysBetween(instructionalStart, instructionalEnd); |
| 1928 | |
|
| 1929 | 0 | Weeks weeks = Weeks.weeksBetween(instructionalStart, instructionalEnd); |
| 1930 | |
|
| 1931 | 0 | int approxWeekends = weeks.getWeeks() * 2; |
| 1932 | |
|
| 1933 | 0 | int totalDaysInTerm = totalDays.getDays(); |
| 1934 | |
|
| 1935 | 0 | return totalDaysInTerm - (approxWeekends + getNumberOfHolidayDatesInTerm(termId, instructionalPeriodKeyDate, contextInfo)); |
| 1936 | |
|
| 1937 | |
} |
| 1938 | |
|
| 1939 | |
private Integer getNumberOfHolidayDatesInTerm(String termId, KeyDateInfo instructionalPeriodKeyDate, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, |
| 1940 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1941 | 0 | List<AcademicCalendarInfo> acalsForTerm = getAcademicCalendarsForTerm(termId, contextInfo); |
| 1942 | 0 | int numberOfHolidayDays = 0; |
| 1943 | 0 | for (AcademicCalendarInfo acal : acalsForTerm) { |
| 1944 | |
|
| 1945 | 0 | List<HolidayInfo> holidays = getHolidaysByDateForAcademicCalendar(acal.getId(), instructionalPeriodKeyDate.getStartDate(), instructionalPeriodKeyDate.getEndDate(), contextInfo); |
| 1946 | |
|
| 1947 | 0 | for (HolidayInfo holiday : holidays) { |
| 1948 | |
Period holidayPeriod; |
| 1949 | 0 | if (holiday.getIsDateRange()){ |
| 1950 | 0 | holidayPeriod = new Period(holiday.getStartDate().getTime(), holiday.getEndDate().getTime()); |
| 1951 | 0 | numberOfHolidayDays = numberOfHolidayDays + holidayPeriod.toStandardDays().getDays(); |
| 1952 | |
}else{ |
| 1953 | 0 | numberOfHolidayDays = numberOfHolidayDays + 1; |
| 1954 | |
} |
| 1955 | |
} |
| 1956 | 0 | } |
| 1957 | 0 | return numberOfHolidayDays; |
| 1958 | |
|
| 1959 | |
} |
| 1960 | |
|
| 1961 | |
@Override |
| 1962 | |
public List<AcademicCalendarInfo> getAcademicCalendarsForTerm(String termId, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, |
| 1963 | |
PermissionDeniedException, DoesNotExistException { |
| 1964 | |
|
| 1965 | 0 | List<AtpAtpRelationInfo> atpAtpRelationsForTerm = this.atpService.getAtpAtpRelationsByAtps(termId, contextInfo); |
| 1966 | |
|
| 1967 | 0 | List<AcademicCalendarInfo> academicCalendars = new ArrayList<AcademicCalendarInfo>(); |
| 1968 | |
|
| 1969 | 0 | for (AtpAtpRelationInfo atpRelationForTerm : atpAtpRelationsForTerm) { |
| 1970 | 0 | if (atpRelationForTerm.getTypeKey().equals(AtpServiceConstants.ATP_ATP_RELATION_INCLUDES_TYPE_KEY)) { |
| 1971 | |
try { |
| 1972 | 0 | AtpInfo acalAtp = this.atpService.getAtp(atpRelationForTerm.getAtpId(), contextInfo); |
| 1973 | 0 | if (acalAtp.getTypeKey().equals(AtpServiceConstants.ATP_ACADEMIC_CALENDAR_TYPE_KEY)) { |
| 1974 | 0 | academicCalendars.add(this.acalAssembler.assemble(acalAtp, contextInfo)); |
| 1975 | |
} |
| 1976 | 0 | } catch (AssemblyException e) { |
| 1977 | 0 | throw new OperationFailedException(e.getMessage()); |
| 1978 | 0 | } |
| 1979 | |
} |
| 1980 | |
} |
| 1981 | |
|
| 1982 | 0 | return academicCalendars; |
| 1983 | |
} |
| 1984 | |
|
| 1985 | |
@Override |
| 1986 | |
public List<HolidayInfo> getHolidaysByDateForAcademicCalendar(String academicCalendarId, Date startDate, Date endDate, ContextInfo contextInfo) throws DoesNotExistException, |
| 1987 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 1988 | 0 | AcademicCalendarInfo acInfo = getAcademicCalendar(academicCalendarId, contextInfo); |
| 1989 | 0 | List<HolidayInfo> holidaysForAcal = new ArrayList<HolidayInfo>(); |
| 1990 | 0 | for (String holidayCalendarId : acInfo.getHolidayCalendarIds()) { |
| 1991 | |
|
| 1992 | 0 | List<HolidayInfo> holidays = getHolidaysForHolidayCalendar(holidayCalendarId, contextInfo); |
| 1993 | |
|
| 1994 | 0 | for (HolidayInfo holiday : holidays) { |
| 1995 | 0 | if (holiday.getStartDate().after(startDate)){ |
| 1996 | 0 | if (holiday.getIsDateRange()){ |
| 1997 | 0 | if (holiday.getEndDate().before(endDate)){ |
| 1998 | 0 | holidaysForAcal.add(holiday); |
| 1999 | |
} |
| 2000 | |
}else{ |
| 2001 | 0 | holidaysForAcal.add(holiday); |
| 2002 | |
} |
| 2003 | |
} |
| 2004 | |
} |
| 2005 | |
|
| 2006 | 0 | } |
| 2007 | |
|
| 2008 | 0 | return holidaysForAcal; |
| 2009 | |
} |
| 2010 | |
} |