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.response.OLESIP2Response;
6 import org.kuali.ole.common.MessageUtil;
7 import org.kuali.ole.common.OLESIP2Util;
8 import org.kuali.ole.sip2.constants.OLESIP2Constants;
9 import org.kuali.ole.sip2.requestParser.OLESIP2PatronEnableRequestParser;
10
11
12
13
14 public class OLESIP2PatronEnableResponse extends OLESIP2Response {
15
16
17 public OLESIP2PatronEnableResponse() {
18 this.code = OLESIP2Constants.PATRON_ENABLE_RESPONSE;
19 }
20
21 public String getSIP2PatronEnableResponse(OlePatronDocument olePatronDocument, OLESIP2PatronEnableRequestParser sip2PatronEnableRequestParser, boolean isValidPatron) {
22
23 StringBuilder builder = new StringBuilder();
24 builder.append(code);
25 builder.append("YYYYYYYYYYYYYY");
26 builder.append("001");
27 builder.append(MessageUtil.getSipDateTime());
28 builder.append(OLESIP2Constants.INSTITUTION_ID_CODE);
29 builder.append(StringUtils.isNotBlank(sip2PatronEnableRequestParser.getInstitutionId()) ? sip2PatronEnableRequestParser.getInstitutionId() : "");
30 builder.append(OLESIP2Constants.SPLIT+
31 OLESIP2Constants.PATRON_IDENTIFIER_CODE);
32 builder.append(StringUtils.isNotBlank(olePatronDocument.getBarcode()) ? olePatronDocument.getBarcode() : sip2PatronEnableRequestParser.getPatronIdentifier());
33 builder.append(OLESIP2Constants.SPLIT+
34 OLESIP2Constants.PERSONAL_NAME_CODE);
35 builder.append(olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + olePatronDocument.getEntity().getNames().get(0).getLastName());
36 builder.append(OLESIP2Constants.SPLIT+
37 OLESIP2Constants.VALID_PATRON_CODE);
38 builder.append(OLESIP2Util.bool2Char(isValidPatron));
39 builder.append(OLESIP2Constants.SPLIT+
40 OLESIP2Constants.SCREEN_MSG_CODE);
41 builder.append(OLESIP2Constants.PATRON_ENABLED);
42 if (sip2PatronEnableRequestParser.getSequenceNum() != null && !sip2PatronEnableRequestParser.getSequenceNum().equalsIgnoreCase("")) {
43 builder.append(OLESIP2Constants.SPLIT+
44 OLESIP2Constants.SEQUENCE_NUM_CODE);
45 builder.append(sip2PatronEnableRequestParser.getSequenceNum());
46 builder.append(MessageUtil.computeChecksum(builder.toString()));
47 }
48 return builder.toString() + '\r';
49
50 }
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 }