View Javadoc
1   package org.kuali.ole.sip2.sip2Response;
2   
3   import org.apache.commons.lang3.StringUtils;
4   import org.kuali.ole.deliver.bo.OlePatronDocument;
5   import org.kuali.ole.sip2.common.MessageUtil;
6   import org.kuali.ole.sip2.common.OLESIP2Util;
7   import org.kuali.ole.sip2.constants.OLESIP2Constants;
8   import org.kuali.ole.sip2.requestParser.OLESIP2PatronEnableRequestParser;
9   
10  /**
11   * Created by gayathria on 10/11/14.
12   */
13  public class OLESIP2PatronEnableResponse extends OLESIP2Response {
14  
15  
16      public OLESIP2PatronEnableResponse() {
17          this.code = OLESIP2Constants.PATRON_ENABLE_RESPONSE;
18      }
19  
20      public String getSIP2PatronEnableResponse(OlePatronDocument olePatronDocument, OLESIP2PatronEnableRequestParser sip2PatronEnableRequestParser, boolean isValidPatron) {
21  
22          StringBuilder builder = new StringBuilder();
23          builder.append(code);
24          builder.append("YYYYYYYYYYYYYY");
25          builder.append("001");
26          builder.append(MessageUtil.getSipDateTime());
27          builder.append(OLESIP2Constants.INSTITUTION_ID_CODE);
28          builder.append(StringUtils.isNotBlank(sip2PatronEnableRequestParser.getInstitutionId()) ? sip2PatronEnableRequestParser.getInstitutionId() : "");
29          builder.append(OLESIP2Constants.SPLIT+
30                  OLESIP2Constants.PATRON_IDENTIFIER_CODE);
31          builder.append(StringUtils.isNotBlank(olePatronDocument.getBarcode()) ? olePatronDocument.getBarcode() : sip2PatronEnableRequestParser.getPatronIdentifier());
32          builder.append(OLESIP2Constants.SPLIT+
33                  OLESIP2Constants.PERSONAL_NAME_CODE);
34          builder.append(olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + olePatronDocument.getEntity().getNames().get(0).getLastName());
35          builder.append(OLESIP2Constants.SPLIT+
36                  OLESIP2Constants.VALID_PATRON_CODE);
37          builder.append(OLESIP2Util.bool2Char(isValidPatron));
38          builder.append(OLESIP2Constants.SPLIT+
39                  OLESIP2Constants.SCREEN_MSG_CODE);
40          builder.append(OLESIP2Constants.PATRON_ENABLED);
41          if (sip2PatronEnableRequestParser.getSequenceNum() != null && !sip2PatronEnableRequestParser.getSequenceNum().equalsIgnoreCase("")) {
42              builder.append(OLESIP2Constants.SPLIT+
43                      OLESIP2Constants.SEQUENCE_NUM_CODE);
44              builder.append(sip2PatronEnableRequestParser.getSequenceNum());
45              builder.append(MessageUtil.computeChecksum(builder.toString()));
46          }
47          return builder.toString() + '\r';
48  
49      }
50  
51  
52  
53  
54  
55  
56  
57  
58      /*
59        StringBuilder builder = new StringBuilder();
60          builder.append(code);
61          builder.append(status);
62  
63          builder.append(this.language);
64          builder.append(this.transactionDate);
65          builder.append("AO");
66          builder.append(this.institutionId);
67          builder.append("|AA");
68          builder.append(this.patronIdentifier);
69          builder.append("|AE");
70          builder.append(this.personalName);
71  
72          if (validPatronUsed) {
73              builder.append("|BL");
74              builder.append(StringUtil.bool2Char(validPatron));
75          }
76          if (validPatronPasswordUsed) {
77              builder.append("|CQ");
78              builder.append(StringUtil.bool2Char(validPatronPassword));
79          }
80  
81          for (String msg : screenMessage) {
82              builder.append("|AF");
83              builder.append(msg);
84          }
85  
86          for (String msg : printLine) {
87              builder.append("|AG");
88              builder.append(msg);
89          }
90  
91          builder.append("|");
92  
93          if (isSequence()) {
94              builder.append("AY");
95              builder.append(sequence);
96          }
97          builder.append("AZ");
98          return MessageUtil.computeChecksum(builder.toString());
99       */
100 }