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