1 package org.kuali.ole.sip2.requestParser;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.sip2.constants.OLESIP2Constants;
5
6
7
8
9 public class OLESIP2HoldRequestParser extends OLESIP2RequestParser {
10
11 private String holdMode;
12 private String ExpirationDate;
13 private String pickupLocation;
14 private String holdType;
15 private String titleIdentifier;
16 private static final Logger LOG = Logger.getLogger(OLESIP2HoldRequestParser.class);
17
18
19 public OLESIP2HoldRequestParser(String requestData) {
20 this.parseHoldRequest(requestData);
21 }
22
23
24 public void parseHoldRequest(String requestData) {
25
26 LOG.info("Entry OLESIP2HoldRequestParser.parseHoldRequest(String requestData)");
27 String[] requestDataArray = requestData.split("\\|");
28 try {
29 for (String data : requestDataArray) {
30 code = data.substring(0, 2);
31 if (data.startsWith(OLESIP2Constants.HOLD_REQUEST)) {
32 char holdMode = data.charAt(2);
33 if (holdMode == '+') {
34 holdType = OLESIP2Constants.ADD_HOLD;
35 } else if (holdMode == '-') {
36 holdType = OLESIP2Constants.DELETE_HOLD;
37 } else if (holdMode == '*') {
38 holdType = OLESIP2Constants.UPDATE_HOLD;
39 }
40 if(data.contains(OLESIP2Constants.PICKUP_LOCATION_CODE)){
41 if(data.length() > data.indexOf(OLESIP2Constants.PICKUP_LOCATION_CODE)+2)
42 pickupLocation = data.substring(data.indexOf(OLESIP2Constants.PICKUP_LOCATION_CODE)+2);
43 }
44 }
45
46 if (data.startsWith(OLESIP2Constants.PICKUP_LOCATION_CODE)) {
47 pickupLocation = (data.replaceFirst(OLESIP2Constants.PICKUP_LOCATION_CODE, "")).trim();
48 }
49 if (data.startsWith(OLESIP2Constants.HOLD_TYPE_CODE)) {
50 holdType = (data.replaceFirst(OLESIP2Constants.HOLD_TYPE_CODE, "")).trim();
51 }
52 if (data.startsWith(OLESIP2Constants.INSTITUTION_ID_CODE)) {
53 institutionId = (data.replaceFirst(OLESIP2Constants.INSTITUTION_ID_CODE, "")).trim();
54 }
55 if (data.startsWith(OLESIP2Constants.PATRON_IDENTIFIER_CODE)) {
56 patronIdentifier = (data.replaceFirst(OLESIP2Constants.PATRON_IDENTIFIER_CODE, "")).trim();
57 }
58 if (data.startsWith(OLESIP2Constants.PATRON_PWD_CODE)) {
59 patronPassword = (data.replaceFirst(OLESIP2Constants.PATRON_PWD_CODE, "")).trim();
60 }
61 if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) {
62 itemIdentifier = (data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim();
63 }
64 if (data.startsWith(OLESIP2Constants.TITLE_IDENTIFIER_CODE)) {
65 titleIdentifier = (data.replaceFirst(OLESIP2Constants.TITLE_IDENTIFIER_CODE, "")).trim();
66 }
67 if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) {
68 terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim();
69 }
70 if (data.startsWith(OLESIP2Constants.FEE_ACKNOWLEDGED_CODE)) {
71 feeAcknowledged = charToBool(data.charAt(2));
72 }
73 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
74 sequenceNum = data.substring(2, 5);
75 checkSum = data.substring(5);
76 }
77 }
78 } catch (Exception e) {
79 LOG.error(e.getMessage(), e);
80 }
81 LOG.info("Exit OLESIP2HoldRequestParser.parseHoldRequest(String requestData)");
82 }
83
84 public String getHoldMode() {
85 return holdMode;
86 }
87
88 public void setHoldMode(String holdMode) {
89 this.holdMode = holdMode;
90 }
91
92 public String getExpirationDate() {
93 return ExpirationDate;
94 }
95
96 public void setExpirationDate(String expirationDate) {
97 ExpirationDate = expirationDate;
98 }
99
100 public String getPickupLocation() {
101 return pickupLocation;
102 }
103
104 public void setPickupLocation(String pickupLocation) {
105 this.pickupLocation = pickupLocation;
106 }
107
108 public String getHoldType() {
109 return holdType;
110 }
111
112 public void setHoldType(String holdType) {
113 this.holdType = holdType;
114 }
115
116 public String getTitleIdentifier() {
117 return titleIdentifier;
118 }
119
120 public void setTitleIdentifier(String titleIdentifier) {
121 this.titleIdentifier = titleIdentifier;
122 }
123 }