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
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
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 }