1 package org.kuali.ole.response;
2
3 import org.apache.commons.lang3.StringUtils;
4 import org.kuali.ole.bo.OLELookupUser;
5 import org.kuali.ole.constants.OLESIP2Constants;
6 import org.kuali.ole.response.OLESIP2Response;
7 import org.kuali.ole.common.MessageUtil;
8 import org.kuali.ole.common.OLESIP2Util;
9 import org.kuali.ole.request.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(OLELookupUser oleLookupUser, OLESIP2PatronEnableRequestParser sip2PatronEnableRequestParser) {
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(oleLookupUser.getPatronId()) ? oleLookupUser.getPatronId() : sip2PatronEnableRequestParser.getPatronIdentifier());
33 builder.append(OLESIP2Constants.SPLIT+
34 OLESIP2Constants.PERSONAL_NAME_CODE);
35 builder.append(oleLookupUser.getPatronName() != null ? oleLookupUser.getPatronName().getFirstName() + " " + oleLookupUser.getPatronName().getLastName() : "");
36 builder.append(OLESIP2Constants.SPLIT+
37 OLESIP2Constants.VALID_PATRON_CODE);
38 builder.append(OLESIP2Util.bool2Char(oleLookupUser.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 }