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.apache.log4j.Logger;
9 import org.kuali.ole.OLEConstants;
10 import org.kuali.ole.PropertyUtil;
11 import org.kuali.ole.deliver.loan.LoanProcessor;
12
13 import java.awt.*;
14 import java.io.File;
15 import java.io.FileOutputStream;
16 import java.io.OutputStream;
17 import java.util.*;
18 import java.util.List;
19
20
21
22
23
24
25
26
27 public class OleDeliverBatchServiceImpl {
28
29 private LoanProcessor loanProcessor;
30 private Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
31 private Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
32
33 private static final Logger LOG = Logger.getLogger(OleDeliverBatchServiceImpl.class);
34
35
36
37
38
39
40 private LoanProcessor getLoanProcessor() {
41 if (loanProcessor == null) {
42 loanProcessor = new LoanProcessor();
43 }
44 return loanProcessor;
45 }
46
47 private void getHTMLHeader(StringBuffer stringBuffer, String title) throws Exception {
48 stringBuffer.append("<HTML>");
49 stringBuffer.append("<TITLE>" + title + "</TITLE>");
50 stringBuffer.append("<HEAD></HEAD>");
51 stringBuffer.append("<BODY>");
52 }
53
54 private void getTemplateHeader(OleNoticeBo noticeBo, StringBuffer stringBuffer) throws Exception {
55
56 stringBuffer.append("<TABLE></BR></BR>");
57 stringBuffer.append("<TR><TD>Patron Name :</TD><TD>" + noticeBo.getPatronName() + "</TD></TR>");
58 stringBuffer.append("<TR><TD>Address :</TD><TD>" + noticeBo.getPatronAddress() + "</TD></TR>");
59 stringBuffer.append("<TR><TD>EMAIL :</TD><TD>" + noticeBo.getPatronEmailAddress() + "</TD></TR>");
60 stringBuffer.append("<TR><TD>Phone Number :</TD><TD>" + noticeBo.getPatronPhoneNumber() + "</TD></TR>");
61 stringBuffer.append("</TABLE>");
62 }
63
64 private void getTemplateBody(StringBuffer stringBuffer, String title, String body) throws Exception {
65 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
66 stringBuffer.append("<TABLE width=\"100%\">");
67 stringBuffer.append("<TR><TD><CENTER>" + title + "</CENTER></TD></TR>");
68 stringBuffer.append("<TR><TD><p>" + body + "</p></TD></TR>");
69 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");
70 }
71
72 private void getTemplateFooter(OleNoticeBo noticeBo, StringBuffer stringBuffer) throws Exception {
73 stringBuffer.append("<TABLE><TR><TD>Circulation Location/Library Name :</TD><TD>" + noticeBo.getCirculationDeskName() + "</TD><TD> </TD><TD>Title :</TD><TD>" + noticeBo.getTitle() + "</TD></TR>");
74 stringBuffer.append("<TR><TD>Address :</TD><TD>" + noticeBo.getPatronAddress() + "</TD><TD> </TD><TD>Author :</TD><TD>" + noticeBo.getAuthor() + "</TD></TR>");
75 stringBuffer.append("<TR><TD>Email :</TD><TD>" + noticeBo.getPatronEmailAddress() + "</TD><TD> </TD><TD>Volume/Issue/Copy Number :</TD><TD>" + noticeBo.getVolumeNumber() + "</TD></TR>");
76 stringBuffer.append("<TR><TD>Phone Number :</TD><TD>" + noticeBo.getPatronPhoneNumber() + "</TD><TD> </TD><TD>Library shelving location :</TD><TD>" + noticeBo.getItemShelvingLocation() + "</TD></TR>");
77 stringBuffer.append("<TR><TD> </TD><TD> </TD><TD> </TD><TD>Call Number :</TD><TD>" + noticeBo.getItemCallNumber() + "</TD></TR>");
78 stringBuffer.append("<TR><TD> </TD><TD> </TD><TD> </TD><TD>Item Barcode :</TD><TD>" + noticeBo.getItemId() + "</TD></TR>");
79 if (noticeBo.getNoticeName().equalsIgnoreCase("Overdue")) {
80 stringBuffer.append("<TR><TD> </TD><TD> </TD><TD> </TD><TD>Item was due :</TD><TD>" + noticeBo.getDueDate() + "</TD></TR>");
81 }
82 if (noticeBo.getNoticeName().equalsIgnoreCase("Recall")) {
83 stringBuffer.append("<TR><TD> </TD><TD> </TD><TD> </TD><TD>Original due date:</TD><TD>" + noticeBo.getOriginalDueDate() + "</TD></TR>");
84 stringBuffer.append("<TR><TD> </TD><TD> </TD><TD> </TD><TD>New due date:</TD><TD>" + noticeBo.getNewDueDate() + "</TD></TR>");
85 }
86 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
87 }
88
89 private void getPickUpLocationTemplate(OleNoticeBo noticeBo, StringBuffer stringBuffer) throws Exception {
90
91 stringBuffer.append("<TR><TD>Pick up location :</TD><TD></TD></TR>");
92 stringBuffer.append("<TR><TD>Circulation Location/Library Name :</TD><TD>" + noticeBo.getCirculationDeskName() + "</TD></TR>");
93 stringBuffer.append("<TR><TD>Address :</TD><TD>" + noticeBo.getCirculationDeskAddress() + "</TD></TR>");
94 stringBuffer.append("<TR><TD>Email :</TD><TD>" + noticeBo.getCirculationDeskEmailAddress() + "</TD></TR>");
95 stringBuffer.append("<TR><TD>Phone Number :</TD><TD>" + noticeBo.getCirculationDeskPhoneNumber() + "</TD></TR>");
96 stringBuffer.append("<TR><TD>Item will be held until</TD><TD>" + noticeBo.getDueDate() + "</TD></TR>");
97 }
98
99 private void getHTMLFooter(StringBuffer stringBuffer) throws Exception {
100 stringBuffer.append("</TABLE></BODY></HTML>");
101 }
102
103 private Map getSMSTemplate(List<OleNoticeBo> noticeBo) throws Exception {
104 List<OleNoticeBo> overDueNoticeList = new ArrayList<OleNoticeBo>();
105 List<OleNoticeBo> onHoldNoticeList = new ArrayList<OleNoticeBo>();
106 List<OleNoticeBo> recallNoticeList = new ArrayList<OleNoticeBo>();
107 List<OleNoticeBo> expiredNoticeList = new ArrayList<OleNoticeBo>();
108 List<OleNoticeBo> expiredRequiredNoticeList = new ArrayList<OleNoticeBo>();
109 Map smsMap = new HashMap();
110 for (int temp = 0; temp < noticeBo.size(); temp++) {
111 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
112 overDueNoticeList.add(noticeBo.get(temp));
113 }
114 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
115 onHoldNoticeList.add(noticeBo.get(temp));
116 }
117 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.RECALL)) {
118 recallNoticeList.add(noticeBo.get(temp));
119 }
120 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) {
121 expiredNoticeList.add(noticeBo.get(temp));
122 }
123 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST)) {
124 expiredRequiredNoticeList.add(noticeBo.get(temp));
125 }
126 }
127 Map overdue = new HashMap();
128 if (overDueNoticeList != null && overDueNoticeList.size() > 0) {
129 overdue = getOverDueList(overdue, overDueNoticeList);
130 }
131 Map hod = new HashMap();
132 if (onHoldNoticeList != null && onHoldNoticeList.size() > 0) {
133 hod = getHoldList(hod, onHoldNoticeList);
134 }
135 Map recl = new HashMap();
136 if (recallNoticeList != null && recallNoticeList.size() > 0) {
137 recl = getRecallList(recl, recallNoticeList);
138 }
139 Map exp = new HashMap();
140 if (expiredNoticeList != null && expiredNoticeList.size() > 0) {
141 exp = getExpiredList(exp, expiredNoticeList);
142 }
143 Map expReq = new HashMap();
144 if (expiredRequiredNoticeList != null && expiredRequiredNoticeList.size() > 0) {
145 expReq = getExpiredRequiredList(expReq, expiredRequiredNoticeList);
146 }
147
148 smsMap.put("OVERDUE", overdue);
149 smsMap.put("HOLD", hod);
150 smsMap.put("RECALL", recl);
151 smsMap.put("EXPIRED", exp);
152 smsMap.put("EXPIREDREQ", expReq);
153 return smsMap;
154 }
155
156 private Map getExpiredRequiredList(Map expReq, List expiredRequiredNoticeList) throws Exception {
157 String smsExpiredReq = "";
158 LoanProcessor loanProcessor = getLoanProcessor();
159 for (int exReq = 0; exReq < expiredRequiredNoticeList.size(); exReq++) {
160 OleNoticeBo oleNoticeBo = (OleNoticeBo) expiredRequiredNoticeList.get(exReq);
161 smsExpiredReq = loanProcessor.getParameter("EXP_REQ_TITLE") + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item was due :" + oleNoticeBo.getDueDate();
162 expReq.put(exReq, smsExpiredReq);
163 }
164 return expReq;
165 }
166
167 private Map getExpiredList(Map expire, List expiredNoticeList) throws Exception {
168 String smsExpire = "";
169 LoanProcessor loanProcessor = getLoanProcessor();
170 for (int exp = 0; exp < expiredNoticeList.size(); exp++) {
171 OleNoticeBo oleNoticeBo = (OleNoticeBo) expiredNoticeList.get(exp);
172 smsExpire = loanProcessor.getParameter("EXPIRED_TITLE") + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item was due :" + oleNoticeBo.getDueDate();
173 expire.put(exp, smsExpire);
174 }
175 return expire;
176 }
177
178 private Map getRecallList(Map rcall, List recallNoticeList) throws Exception {
179 String smsRecall = "";
180 LoanProcessor loanProcessor = getLoanProcessor();
181 for (int recall = 0; recall < recallNoticeList.size(); recall++) {
182 OleNoticeBo oleNoticeBo = (OleNoticeBo) recallNoticeList.get(recall);
183 smsRecall = loanProcessor.getParameter("RECALL_TITLE") + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Original due date :" + oleNoticeBo.getDueDate() + ",New due date: " + oleNoticeBo.getNewDueDate();
184 rcall.put(recall, smsRecall);
185 }
186 return rcall;
187 }
188
189 private Map getHoldList(Map hod, List onHoldNoticeList) throws Exception {
190 String smsHod = "";
191 LoanProcessor loanProcessor = getLoanProcessor();
192 for (int hold = 0; hold < onHoldNoticeList.size(); hold++) {
193 OleNoticeBo oleNoticeBo = (OleNoticeBo) onHoldNoticeList.get(hold);
194 smsHod = loanProcessor.getParameter("ONHOLD_TITLE") + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item will be held until :" + oleNoticeBo.getDueDate() + ",Pick up location:" + oleNoticeBo.getCirculationDeskName() + ",Pick up location Address :" + oleNoticeBo.getCirculationDeskAddress();
195 hod.put(hold, smsHod);
196 }
197 return hod;
198 }
199
200
201 private Map getOverDueList(Map overdue, List overDueNoticeList) throws Exception {
202 String smsDue = "";
203 LoanProcessor loanProcessor = getLoanProcessor();
204 for (int due = 0; due < overDueNoticeList.size(); due++) {
205 OleNoticeBo oleNoticeBo = (OleNoticeBo) overDueNoticeList.get(due);
206 smsDue = loanProcessor.getParameter("OVERDUE_TITLE") + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item was due :" + oleNoticeBo.getDueDate();
207 overdue.put(due, smsDue);
208 }
209
210 return overdue;
211 }
212
213 private List getTemplate(List<OleNoticeBo> noticeBo) throws Exception {
214 StringBuffer stringBuffer = new StringBuffer();
215
216 List templateForNoticeList = new ArrayList();
217 List<OleNoticeBo> overDueNoticeList = new ArrayList<OleNoticeBo>();
218 List<OleNoticeBo> onHoldNoticeList = new ArrayList<OleNoticeBo>();
219 List<OleNoticeBo> recallNoticeList = new ArrayList<OleNoticeBo>();
220 List<OleNoticeBo> expiredNoticeList = new ArrayList<OleNoticeBo>();
221 List<OleNoticeBo> expiredRequiredNoticeList = new ArrayList<OleNoticeBo>();
222 List<OleNoticeBo> courtesyNoticeList = new ArrayList<OleNoticeBo>();
223
224 for (int temp = 0; temp < noticeBo.size(); temp++) {
225 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
226 overDueNoticeList.add(noticeBo.get(temp));
227 }
228 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
229 onHoldNoticeList.add(noticeBo.get(temp));
230 }
231 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.RECALL)) {
232 recallNoticeList.add(noticeBo.get(temp));
233 }
234 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) {
235 expiredNoticeList.add(noticeBo.get(temp));
236 }
237 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST)) {
238 expiredRequiredNoticeList.add(noticeBo.get(temp));
239 }
240 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_COURTESY)) {
241 courtesyNoticeList.add(noticeBo.get(temp));
242 }
243 }
244 LoanProcessor loanProcessor = getLoanProcessor();
245
246 if (overDueNoticeList != null && overDueNoticeList.size() > 0) {
247 getHTMLHeader(stringBuffer, loanProcessor.getParameter("OVERDUE_TITLE"));
248 getTemplateHeader(overDueNoticeList.get(0), stringBuffer);
249 getTemplateBody(stringBuffer, loanProcessor.getParameter("OVERDUE_TITLE"), loanProcessor.getParameter("OVERDUE_BODY"));
250 for (int overdue = 0; overdue < overDueNoticeList.size(); overdue++) {
251 getTemplateFooter(noticeBo.get(overdue), stringBuffer);
252 }
253 getHTMLFooter(stringBuffer);
254 }
255
256 if (onHoldNoticeList != null && onHoldNoticeList.size() > 0) {
257 getHTMLHeader(stringBuffer, loanProcessor.getParameter("ONHOLD_TITLE"));
258 getTemplateHeader(onHoldNoticeList.get(0), stringBuffer);
259 getTemplateBody(stringBuffer, loanProcessor.getParameter("ONHOLD_TITLE"), loanProcessor.getParameter("ONHOLD_BODY"));
260 for (int onHold = 0; onHold < onHoldNoticeList.size(); onHold++) {
261 getTemplateFooter(noticeBo.get(onHold), stringBuffer);
262 getPickUpLocationTemplate(noticeBo.get(onHold), stringBuffer);
263 }
264 getHTMLFooter(stringBuffer);
265 }
266
267 if (recallNoticeList != null && recallNoticeList.size() > 0) {
268 getHTMLHeader(stringBuffer, loanProcessor.getParameter("RECALL_TITLE"));
269 getTemplateHeader(recallNoticeList.get(0), stringBuffer);
270 getTemplateBody(stringBuffer, loanProcessor.getParameter("RECALL_TITLE"), loanProcessor.getParameter("RECALL_BODY"));
271 for (int recall = 0; recall < recallNoticeList.size(); recall++) {
272 getTemplateFooter(noticeBo.get(recall), stringBuffer);
273 }
274 getHTMLFooter(stringBuffer);
275 }
276
277 if (expiredNoticeList != null && expiredNoticeList.size() > 0) {
278 getHTMLHeader(stringBuffer, loanProcessor.getParameter("EXPIRED_TITLE"));
279 getTemplateHeader(expiredNoticeList.get(0), stringBuffer);
280 getTemplateBody(stringBuffer, loanProcessor.getParameter("EXPIRED_TITLE"), loanProcessor.getParameter("EXPIRED_BODY"));
281 for (int exp = 0; exp < expiredNoticeList.size(); exp++) {
282 getTemplateFooter(noticeBo.get(exp), stringBuffer);
283 }
284 getHTMLFooter(stringBuffer);
285 }
286
287 if (expiredRequiredNoticeList != null && expiredRequiredNoticeList.size() > 0) {
288 getHTMLHeader(stringBuffer, loanProcessor.getParameter("EXP_REQ_TITLE"));
289 getTemplateHeader(expiredRequiredNoticeList.get(0), stringBuffer);
290 getTemplateBody(stringBuffer, loanProcessor.getParameter("EXP_REQ_TITLE"), loanProcessor.getParameter("EXP_REQ_BODY"));
291 for (int exReq = 0; exReq < expiredRequiredNoticeList.size(); exReq++) {
292 getTemplateFooter(noticeBo.get(exReq), stringBuffer);
293 }
294 getHTMLFooter(stringBuffer);
295 }
296 if (courtesyNoticeList != null && courtesyNoticeList.size() > 0) {
297 getHTMLHeader(stringBuffer, loanProcessor.getParameter("COURTESY_TITLE"));
298 getTemplateHeader(courtesyNoticeList.get(0), stringBuffer);
299 getTemplateBody(stringBuffer, loanProcessor.getParameter("COURTESY_TITLE"), loanProcessor.getParameter("COURTESY_BODY"));
300 for (int exReq = 0; exReq < courtesyNoticeList.size(); exReq++) {
301 getTemplateFooter(noticeBo.get(exReq), stringBuffer);
302 }
303 getHTMLFooter(stringBuffer);
304 }
305
306
307 templateForNoticeList.add(stringBuffer);
308
309 return templateForNoticeList;
310 }
311
312 private OutputStream getPdfHeader(Document document, OutputStream outputStream, String title, String itemId) throws Exception {
313 StringBuffer stringBuffer = new StringBuffer();
314 String pdfLocationSystemParam = getLoanProcessor().getParameter("PDF_LOCATION");
315 if (LOG.isInfoEnabled()) {
316 LOG.info("System Parameter for PDF_Location --> " + pdfLocationSystemParam);
317 }
318 if (pdfLocationSystemParam == null || pdfLocationSystemParam.trim().isEmpty()) {
319 pdfLocationSystemParam = PropertyUtil.getPropertyUtil().getProperty("staging.directory") + "/";
320 if (LOG.isInfoEnabled()) {
321 LOG.info("System Parameter for PDF_Location staging dir--> " + pdfLocationSystemParam);
322 }
323 } else{
324 pdfLocationSystemParam = PropertyUtil.getPropertyUtil().getProperty("homeDirectory")+ "/" + pdfLocationSystemParam +"/";
325 }
326 boolean locationExist = new File(pdfLocationSystemParam).exists();
327 boolean fileCreated = false;
328 if (LOG.isInfoEnabled()) {
329 LOG.info("Is directory Exist ::" + locationExist);
330 }
331 try {
332 if (!locationExist) {
333 fileCreated = new File(pdfLocationSystemParam).mkdirs();
334 if (!fileCreated) {
335 throw new RuntimeException("Not Able to create directory :" + pdfLocationSystemParam);
336 }
337 }
338 } catch (Exception e) {
339 LOG.error("Exception occured while creating the directory : " + e.getMessage());
340 throw e;
341 }
342
343 if (title == null || title.trim().isEmpty()) {
344 title = OLEConstants.ITEM_TITLE;
345 }
346 title = title.replaceAll(" ", "_");
347
348 if (itemId == null || itemId.trim().isEmpty()) {
349 itemId = OLEConstants.ITEM_ID;
350 }
351 String fileName = pdfLocationSystemParam + title + "_" + itemId + "_" + new Date(System.currentTimeMillis()) + ".pdf";
352 if (LOG.isInfoEnabled()) {
353 LOG.info("File Created :" + title + "file name ::" + fileName + "::");
354 }
355 outputStream = new FileOutputStream(fileName);
356 PdfWriter writer = PdfWriter.getInstance(document, outputStream);
357 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
358 Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
359 document.open();
360 document.newPage();
361 Paragraph paraGraph = new Paragraph();
362 paraGraph.setAlignment(Element.ALIGN_CENTER);
363 paraGraph.add(new Chunk(title, boldFont));
364 paraGraph.add(Chunk.NEWLINE);
365 document.add(paraGraph);
366 return outputStream;
367 }
368
369
370 private void getPdfTemplateHeader(OleNoticeBo noticeBo, Document document) throws Exception {
371 LOG.info("Header for the notice" + noticeBo.getNoticeName() + noticeBo.getItemId());
372 PdfPTable pdfTable = new PdfPTable(3);
373 PdfPCell pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
374 pdfPCell.setBorder(pdfPCell.NO_BORDER);
375 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
376 pdfTable.addCell(pdfPCell);
377 pdfPCell = new PdfPCell(new Paragraph(":"));
378 pdfPCell.setBorder(pdfPCell.NO_BORDER);
379 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
380 pdfTable.addCell(pdfPCell);
381 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "")));
382 pdfPCell.setBorder(pdfPCell.NO_BORDER);
383 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
384 pdfTable.addCell(pdfPCell);
385 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
386 pdfPCell.setBorder(pdfPCell.NO_BORDER);
387 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
388 pdfTable.addCell(pdfPCell);
389 pdfPCell = new PdfPCell(new Paragraph(":"));
390 pdfPCell.setBorder(pdfPCell.NO_BORDER);
391 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
392 pdfTable.addCell(pdfPCell);
393 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronAddress() != null ? noticeBo.getPatronAddress() : "")));
394 pdfPCell.setBorder(pdfPCell.NO_BORDER);
395 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
396 pdfTable.addCell(pdfPCell);
397 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
398 pdfPCell.setBorder(pdfPCell.NO_BORDER);
399 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
400 pdfTable.addCell(pdfPCell);
401 pdfPCell = new PdfPCell(new Paragraph(":"));
402 pdfPCell.setBorder(pdfPCell.NO_BORDER);
403 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
404 pdfTable.addCell(pdfPCell);
405 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronEmailAddress() != null ? noticeBo.getPatronEmailAddress() : "")));
406 pdfPCell.setBorder(pdfPCell.NO_BORDER);
407 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
408 pdfTable.addCell(pdfPCell);
409 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
410 pdfPCell.setBorder(pdfPCell.NO_BORDER);
411 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
412 pdfTable.addCell(pdfPCell);
413 pdfPCell = new PdfPCell(new Paragraph(":"));
414 pdfPCell.setBorder(pdfPCell.NO_BORDER);
415 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
416 pdfTable.addCell(pdfPCell);
417 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronPhoneNumber() != null ? noticeBo.getPatronPhoneNumber() : "")));
418 pdfPCell.setBorder(pdfPCell.NO_BORDER);
419 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
420 pdfTable.addCell(pdfPCell);
421 document.add(pdfTable);
422 Paragraph paraGraph = new Paragraph();
423 paraGraph.add(Chunk.NEWLINE);
424 document.add(paraGraph);
425 paraGraph = new Paragraph();
426 paraGraph.add(new Chunk("Patron information", boldFont));
427 paraGraph.add(Chunk.NEWLINE);
428 document.add(paraGraph);
429
430 pdfTable = new PdfPTable(3);
431 pdfPCell = new PdfPCell(new Paragraph("Patron Name"));
432 pdfPCell.setBorder(pdfPCell.NO_BORDER);
433 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
434 pdfTable.addCell(pdfPCell);
435 pdfPCell = new PdfPCell(new Paragraph(":"));
436 pdfPCell.setBorder(pdfPCell.NO_BORDER);
437 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
438 pdfTable.addCell(pdfPCell);
439 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronName() != null ? noticeBo.getPatronName() : "")));
440 pdfPCell.setBorder(pdfPCell.NO_BORDER);
441 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
442 pdfTable.addCell(pdfPCell);
443 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
444 pdfPCell.setBorder(pdfPCell.NO_BORDER);
445 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
446 pdfTable.addCell(pdfPCell);
447 pdfPCell = new PdfPCell(new Paragraph(":"));
448 pdfPCell.setBorder(pdfPCell.NO_BORDER);
449 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
450 pdfTable.addCell(pdfPCell);
451 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronAddress() != null ? noticeBo.getPatronAddress() : "")));
452 pdfPCell.setBorder(pdfPCell.NO_BORDER);
453 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
454 pdfTable.addCell(pdfPCell);
455 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
456 pdfPCell.setBorder(pdfPCell.NO_BORDER);
457 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
458 pdfTable.addCell(pdfPCell);
459 pdfPCell = new PdfPCell(new Paragraph(":"));
460 pdfPCell.setBorder(pdfPCell.NO_BORDER);
461 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
462 pdfTable.addCell(pdfPCell);
463 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronEmailAddress() != null ? noticeBo.getPatronEmailAddress() : "")));
464 pdfPCell.setBorder(pdfPCell.NO_BORDER);
465 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
466 pdfTable.addCell(pdfPCell);
467 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
468 pdfPCell.setBorder(pdfPCell.NO_BORDER);
469 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
470 pdfTable.addCell(pdfPCell);
471 pdfPCell = new PdfPCell(new Paragraph(":"));
472 pdfPCell.setBorder(pdfPCell.NO_BORDER);
473 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
474 pdfTable.addCell(pdfPCell);
475 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronPhoneNumber() != null ? noticeBo.getPatronPhoneNumber() : "")));
476 pdfPCell.setBorder(pdfPCell.NO_BORDER);
477 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
478 pdfTable.addCell(pdfPCell);
479 document.add(pdfTable);
480 paraGraph = new Paragraph();
481 paraGraph.add(Chunk.NEWLINE);
482 document.add(paraGraph);
483
484
485 }
486
487 private void getPdfTemplateBody(Document document, String title, String body) throws Exception {
488
489 LOG.info("Body Content of the notice :" + title);
490 Paragraph paraGraph = new Paragraph();
491 paraGraph.add(new Chunk(title, boldFont));
492 paraGraph.setAlignment(Element.ALIGN_CENTER);
493 paraGraph.add(Chunk.NEWLINE);
494 document.add(paraGraph);
495
496
497
498 paraGraph = new Paragraph();
499 paraGraph.add(new Chunk(body, boldFont));
500 paraGraph.setAlignment(Element.ALIGN_CENTER);
501 paraGraph.add(Chunk.NEWLINE);
502 document.add(paraGraph);
503 }
504
505 private void getPdfTemplateFooter(OleNoticeBo noticeBo, Document document) throws Exception {
506 LOG.info("Footer for the notice : " + noticeBo.getNoticeName() + noticeBo.getItemId());
507 Paragraph paraGraph = new Paragraph();
508 paraGraph.add(new Chunk("Title/item information", boldFont));
509 paraGraph.add(Chunk.NEWLINE);
510 document.add(paraGraph);
511 PdfPTable pdfTable = new PdfPTable(3);
512 PdfPCell pdfPCell = new PdfPCell(new Paragraph("Title "));
513 pdfPCell.setBorder(pdfPCell.NO_BORDER);
514 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
515 pdfTable.addCell(pdfPCell);
516 pdfPCell = new PdfPCell(new Paragraph(":"));
517 pdfPCell.setBorder(pdfPCell.NO_BORDER);
518 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
519 pdfTable.addCell(pdfPCell);
520 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getTitle() == null ? "" : noticeBo.getTitle())));
521 pdfPCell.setBorder(pdfPCell.NO_BORDER);
522 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
523 pdfTable.addCell(pdfPCell);
524 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Author ")));
525 pdfPCell.setBorder(pdfPCell.NO_BORDER);
526 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
527 pdfTable.addCell(pdfPCell);
528 pdfPCell = new PdfPCell(new Paragraph(":"));
529 pdfPCell.setBorder(pdfPCell.NO_BORDER);
530 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
531 pdfTable.addCell(pdfPCell);
532 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getAuthor() == null ? "" : noticeBo.getAuthor())));
533 pdfPCell.setBorder(pdfPCell.NO_BORDER);
534 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
535 pdfTable.addCell(pdfPCell);
536 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Volume/Issue/Copy # ")));
537 pdfPCell.setBorder(pdfPCell.NO_BORDER);
538 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
539 pdfTable.addCell(pdfPCell);
540 pdfPCell = new PdfPCell(new Paragraph(":"));
541 pdfPCell.setBorder(pdfPCell.NO_BORDER);
542 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
543 pdfTable.addCell(pdfPCell);
544 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getVolumeNumber() == null ? "" : noticeBo.getVolumeNumber())));
545 pdfPCell.setBorder(pdfPCell.NO_BORDER);
546 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
547 pdfTable.addCell(pdfPCell);
548 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Library shelving location ")));
549 pdfPCell.setBorder(pdfPCell.NO_BORDER);
550 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
551 pdfTable.addCell(pdfPCell);
552 pdfPCell = new PdfPCell(new Paragraph(":"));
553 pdfPCell.setBorder(pdfPCell.NO_BORDER);
554 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
555 pdfTable.addCell(pdfPCell);
556 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemShelvingLocation() == null ? "" : noticeBo.getItemShelvingLocation())));
557 pdfPCell.setBorder(pdfPCell.NO_BORDER);
558 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
559 pdfTable.addCell(pdfPCell);
560 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Call # ")));
561 pdfPCell.setBorder(pdfPCell.NO_BORDER);
562 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
563 pdfTable.addCell(pdfPCell);
564 pdfPCell = new PdfPCell(new Paragraph(":"));
565 pdfPCell.setBorder(pdfPCell.NO_BORDER);
566 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
567 pdfTable.addCell(pdfPCell);
568 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemCallNumber() == null ? "" : noticeBo.getItemCallNumber())));
569 pdfPCell.setBorder(pdfPCell.NO_BORDER);
570 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
571 pdfTable.addCell(pdfPCell);
572 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item barcode")));
573 pdfPCell.setBorder(pdfPCell.NO_BORDER);
574 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
575 pdfTable.addCell(pdfPCell);
576 pdfPCell = new PdfPCell(new Paragraph(":"));
577 pdfPCell.setBorder(pdfPCell.NO_BORDER);
578 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
579 pdfTable.addCell(pdfPCell);
580 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemId() == null ? "" : noticeBo.getItemId())));
581 pdfPCell.setBorder(pdfPCell.NO_BORDER);
582 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
583 pdfTable.addCell(pdfPCell);
584 document.add(pdfTable);
585 paraGraph = new Paragraph();
586 paraGraph.add(Chunk.NEWLINE);
587 document.add(paraGraph);
588
589
590
591
592
593
594 if (noticeBo.getNoticeName().equals(OLEConstants.NOTICE_RECALL)) {
595 LOG.info("Recall Notice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
596 pdfTable = new PdfPTable(3);
597 pdfPCell = new PdfPCell(new Paragraph("Original Due Date"));
598 pdfPCell.setBorder(pdfPCell.NO_BORDER);
599 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
600 pdfTable.addCell(pdfPCell);
601 pdfPCell = new PdfPCell(new Paragraph(":"));
602 pdfPCell.setBorder(pdfPCell.NO_BORDER);
603 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
604 pdfTable.addCell(pdfPCell);
605 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getOriginalDueDate() == null ? "" : noticeBo.getOriginalDueDate().toString())));
606 pdfPCell.setBorder(pdfPCell.NO_BORDER);
607 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
608 pdfTable.addCell(pdfPCell);
609 pdfPCell = new PdfPCell(new Paragraph(new Chunk("New Due Date")));
610 pdfPCell.setBorder(pdfPCell.NO_BORDER);
611 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
612 pdfTable.addCell(pdfPCell);
613 pdfPCell = new PdfPCell(new Paragraph(":"));
614 pdfPCell.setBorder(pdfPCell.NO_BORDER);
615 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
616 pdfTable.addCell(pdfPCell);
617 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getNewDueDate() == null ? "" : noticeBo.getNewDueDate().toString())));
618 pdfPCell.setBorder(pdfPCell.NO_BORDER);
619 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
620 pdfTable.addCell(pdfPCell);
621 document.add(pdfTable);
622 paraGraph = new Paragraph();
623 paraGraph.add(Chunk.NEWLINE);
624 document.add(paraGraph);
625 } else if (noticeBo.getNoticeName().equals("OnHold")) {
626 LOG.info("OnHold Notice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
627 pdfTable = new PdfPTable(3);
628 pdfPCell = new PdfPCell(new Paragraph("Pick Up Location"));
629 pdfPCell.setBorder(pdfPCell.NO_BORDER);
630 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
631 pdfTable.addCell(pdfPCell);
632 pdfPCell = new PdfPCell(new Paragraph(":"));
633 pdfPCell.setBorder(pdfPCell.NO_BORDER);
634 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
635 pdfTable.addCell(pdfPCell);
636 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPickUpLocation() != null ? noticeBo.getPickUpLocation() : "")));
637 pdfPCell.setBorder(pdfPCell.NO_BORDER);
638 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
639 pdfTable.addCell(pdfPCell);
640 pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
641 pdfPCell.setBorder(pdfPCell.NO_BORDER);
642 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
643 pdfTable.addCell(pdfPCell);
644 pdfPCell = new PdfPCell(new Paragraph(":"));
645 pdfPCell.setBorder(pdfPCell.NO_BORDER);
646 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
647 pdfTable.addCell(pdfPCell);
648 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "")));
649 pdfPCell.setBorder(pdfPCell.NO_BORDER);
650 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
651 pdfTable.addCell(pdfPCell);
652 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
653 pdfPCell.setBorder(pdfPCell.NO_BORDER);
654 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
655 pdfTable.addCell(pdfPCell);
656 pdfPCell = new PdfPCell(new Paragraph(":"));
657 pdfPCell.setBorder(pdfPCell.NO_BORDER);
658 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
659 pdfTable.addCell(pdfPCell);
660 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronAddress() != null ? noticeBo.getPatronAddress() : "")));
661 pdfPCell.setBorder(pdfPCell.NO_BORDER);
662 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
663 pdfTable.addCell(pdfPCell);
664 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
665 pdfPCell.setBorder(pdfPCell.NO_BORDER);
666 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
667 pdfTable.addCell(pdfPCell);
668 pdfPCell = new PdfPCell(new Paragraph(":"));
669 pdfPCell.setBorder(pdfPCell.NO_BORDER);
670 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
671 pdfTable.addCell(pdfPCell);
672 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronEmailAddress() != null ? noticeBo.getPatronEmailAddress() : "")));
673 pdfPCell.setBorder(pdfPCell.NO_BORDER);
674 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
675 pdfTable.addCell(pdfPCell);
676 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
677 pdfPCell.setBorder(pdfPCell.NO_BORDER);
678 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
679 pdfTable.addCell(pdfPCell);
680 pdfPCell = new PdfPCell(new Paragraph(":"));
681 pdfPCell.setBorder(pdfPCell.NO_BORDER);
682 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
683 pdfTable.addCell(pdfPCell);
684 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronPhoneNumber() != null ? noticeBo.getPatronPhoneNumber() : "")));
685 pdfPCell.setBorder(pdfPCell.NO_BORDER);
686 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
687 pdfTable.addCell(pdfPCell);
688 document.add(pdfTable);
689 paraGraph = new Paragraph();
690 paraGraph.add(Chunk.NEWLINE);
691 document.add(paraGraph);
692 pdfTable = new PdfPTable(3);
693 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item Will Be Held until")));
694 pdfPCell.setBorder(pdfPCell.NO_BORDER);
695 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
696 pdfTable.addCell(pdfPCell);
697 pdfPCell = new PdfPCell(new Paragraph(":"));
698 pdfPCell.setBorder(pdfPCell.NO_BORDER);
699 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
700 pdfTable.addCell(pdfPCell);
701 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getOnHoldDueDate() != null ? noticeBo.getOnHoldDueDate().toString() : "")));
702 pdfPCell.setBorder(pdfPCell.NO_BORDER);
703 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
704 pdfTable.addCell(pdfPCell);
705 document.add(pdfTable);
706 paraGraph = new Paragraph();
707 paraGraph.add(Chunk.NEWLINE);
708 document.add(paraGraph);
709 } else if (noticeBo.getNoticeName().equals("OverdueNotice")) {
710 LOG.info("OverdueNotice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
711 pdfTable = new PdfPTable(3);
712 pdfPCell = new PdfPCell(new Paragraph("Item was due"));
713 pdfPCell.setBorder(pdfPCell.NO_BORDER);
714 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
715 pdfTable.addCell(pdfPCell);
716 pdfPCell = new PdfPCell(new Paragraph(":"));
717 pdfPCell.setBorder(pdfPCell.NO_BORDER);
718 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
719 pdfTable.addCell(pdfPCell);
720 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getDueDate() == null ? "" : (noticeBo.getDueDate()))));
721 pdfPCell.setBorder(pdfPCell.NO_BORDER);
722 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
723 pdfTable.addCell(pdfPCell);
724 document.add(pdfTable);
725 paraGraph = new Paragraph();
726 paraGraph.add(Chunk.NEWLINE);
727 document.add(paraGraph);
728 }
729
730 }
731
732 private void getPdfFooter(Document document, OutputStream outputStream) throws Exception {
733 ver_15_normal.setColor(Color.blue);
734 ver_15_normal.setStyle(Font.UNDERLINE);
735 Anchor anchor = new Anchor("MyAccount", ver_15_normal);
736 anchor.setName("My Account");
737 String url = PropertyUtil.getPropertyUtil().getProperty("ole.rice2.url.base");
738 anchor.setReference(url + "/portal.do?channelTitle=MyAccount&channelUrl=" + url + "/kr-krad/myaccountcontroller?viewId=RenewalItemView&methodToCall=start");
739 Paragraph paraGraph = new Paragraph();
740 paraGraph.add(anchor);
741 paraGraph.setAlignment(Element.ALIGN_CENTER);
742 document.add(paraGraph);
743 outputStream.flush();
744 document.close();
745 outputStream.close();
746 }
747
748 public List getPdfNoticeForPatron(List<OleNoticeBo> noticeBoList) throws Exception {
749 return getPdfTemplate(noticeBoList);
750 }
751
752 private List getPdfTemplate(List<OleNoticeBo> noticeBoList) throws Exception {
753 List templateForNoticeList = new ArrayList();
754 LOG.info("In getPdfTemplate()");
755 try {
756 Document document = new Document(PageSize.A4);
757 OutputStream outputStream = null;
758
759 List<OleNoticeBo> overDueNoticeList = new ArrayList<OleNoticeBo>();
760 List<OleNoticeBo> onHoldNoticeList = new ArrayList<OleNoticeBo>();
761 List<OleNoticeBo> recallNoticeList = new ArrayList<OleNoticeBo>();
762 List<OleNoticeBo> expiredNoticeList = new ArrayList<OleNoticeBo>();
763 List<OleNoticeBo> expiredRequiredNoticeList = new ArrayList<OleNoticeBo>();
764 List<OleNoticeBo> courtesyNoticeList = new ArrayList<OleNoticeBo>();
765
766 for (int temp = 0; temp < noticeBoList.size(); temp++) {
767 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
768 overDueNoticeList.add(noticeBoList.get(temp));
769 }
770 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
771 onHoldNoticeList.add(noticeBoList.get(temp));
772 }
773 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)) {
774 recallNoticeList.add(noticeBoList.get(temp));
775 }
776 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) {
777 expiredNoticeList.add(noticeBoList.get(temp));
778 }
779 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST)) {
780 expiredRequiredNoticeList.add(noticeBoList.get(temp));
781 }
782 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_COURTESY)) {
783 courtesyNoticeList.add(noticeBoList.get(temp));
784 }
785 }
786 LoanProcessor loanProcessor = getLoanProcessor();
787
788 if (overDueNoticeList != null && overDueNoticeList.size() > 0) {
789 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter("OVERDUE_TITLE"), overDueNoticeList.get(0).getItemId());
790 getPdfTemplateHeader(overDueNoticeList.get(0), document);
791 getPdfTemplateBody(document, loanProcessor.getParameter("OVERDUE_TITLE"), loanProcessor.getParameter("OVERDUE_BODY"));
792 for (int overdue = 0; overdue < overDueNoticeList.size(); overdue++) {
793 getPdfTemplateFooter(noticeBoList.get(overdue), document);
794 }
795 getPdfFooter(document, outputStream);
796 }
797
798 if (onHoldNoticeList != null && onHoldNoticeList.size() > 0) {
799 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter("ONHOLD_TITLE"), onHoldNoticeList.get(0).getItemId());
800 getPdfTemplateHeader(onHoldNoticeList.get(0), document);
801 getPdfTemplateBody(document, loanProcessor.getParameter("ONHOLD_TITLE"), loanProcessor.getParameter("ONHOLD_BODY"));
802 for (int onHold = 0; onHold < onHoldNoticeList.size(); onHold++) {
803 getPdfTemplateFooter(noticeBoList.get(onHold), document);
804
805 }
806 getPdfFooter(document, outputStream);
807 }
808
809 if (recallNoticeList != null && recallNoticeList.size() > 0) {
810 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter("RECALL_TITLE"), recallNoticeList.get(0).getItemId());
811 getPdfTemplateHeader(recallNoticeList.get(0), document);
812 getPdfTemplateBody(document, loanProcessor.getParameter("RECALL_TITLE"), loanProcessor.getParameter("RECALL_BODY"));
813 for (int recall = 0; recall < recallNoticeList.size(); recall++) {
814 getPdfTemplateFooter(noticeBoList.get(recall), document);
815 }
816 getPdfFooter(document, outputStream);
817 }
818
819 if (expiredNoticeList != null && expiredNoticeList.size() > 0) {
820 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter("EXPIRED_TITLE"), expiredNoticeList.get(0).getItemId());
821 getPdfTemplateHeader(expiredNoticeList.get(0), document);
822 getPdfTemplateBody(document, loanProcessor.getParameter("EXPIRED_TITLE"), loanProcessor.getParameter("EXPIRED_BODY"));
823 for (int exp = 0; exp < expiredNoticeList.size(); exp++) {
824 getPdfTemplateFooter(noticeBoList.get(exp), document);
825 }
826 getPdfFooter(document, outputStream);
827 }
828
829 if (expiredRequiredNoticeList != null && expiredRequiredNoticeList.size() > 0) {
830 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter("EXP_REQ_TITLE"), expiredRequiredNoticeList.get(0).getItemId());
831 getPdfTemplateHeader(expiredRequiredNoticeList.get(0), document);
832 getPdfTemplateBody(document, loanProcessor.getParameter("EXP_REQ_TITLE"), loanProcessor.getParameter("EXP_REQ_BODY"));
833 for (int exReq = 0; exReq < expiredRequiredNoticeList.size(); exReq++) {
834 getPdfTemplateFooter(noticeBoList.get(exReq), document);
835 }
836 getPdfFooter(document, outputStream);
837 }
838 if (courtesyNoticeList != null && courtesyNoticeList.size() > 0) {
839 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter("COURTESY_TITLE"), courtesyNoticeList.get(0).getItemId());
840 getPdfTemplateHeader(courtesyNoticeList.get(0), document);
841 getPdfTemplateBody(document, loanProcessor.getParameter("COURTESY_TITLE"), loanProcessor.getParameter("COURTESY_BODY"));
842 for (int exReq = 0; exReq < courtesyNoticeList.size(); exReq++) {
843 getPdfTemplateFooter(noticeBoList.get(exReq), document);
844 }
845 getPdfFooter(document, outputStream);
846 }
847
848 } catch (Exception e) {
849 e.printStackTrace();
850 }
851
852
853 return templateForNoticeList;
854 }
855
856
857 public List getNoticeForPatron(List<OleNoticeBo> noticeBo) throws Exception {
858 return getTemplate(noticeBo);
859
860 }
861
862 public Map getSMSForPatron(List<OleNoticeBo> noticeBo) throws Exception {
863 return getSMSTemplate(noticeBo);
864 }
865
866
867 public String sendMissingNotice(OleNoticeBo oleNoticeBo) {
868
869 StringBuffer stringBuffer = new StringBuffer();
870 stringBuffer.append("<HTML>");
871 stringBuffer.append("<TITLE>" + oleNoticeBo.getNoticeName() + "</TITLE>");
872 stringBuffer.append("<HEAD><TR><TD><CENTER>" + oleNoticeBo.getNoticeName() + "</CENTER></TD></TR></HEAD>");
873 stringBuffer.append("<BODY>");
874 stringBuffer.append("<TABLE></BR></BR>");
875 stringBuffer.append("<TR><TD>Circulation Location / Library Name :</TD><TD>" + oleNoticeBo.getCirculationDeskName() + "</TD></TR>");
876 stringBuffer.append("<TR><TD>Address :</TD><TD>" + oleNoticeBo.getCirculationDeskAddress() + "</TD></TR>");
877 stringBuffer.append("<TR><TD>EMAIL :</TD><TD>" + oleNoticeBo.getCirculationDeskEmailAddress() + "</TD></TR>");
878 stringBuffer.append("<TR><TD>PhoneNumber :</TD><TD>" + oleNoticeBo.getCirculationDeskPhoneNumber() + "</TD></TR>");
879 stringBuffer.append("</TABLE>");
880 stringBuffer.append("<TABLE></BR></BR>");
881 stringBuffer.append("<TR><TD>PatronName :</TD><TD>" + oleNoticeBo.getPatronName() + "</TD></TR>");
882 stringBuffer.append("<TR><TD>Address :</TD><TD>" + oleNoticeBo.getPatronAddress() + "</TD></TR>");
883 stringBuffer.append("<TR><TD>EMAIL :</TD><TD>" + oleNoticeBo.getPatronEmailAddress() + "</TD></TR>");
884 stringBuffer.append("<TR><TD>PhoneNumber :</TD><TD>" + oleNoticeBo.getPatronPhoneNumber() + "</TD></TR>");
885 stringBuffer.append("</TABLE>");
886 stringBuffer.append("<TABLE></BR></BR>");
887 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
888 stringBuffer.append("<TABLE width=\"100%\">");
889 stringBuffer.append("<TR><TD><CENTER>" + oleNoticeBo.getNoticeName() + "</CENTER></TD></TR>");
890 stringBuffer.append("<TR><TD><p>" + oleNoticeBo.getNoticeSpecificContent() + "</p></TD></TR>");
891 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");
892 stringBuffer.append("<TABLE></BR></BR>");
893 stringBuffer.append("<TR><TD>Title :</TD><TD>" + oleNoticeBo.getTitle() + "</TD></TR>");
894 stringBuffer.append("<TR><TD>Author :</TD><TD>" + oleNoticeBo.getAuthor() + "</TD></TR>");
895 stringBuffer.append("<TR><TD>Volume/Issue/Copy # :</TD><TD>" + oleNoticeBo.getVolumeNumber() + "</TD></TR>");
896 stringBuffer.append("<TR><TD>Library shelvinglocation :</TD><TD>" + oleNoticeBo.getItemShelvingLocation() + "</TD></TR>");
897 stringBuffer.append("<TR><TD>Call #:</TD><TD>" + oleNoticeBo.getItemCallNumber() + "</TD></TR>");
898 stringBuffer.append("<TR><TD>Item barcode :</TD><TD>" + oleNoticeBo.getItemId() + "</TD></TR>");
899 stringBuffer.append("</TABLE>");
900 stringBuffer.append("</BODY>");
901 stringBuffer.append("</HTML>");
902 return stringBuffer.toString();
903 }
904
905 }