| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package org.kuali.student.process.poc; |
| 6 | |
|
| 7 | |
import java.text.ParseException; |
| 8 | |
import java.text.SimpleDateFormat; |
| 9 | |
import java.util.Date; |
| 10 | |
import java.util.logging.Level; |
| 11 | |
import java.util.logging.Logger; |
| 12 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 13 | |
import org.kuali.student.r2.common.util.constants.HoldServiceConstants; |
| 14 | |
import org.kuali.student.r2.core.hold.dto.HoldInfo; |
| 15 | |
import org.kuali.student.r2.core.hold.dto.IssueInfo; |
| 16 | |
import org.kuali.student.r2.core.hold.service.HoldService; |
| 17 | |
import org.kuali.student.r2.core.hold.service.HoldServiceDecorator; |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
public class ProcessPocHoldServiceDecorator extends HoldServiceDecorator { |
| 24 | |
|
| 25 | |
public ProcessPocHoldServiceDecorator(HoldService nextDecorator) { |
| 26 | 0 | super(); |
| 27 | 0 | this.setNextDecorator(nextDecorator); |
| 28 | 0 | _initializeData(); |
| 29 | 0 | } |
| 30 | |
|
| 31 | |
private void _initializeData() { |
| 32 | 0 | ContextInfo context = new ContextInfo(); |
| 33 | 0 | context.setPrincipalId("POC-Initializer"); |
| 34 | |
|
| 35 | 0 | IssueInfo unpaidTuitionIssue = _createIssue(HoldServiceConstants.ISSUE_KEY_UNPAID_TUITION_PRIOR_TERM, |
| 36 | |
"Unpaid tuition from last term", HoldServiceConstants.FINANCIAL_ISSUE_TYPE_KEY, context); |
| 37 | |
|
| 38 | |
|
| 39 | 0 | IssueInfo overdueBookIssue = _createIssue(HoldServiceConstants.ISSUE_KEY_BOOK_OVERDUE, |
| 40 | |
"Overdue Library Book", HoldServiceConstants.OVERDUE_LIBRARY_MATERIALS_ISSUE_TYPE_KEY, context); |
| 41 | |
|
| 42 | 0 | this._createHold(ProcessPocConstants.PERSON_ID_KARA_STONE_2272, unpaidTuitionIssue, context); |
| 43 | 0 | this._createHold(ProcessPocConstants.PERSON_ID_CLIFFORD_RIDDLE_2397, unpaidTuitionIssue, context); |
| 44 | 0 | this._createHold(ProcessPocConstants.PERSON_ID_NINA_WELCH_2166, unpaidTuitionIssue, context); |
| 45 | 0 | this._createHold(ProcessPocConstants.PERSON_ID_BETTY_MARTIN_2005, overdueBookIssue, context); |
| 46 | 0 | this._createHold(ProcessPocConstants.PERSON_ID_NINA_WELCH_2166, overdueBookIssue, context); |
| 47 | 0 | } |
| 48 | |
|
| 49 | |
private IssueInfo _createIssue(String key, String name, String type, ContextInfo context) { |
| 50 | 0 | IssueInfo issue = new IssueInfo(); |
| 51 | 0 | issue.setKey(key); |
| 52 | 0 | issue.setName(name); |
| 53 | 0 | issue.setTypeKey(type); |
| 54 | 0 | issue.setStateKey(HoldServiceConstants.ISSUE_ACTIVE_STATE_KEY); |
| 55 | |
try { |
| 56 | 0 | issue = this.createIssue(issue, context); |
| 57 | 0 | } catch (Exception ex) { |
| 58 | 0 | throw new RuntimeException("error creating hold", ex); |
| 59 | 0 | } |
| 60 | 0 | return issue; |
| 61 | |
} |
| 62 | |
|
| 63 | |
private HoldInfo _createHold(String personId, IssueInfo issue, ContextInfo context) { |
| 64 | 0 | HoldInfo hold = new HoldInfo(); |
| 65 | 0 | hold.setTypeKey(HoldServiceConstants.STUDENT_HOLD_TYPE_KEY); |
| 66 | 0 | hold.setStateKey(HoldServiceConstants.HOLD_ACTIVE_STATE_KEY); |
| 67 | 0 | hold.setIssueKey(issue.getKey()); |
| 68 | 0 | hold.setName(issue.getName()); |
| 69 | 0 | hold.setIsOverridable(true); |
| 70 | 0 | hold.setIsWarning(false); |
| 71 | 0 | Date effDate = null; |
| 72 | |
try { |
| 73 | 0 | effDate = new SimpleDateFormat ("yyyy-MM-dd").parse ("2011-01-01"); |
| 74 | 0 | } catch (ParseException ex) { |
| 75 | 0 | throw new RuntimeException (ex); |
| 76 | 0 | } |
| 77 | 0 | hold.setEffectiveDate(effDate); |
| 78 | 0 | hold.setPersonId(personId); |
| 79 | |
try { |
| 80 | 0 | hold = this.createHold(hold, context); |
| 81 | 0 | } catch (Exception ex) { |
| 82 | 0 | throw new RuntimeException("error creating hold", ex); |
| 83 | 0 | } |
| 84 | 0 | return hold; |
| 85 | |
} |
| 86 | |
} |