001package org.kuali.ole.sip2.requestParser; 002 003import org.apache.log4j.Logger; 004import org.kuali.ole.request.OLESIP2RequestParser; 005import org.kuali.ole.sip2.constants.OLESIP2Constants; 006 007/** 008 * Created by gayathria on 2/12/14. 009 * 010 */ 011public class OLESIP2CheckInRequestParser extends OLESIP2RequestParser { 012 013 private static final Logger LOG = Logger.getLogger(OLESIP2CheckInRequestParser.class); 014 015 private String returnDate; 016 private String currentLocation; 017 private Boolean noBlock; 018 private Boolean cancel; 019 020 public OLESIP2CheckInRequestParser(String requestData) { 021 this.parseCheckInRequest(requestData); 022 } 023 024 public void parseCheckInRequest(String requestData) { 025 026 LOG.info("Entry OLESIP2CheckInRequestParser.parseCheckinRequest(String requestData)"); 027 String[] requestDataArray = requestData.split("\\|"); 028 try { 029 030 for (String data : requestDataArray) { 031 if (data.startsWith(OLESIP2Constants.CHECK_IN_REQUEST)) { 032 code = data.substring(0, 2); 033 noBlock = charToBool(data.charAt(2)); 034 transactionDate = data.substring(3, 21); 035 returnDate = data.substring(21, 39); 036 currentLocation = data.substring(41); 037 } 038 if (data.startsWith(OLESIP2Constants.INSTITUTION_ID_CODE)) { 039 institutionId = (data.replaceFirst(OLESIP2Constants.INSTITUTION_ID_CODE, "")).trim(); 040 } 041 if (data.startsWith(OLESIP2Constants.ITEM_IDENTIFIER_CODE)) { 042 itemIdentifier = (data.replaceFirst(OLESIP2Constants.ITEM_IDENTIFIER_CODE, "")).trim(); 043 } 044 if (data.startsWith(OLESIP2Constants.TERMINAL_PWD_CODE)) { 045 terminalPassword = (data.replaceFirst(OLESIP2Constants.TERMINAL_PWD_CODE, "")).trim(); 046 } 047 if (data.startsWith(OLESIP2Constants.ITEM_PROPERTIES_CODE)) { 048 itemProperties = (data.replaceFirst(OLESIP2Constants.ITEM_PROPERTIES_CODE, "")).trim(); 049 } 050 if (data.startsWith(OLESIP2Constants.CANCEL_CODE)) { 051 cancel = charToBool(data.charAt(2)); 052 } 053 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) { 054 sequenceNum = data.substring(2, 5); 055 checkSum = data.substring(5); 056 } 057 } 058 } catch (Exception e) { 059 LOG.error(e.getMessage(), e); 060 061 } 062 LOG.info("Exit OLESIP2CheckInRequestParser.parseCheckInRequest(String requestData)"); 063 } 064 065 public String getReturnDate() { 066 return returnDate; 067 } 068 069 public void setReturnDate(String returnDate) { 070 this.returnDate = returnDate; 071 } 072 073 public String getCurrentLocation() { 074 return currentLocation; 075 } 076 077 public void setCurrentLocation(String currentLocation) { 078 this.currentLocation = currentLocation; 079 } 080 081 public Boolean getNoBlock() { 082 return noBlock; 083 } 084 085 public void setNoBlock(Boolean noBlock) { 086 this.noBlock = noBlock; 087 } 088 089 public Boolean getCancel() { 090 return cancel; 091 } 092 093 public void setCancel(Boolean cancel) { 094 this.cancel = cancel; 095 } 096}