1 package org.kuali.ole.deliver.batch;
2
3 import com.lowagie.text.*;
4 import com.lowagie.text.Font;
5 import com.lowagie.text.pdf.PdfPCell;
6 import com.lowagie.text.pdf.PdfPTable;
7 import com.lowagie.text.pdf.PdfWriter;
8 import org.kuali.ole.OLEConstants;
9 import org.kuali.ole.PropertyUtil;
10 import org.kuali.ole.deliver.circulationdesk.bo.OleCirculationDeskDetail;
11 import org.kuali.ole.deliver.loan.LoanProcessor;
12 import org.kuali.ole.deliver.request.bo.OleDeliverRequestBo;
13 import org.kuali.rice.krad.service.KRADServiceLocator;
14
15 import javax.servlet.ServletOutputStream;
16 import javax.servlet.http.HttpServletResponse;
17 import java.awt.*;
18 import java.awt.List;
19 import java.io.ByteArrayOutputStream;
20 import java.io.FileOutputStream;
21 import java.io.OutputStream;
22 import java.util.Date;
23 import java.util.HashMap;
24 import java.util.Map;
25
26
27
28
29
30
31
32
33 public class OleDeliverNoticeService {
34 private LoanProcessor loanProcessor = new LoanProcessor();
35 public LoanProcessor getLoanProcessor() {
36 return loanProcessor;
37 }
38
39 public void setLoanProcessor(LoanProcessor loanProcessor) {
40 this.loanProcessor = loanProcessor;
41 }
42 public boolean createPdf(OleNoticeBo noticeBo){
43 boolean result = false;
44 String directory = getLoanProcessor().getParameter("PDF_LOCATION");
45 OutputStream outputStream = null;
46 String fileName = noticeBo.getNoticeName()+"/"+noticeBo.getItemId();
47 try{
48 Document document = new Document(PageSize.A4);
49 outputStream = new FileOutputStream(directory+"/"+fileName+".pdf");
50 PdfWriter writer = PdfWriter.getInstance(document, outputStream);
51 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
52 Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
53 document.open();
54 document.newPage();
55
56
57
58
59 Paragraph paraGraph = new Paragraph();
60 paraGraph.add(new Chunk(noticeBo.getNoticeName(),boldFont));
61 paraGraph.add(Chunk.NEWLINE);
62 document.add(paraGraph);
63 PdfPTable pdfTable =new PdfPTable(3);
64 PdfPCell pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
65 pdfPCell.setBorder(pdfPCell.NO_BORDER);
66 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
67 pdfTable.addCell(pdfPCell);
68 pdfPCell = new PdfPCell(new Paragraph(":"));
69 pdfPCell.setBorder(pdfPCell.NO_BORDER);
70 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
71 pdfTable.addCell(pdfPCell);
72 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName())));
73 pdfPCell.setBorder(pdfPCell.NO_BORDER);
74 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
75 pdfTable.addCell(pdfPCell);
76 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
77 pdfPCell.setBorder(pdfPCell.NO_BORDER);
78 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
79 pdfTable.addCell(pdfPCell);
80 pdfPCell = new PdfPCell(new Paragraph(":"));
81 pdfPCell.setBorder(pdfPCell.NO_BORDER);
82 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
83 pdfTable.addCell(pdfPCell);
84 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskAddress())));
85 pdfPCell.setBorder(pdfPCell.NO_BORDER);
86 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
87 pdfTable.addCell(pdfPCell);
88 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
89 pdfPCell.setBorder(pdfPCell.NO_BORDER);
90 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
91 pdfTable.addCell(pdfPCell);
92 pdfPCell = new PdfPCell(new Paragraph(":"));
93 pdfPCell.setBorder(pdfPCell.NO_BORDER);
94 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
95 pdfTable.addCell(pdfPCell);
96 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskEmailAddress())));
97 pdfPCell.setBorder(pdfPCell.NO_BORDER);
98 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
99 pdfTable.addCell(pdfPCell);
100 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
101 pdfPCell.setBorder(pdfPCell.NO_BORDER);
102 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
103 pdfTable.addCell(pdfPCell);
104 pdfPCell = new PdfPCell(new Paragraph(":"));
105 pdfPCell.setBorder(pdfPCell.NO_BORDER);
106 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
107 pdfTable.addCell(pdfPCell);
108 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskPhoneNumber())));
109 pdfPCell.setBorder(pdfPCell.NO_BORDER);
110 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
111 pdfTable.addCell(pdfPCell);
112 document.add(pdfTable);
113 paraGraph = new Paragraph();
114 paraGraph.add(Chunk.NEWLINE);
115 document.add(paraGraph);
116
117
118 paraGraph = new Paragraph();
119 paraGraph.add(new Chunk("Addressee",boldFont));
120 paraGraph.add(Chunk.NEWLINE);
121 document.add(paraGraph);
122 pdfTable =new PdfPTable(3);
123 pdfPCell = new PdfPCell(new Paragraph("Borrower Name"));
124 pdfPCell.setBorder(pdfPCell.NO_BORDER);
125 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
126 pdfTable.addCell(pdfPCell);
127 pdfPCell = new PdfPCell(new Paragraph(":"));
128 pdfPCell.setBorder(pdfPCell.NO_BORDER);
129 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
130 pdfTable.addCell(pdfPCell);
131 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronName()==null?"":noticeBo.getPatronName())));
132 pdfPCell.setBorder(pdfPCell.NO_BORDER);
133 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
134 pdfTable.addCell(pdfPCell);
135 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
136 pdfPCell.setBorder(pdfPCell.NO_BORDER);
137 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
138 pdfTable.addCell(pdfPCell);
139 pdfPCell = new PdfPCell(new Paragraph(":"));
140 pdfPCell.setBorder(pdfPCell.NO_BORDER);
141 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
142 pdfTable.addCell(pdfPCell);
143 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronAddress()==null?"":noticeBo.getPatronAddress())));
144 pdfPCell.setBorder(pdfPCell.NO_BORDER);
145 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
146 pdfTable.addCell(pdfPCell);
147 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
148 pdfPCell.setBorder(pdfPCell.NO_BORDER);
149 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
150 pdfTable.addCell(pdfPCell);
151 pdfPCell = new PdfPCell(new Paragraph(":"));
152 pdfPCell.setBorder(pdfPCell.NO_BORDER);
153 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
154 pdfTable.addCell(pdfPCell);
155 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronEmailAddress()==null?"":noticeBo.getPatronEmailAddress())));
156 pdfPCell.setBorder(pdfPCell.NO_BORDER);
157 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
158 pdfTable.addCell(pdfPCell);
159 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
160 pdfPCell.setBorder(pdfPCell.NO_BORDER);
161 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
162 pdfTable.addCell(pdfPCell);
163 pdfPCell = new PdfPCell(new Paragraph(":"));
164 pdfPCell.setBorder(pdfPCell.NO_BORDER);
165 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
166 pdfTable.addCell(pdfPCell);
167 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronPhoneNumber()==null?"":noticeBo.getPatronPhoneNumber())));
168 pdfPCell.setBorder(pdfPCell.NO_BORDER);
169 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
170 pdfTable.addCell(pdfPCell);
171 document.add(pdfTable);
172 paraGraph = new Paragraph();
173 paraGraph.add(Chunk.NEWLINE);
174 document.add(paraGraph);
175
176
177 paraGraph = new Paragraph();
178 paraGraph.add(new Chunk(noticeBo.getNoticeName(),boldFont));
179 paraGraph.setAlignment(Element.ALIGN_CENTER);
180 paraGraph.add(Chunk.NEWLINE);
181 document.add(paraGraph);
182
183
184
185 paraGraph = new Paragraph();
186 paraGraph.add(new Chunk(noticeBo.getNoticeSpecificContent(),boldFont));
187 paraGraph.setAlignment(Element.ALIGN_CENTER);
188 paraGraph.add(Chunk.NEWLINE);
189 document.add(paraGraph);
190
191 paraGraph = new Paragraph();
192 paraGraph.add(new Chunk("Title/item information",boldFont));
193 paraGraph.add(Chunk.NEWLINE);
194 document.add(paraGraph);
195 pdfTable =new PdfPTable(3);
196 pdfPCell = new PdfPCell(new Paragraph("Title "));
197 pdfPCell.setBorder(pdfPCell.NO_BORDER);
198 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
199 pdfTable.addCell(pdfPCell);
200 pdfPCell = new PdfPCell(new Paragraph(":"));
201 pdfPCell.setBorder(pdfPCell.NO_BORDER);
202 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
203 pdfTable.addCell(pdfPCell);
204 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getTitle()==null?"":noticeBo.getTitle())));
205 pdfPCell.setBorder(pdfPCell.NO_BORDER);
206 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
207 pdfTable.addCell(pdfPCell);
208 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Author ")));
209 pdfPCell.setBorder(pdfPCell.NO_BORDER);
210 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
211 pdfTable.addCell(pdfPCell);
212 pdfPCell = new PdfPCell(new Paragraph(":"));
213 pdfPCell.setBorder(pdfPCell.NO_BORDER);
214 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
215 pdfTable.addCell(pdfPCell);
216 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getAuthor()==null?"":noticeBo.getAuthor())));
217 pdfPCell.setBorder(pdfPCell.NO_BORDER);
218 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
219 pdfTable.addCell(pdfPCell);
220 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Volume/Issue/Copy # ")));
221 pdfPCell.setBorder(pdfPCell.NO_BORDER);
222 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
223 pdfTable.addCell(pdfPCell);
224 pdfPCell = new PdfPCell(new Paragraph(":"));
225 pdfPCell.setBorder(pdfPCell.NO_BORDER);
226 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
227 pdfTable.addCell(pdfPCell);
228 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getVolumeNumber()==null?"":noticeBo.getVolumeNumber())));
229 pdfPCell.setBorder(pdfPCell.NO_BORDER);
230 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
231 pdfTable.addCell(pdfPCell);
232 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Library shelving location ")));
233 pdfPCell.setBorder(pdfPCell.NO_BORDER);
234 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
235 pdfTable.addCell(pdfPCell);
236 pdfPCell = new PdfPCell(new Paragraph(":"));
237 pdfPCell.setBorder(pdfPCell.NO_BORDER);
238 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
239 pdfTable.addCell(pdfPCell);
240 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemShelvingLocation()==null?"":noticeBo.getItemShelvingLocation())));
241 pdfPCell.setBorder(pdfPCell.NO_BORDER);
242 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
243 pdfTable.addCell(pdfPCell);
244 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Call # ")));
245 pdfPCell.setBorder(pdfPCell.NO_BORDER);
246 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
247 pdfTable.addCell(pdfPCell);
248 pdfPCell = new PdfPCell(new Paragraph(":"));
249 pdfPCell.setBorder(pdfPCell.NO_BORDER);
250 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
251 pdfTable.addCell(pdfPCell);
252 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemCallNumber()==null?"":noticeBo.getItemCallNumber())));
253 pdfPCell.setBorder(pdfPCell.NO_BORDER);
254 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
255 pdfTable.addCell(pdfPCell);
256 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item barcode")));
257 pdfPCell.setBorder(pdfPCell.NO_BORDER);
258 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
259 pdfTable.addCell(pdfPCell);
260 pdfPCell = new PdfPCell(new Paragraph(":"));
261 pdfPCell.setBorder(pdfPCell.NO_BORDER);
262 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
263 pdfTable.addCell(pdfPCell);
264 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemId()==null?"":noticeBo.getItemId())));
265 pdfPCell.setBorder(pdfPCell.NO_BORDER);
266 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
267 pdfTable.addCell(pdfPCell);
268 document.add(pdfTable);
269 paraGraph = new Paragraph();
270 paraGraph.add(Chunk.NEWLINE);
271 document.add(paraGraph);
272
273
274
275
276
277
278 if(noticeBo.getNoticeName().equals("Recall")){
279 pdfTable =new PdfPTable(3);
280 pdfPCell = new PdfPCell(new Paragraph("Original Due Date"));
281 pdfPCell.setBorder(pdfPCell.NO_BORDER);
282 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
283 pdfTable.addCell(pdfPCell);
284 pdfPCell = new PdfPCell(new Paragraph(":"));
285 pdfPCell.setBorder(pdfPCell.NO_BORDER);
286 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
287 pdfTable.addCell(pdfPCell);
288 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getOriginalDueDate()== null ? "":noticeBo.getOriginalDueDate().toString())));
289 pdfPCell.setBorder(pdfPCell.NO_BORDER);
290 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
291 pdfTable.addCell(pdfPCell);
292 pdfPCell = new PdfPCell(new Paragraph(new Chunk("New Due Date")));
293 pdfPCell.setBorder(pdfPCell.NO_BORDER);
294 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
295 pdfTable.addCell(pdfPCell);
296 pdfPCell = new PdfPCell(new Paragraph(":"));
297 pdfPCell.setBorder(pdfPCell.NO_BORDER);
298 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
299 pdfTable.addCell(pdfPCell);
300 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getNewDueDate()== null ? "":noticeBo.getNewDueDate().toString())));
301 pdfPCell.setBorder(pdfPCell.NO_BORDER);
302 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
303 pdfTable.addCell(pdfPCell);
304 document.add(pdfTable);
305 paraGraph = new Paragraph();
306 paraGraph.add(Chunk.NEWLINE);
307 document.add(paraGraph);
308 } else if(noticeBo.getNoticeName().equals("OnHold")){
309 pdfTable =new PdfPTable(3);
310 pdfPCell = new PdfPCell(new Paragraph("Pick Up Location"));
311 pdfPCell.setBorder(pdfPCell.NO_BORDER);
312 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
313 pdfTable.addCell(pdfPCell);
314 pdfPCell = new PdfPCell(new Paragraph(":"));
315 pdfPCell.setBorder(pdfPCell.NO_BORDER);
316 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
317 pdfTable.addCell(pdfPCell);
318 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPickUpLocation())));
319 pdfPCell.setBorder(pdfPCell.NO_BORDER);
320 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
321 pdfTable.addCell(pdfPCell);
322 pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
323 pdfPCell.setBorder(pdfPCell.NO_BORDER);
324 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
325 pdfTable.addCell(pdfPCell);
326 pdfPCell = new PdfPCell(new Paragraph(":"));
327 pdfPCell.setBorder(pdfPCell.NO_BORDER);
328 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
329 pdfTable.addCell(pdfPCell);
330 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName())));
331 pdfPCell.setBorder(pdfPCell.NO_BORDER);
332 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
333 pdfTable.addCell(pdfPCell);
334 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
335 pdfPCell.setBorder(pdfPCell.NO_BORDER);
336 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
337 pdfTable.addCell(pdfPCell);
338 pdfPCell = new PdfPCell(new Paragraph(":"));
339 pdfPCell.setBorder(pdfPCell.NO_BORDER);
340 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
341 pdfTable.addCell(pdfPCell);
342 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskAddress())));
343 pdfPCell.setBorder(pdfPCell.NO_BORDER);
344 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
345 pdfTable.addCell(pdfPCell);
346 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
347 pdfPCell.setBorder(pdfPCell.NO_BORDER);
348 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
349 pdfTable.addCell(pdfPCell);
350 pdfPCell = new PdfPCell(new Paragraph(":"));
351 pdfPCell.setBorder(pdfPCell.NO_BORDER);
352 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
353 pdfTable.addCell(pdfPCell);
354 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskEmailAddress())));
355 pdfPCell.setBorder(pdfPCell.NO_BORDER);
356 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
357 pdfTable.addCell(pdfPCell);
358 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
359 pdfPCell.setBorder(pdfPCell.NO_BORDER);
360 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
361 pdfTable.addCell(pdfPCell);
362 pdfPCell = new PdfPCell(new Paragraph(":"));
363 pdfPCell.setBorder(pdfPCell.NO_BORDER);
364 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
365 pdfTable.addCell(pdfPCell);
366 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskPhoneNumber())));
367 pdfPCell.setBorder(pdfPCell.NO_BORDER);
368 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
369 pdfTable.addCell(pdfPCell);
370 document.add(pdfTable);
371 paraGraph = new Paragraph();
372 paraGraph.add(Chunk.NEWLINE);
373 document.add(paraGraph);
374 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item Will Be Held until")));
375 pdfPCell.setBorder(pdfPCell.NO_BORDER);
376 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
377 pdfTable.addCell(pdfPCell);
378 pdfPCell = new PdfPCell(new Paragraph(":"));
379 pdfPCell.setBorder(pdfPCell.NO_BORDER);
380 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
381 pdfTable.addCell(pdfPCell);
382 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getOnHoldDueDate().toString())));
383 pdfPCell.setBorder(pdfPCell.NO_BORDER);
384 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
385 pdfTable.addCell(pdfPCell);
386 document.add(pdfTable);
387 paraGraph = new Paragraph();
388 paraGraph.add(Chunk.NEWLINE);
389 document.add(paraGraph);
390 } else if(noticeBo.getNoticeName().equals("OverdueNotice")){
391 pdfTable =new PdfPTable(3);
392 pdfPCell = new PdfPCell(new Paragraph("Item was due"));
393 pdfPCell.setBorder(pdfPCell.NO_BORDER);
394 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
395 pdfTable.addCell(pdfPCell);
396 pdfPCell = new PdfPCell(new Paragraph(":"));
397 pdfPCell.setBorder(pdfPCell.NO_BORDER);
398 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
399 pdfTable.addCell(pdfPCell);
400 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getDueDate()== null ? "":(noticeBo.getDueDate()))));
401 pdfPCell.setBorder(pdfPCell.NO_BORDER);
402 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
403 pdfTable.addCell(pdfPCell);
404 document.add(pdfTable);
405 paraGraph = new Paragraph();
406 paraGraph.add(Chunk.NEWLINE);
407 document.add(paraGraph);
408 }
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424 ver_15_normal.setColor(Color.blue);
425 ver_15_normal.setStyle(Font.UNDERLINE);
426 Anchor anchor = new Anchor("MyAccount", ver_15_normal);
427 anchor.setName("My Account");
428 String url = PropertyUtil.getPropertyUtil().getProperty("ole.rice2.url.base");
429 anchor.setReference(url+"/portal.do?channelTitle=MyAccount&channelUrl="+url+"/kr-krad/myaccountcontroller?viewId=RenewalItemView&methodToCall=start");
430 paraGraph.add(anchor);
431 paraGraph.setAlignment(Element.ALIGN_CENTER);
432 document.add(paraGraph);
433
434
435 outputStream.flush();
436 document.close();
437 outputStream.close();
438 result=true;
439 }catch (Exception ex){
440
441 }
442 return result;
443 }
444
445 public void createSlip(OleDeliverRequestBo oleDeliverRequestBo,HttpServletResponse response){
446 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
447 OutputStream outputStream = null;
448 String directory = getLoanProcessor().getParameter("PDF_LOCATION");
449
450 String fileName ="In Transit Routing slip"+oleDeliverRequestBo.getItemId();
451
452 Document document = new Document(PageSize.A4);
453 try{
454 response.setContentType("application/pdf");
455 outputStream = new FileOutputStream(directory+"/"+fileName+".pdf");
456 PdfWriter writer = PdfWriter.getInstance(document, outputStream);
457 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
458 Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
459 document.open();
460 document.newPage();
461 PdfPTable pdfTable =new PdfPTable(3);
462 Paragraph paraGraph = new Paragraph();
463 paraGraph.setAlignment(Element.ALIGN_CENTER);
464 paraGraph.add(new Chunk("Routing Slip In-Transit Per Staff Request",boldFont));
465 paraGraph.add(Chunk.NEWLINE);
466 paraGraph.add(Chunk.NEWLINE);
467 paraGraph.add(Chunk.NEWLINE);
468 pdfTable.addCell(getPdfPCellInJustified("Route To"));
469 pdfTable.addCell(getPdfPCellInLeft(":"));
470 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCirculationLocationId()));
471
472 pdfTable.addCell(getPdfPCellInJustified("Requested By"));
473 pdfTable.addCell(getPdfPCellInLeft(":"));
474 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getBorrowerId()));
475
476
477 pdfTable.addCell(getPdfPCellInJustified("Date/Time "));
478 pdfTable.addCell(getPdfPCellInLeft(":"));
479 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCreateDate().toString()));
480
481 Map<String,String> operatorMap = new HashMap<String,String>();
482 operatorMap.put("operatorId",oleDeliverRequestBo.getOperatorCreateId());
483 operatorMap.put("defaultLocation","true");
484 java.util.List<OleCirculationDeskDetail> circulationDeskDetailList= (java.util.List<OleCirculationDeskDetail>) KRADServiceLocator.getBusinessObjectService().findMatching(OleCirculationDeskDetail.class, operatorMap);
485 String locationName="";
486 if(circulationDeskDetailList.size()>0){
487 locationName = circulationDeskDetailList.get(0).getOleCirculationDesk().getOleCirculationDeskLocations().get(0).getCirculationDeskLocation();
488 }
489
490
491 pdfTable.addCell(getPdfPCellInJustified("Circulation Location"));
492 pdfTable.addCell(getPdfPCellInLeft(":"));
493 pdfTable.addCell(getPdfPCellInJustified(locationName));
494
495
496
497 pdfTable.addCell(getPdfPCellInJustified("Item Barcode"));
498 pdfTable.addCell(getPdfPCellInLeft(":"));
499 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getItemId()));
500
501 pdfTable.addCell(getPdfPCellInJustified("Title"));
502 pdfTable.addCell(getPdfPCellInLeft(":"));
503 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getTitle()));
504
505 pdfTable.addCell(getPdfPCellInJustified("Call Number"));
506 pdfTable.addCell(getPdfPCellInLeft(":"));
507 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCallNumber()));
508
509 pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
510 pdfTable.addCell(getPdfPCellInLeft(":"));
511 pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCopyNumber()));
512
513
514 response.setContentType("application/pdf");
515 OutputStream os =response.getOutputStream();
516 PdfWriter.getInstance(document, os);
517 document.open();
518 document.add(paraGraph);
519 document.add(pdfTable);
520 document.close();
521 byteArrayOutputStream.flush();
522 byteArrayOutputStream.close();
523 os.flush();
524 os.close();
525 }catch(Exception e){
526
527 }
528 }
529 private PdfPCell getPdfPCellInJustified(String chunk){
530 PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
531 pdfPCell.setBorder(pdfPCell.NO_BORDER);
532 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
533 return pdfPCell;
534 }
535 private PdfPCell getPdfPCellInLeft(String chunk){
536 PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
537 pdfPCell.setBorder(pdfPCell.NO_BORDER);
538 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
539 return pdfPCell;
540 }
541
542
543 }