001package org.kuali.ole.deliver.printSlip; 002 003 004import com.lowagie.text.*; 005import com.lowagie.text.Font; 006import com.lowagie.text.Rectangle; 007import com.lowagie.text.pdf.PdfPCell; 008import com.lowagie.text.pdf.PdfPTable; 009import com.lowagie.text.pdf.PdfPageEventHelper; 010import com.lowagie.text.pdf.PdfWriter; 011import org.apache.log4j.Logger; 012import org.kuali.ole.OLEConstants; 013import org.kuali.ole.deliver.bo.*; 014import org.kuali.ole.deliver.processor.LoanProcessor; 015import org.kuali.ole.deliver.service.OleDeliverRequestDocumentHelperServiceImpl; 016import org.kuali.ole.describe.bo.OleLocation; 017import org.kuali.ole.docstore.common.client.DocstoreClient; 018import org.kuali.ole.docstore.common.client.DocstoreClientLocator; 019import org.kuali.ole.docstore.common.document.Bib; 020import org.kuali.ole.docstore.common.document.ItemOleml; 021import org.kuali.ole.docstore.common.document.content.enums.DocType; 022import org.kuali.ole.docstore.common.document.content.instance.Item; 023import org.kuali.ole.docstore.common.search.SearchResponse; 024import org.kuali.ole.docstore.common.search.SearchResult; 025import org.kuali.ole.docstore.common.search.SearchResultField; 026import org.kuali.ole.service.OlePatronHelperService; 027import org.kuali.ole.service.OlePatronHelperServiceImpl; 028import org.kuali.ole.sys.context.SpringContext; 029import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 030import org.kuali.rice.kim.impl.identity.address.EntityAddressBo; 031import org.kuali.rice.kim.impl.identity.email.EntityEmailBo; 032import org.kuali.rice.kim.impl.identity.entity.EntityBo; 033import org.kuali.rice.kim.impl.identity.name.EntityNameBo; 034 035import javax.servlet.ServletOutputStream; 036import javax.servlet.http.HttpServletResponse; 037import java.awt.*; 038import java.io.ByteArrayOutputStream; 039import java.io.OutputStream; 040import java.text.DateFormat; 041import java.text.SimpleDateFormat; 042import java.util.*; 043import java.util.List; 044 045/** 046 * The OlePrintSlip class used to create pdf document . 047 */ 048public class OlePrintSlip extends PdfPageEventHelper { 049 050 private static final Logger LOG = Logger.getLogger(OlePrintSlip.class); 051 052 private Map<String, Font> printFontMap = new HashMap<String, Font>(); 053 054 private Map<String, Font> fontMap = new HashMap<String, Font>(); 055 private Map<String, Color> colorMap = new HashMap<String, Color>(); 056 private Map<String, Color> printColorMap = new HashMap<String, Color>(); 057 private DocstoreClientLocator docstoreClientLocator; 058 059 public DocstoreClientLocator getDocstoreClientLocator() { 060 061 if (docstoreClientLocator == null) { 062 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class); 063 064 } 065 return docstoreClientLocator; 066 } 067 068 private OlePatronHelperService olePatronHelperService; 069 070 public OlePatronHelperService getOlePatronHelperService(){ 071 if(olePatronHelperService==null){ 072 olePatronHelperService = GlobalResourceLoader.getService("olePatronHelperService"); 073 } 074 return olePatronHelperService; 075 } 076 077 public void populateFontMap() { 078 fontMap.put("COURIER", new Font(Font.COURIER)); 079 fontMap.put("BOLD", new Font(Font.BOLD)); 080 fontMap.put("BOLDITALIC", new Font(Font.BOLDITALIC)); 081 fontMap.put("DEFAULTSIZE", new Font(Font.DEFAULTSIZE)); 082 fontMap.put("HELVETICA", new Font(Font.HELVETICA)); 083 fontMap.put("ITALIC", new Font(Font.ITALIC)); 084 fontMap.put("NORMAL", new Font(Font.NORMAL)); 085 fontMap.put("STRIKETHRU", new Font(Font.STRIKETHRU)); 086 fontMap.put("SYMBOL", new Font(Font.SYMBOL)); 087 fontMap.put("TIMES_ROMAN", new Font(Font.TIMES_ROMAN)); 088 fontMap.put("UNDEFINED", new Font(Font.UNDEFINED)); 089 fontMap.put("UNDERLINE", new Font(Font.UNDERLINE)); 090 fontMap.put("ZAPFDINGBATS", new Font(Font.ZAPFDINGBATS)); 091 092 } 093 094 public void populateColorMap() { 095 colorMap.put("WHITE", Color.WHITE); 096 colorMap.put("YELLOW", Color.YELLOW); 097 colorMap.put("BLACK", Color.BLACK); 098 colorMap.put("BLUE", Color.BLUE); 099 colorMap.put("CYAN", Color.CYAN); 100 colorMap.put("DARK_GRAY", Color.DARK_GRAY); 101 colorMap.put("GRAY", Color.GRAY); 102 colorMap.put("GREEN", Color.GREEN); 103 colorMap.put("LIGHT_GRAY", Color.LIGHT_GRAY); 104 colorMap.put("MAGENTA", Color.MAGENTA); 105 colorMap.put("ORANGE", Color.ORANGE); 106 colorMap.put("PINK", Color.PINK); 107 colorMap.put("RED", Color.RED); 108 colorMap.put("PINK", Color.PINK); 109 } 110 111 112 /** 113 * Used to create pdf document for hold slip 114 * 115 * @param oleLoanDocument 116 * @return Void 117 */ 118 public void createPdfForPrintingSlip(OleLoanDocument oleLoanDocument, HttpServletResponse response) { 119 LOG.debug("Initialize Normal pdf Template"); 120 LoanProcessor loanProcessor = new LoanProcessor(); 121 OleDeliverRequestBo oleDeliverRequestBo = oleLoanDocument.getOleDeliverRequestBo(); 122 OlePatronDocument oleRequestPatronDocument = oleDeliverRequestBo != null ? getOlePatronHelperService().getPatronDocumentByOlePatronId(oleDeliverRequestBo.getBorrowerId()) : null; 123 String patronName = oleRequestPatronDocument.getPatronName(); 124 Date expirationDate = oleRequestPatronDocument != null ? oleRequestPatronDocument.getExpirationDate() : null; 125 OlePatronDocument olePatronDocument = oleLoanDocument != null ? getOlePatronHelperService().getPatronDocumentByOlePatronId(oleLoanDocument.getPatronId()) : null; 126 OleLocation oleLocation = null; 127 OleCirculationDesk oleCirculationDesk = null; 128 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT); 129 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP); 130 try { 131 if (oleLoanDocument.getCirculationLocationId() != null) { 132 oleCirculationDesk = loanProcessor.getOleCirculationDesk(oleLoanDocument.getCirculationLocationId()); 133 oleLocation = oleCirculationDesk != null ? oleCirculationDesk.getOleCirculationDeskLocations().get(0).getLocation() : null; 134 } 135 String locationName = oleLocation != null ? oleLocation.getLocationName() : null; 136 String itemBarcode = oleLoanDocument.getItemId(); 137 String itemCallNumber = null; 138 String copyNumber = null; 139 String volumeNumber = null; 140 Item oleItem = oleLoanDocument.getOleItem(); 141 if (oleItem != null) { 142 itemCallNumber = loanProcessor.getItemCallNumber(oleItem, oleLoanDocument.getInstanceUuid()); 143 copyNumber = oleItem.getCopyNumber(); 144 volumeNumber = oleItem.getEnumeration(); 145 } else { 146 getItemDetails(loanProcessor, oleLoanDocument, oleItem, itemBarcode); 147 itemCallNumber = loanProcessor.getItemCallNumber(oleItem, oleLoanDocument.getInstanceUuid()); 148 copyNumber = oleItem.getCopyNumber(); 149 volumeNumber = oleItem.getEnumeration(); 150 } 151 if (copyNumber == null) { 152 copyNumber = ""; 153 } 154 if (volumeNumber == null) { 155 volumeNumber = ""; 156 } 157 String itemTitle = oleLoanDocument.getTitle(); 158 String requestedBy = null; 159 if (oleDeliverRequestBo != null) { 160 oleDeliverRequestBo=(new OleDeliverRequestDocumentHelperServiceImpl()).buildDeliverRequestDefaultValues(oleDeliverRequestBo); 161 requestedBy = oleDeliverRequestBo.getFirstName() + " " + oleDeliverRequestBo.getLastName(); 162 } 163 String routeTo = oleLoanDocument.getRouteToLocationName() != null ? oleLoanDocument.getRouteToLocationName() : oleCirculationDesk.getCirculationDeskPublicName(); 164 String checkInNote = oleItem != null ? oleItem.getCheckinNote() : null; 165 String itemStatusCode = oleLoanDocument.getItemStatusCode() != null ? oleLoanDocument.getItemStatusCode() : ""; 166 boolean checkInNoteDisplay = checkInNote != null && !checkInNote.trim().isEmpty() && !oleLoanDocument.getItemStatusCode().contains(OLEConstants.ITEM_STATUS_IN_TRANSIT) && oleLoanDocument.getRouteToLocation() != null && !oleLoanDocument.getRouteToLocation().trim().isEmpty(); 167 boolean holdSlip = itemStatusCode.equalsIgnoreCase(OLEConstants.ITEM_STATUS_ON_HOLD); 168 boolean inTransitSlip = itemStatusCode.equalsIgnoreCase(OLEConstants.ITEM_STATUS_IN_TRANSIT); 169 boolean inTransitForHold = itemStatusCode.equalsIgnoreCase(OLEConstants.ITEM_STATUS_IN_TRANSIT_HOLD); 170 boolean inTransitPerStaff = itemStatusCode.equalsIgnoreCase(OLEConstants.ITEM_STATUS_IN_TRANSIT_STAFF); 171 boolean missingPieceCheck = oleLoanDocument.isMissingPieceFlag(); 172 boolean returnedDamaged = oleLoanDocument.isItemDamagedStatus(); 173 boolean claimsReturned = oleLoanDocument.isClaimsReturnedIndicator(); 174 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 175 populateColorMap(); 176 populateFontMap(); 177 response.setContentType("application/pdf"); 178 OutputStream os = null; 179 180 if (holdSlip && oleCirculationDesk != null && oleCirculationDesk.getHoldFormat() != null && oleCirculationDesk.getHoldFormat().equals(OLEConstants.RECEIPT_PRINTER)) { 181 getHoldSlipForReceiptPrinter(patronName, expirationDate, missingPieceCheck, oleCirculationDesk, itemBarcode, itemTitle, itemCallNumber, copyNumber, volumeNumber, response); 182 } else { 183 Document document = this.getDocument(0, 0, 5, 5); 184 if (missingPieceCheck) { 185 os = response.getOutputStream(); 186 PdfWriter.getInstance(document, os); 187 } 188 document.open(); 189 document.newPage(); 190 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD); 191 PdfPTable pdfTable = new PdfPTable(3); 192 Paragraph paraGraph = new Paragraph(); 193 paraGraph.setAlignment(Element.ALIGN_CENTER); 194 if (holdSlip) { 195 paraGraph.add(new Chunk("Hold Slip", boldFont)); 196 } else if (inTransitSlip) { 197 paraGraph.add(new Chunk("Routing Slip In-Transit", boldFont)); 198 } else if (inTransitForHold) { 199 paraGraph.add(new Chunk("Routing Slip In-Transit For Hold", boldFont)); 200 } else if (inTransitPerStaff) { 201 paraGraph.add(new Chunk("Routing Slip In-Transit Per Staff Request", boldFont)); 202 } else if (missingPieceCheck) { 203 paraGraph.add(new Chunk("Missing Pieces Notice", boldFont)); 204 } else if (returnedDamaged) { 205 paraGraph.add(new Chunk("Returned Damaged", boldFont)); 206 } else if (claimsReturned) { 207 paraGraph.add(new Chunk("Claims Returned Notice", boldFont)); 208 } else if (checkInNoteDisplay) { 209 paraGraph.add(new Chunk("Routing Slip", boldFont)); 210 } else { 211 paraGraph.add(new Chunk("Receipt(CheckIn) Slip", boldFont)); 212 } 213 paraGraph.add(Chunk.NEWLINE); 214 paraGraph.add(Chunk.NEWLINE); 215 paraGraph.add(Chunk.NEWLINE); 216 if (holdSlip) { 217 pdfTable.addCell(getPdfPCellInJustified("Patron Name")); 218 pdfTable.addCell(getPdfPCellInLeft(":")); 219 pdfTable.addCell(getPdfPCellInJustified(patronName)); 220 221 pdfTable.addCell(getPdfPCellInJustified("Expiration Date")); 222 pdfTable.addCell(getPdfPCellInLeft(":")); 223 pdfTable.addCell(getPdfPCellInJustified(expirationDate != null ? dateFormat.format(expirationDate).toString() : null)); 224 } else if (inTransitSlip || checkInNoteDisplay) { 225 226 pdfTable.addCell(getPdfPCellInJustified("Route To")); 227 pdfTable.addCell(getPdfPCellInLeft(":")); 228 pdfTable.addCell(getPdfPCellInJustified(routeTo)); 229 230 pdfTable.addCell(getPdfPCellInJustified("Date/Time ")); 231 pdfTable.addCell(getPdfPCellInLeft(":")); 232 pdfTable.addCell(getPdfPCellInJustified(sdf.format(oleLoanDocument.getCheckInDate()).toString())); 233 234 } else if (inTransitForHold) { 235 236 pdfTable.addCell(getPdfPCellInJustified("Route To")); 237 pdfTable.addCell(getPdfPCellInLeft(":")); 238 pdfTable.addCell(getPdfPCellInJustified(routeTo)); 239 240 pdfTable.addCell(getPdfPCellInJustified("Place on hold for")); 241 pdfTable.addCell(getPdfPCellInLeft(":")); 242 pdfTable.addCell(getPdfPCellInJustified(requestedBy)); 243 244 245 pdfTable.addCell(getPdfPCellInJustified("Date/Time ")); 246 pdfTable.addCell(getPdfPCellInLeft(":")); 247 pdfTable.addCell(getPdfPCellInJustified(sdf.format(oleLoanDocument.getCheckInDate()).toString())); 248 249 } else if (inTransitPerStaff) { 250 251 pdfTable.addCell(getPdfPCellInJustified("Route To")); 252 pdfTable.addCell(getPdfPCellInLeft(":")); 253 pdfTable.addCell(getPdfPCellInJustified(routeTo)); 254 255 pdfTable.addCell(getPdfPCellInJustified("Requested By")); 256 pdfTable.addCell(getPdfPCellInLeft(":")); 257 pdfTable.addCell(getPdfPCellInJustified(requestedBy)); 258 259 260 pdfTable.addCell(getPdfPCellInJustified("Date/Time ")); 261 pdfTable.addCell(getPdfPCellInLeft(":")); 262 pdfTable.addCell(getPdfPCellInJustified(sdf.format(oleLoanDocument.getCheckInDate()).toString())); 263 264 } else if (returnedDamaged) { 265 pdfTable.addCell(getPdfPCellInJustified("Route To")); 266 pdfTable.addCell(getPdfPCellInLeft(":")); 267 pdfTable.addCell(getPdfPCellInJustified(routeTo)); 268 } else if (missingPieceCheck) { 269 document.add(paraGraph); 270 //Circulation Desk 271 pdfTable.addCell(getPdfPCellInJustified("Circulation Location / Library Name")); 272 pdfTable.addCell(getPdfPCellInLeft(":")); 273 pdfTable.addCell(getPdfPCellInJustified(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : "")); 274 275 pdfTable.addCell(getPdfPCellInJustified("Address")); 276 pdfTable.addCell(getPdfPCellInLeft(":")); 277 pdfTable.addCell(getPdfPCellInJustified("")); 278 279 pdfTable.addCell(getPdfPCellInJustified("Email")); 280 pdfTable.addCell(getPdfPCellInLeft(":")); 281 pdfTable.addCell(getPdfPCellInJustified("kuali.ole@org.com")); 282 283 pdfTable.addCell(getPdfPCellInJustified("Phone #")); 284 pdfTable.addCell(getPdfPCellInLeft(":")); 285 pdfTable.addCell(getPdfPCellInJustified("111-5555")); 286 287 document.add(pdfTable); 288 paraGraph = new Paragraph(); 289 paraGraph.add(Chunk.NEWLINE); 290 document.add(paraGraph); 291 292 //Patron 293 paraGraph = new Paragraph(); 294 paraGraph.add(new Chunk("Addressee", boldFont)); 295 paraGraph.add(Chunk.NEWLINE); 296 document.add(paraGraph); 297 298 pdfTable = new PdfPTable(3); 299 pdfTable.addCell(getPdfPCellInJustified("Borrower Name")); 300 pdfTable.addCell(getPdfPCellInLeft(":")); 301 pdfTable.addCell(getPdfPCellInJustified(patronName)); 302 303 pdfTable.addCell(getPdfPCellInJustified("Address")); 304 pdfTable.addCell(getPdfPCellInLeft(":")); 305 pdfTable.addCell(getPdfPCellInJustified("")); 306 307 pdfTable.addCell(getPdfPCellInJustified("Email")); 308 pdfTable.addCell(getPdfPCellInLeft(":")); 309 pdfTable.addCell(getPdfPCellInJustified(olePatronDocument.getDefaultEmailAddress())); 310 311 pdfTable.addCell(getPdfPCellInJustified("Phone #")); 312 pdfTable.addCell(getPdfPCellInLeft(":")); 313 pdfTable.addCell(getPdfPCellInJustified(olePatronDocument.getDefaultPhoneNumber())); 314 315 document.add(pdfTable); 316 //Notice Type 317 paraGraph = new Paragraph(); 318 paraGraph.add(new Chunk("Return with Missing Piece(s) Notice", boldFont)); 319 paraGraph.setAlignment(Element.ALIGN_CENTER); 320 paraGraph.add(Chunk.NEWLINE); 321 document.add(paraGraph); 322 323 324 //Notice-specific text 325 paraGraph = new Paragraph(); 326 paraGraph.add(new Chunk("The following item(s) returned by you is missing one or more of its pieces.Please return the missing piece(s) to the library shown above or contact the library about this matter to avoid incurring any penalties.", boldFont)); 327 paraGraph.setAlignment(Element.ALIGN_CENTER); 328 paraGraph.add(Chunk.NEWLINE); 329 document.add(paraGraph); 330 331 //Title/item information 332 paraGraph = new Paragraph(); 333 paraGraph.add(new Chunk("Title/item information", boldFont)); 334 paraGraph.add(Chunk.NEWLINE); 335 document.add(paraGraph); 336 337 pdfTable = new PdfPTable(3); 338 pdfTable.addCell(getPdfPCellInJustified("Title")); 339 pdfTable.addCell(getPdfPCellInLeft(":")); 340 pdfTable.addCell(getPdfPCellInJustified(itemTitle)); 341 342 pdfTable.addCell(getPdfPCellInJustified("Author")); 343 pdfTable.addCell(getPdfPCellInLeft(":")); 344 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getAuthor())); 345 346 pdfTable.addCell(getPdfPCellInJustified("Volume/Issue/Copy #")); 347 pdfTable.addCell(getPdfPCellInLeft(":")); 348 pdfTable.addCell(getPdfPCellInJustified(copyNumber)); 349 350 pdfTable.addCell(getPdfPCellInJustified("Library shelving location ")); 351 pdfTable.addCell(getPdfPCellInLeft(":")); 352 pdfTable.addCell(getPdfPCellInJustified(locationName)); 353 354 pdfTable.addCell(getPdfPCellInJustified("Call #")); 355 pdfTable.addCell(getPdfPCellInLeft(":")); 356 pdfTable.addCell(getPdfPCellInJustified(itemCallNumber)); 357 358 pdfTable.addCell(getPdfPCellInJustified("Item barcode")); 359 pdfTable.addCell(getPdfPCellInLeft(":")); 360 pdfTable.addCell(getPdfPCellInJustified(itemBarcode)); 361 document.add(pdfTable); 362 363 } 364 if (!missingPieceCheck) { 365 pdfTable.addCell(getPdfPCellInJustified("Route From")); 366 pdfTable.addCell(getPdfPCellInLeft(":")); 367 pdfTable.addCell(getPdfPCellInJustified(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : "")); 368 369 pdfTable.addCell(getPdfPCellInJustified("Item Barcode")); 370 pdfTable.addCell(getPdfPCellInLeft(":")); 371 pdfTable.addCell(getPdfPCellInJustified(itemBarcode)); 372 373 pdfTable.addCell(getPdfPCellInJustified("Title")); 374 pdfTable.addCell(getPdfPCellInLeft(":")); 375 pdfTable.addCell(getPdfPCellInJustified(itemTitle)); 376 377 pdfTable.addCell(getPdfPCellInJustified("Call Number")); 378 pdfTable.addCell(getPdfPCellInLeft(":")); 379 pdfTable.addCell(getPdfPCellInJustified(itemCallNumber)); 380 381 pdfTable.addCell(getPdfPCellInJustified("Copy Number")); 382 pdfTable.addCell(getPdfPCellInLeft(":")); 383 pdfTable.addCell(getPdfPCellInJustified(copyNumber)); 384 if (!(holdSlip | inTransitSlip | inTransitForHold | inTransitPerStaff | checkInNoteDisplay)) { 385 pdfTable.addCell(getPdfPCellInJustified("Check-in Date")); 386 pdfTable.addCell(getPdfPCellInLeft(":")); 387 pdfTable.addCell(getPdfPCellInJustified(sdf.format(oleLoanDocument.getCheckInDate()).toString())); 388 389 pdfTable.addCell(getPdfPCellInJustified("Patron Barcode")); 390 pdfTable.addCell(getPdfPCellInLeft(":")); 391 pdfTable.addCell(getPdfPCellInJustified(olePatronDocument != null && olePatronDocument.getBarcode() != null ? olePatronDocument.getBarcode() : "")); 392 } 393 } 394 if (holdSlip) { 395 if (oleCirculationDesk != null) { 396 int noDays = Integer.parseInt(oleCirculationDesk.getOnHoldDays()); 397 Calendar calendar = Calendar.getInstance(); 398 calendar.add(Calendar.DATE, noDays); 399 Date date = calendar.getTime(); 400 if (date != null) { 401 DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); 402 pdfTable.addCell(getPdfPCellInJustified("Expiration onHoldDate")); 403 pdfTable.addCell(getPdfPCellInLeft(":")); 404 String dateString = date == null ? "" : df.format(date); 405 pdfTable.addCell(getPdfPCellInJustified(dateString)); 406 } 407 } 408 } 409 response.setContentType("application/pdf"); 410 if (!missingPieceCheck) { 411 os = response.getOutputStream(); 412 PdfWriter.getInstance(document, os); 413 document.open(); 414 document.add(paraGraph); 415 document.add(pdfTable); 416 document.close(); 417 } else { 418 document.close(); 419 } 420 byteArrayOutputStream.flush(); 421 byteArrayOutputStream.close(); 422 os.flush(); 423 os.close(); 424 } 425 }catch (Exception e) { 426 LOG.error("Exception while creating pdf for printing slip", e); 427 } 428 } 429 430 /** 431 * Used to create pdf document for checkout slip 432 * 433 * @param oleLoanDocument 434 * @return Void 435 */ 436 public void createPdfForBackGroundCheckOut(OleLoanDocument oleLoanDocument, HttpServletResponse response) { 437 LOG.debug("Initialize Normal pdf Template"); 438 LoanProcessor loanProcessor = new LoanProcessor(); 439 OlePatronDocument olePatronDocument = oleLoanDocument != null ? getOlePatronHelperService().getPatronDocumentByOlePatronId(oleLoanDocument.getPatronId()) : null; 440 if (olePatronDocument != null) { 441 String patronName = olePatronDocument.getFirstName()+" "+olePatronDocument.getLastName(); 442 String line1 = ""; 443 String line2 = ""; 444 String line3 = ""; 445 String city = ""; 446 String stateProvisionalCode = ""; 447 String countryCode = ""; 448 String postalCode = ""; 449 for (OLEPatronDocumentAddress olePatronDocumentAddress : olePatronDocument.getOlePatronDocumentAddresses()) { 450 if (olePatronDocumentAddress.isDefaultValue()) { 451 line1 = olePatronDocumentAddress.getLine1() != null && !olePatronDocumentAddress.getLine1().isEmpty() ? olePatronDocumentAddress.getLine1() + OLEConstants.COMMA : ""; 452 line2 = olePatronDocumentAddress.getLine2() != null && !olePatronDocumentAddress.getLine2().isEmpty() ? olePatronDocumentAddress.getLine2() + OLEConstants.COMMA : ""; 453 line3 = olePatronDocumentAddress.getLine3() != null && !olePatronDocumentAddress.getLine3().isEmpty() ? olePatronDocumentAddress.getLine3() + OLEConstants.COMMA : ""; 454 city = olePatronDocumentAddress.getCity() != null && !olePatronDocumentAddress.getCity().isEmpty() ? olePatronDocumentAddress.getCity() + OLEConstants.COMMA : ""; 455 stateProvisionalCode = olePatronDocumentAddress.getStateProvinceCode() != null && !olePatronDocumentAddress.getStateProvinceCode().isEmpty() ? olePatronDocumentAddress.getStateProvinceCode() + OLEConstants.COMMA : ""; 456 countryCode = olePatronDocumentAddress.getCountryCode() != null && !olePatronDocumentAddress.getCountryCode().isEmpty() ? olePatronDocumentAddress.getCountryCode() + OLEConstants.COMMA : ""; 457 postalCode = olePatronDocumentAddress.getPostalCode() != null && !olePatronDocumentAddress.getPostalCode().isEmpty() ? olePatronDocumentAddress.getPostalCode() : ""; 458 } 459 } 460 try { 461 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 462 populateColorMap(); 463 populateFontMap(); 464 response.setContentType("application/pdf"); 465 OutputStream os = null; 466 Document document = this.getDocument(0, 0, 5, 5); 467 document.open(); 468 document.newPage(); 469 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD); 470 PdfPTable pdfTable = new PdfPTable(1); 471 Paragraph paraGraph = new Paragraph(); 472 paraGraph.setAlignment(Element.ALIGN_CENTER); 473 paraGraph.add(new Chunk("Mailing Label", boldFont)); 474 paraGraph.add(Chunk.NEWLINE); 475 paraGraph.add(Chunk.NEWLINE); 476 paraGraph.add(Chunk.NEWLINE); 477 pdfTable.setHorizontalAlignment(Element.ALIGN_CENTER); 478 pdfTable.addCell(getPdfPCellInJustified(patronName)); 479 if (!line1.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(line1)); 480 if (!line2.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(line2)); 481 if (!line3.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(line3)); 482 if (!city.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(city)); 483 if (!stateProvisionalCode.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(stateProvisionalCode)); 484 if (!countryCode.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(countryCode)); 485 if (!postalCode.isEmpty()) pdfTable.addCell(getPdfPCellInJustified(postalCode)); 486 pdfTable.addCell(getPdfPCellInJustified(olePatronDocument.getDefaultEmailAddress())); 487 document.add(pdfTable); 488 response.setContentType("application/pdf"); 489 os = response.getOutputStream(); 490 PdfWriter.getInstance(document, os); 491 document.open(); 492 document.add(paraGraph); 493 document.add(pdfTable); 494 document.close(); 495 byteArrayOutputStream.flush(); 496 byteArrayOutputStream.close(); 497 os.flush(); 498 os.close(); 499 } catch (Exception e) { 500 LOG.error("Exception while creating pdf for backgroung check out", e); 501 } 502 } 503 } 504 505 506 public void createDueDateSlipPdf(List<OleLoanDocument> oleLoanDocument, HttpServletResponse response) { 507 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 508 509 try { 510 populateColorMap(); 511 populateFontMap(); 512 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT); 513 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP); 514 String date = dateFormat.format(System.currentTimeMillis()); 515 response.setContentType("application/pdf"); 516 Document document = this.getDocument(0, 0, 5, 5); 517 PdfWriter writer = PdfWriter.getInstance(document, byteArrayOutputStream); 518 document.open(); 519 document.newPage(); 520 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD); 521 PdfPTable pdfTable = new PdfPTable(3); 522 Paragraph paraGraph = new Paragraph(); 523 paraGraph.setAlignment(Element.ALIGN_CENTER); 524 paraGraph.add(new Chunk("Due Date Slip", boldFont)); 525 paraGraph.add(Chunk.NEWLINE); 526 paraGraph.add(Chunk.NEWLINE); 527 paraGraph.add(Chunk.NEWLINE); 528 LoanProcessor loanProcessor = new LoanProcessor(); 529 OleLocation oleLocation = null; 530 OleCirculationDesk oleCirculationDesk = null; 531 try { 532 if (oleLoanDocument.get(0).getCirculationLocationId() != null) { 533 oleCirculationDesk = loanProcessor.getOleCirculationDesk(oleLoanDocument.get(0).getCirculationLocationId()); 534 } 535 oleLocation = oleCirculationDesk.getOleCirculationDeskLocations().get(0).getLocation(); 536 // oleLocation = loanProcessor.getLocationByLocationId(oleLoanDocument.get(0).getCirculationLocationId()); 537 } catch (Exception e) { 538 LOG.error("Exception", e); 539 } 540 String locationName = oleLocation != null ? oleLocation.getLocationName() : null; 541 542 543 for (int dueDateSlip = 0; dueDateSlip < oleLoanDocument.size(); dueDateSlip++) { 544 545 pdfTable.addCell(getPdfPCellInJustified("Circulation Location/Library Name")); 546 pdfTable.addCell(getPdfPCellInLeft(":")); 547 pdfTable.addCell(getPdfPCellInJustified(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : "")); 548 549 pdfTable.addCell(getPdfPCellInJustified("Item Barcode")); 550 pdfTable.addCell(getPdfPCellInLeft(":")); 551 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getItemId())); 552 553 pdfTable.addCell(getPdfPCellInJustified("Title")); 554 pdfTable.addCell(getPdfPCellInLeft(":")); 555 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getTitle())); 556 557 pdfTable.addCell(getPdfPCellInJustified("Call Number")); 558 pdfTable.addCell(getPdfPCellInLeft(":")); 559 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getItemCallNumber())); 560 561 pdfTable.addCell(getPdfPCellInJustified("Copy Number")); 562 pdfTable.addCell(getPdfPCellInLeft(":")); 563 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getItemCopyNumber())); 564 565 pdfTable.addCell(getPdfPCellInJustified("Due Date")); 566 pdfTable.addCell(getPdfPCellInLeft(":")); 567 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getLoanDueDate()!=null? 568 sdf.format(oleLoanDocument.get(dueDateSlip).getLoanDueDate()).toString():"")); 569 570 pdfTable.addCell(getPdfPCellInJustified("Patron Barcode")); 571 pdfTable.addCell(getPdfPCellInLeft(":")); 572 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getPatronBarcode())); 573 574 575 576 /*paraGraph.add(Chunk.NEWLINE); 577 paraGraph.add(Chunk.NEWLINE); 578*/ 579 pdfTable.addCell(getEmptyCell()); 580 pdfTable.addCell(getEmptyCell()); 581 pdfTable.addCell(getEmptyCell()); 582 583 pdfTable.addCell(getEmptyCell()); 584 pdfTable.addCell(getEmptyCell()); 585 pdfTable.addCell(getEmptyCell()); 586 } 587 response.setContentType("application/pdf"); 588 ServletOutputStream sos = response.getOutputStream(); 589 PdfWriter.getInstance(document, sos); 590 document.open(); 591 document.add(paraGraph); 592 document.add(pdfTable); 593 document.close(); 594 String fileName = "Due date slip_" + date; 595 ///OutputStream outputStream = new FileOutputStream(""+fileName+".pdf"); 596 // byteArrayOutputStream.writeTo(outputStream); 597 byteArrayOutputStream.flush(); 598 byteArrayOutputStream.close(); 599 sos.flush(); 600 sos.close(); 601 // outputStream.close(); 602 } catch (Exception e) { 603 LOG.error("Exception while creating due date pdf slip", e); 604 } 605 } 606 607 private PdfPCell getEmptyCell() { 608 PdfPCell pdfPCell = new PdfPCell(new Paragraph(Chunk.NEWLINE)); 609 pdfPCell.setBorder(pdfPCell.NO_BORDER); 610 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED); 611 return pdfPCell; 612 } 613 614 private PdfPCell getPdfPCellInJustified(String chunk) { 615 PdfPCell pdfPCell=null; 616 if(chunk!=null){ 617 pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk))); 618 } 619 else{ 620 pdfPCell = new PdfPCell(new Paragraph()); 621 } 622 pdfPCell.setBorder(pdfPCell.NO_BORDER); 623 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED); 624 return pdfPCell; 625 } 626 627 private PdfPCell getPdfPCellAligned(String chunk, int font, int val) { 628 PdfPCell pdfPCell = new PdfPCell(new Phrase(chunk,FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, font))); 629 pdfPCell.setBorder(pdfPCell.NO_BORDER); 630 pdfPCell.setPaddingLeft(val); 631 return pdfPCell; 632 } 633 634 private PdfPCell getPdfPCellInLeft(String chunk) { 635 PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk))); 636 pdfPCell.setBorder(pdfPCell.NO_BORDER); 637 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT); 638 return pdfPCell; 639 } 640 641 public Document getDocument(float f1, float f2, float f3, float f4) { 642 Document document = new Document(PageSize.A4); 643 document.setMargins(f1, f2, f3, f4); 644 return document; 645 } 646 647 private void getHoldSlipForReceiptPrinter(String patronName, Date expirationDate, boolean missingPieceCheck, OleCirculationDesk oleCirculationDesk, String itemBarcode, String itemTitle, String itemCallNumber, String copyNumber, String volumeNumber, HttpServletResponse response) throws Exception { 648 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT); 649 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 650 OutputStream os = null; 651 Document document = new Document(new Rectangle(253, 430)); 652 document.setMargins(0, 0, 5, 5); 653 document.open(); 654 document.newPage(); 655 PdfPTable pdfTable = new PdfPTable(1); 656 pdfTable.addCell(getEmptyCell()); 657 pdfTable.addCell(getEmptyCell()); 658 pdfTable.addCell(getPdfPCellAligned("Hold Slip", Font.BOLD, 11)); 659 pdfTable.addCell(getEmptyCell()); 660 pdfTable.addCell(getPdfPCellAligned(patronName, Font.NORMAL, 11)); 661 if (oleCirculationDesk != null) { 662 int noDays = Integer.parseInt(oleCirculationDesk.getOnHoldDays()); 663 Calendar calendar = Calendar.getInstance(); 664 calendar.add(Calendar.DATE, noDays); 665 Date date = calendar.getTime(); 666 if (date != null) { 667 DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); 668 String dateString = date == null ? "" : df.format(date); 669 pdfTable.addCell(getPdfPCellAligned(dateString, Font.NORMAL, 11)); 670 } 671 } 672 pdfTable.addCell(getEmptyCell()); 673 if (!missingPieceCheck) { 674 pdfTable.addCell(getPdfPCellAligned(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : "", Font.NORMAL, 11)); 675 pdfTable.addCell(getPdfPCellAligned(itemBarcode, Font.NORMAL, 11)); 676 pdfTable.addCell(getPdfPCellAligned(itemTitle, Font.NORMAL, 11)); 677 pdfTable.addCell(getPdfPCellAligned(itemCallNumber, Font.NORMAL, 11)); 678 pdfTable.addCell(getPdfPCellAligned(copyNumber, Font.NORMAL, 11)); 679 pdfTable.addCell(getPdfPCellAligned(volumeNumber, Font.NORMAL, 11)); 680 } 681 pdfTable.addCell(getEmptyCell()); 682 pdfTable.addCell(getEmptyCell()); 683 pdfTable.addCell(getEmptyCell()); 684 pdfTable.addCell(getEmptyCell()); 685 pdfTable.addCell(getEmptyCell()); 686 pdfTable.addCell(getEmptyCell()); 687 pdfTable.addCell(getEmptyCell()); 688 pdfTable.addCell(getEmptyCell()); 689 response.setContentType("application/pdf"); 690 if (!missingPieceCheck) { 691 os = response.getOutputStream(); 692 PdfWriter.getInstance(document, os); 693 document.open(); 694 document.add(pdfTable); 695 document.close(); 696 } else { 697 document.close(); 698 } 699 byteArrayOutputStream.flush(); 700 byteArrayOutputStream.close(); 701 os.flush(); 702 os.close(); 703 } 704 705 public void createHoldSlipPdf(List<OleLoanDocument> oleLoanDocumentList, HttpServletResponse response, OleCirculationDesk oleCirculationDesk) throws Exception { 706 LoanProcessor loanProcessor = new LoanProcessor(); 707 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT); 708 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 709 OutputStream os = null; 710 Document document; 711 PdfPTable pdfTable; 712 if (oleCirculationDesk != null && oleCirculationDesk.getHoldFormat().equals(OLEConstants.RECEIPT_PRINTER)) { 713 document = new Document(new Rectangle(253, 430)); 714 document.open(); 715 document.newPage(); 716 } else { 717 document = this.getDocument(0, 0, 5, 5); 718 document.open(); 719 document.newPage(); 720 } 721 response.setContentType("application/pdf"); 722 os = response.getOutputStream(); 723 PdfWriter.getInstance(document, os); 724 document.open(); 725 for (OleLoanDocument oleLoanDocument : oleLoanDocumentList) { 726 OleDeliverRequestBo oleDeliverRequestBo = oleLoanDocument.getOleDeliverRequestBo(); 727 OlePatronDocument oleRequestPatronDocument = oleDeliverRequestBo != null ? getOlePatronHelperService().getPatronDocumentByOlePatronId(oleDeliverRequestBo.getBorrowerId()) : null; 728 String patronName = oleRequestPatronDocument.getPatronName(); 729 Date expirationDate = oleRequestPatronDocument != null ? oleRequestPatronDocument.getExpirationDate() : null; 730 String itemCallNumber = null; 731 String copyNumber = null; 732 String volumeNumber = null; 733 String itemBarcode = oleLoanDocument.getItemId(); 734 Item oleItem = oleLoanDocument.getOleItem(); 735 if (oleItem != null) { 736 itemCallNumber = loanProcessor.getItemCallNumber(oleItem, oleLoanDocument.getInstanceUuid()); 737 copyNumber = oleItem.getCopyNumber(); 738 volumeNumber = oleItem.getEnumeration(); 739 } else { 740 getItemDetails(loanProcessor, oleLoanDocument, oleItem, itemBarcode); 741 itemCallNumber = loanProcessor.getItemCallNumber(oleItem, oleLoanDocument.getInstanceUuid()); 742 copyNumber = oleItem.getCopyNumber(); 743 volumeNumber = oleItem.getEnumeration(); 744 } 745 if (copyNumber == null) { 746 copyNumber = ""; 747 } 748 if (volumeNumber == null) { 749 volumeNumber = ""; 750 } 751 if (oleCirculationDesk != null && oleCirculationDesk.getHoldFormat().equals(OLEConstants.RECEIPT_PRINTER)) { 752 pdfTable = new PdfPTable(1); 753 pdfTable.addCell(getPdfPCellAligned("Hold Slip", Font.BOLD, -18)); 754 pdfTable.addCell(getEmptyCell()); 755 pdfTable.addCell(getPdfPCellAligned(patronName, Font.NORMAL, -18)); 756 if (oleCirculationDesk != null) { 757 int noDays = Integer.parseInt(oleCirculationDesk.getOnHoldDays()); 758 Calendar calendar = Calendar.getInstance(); 759 calendar.add(Calendar.DATE, noDays); 760 Date date = calendar.getTime(); 761 if (date != null) { 762 DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); 763 String dateString = date == null ? "" : df.format(date); 764 pdfTable.addCell(getPdfPCellAligned(dateString, Font.NORMAL, -18)); 765 } 766 } 767 pdfTable.addCell(getEmptyCell()); 768 if (!oleLoanDocument.isMissingPieceFlag()) { 769 pdfTable.addCell(getPdfPCellAligned(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : "", Font.NORMAL, -18)); 770 pdfTable.addCell(getPdfPCellAligned(itemBarcode, Font.NORMAL, -18)); 771 pdfTable.addCell(getPdfPCellAligned(oleLoanDocument.getTitle(), Font.NORMAL, -18)); 772 pdfTable.addCell(getPdfPCellAligned(itemCallNumber, Font.NORMAL, -18)); 773 pdfTable.addCell(getPdfPCellAligned(copyNumber, Font.NORMAL, -18)); 774 pdfTable.addCell(getPdfPCellAligned(volumeNumber, Font.NORMAL, -18)); 775 } 776 pdfTable.addCell(getEmptyCell()); 777 pdfTable.addCell(getEmptyCell()); 778 pdfTable.addCell(getEmptyCell()); 779 pdfTable.addCell(getEmptyCell()); 780 document.add(pdfTable); 781 document.newPage(); 782 783 } else { 784 pdfTable = new PdfPTable(3); 785 pdfTable.addCell(getEmptyCell()); 786 PdfPCell pdfPCell = new PdfPCell(new Phrase("Hold Slip", FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD))); 787 pdfPCell.setBorder(pdfPCell.NO_BORDER); 788 pdfPCell.setHorizontalAlignment(Element.ALIGN_CENTER); 789 pdfTable.addCell(pdfPCell); 790 pdfTable.addCell(getEmptyCell()); 791 792 pdfTable.addCell(getEmptyCell()); 793 pdfTable.addCell(getEmptyCell()); 794 pdfTable.addCell(getEmptyCell()); 795 796 pdfTable.addCell(getEmptyCell()); 797 pdfTable.addCell(getEmptyCell()); 798 pdfTable.addCell(getEmptyCell()); 799 800 pdfTable.addCell(getPdfPCellInJustified("Patron Name")); 801 pdfTable.addCell(getPdfPCellInLeft(":")); 802 pdfTable.addCell(getPdfPCellInJustified(patronName)); 803 804 pdfTable.addCell(getPdfPCellInJustified("Expiration Date")); 805 pdfTable.addCell(getPdfPCellInLeft(":")); 806 pdfTable.addCell(getPdfPCellInJustified(expirationDate != null ? dateFormat.format(expirationDate).toString() : null)); 807 if (!oleLoanDocument.isMissingPieceFlag()) { 808 pdfTable.addCell(getPdfPCellInJustified("Route From")); 809 pdfTable.addCell(getPdfPCellInLeft(":")); 810 pdfTable.addCell(getPdfPCellInJustified(oleCirculationDesk != null ? oleCirculationDesk.getCirculationDeskPublicName() : "")); 811 812 pdfTable.addCell(getPdfPCellInJustified("Item Barcode")); 813 pdfTable.addCell(getPdfPCellInLeft(":")); 814 pdfTable.addCell(getPdfPCellInJustified(itemBarcode)); 815 816 pdfTable.addCell(getPdfPCellInJustified("Title")); 817 pdfTable.addCell(getPdfPCellInLeft(":")); 818 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getTitle())); 819 820 pdfTable.addCell(getPdfPCellInJustified("Call Number")); 821 pdfTable.addCell(getPdfPCellInLeft(":")); 822 pdfTable.addCell(getPdfPCellInJustified(itemCallNumber)); 823 824 pdfTable.addCell(getPdfPCellInJustified("Copy Number")); 825 pdfTable.addCell(getPdfPCellInLeft(":")); 826 pdfTable.addCell(getPdfPCellInJustified(copyNumber)); 827 828 if (oleCirculationDesk != null) { 829 int noDays = Integer.parseInt(oleCirculationDesk.getOnHoldDays()); 830 Calendar calendar = Calendar.getInstance(); 831 calendar.add(Calendar.DATE, noDays); 832 Date date = calendar.getTime(); 833 if (date != null) { 834 DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); 835 pdfTable.addCell(getPdfPCellInJustified("Expiration onHoldDate")); 836 pdfTable.addCell(getPdfPCellInLeft(":")); 837 String dateString = date == null ? "" : df.format(date); 838 pdfTable.addCell(getPdfPCellInJustified(dateString)); 839 } 840 } 841 } 842 pdfTable.addCell(getEmptyCell()); 843 pdfTable.addCell(getEmptyCell()); 844 pdfTable.addCell(getEmptyCell()); 845 document.add(pdfTable); 846 document.newPage(); 847 } 848 } 849 document.close(); 850 byteArrayOutputStream.flush(); 851 byteArrayOutputStream.close(); 852 os.flush(); 853 os.close(); 854 } 855 856 private void getItemDetails(LoanProcessor loanProcessor, OleLoanDocument oleLoanDocument, Item oleItem, String itemBarcode) throws Exception { 857 org.kuali.ole.docstore.common.document.Item item = new ItemOleml(); 858 org.kuali.ole.docstore.common.search.SearchParams search_Params = new org.kuali.ole.docstore.common.search.SearchParams(); 859 SearchResponse searchResponse = null; 860 search_Params.getSearchConditions().add(search_Params.buildSearchCondition("phrase", search_Params.buildSearchField(org.kuali.ole.docstore.common.document.content.enums.DocType.ITEM.getCode(), item.ITEM_BARCODE, itemBarcode), "")); 861 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(DocType.ITEM.getCode(), "id")); 862 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.HOLDINGS.getCode(), "id")); 863 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), "id")); 864 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), Bib.TITLE)); 865 search_Params.getSearchResultFields().add(search_Params.buildSearchResultField(org.kuali.ole.docstore.common.document.content.enums.DocType.BIB.getCode(), Bib.AUTHOR)); 866 searchResponse = getDocstoreClientLocator().getDocstoreClient().search(search_Params); 867 for (SearchResult searchResult : searchResponse.getSearchResults()) { 868 for (SearchResultField searchResultField : searchResult.getSearchResultFields()) { 869 String fieldName = searchResultField.getFieldName(); 870 String fieldValue = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : ""; 871 if (fieldName.equalsIgnoreCase("id") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("holdings")) { 872 oleLoanDocument.setInstanceUuid(fieldValue); 873 } else if (fieldName.equalsIgnoreCase("id") && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("item")) { 874 oleLoanDocument.setItemUuid(fieldValue); 875 } else if (fieldName.equalsIgnoreCase(Bib.TITLE) && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("bibliographic")) { 876 oleLoanDocument.setTitle(fieldValue); 877 } else if (fieldName.equalsIgnoreCase(Bib.AUTHOR) && !fieldValue.isEmpty() && searchResultField.getDocType().equalsIgnoreCase("bibliographic")) { 878 oleLoanDocument.setAuthor(fieldValue); 879 } 880 } 881 } 882 String itemXml = null; 883 itemXml = loanProcessor.getItemXML(oleLoanDocument.getItemUuid()); 884 oleItem = loanProcessor.getItemPojo(itemXml); 885 } 886} 887 888