View Javadoc
1   package org.kuali.ole.sip2.requestParser;
2   
3   import org.apache.log4j.Logger;
4   import org.kuali.ole.request.OLESIP2RequestParser;
5   import org.kuali.ole.sip2.constants.OLESIP2Constants;
6   
7   /**
8    * Created by gayathria on 2/12/14.
9    */
10  public class OLESIP2FeePaidRequestParser extends OLESIP2RequestParser {
11  
12      private String feeType;
13      private String paymentType;
14      private String currencyType;
15      private String feeAmount;
16      private String feeIdentifier;
17      private String transactionId;
18  
19      private static final Logger LOG = Logger.getLogger(OLESIP2FeePaidRequestParser.class);
20  
21  
22      public OLESIP2FeePaidRequestParser(String requestData) {
23          this.parseFeePaidMessage(requestData);
24      }
25  
26  
27      public void parseFeePaidMessage(String requestData) {
28  
29          LOG.info("Entry OLESIP2FeePaidRequestParser.parseFeePaidMessage(String requestData)");
30  
31          String[] requestDataArray = requestData.split("\\|");
32          try {
33  
34              for (String data : requestDataArray) {
35                  if (data.startsWith(OLESIP2Constants.FEE_PAID_REQUEST)) {
36                      code = data.substring(0, 2);
37                      transactionDate = data.substring(2, 20);
38                      feeType = getFeeType(data.substring(20, 22));
39                      paymentType = data.substring(22, 24);
40                      currencyType = data.substring(24, 27);
41                      feeAmount = data.substring(29);
42                  }
43                  if (data.startsWith(OLESIP2Constants.INSTITUTION_ID_CODE)) {
44                      institutionId = (data.replaceFirst(OLESIP2Constants.INSTITUTION_ID_CODE, "")).trim();
45                  }
46                  if (data.startsWith(OLESIP2Constants.PATRON_IDENTIFIER_CODE)) {
47                      patronIdentifier = (data.replaceFirst(OLESIP2Constants.PATRON_IDENTIFIER_CODE, "")).trim();
48                  }
49                  if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) {
50                      terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim();
51                  }
52                  if (data.startsWith(OLESIP2Constants.PATRON_PWD_CODE)) {
53                      patronPassword = (data.replaceFirst(OLESIP2Constants.PATRON_PWD_CODE, "")).trim();
54                  }
55                  if (data.startsWith(OLESIP2Constants.FEE_IDENTIFIER_CODE)) {
56                      feeIdentifier = (data.replaceFirst(OLESIP2Constants.FEE_IDENTIFIER_CODE, "")).trim();
57                  }
58                  if (data.startsWith(OLESIP2Constants.TRANSACTION_ID_CODE)) {
59                      transactionId = (data.replaceFirst(OLESIP2Constants.TRANSACTION_ID_CODE, "")).trim();
60                  }
61                  if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
62                      sequenceNum = data.substring(2, 5);
63                      checkSum = data.substring(5);
64                  }
65              }
66          } catch (Exception e) {
67              LOG.error(e.getMessage(), e);
68          }
69      }
70  
71      public String getFeeType(String code) throws Exception {
72          if (code.equals("01")) {
73              // return "other/unknown";
74              return "SER_FEE";
75          } else if (code.equals("02")) {
76              return "ADMINISTRATIVE";
77          } else if (code.equals("03")) {
78              return "DAMAGE";
79          } else if (code.equals("04")) {
80              return "OVR_DUE";
81          } else if (code.equals("05")) {
82              return "PROCESSING";
83          } else if (code.equals("06")) {
84              //return FeeType.RENTAL;
85              return "SER_FEE";
86          } else if (code.equals("07")) {
87              return "REPL_FEE";
88          } else if (code.equals("08")) {
89              //return FeeType.COMPUTER_ACCESS_CHARGE;
90              return "SER_FEE";
91          } else if (code.equals("09")) {
92              return "HOLD_FEE";
93          } else {
94              // throw new InvalidSIP2ResponseValueException("Invalid fee type code! The given code \"" + code + "\" doesn't match with any fee type!");
95              throw new Exception("Invalid fee type code! The given code \"" + code + "\" doesn't match with any fee type!");
96          }
97      }
98  
99      public String getFeeType() {
100         return feeType;
101     }
102 
103     public void setFeeType(String feeType) {
104         this.feeType = feeType;
105     }
106 
107     public String getPaymentType() {
108         return paymentType;
109     }
110 
111     public void setPaymentType(String paymentType) {
112         this.paymentType = paymentType;
113     }
114 
115     public String getCurrencyType() {
116         return currencyType;
117     }
118 
119     public void setCurrencyType(String currencyType) {
120         this.currencyType = currencyType;
121     }
122 
123     public String getFeeAmount() {
124         return feeAmount;
125     }
126 
127     public void setFeeAmount(String feeAmount) {
128         this.feeAmount = feeAmount;
129     }
130 
131     public String getFeeIdentifier() {
132         return feeIdentifier;
133     }
134 
135     public void setFeeIdentifier(String feeIdentifier) {
136         this.feeIdentifier = feeIdentifier;
137     }
138 
139     public String getTransactionId() {
140         return transactionId;
141     }
142 
143     public void setTransactionId(String transactionId) {
144         this.transactionId = transactionId;
145     }
146 }