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.OLEParameterConstants;
11 import org.kuali.ole.deliver.bo.*;
12 import org.kuali.ole.deliver.processor.LoanProcessor;
13 import org.kuali.ole.deliver.service.OleDeliverRequestDocumentHelperServiceImpl;
14 import org.kuali.ole.describe.bo.OleLocation;
15 import org.kuali.ole.docstore.common.client.DocstoreClientLocator;
16 import org.kuali.ole.docstore.common.document.Bib;
17 import org.kuali.ole.docstore.common.document.Item;
18 import org.kuali.ole.docstore.common.document.ItemOleml;
19 import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
20 import org.kuali.ole.docstore.common.search.SearchResponse;
21 import org.kuali.ole.docstore.common.search.SearchResult;
22 import org.kuali.ole.docstore.common.search.SearchResultField;
23 import org.kuali.ole.sys.context.SpringContext;
24 import org.kuali.rice.core.api.config.property.ConfigContext;
25 import org.kuali.rice.kim.impl.identity.type.EntityTypeContactInfoBo;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27 import org.kuali.rice.krad.service.KRADServiceLocator;
28
29 import javax.servlet.http.HttpServletResponse;
30 import java.awt.*;
31 import java.io.File;
32 import java.io.FileOutputStream;
33 import java.io.OutputStream;
34 import java.text.SimpleDateFormat;
35 import java.util.*;
36 import java.util.List;
37
38
39
40
41
42
43
44
45 public class OleDeliverBatchServiceImpl {
46
47 private LoanProcessor loanProcessor;
48 private Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
49 private Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
50 private DocstoreClientLocator docstoreClientLocator;
51 private OutputStream overdueOutPutStream=null;
52 private Document overdueDocument=null;
53
54 public DocstoreClientLocator getDocstoreClientLocator() {
55
56 if (docstoreClientLocator == null) {
57 docstoreClientLocator = SpringContext.getBean(DocstoreClientLocator.class);
58
59 }
60 return docstoreClientLocator;
61 }
62
63
64 public void setDocstoreClientLocator(DocstoreClientLocator docstoreClientLocator) {
65 this.docstoreClientLocator = docstoreClientLocator;
66 }
67
68 public void setLoanProcessor(LoanProcessor loanProcessor) {
69 this.loanProcessor = loanProcessor;
70 }
71
72 private static final Logger LOG = Logger.getLogger(OleDeliverBatchServiceImpl.class);
73
74
75
76
77
78
79 private LoanProcessor getLoanProcessor() {
80 if (loanProcessor == null) {
81 loanProcessor = SpringContext.getBean(LoanProcessor.class);
82 }
83 return loanProcessor;
84 }
85
86 public OutputStream getOverdueOutPutStream() {
87 return overdueOutPutStream;
88 }
89
90 public void setOverdueOutPutStream(OutputStream overdueOutPutStream) {
91 this.overdueOutPutStream = overdueOutPutStream;
92 }
93
94 public Document getOverdueDocument() {
95 return overdueDocument;
96 }
97
98 public void setOverdueDocument(Document overdueDocument) {
99 this.overdueDocument = overdueDocument;
100 }
101
102 private void getHTMLHeader(StringBuffer stringBuffer, String title) throws Exception {
103 stringBuffer.append("<HTML>");
104 stringBuffer.append("<TITLE>" + title + "</TITLE>");
105 stringBuffer.append("<HEAD></HEAD>");
106 stringBuffer.append("<BODY>");
107 }
108
109 private void getTemplateHeader(OleNoticeBo noticeBo, StringBuffer stringBuffer) throws Exception {
110
111 stringBuffer.append("<TABLE></BR></BR>");
112 stringBuffer.append("<TR><TD>Patron Name :</TD><TD>" + noticeBo.getPatronName() + "</TD></TR>");
113 stringBuffer.append("<TR><TD>Address :</TD><TD>" + noticeBo.getPatronAddress() + "</TD></TR>");
114 stringBuffer.append("<TR><TD>EMAIL :</TD><TD>" + noticeBo.getPatronEmailAddress() + "</TD></TR>");
115 stringBuffer.append("<TR><TD>Phone Number :</TD><TD>" + ( noticeBo.getPatronPhoneNumber()!=null ? noticeBo.getPatronPhoneNumber() : "") + "</TD></TR>");
116 stringBuffer.append("</TABLE>");
117 }
118
119 private void getTemplateBody(StringBuffer stringBuffer, String title, String body) throws Exception {
120 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
121 stringBuffer.append("<TABLE width=\"100%\">");
122 stringBuffer.append("<TR><TD><CENTER>" + title + "</CENTER></TD></TR>");
123 stringBuffer.append("<TR><TD><p>" + body + "</p></TD></TR>");
124 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");
125 }
126
127 public BusinessObjectService getBusinessObjectService() {
128 BusinessObjectService businessObjectService = KRADServiceLocator.getBusinessObjectService();
129 return businessObjectService;
130 }
131
132 private String itemShelvingLocationName(String code) {
133 Map<String, String> criteria = new HashMap<String, String>();
134 criteria.put("locationCode", code);
135 List<OleLocation> oleLocation = (List<OleLocation>) getBusinessObjectService().findMatching(OleLocation.class, criteria);
136
137 return oleLocation.size() == 1 ? oleLocation.get(0).getLocationName() : "";
138 }
139
140 private void getTemplateFooter(OleNoticeBo noticeBo, StringBuffer stringBuffer) throws Exception {
141 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
142 stringBuffer.append("<table>");
143 if (!(noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL) || noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.CANCELLATION_NOTICE))) {
144 stringBuffer.append("<TR><TD>Circulation Location/Library Name :</TD><TD>" + (noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "") + "</TD></TR>");
145 }
146 stringBuffer.append("<TR><TD>Title :</TD><TD>" + (noticeBo.getTitle()!=null ? noticeBo.getTitle() : "") + "</TD></TR>");
147 stringBuffer.append("<TR><TD>Author :</TD><TD>" + (noticeBo.getAuthor()!=null ? noticeBo.getAuthor() : "") + "</TD></TR>");
148 if (!noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.CANCELLATION_NOTICE)){
149 stringBuffer.append("<TR><TD>Volume/Issue/Copy Number :</TD><TD>" + (noticeBo.getVolumeIssueCopyNumber()!=null ? noticeBo.getVolumeIssueCopyNumber() : "") + "</TD></TR>");
150 }
151 stringBuffer.append("<TR><TD>Library shelving location :</TD><TD>" + (itemShelvingLocationName(noticeBo.getItemShelvingLocation())!=null ? itemShelvingLocationName(noticeBo.getItemShelvingLocation()) : "" )+ "</TD></TR>");
152
153 stringBuffer.append("<TR><TD>Call Number :</TD><TD>" +(noticeBo.getItemCallNumber()!=null ? noticeBo.getItemCallNumber() : "") + "</TD></TR>");
154 stringBuffer.append("<TR><TD>Item Barcode :</TD><TD>" +(noticeBo.getItemId()!=null ? noticeBo.getItemId() : "") + "</TD></TR>");
155 if (noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
156 stringBuffer.append("<TR><TD>Item was due :</TD><TD>" +( noticeBo.getDueDate()!=null ? sdf.format(noticeBo.getDueDate()).toString() : "" )+ "</TD></TR>");
157 }
158 if (noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)) {
159 stringBuffer.append("<TR><TD>Original due date:</TD><TD>" + (noticeBo.getOriginalDueDate()!=null ? sdf.format(noticeBo.getOriginalDueDate()) : "") + "</TD></TR>");
160 stringBuffer.append("<TR><TD>New due date:</TD><TD>" + (noticeBo.getNewDueDate()!=null ? sdf.format(noticeBo.getNewDueDate()) : "") + "</TD></TR>");
161 }
162 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
163 stringBuffer.append("</table>");
164 }
165
166 private void getTemplateFooterList(List<OleNoticeBo> noticeBoList, StringBuffer stringBuffer) throws Exception {
167 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
168 for (int courtesy = 0; courtesy < noticeBoList.size(); courtesy++) {
169 stringBuffer.append("<table>");
170 if (courtesy == 0) {
171 stringBuffer.append("<TR><TD>Title/item information</TD></TR>");
172 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
173 }
174 stringBuffer.append("<TR><TD>Title :</TD><TD>" + (noticeBoList.get(courtesy).getTitle() != null ? noticeBoList.get(courtesy).getTitle() : "") + "</TD></TR>");
175 stringBuffer.append("<TR><TD>Author :</TD><TD>" + (noticeBoList.get(courtesy).getAuthor() != null ? noticeBoList.get(courtesy).getAuthor() : "") + "</TD></TR>");
176 if (!noticeBoList.get(courtesy).getNoticeName().equalsIgnoreCase(OLEConstants.CANCELLATION_NOTICE)) {
177 stringBuffer.append("<TR><TD>Volume/Issue/Copy Number :</TD><TD>" + (noticeBoList.get(courtesy).getVolumeIssueCopyNumber() != null ? noticeBoList.get(courtesy).getVolumeIssueCopyNumber() : "") + "</TD></TR>");
178 }
179 if (noticeBoList.get(courtesy).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
180 stringBuffer.append("<TR><TD>Item was due :</TD><TD>" + (noticeBoList.get(courtesy).getDueDate() != null ? sdf.format(noticeBoList.get(courtesy).getDueDate()).toString() : "") + "</TD></TR>");
181 }
182 stringBuffer.append("<TR><TD>Library shelving location :</TD><TD>" + (itemShelvingLocationName(noticeBoList.get(courtesy).getItemShelvingLocation()) != null ? itemShelvingLocationName(noticeBoList.get(courtesy).getItemShelvingLocation()) : "") + "</TD></TR>");
183 stringBuffer.append("<TR><TD>Call Number :</TD><TD>" + (noticeBoList.get(courtesy).getItemCallNumber() != null ? noticeBoList.get(courtesy).getItemCallNumber() : "") + "</TD></TR>");
184 stringBuffer.append("<TR><TD>Item Barcode :</TD><TD>" + (noticeBoList.get(courtesy).getItemId() != null ? noticeBoList.get(courtesy).getItemId() : "") + "</TD></TR>");
185 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
186 stringBuffer.append("</table>");
187 }
188 }
189
190
191 private void getPickUpLocationTemplate(OleNoticeBo noticeBo, StringBuffer stringBuffer) throws Exception {
192 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
193 stringBuffer.append("<table>");
194 stringBuffer.append("<TR><TD>Pick up location :</TD><TD></TD></TR>");
195 if (!noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)) {
196 stringBuffer.append("<TR><TD>Circulation Location/Library Name :</TD><TD>" + (noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "") + "</TD></TR>");
197 }
198 stringBuffer.append("<TR><TD>Address :</TD><TD>" + (noticeBo.getCirculationDeskAddress()!=null ? noticeBo.getCirculationDeskAddress() : "" )+ "</TD></TR>");
199 stringBuffer.append("<TR><TD>Email :</TD><TD>" + (noticeBo.getCirculationDeskEmailAddress()!=null ? noticeBo.getCirculationDeskEmailAddress() : "" )+ "</TD></TR>");
200 stringBuffer.append("<TR><TD>Phone Number :</TD><TD>" +( noticeBo.getCirculationDeskPhoneNumber()!=null ? noticeBo.getCirculationDeskPhoneNumber() : "") + "</TD></TR>");
201 if (noticeBo.getNoticeName() != null && noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
202 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
203 if(noticeBo.getExpiredOnHoldDate() != null){
204 String dateAfterFormat=dateFormat.format(noticeBo.getExpiredOnHoldDate());
205 stringBuffer.append("<TR><TD>Item will be held until</TD><TD>" + dateAfterFormat + "</TD></TR>");
206 }
207
208 } else {
209 stringBuffer.append("<TR><TD>Item will be held until</TD><TD>" +( noticeBo.getDueDate()!=null ?sdf.format( noticeBo.getDueDate()).toString() : "") + "</TD></TR>");
210 }
211 stringBuffer.append("</table>");
212 }
213
214 private void getHTMLFooter(StringBuffer stringBuffer) throws Exception {
215 String url = ConfigContext.getCurrentContextConfig().getProperty("ole.fs.url.base");
216 String myAccountURL = loanProcessor.getParameter(OLEConstants.MY_ACCOUNT_URL);
217 if(myAccountURL!=null && !myAccountURL.trim().isEmpty()){
218 stringBuffer.append("<TABLE width=\"100%\"><TR><TD><CENTER><a href = "+myAccountURL+">"+"My Account"+"</a></CENTER></TD></TR></TABLE>");
219 }
220 stringBuffer.append("</TABLE></BODY></HTML>");
221 if (LOG.isDebugEnabled()){
222 LOG.debug("MAIL HTML CONTENT : "+stringBuffer.toString());
223 }
224 }
225
226 private Map getSMSTemplate(List<OleNoticeBo> noticeBo) throws Exception {
227 List<OleNoticeBo> overDueNoticeList = new ArrayList<OleNoticeBo>();
228 List<OleNoticeBo> onHoldNoticeList = new ArrayList<OleNoticeBo>();
229 List<OleNoticeBo> recallNoticeList = new ArrayList<OleNoticeBo>();
230 List<OleNoticeBo> expiredNoticeList = new ArrayList<OleNoticeBo>();
231 List<OleNoticeBo> expiredRequiredNoticeList = new ArrayList<OleNoticeBo>();
232 Map smsMap = new HashMap();
233 for (int temp = 0; temp < noticeBo.size(); temp++) {
234 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
235 overDueNoticeList.add(noticeBo.get(temp));
236 }
237 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
238 onHoldNoticeList.add(noticeBo.get(temp));
239 }
240 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.RECALL)) {
241 recallNoticeList.add(noticeBo.get(temp));
242 }
243 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) {
244 expiredNoticeList.add(noticeBo.get(temp));
245 }
246 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST)) {
247 expiredRequiredNoticeList.add(noticeBo.get(temp));
248 }
249 }
250 Map overdue = new HashMap();
251 if (overDueNoticeList != null && overDueNoticeList.size() > 0) {
252 overdue = getOverDueList(overdue, overDueNoticeList);
253 }
254 Map hod = new HashMap();
255 if (onHoldNoticeList != null && onHoldNoticeList.size() > 0) {
256 hod = getHoldList(hod, onHoldNoticeList);
257 }
258 Map recl = new HashMap();
259 if (recallNoticeList != null && recallNoticeList.size() > 0) {
260 recl = getRecallList(recl, recallNoticeList);
261 }
262 Map exp = new HashMap();
263 if (expiredNoticeList != null && expiredNoticeList.size() > 0) {
264 exp = getExpiredList(exp, expiredNoticeList);
265 }
266 Map expReq = new HashMap();
267 if (expiredRequiredNoticeList != null && expiredRequiredNoticeList.size() > 0) {
268 expReq = getExpiredRequiredList(expReq, expiredRequiredNoticeList);
269 }
270
271 smsMap.put("OVERDUE", overdue);
272 smsMap.put("HOLD", hod);
273 smsMap.put("RECALL", recl);
274 smsMap.put("EXPIRED", exp);
275 smsMap.put("EXPIREDREQ", expReq);
276 return smsMap;
277 }
278
279 private Map getExpiredRequiredList(Map expReq, List expiredRequiredNoticeList) throws Exception {
280 String smsExpiredReq = "";
281 LoanProcessor loanProcessor = getLoanProcessor();
282 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
283 for (int exReq = 0; exReq < expiredRequiredNoticeList.size(); exReq++) {
284 OleNoticeBo oleNoticeBo = (OleNoticeBo) expiredRequiredNoticeList.get(exReq);
285 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 :" + sdf.format(oleNoticeBo.getDueDate()).toString();
286 expReq.put(exReq, smsExpiredReq);
287 }
288 return expReq;
289 }
290
291 private Map getExpiredList(Map expire, List expiredNoticeList) throws Exception {
292 String smsExpire = "";
293 LoanProcessor loanProcessor = getLoanProcessor();
294 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
295 for (int exp = 0; exp < expiredNoticeList.size(); exp++) {
296 OleNoticeBo oleNoticeBo = (OleNoticeBo) expiredNoticeList.get(exp);
297 smsExpire = loanProcessor.getParameter(OLEParameterConstants.EXPIRED_TITLE) + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item was due :" + sdf.format(oleNoticeBo.getDueDate()).toString();
298 expire.put(exp, smsExpire);
299 }
300 return expire;
301 }
302
303 private Map getRecallList(Map rcall, List recallNoticeList) throws Exception {
304 String smsRecall = "";
305 LoanProcessor loanProcessor = getLoanProcessor();
306 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
307 for (int recall = 0; recall < recallNoticeList.size(); recall++) {
308 OleNoticeBo oleNoticeBo = (OleNoticeBo) recallNoticeList.get(recall);
309 smsRecall = loanProcessor.getParameter(OLEParameterConstants.RECALL_TITLE) + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Original due date :" + sdf.format(oleNoticeBo.getDueDate()).toString() + ",New due date: " + sdf.format(oleNoticeBo.getNewDueDate());
310 rcall.put(recall, smsRecall);
311 }
312 return rcall;
313 }
314
315 private Map getHoldList(Map hod, List onHoldNoticeList) throws Exception {
316 String smsHod = "";
317 LoanProcessor loanProcessor = getLoanProcessor();
318 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
319 for (int hold = 0; hold < onHoldNoticeList.size(); hold++) {
320 OleNoticeBo oleNoticeBo = (OleNoticeBo) onHoldNoticeList.get(hold);
321 smsHod = loanProcessor.getParameter(OLEParameterConstants.ONHOLD_TITLE) + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item will be held until :" + sdf.format(oleNoticeBo.getDueDate()).toString() + ",Pick up location:" + oleNoticeBo.getCirculationDeskName() + ",Pick up location Address :" + oleNoticeBo.getCirculationDeskAddress();
322 hod.put(hold, smsHod);
323 }
324 return hod;
325 }
326
327
328 private Map getOverDueList(Map overdue, List overDueNoticeList) throws Exception {
329 String smsDue = "";
330 LoanProcessor loanProcessor = getLoanProcessor();
331 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
332 for (int due = 0; due < overDueNoticeList.size(); due++) {
333 OleNoticeBo oleNoticeBo = (OleNoticeBo) overDueNoticeList.get(due);
334 smsDue = loanProcessor.getParameter(OLEParameterConstants.OVERDUE_TITLE) + " " + "Circulation Location/Library Name :" + oleNoticeBo.getCirculationDeskName() + ",Address :" + oleNoticeBo.getCirculationDeskAddress() + ",Title :" + oleNoticeBo.getTitle() + ",Call Number :" + oleNoticeBo.getItemCallNumber() + ",Item was due :" + sdf.format(oleNoticeBo.getDueDate()).toString();
335 overdue.put(due, smsDue);
336 }
337
338 return overdue;
339 }
340
341 private List getTemplate(List<OleNoticeBo> noticeBo) throws Exception {
342 StringBuffer stringBuffer = new StringBuffer();
343
344 List templateForNoticeList = new ArrayList();
345 List<OleNoticeBo> overDueNoticeList = new ArrayList<OleNoticeBo>();
346 List<OleNoticeBo> onHoldNoticeList = new ArrayList<OleNoticeBo>();
347 List<OleNoticeBo> recallNoticeList = new ArrayList<OleNoticeBo>();
348 List<OleNoticeBo> expiredNoticeList = new ArrayList<OleNoticeBo>();
349 List<OleNoticeBo> expiredRequiredNoticeList = new ArrayList<OleNoticeBo>();
350 List<OleNoticeBo> courtesyNoticeList = new ArrayList<OleNoticeBo>();
351 List<OleNoticeBo> cancellationNoticeList = new ArrayList<OleNoticeBo>();
352
353 for (int temp = 0; temp < noticeBo.size(); temp++) {
354 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
355 overDueNoticeList.add(noticeBo.get(temp));
356 }
357 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
358 onHoldNoticeList.add(noticeBo.get(temp));
359 }
360 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase("RecallNotice")) {
361 recallNoticeList.add(noticeBo.get(temp));
362 }
363 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) {
364 expiredNoticeList.add(noticeBo.get(temp));
365 }
366 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST)) {
367 expiredRequiredNoticeList.add(noticeBo.get(temp));
368 }
369 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_COURTESY)) {
370 courtesyNoticeList.add(noticeBo.get(temp));
371 }
372 if (noticeBo.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.CANCELLATION_NOTICE)) {
373 cancellationNoticeList.add(noticeBo.get(temp));
374 }
375 }
376
377 LoanProcessor loanProcessor = getLoanProcessor();
378
379 if (overDueNoticeList != null && overDueNoticeList.size() > 0) {
380 getHTMLHeader(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.OVERDUE_TITLE));
381 getTemplateHeader(overDueNoticeList.get(0), stringBuffer);
382 getTemplateBody(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.OVERDUE_TITLE), loanProcessor.getParameter(OLEParameterConstants.OVERDUE_BODY));
383 getTemplateFooterList(overDueNoticeList, stringBuffer);
384 getHTMLFooter(stringBuffer);
385 }
386
387 if (onHoldNoticeList != null && onHoldNoticeList.size() > 0) {
388 getHTMLHeader(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.ONHOLD_TITLE));
389 getTemplateHeader(onHoldNoticeList.get(0), stringBuffer);
390 getTemplateBody(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.ONHOLD_TITLE), loanProcessor.getParameter(OLEParameterConstants.ONHOLD_BODY));
391 for (int onHold = 0; onHold < onHoldNoticeList.size(); onHold++) {
392 getTemplateFooter(noticeBo.get(onHold), stringBuffer);
393 getPickUpLocationTemplate(noticeBo.get(onHold), stringBuffer);
394 }
395 getHTMLFooter(stringBuffer);
396 }
397
398 if (recallNoticeList != null && recallNoticeList.size() > 0) {
399 getHTMLHeader(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.RECALL_TITLE));
400 getTemplateHeader(recallNoticeList.get(0), stringBuffer);
401 getTemplateBody(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.RECALL_TITLE), loanProcessor.getParameter(OLEParameterConstants.RECALL_BODY));
402 for (int recall = 0; recall < recallNoticeList.size(); recall++) {
403 getTemplateFooter(noticeBo.get(recall), stringBuffer);
404 }
405 getHTMLFooter(stringBuffer);
406 }
407
408 if (expiredNoticeList != null && expiredNoticeList.size() > 0) {
409 getHTMLHeader(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.EXPIRED_TITLE));
410 getTemplateHeader(expiredNoticeList.get(0), stringBuffer);
411 getTemplateBody(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.EXPIRED_TITLE), loanProcessor.getParameter(OLEParameterConstants.EXPIRED_BODY));
412
413 for (int exp = 0; exp < expiredNoticeList.size(); exp++) {
414 getTemplateFooter(noticeBo.get(exp), stringBuffer);
415 }
416 getHTMLFooter(stringBuffer);
417 }
418
419 if (expiredRequiredNoticeList != null && expiredRequiredNoticeList.size() > 0) {
420 getHTMLHeader(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.EXP_REQ_TITLE));
421 getTemplateHeader(expiredRequiredNoticeList.get(0), stringBuffer);
422 getTemplateBody(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.EXP_REQ_TITLE), loanProcessor.getParameter(OLEParameterConstants.EXP_REQ_BODY));
423 for (int exReq = 0; exReq < expiredRequiredNoticeList.size(); exReq++) {
424 getTemplateFooter(noticeBo.get(exReq), stringBuffer);
425 }
426 getHTMLFooter(stringBuffer);
427 }
428 if (courtesyNoticeList != null && courtesyNoticeList.size() > 0) {
429 getHTMLHeader(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.COURTESY_TITLE));
430 getTemplateHeader(courtesyNoticeList.get(0), stringBuffer);
431 getTemplateBody(stringBuffer, loanProcessor.getParameter(OLEParameterConstants.COURTESY_TITLE), loanProcessor.getParameter(OLEParameterConstants.COURTESY_BODY));
432 getTemplateFooterList(courtesyNoticeList, stringBuffer);
433 getHTMLFooter(stringBuffer);
434 }
435 if (cancellationNoticeList != null && cancellationNoticeList.size() > 0) {
436 getHTMLHeader(stringBuffer, loanProcessor.getParameter("CANCELLATION_NOTICE"));
437 getTemplateHeader(cancellationNoticeList.get(0), stringBuffer);
438 getTemplateBody(stringBuffer, loanProcessor.getParameter("CANCELLATION_NOTICE"), loanProcessor.getParameter(OLEParameterConstants.CANCELLATION_BODY));
439 for (int exReq = 0; exReq < cancellationNoticeList.size(); exReq++) {
440 getTemplateFooter(noticeBo.get(exReq), stringBuffer);
441 }
442 getHTMLFooter(stringBuffer);
443 }
444 templateForNoticeList.add(stringBuffer);
445
446 return templateForNoticeList;
447 }
448
449 private OutputStream getPdfHeader(Document document, OutputStream outputStream, String title, String itemId) throws Exception {
450 StringBuffer stringBuffer = new StringBuffer();
451 String pdfLocationSystemParam = getLoanProcessor().getParameter(OLEParameterConstants.PDF_LOCATION);
452 if (LOG.isDebugEnabled()) {
453 LOG.debug("System Parameter for PDF_Location --> " + pdfLocationSystemParam);
454 }
455 if (pdfLocationSystemParam == null || pdfLocationSystemParam.trim().isEmpty()) {
456 pdfLocationSystemParam = ConfigContext.getCurrentContextConfig().getProperty("staging.directory") + "/";
457 if (LOG.isDebugEnabled()) {
458 LOG.debug("System Parameter for PDF_Location staging dir--> " + pdfLocationSystemParam);
459 }
460 } else {
461 pdfLocationSystemParam = ConfigContext.getCurrentContextConfig().getProperty("homeDirectory") + "/" + pdfLocationSystemParam + "/";
462 }
463 boolean locationExist = new File(pdfLocationSystemParam).exists();
464 boolean fileCreated = false;
465 if (LOG.isDebugEnabled()) {
466 LOG.debug("Is directory Exist ::" + locationExist);
467 }
468 try {
469 if (!locationExist) {
470 fileCreated = new File(pdfLocationSystemParam).mkdirs();
471 if (!fileCreated) {
472 throw new RuntimeException("Not Able to create directory :" + pdfLocationSystemParam);
473 }
474 }
475 } catch (Exception e) {
476 LOG.error("Exception occured while creating the directory : " + e.getMessage(), e);
477 throw e;
478 }
479
480 if (title == null || title.trim().isEmpty()) {
481 title = OLEConstants.ITEM_TITLE;
482 }
483 title = title.replaceAll(" ", "_");
484
485 if (itemId == null || itemId.trim().isEmpty()) {
486 itemId = OLEConstants.ITEM_ID;
487 }
488 String fileName = pdfLocationSystemParam + title + "_" + itemId + "_" + (new Date(System.currentTimeMillis())).toString().replaceAll(":","_") + ".pdf";
489 fileName = fileName.replace(" ","_");
490 if (LOG.isDebugEnabled()) {
491 LOG.debug("File Created :" + title + "file name ::" + fileName + "::");
492 }
493 outputStream = new FileOutputStream(fileName);
494 PdfWriter writer = PdfWriter.getInstance(document, outputStream);
495 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
496 Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
497 document.open();
498 document.newPage();
499 Paragraph paraGraph = new Paragraph();
500 paraGraph.setAlignment(Element.ALIGN_CENTER);
501 paraGraph.add(new Chunk(title, boldFont));
502 paraGraph.add(Chunk.NEWLINE);
503 document.add(paraGraph);
504 return outputStream;
505 }
506
507 public void createPdfForIntransitRequest(OleDeliverRequestBo oleDeliverRequestBo, HttpServletResponse response) {
508 LOG.debug("Creating pdf for intransit request");
509 String title = "InTransit Request";
510 OutputStream outputStream = null;
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539 String fileName = "IntransitRequestSlip" + "_" + oleDeliverRequestBo.getItemId() + "_" + new Date(System.currentTimeMillis()) + ".pdf";
540 if (LOG.isDebugEnabled()) {
541 LOG.debug("File Created :" + title + "file name ::" + fileName + "::");
542 }
543 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
544 try {
545 String itemTitle = oleDeliverRequestBo.getTitle() != null ? oleDeliverRequestBo.getTitle() : "";
546 Date dateOfReq = oleDeliverRequestBo.getCreateDate()!=null?oleDeliverRequestBo.getCreateDate():null;
547
548 String circulationLocation = oleDeliverRequestBo.getCirculationLocationCode() != null ? oleDeliverRequestBo.getCirculationLocationCode() : "";
549 String itemBarcode = oleDeliverRequestBo.getItemId() != null ? oleDeliverRequestBo.getItemId() : "";
550 String patronBarcode = oleDeliverRequestBo.getBorrowerBarcode() != null ? oleDeliverRequestBo.getBorrowerBarcode() : "";
551 String requestType = oleDeliverRequestBo.getRequestTypeId() != null ? oleDeliverRequestBo.getRequestTypeId() : "";
552 boolean inTransitSlip = requestType.equalsIgnoreCase("8");
553
554 Document document = this.getDocument(0, 0, 5, 5);
555
556
557 response.setContentType("application/pdf");
558 response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
559 outputStream = response.getOutputStream();
560 PdfWriter.getInstance(document, outputStream);
561 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
562 document.open();
563 document.newPage();
564 PdfPTable pdfTable = new PdfPTable(3);
565 pdfTable.setWidths(new int[]{20,2,30});
566 Paragraph paraGraph = new Paragraph();
567 if (inTransitSlip) {
568 paraGraph.setAlignment(Element.ALIGN_CENTER);
569 paraGraph.add(new Chunk("InTransit Request Slip", boldFont));
570 }
571 paraGraph.add(Chunk.NEWLINE);
572 paraGraph.add(Chunk.NEWLINE);
573 paraGraph.add(Chunk.NEWLINE);
574 document.add(paraGraph);
575 if (inTransitSlip) {
576 pdfTable.addCell(getPdfPCellInJustified("Date/Time "));
577 pdfTable.addCell(getPdfPCellInLeft(":"));
578 pdfTable.addCell(getPdfPCellInJustified(sdf.format(dateOfReq)));
579
580 pdfTable.addCell(getPdfPCellInJustified("Circulation Location"));
581 pdfTable.addCell(getPdfPCellInLeft(":"));
582 pdfTable.addCell(getPdfPCellInJustified(circulationLocation));
583
584 pdfTable.addCell(getPdfPCellInJustified("Item Barcode"));
585 pdfTable.addCell(getPdfPCellInLeft(":"));
586 pdfTable.addCell(getPdfPCellInJustified(itemBarcode));
587
588 pdfTable.addCell(getPdfPCellInJustified("Title"));
589 pdfTable.addCell(getPdfPCellInLeft(":"));
590 pdfTable.addCell(getPdfPCellInJustified(itemTitle));
591
592 pdfTable.addCell(getPdfPCellInJustified("Patron Barcode"));
593 pdfTable.addCell(getPdfPCellInLeft(":"));
594 pdfTable.addCell(getPdfPCellInJustified(patronBarcode));
595 document.add(pdfTable);
596 }
597 document.close();
598 outputStream.flush();
599 outputStream.close();
600 } catch (Exception e) {
601 LOG.error("Exception while creating Pdf For IntransitRequest", e);
602 }
603 }
604
605 private PdfPCell getPdfPCellInJustified(String chunk) {
606 PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
607 pdfPCell.setBorder(pdfPCell.NO_BORDER);
608 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
609 return pdfPCell;
610 }
611
612 private PdfPCell getPdfPCellInLeft(String chunk) {
613 PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
614 pdfPCell.setBorder(pdfPCell.NO_BORDER);
615 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
616 return pdfPCell;
617 }
618
619 public Document getDocument(float f1, float f2, float f3, float f4) {
620 Document document = new Document(PageSize.A4);
621 document.setMargins(f1, f2, f3, f4);
622 return document;
623 }
624
625 private void getPdfTemplateHeader(OleNoticeBo noticeBo, Document document) throws Exception {
626 if (LOG.isDebugEnabled()){
627 LOG.debug("Header for the notice" + noticeBo.getNoticeName() + noticeBo.getItemId());
628 }
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679 Paragraph paraGraph = new Paragraph();
680 paraGraph.add(Chunk.NEWLINE);
681 document.add(paraGraph);
682 paraGraph = new Paragraph();
683 paraGraph.add(new Chunk("Patron information", boldFont));
684 paraGraph.add(Chunk.NEWLINE);
685 paraGraph.add(Chunk.NEWLINE);
686 document.add(paraGraph);
687
688 PdfPTable pdfTable = new PdfPTable(3);
689 pdfTable.setWidths(new int[]{20,2,30});
690 PdfPCell pdfPCell= new PdfPCell(new Paragraph("Patron Name"));
691 pdfPCell.setBorder(pdfPCell.NO_BORDER);
692 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
693 pdfTable.addCell(pdfPCell);
694 pdfPCell = new PdfPCell(new Paragraph(":"));
695 pdfPCell.setBorder(pdfPCell.NO_BORDER);
696 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
697 pdfTable.addCell(pdfPCell);
698 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronName() != null ? noticeBo.getPatronName() : "")));
699 pdfPCell.setBorder(pdfPCell.NO_BORDER);
700 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
701 pdfTable.addCell(pdfPCell);
702 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
703 pdfPCell.setBorder(pdfPCell.NO_BORDER);
704 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
705 pdfTable.addCell(pdfPCell);
706 pdfPCell = new PdfPCell(new Paragraph(":"));
707 pdfPCell.setBorder(pdfPCell.NO_BORDER);
708 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
709 pdfTable.addCell(pdfPCell);
710 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronAddress() != null ? noticeBo.getPatronAddress() : "")));
711 pdfPCell.setBorder(pdfPCell.NO_BORDER);
712 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
713 pdfTable.addCell(pdfPCell);
714 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
715 pdfPCell.setBorder(pdfPCell.NO_BORDER);
716 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
717 pdfTable.addCell(pdfPCell);
718 pdfPCell = new PdfPCell(new Paragraph(":"));
719 pdfPCell.setBorder(pdfPCell.NO_BORDER);
720 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
721 pdfTable.addCell(pdfPCell);
722 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronEmailAddress() != null ? noticeBo.getPatronEmailAddress() : "")));
723 pdfPCell.setBorder(pdfPCell.NO_BORDER);
724 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
725 pdfTable.addCell(pdfPCell);
726 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
727 pdfPCell.setBorder(pdfPCell.NO_BORDER);
728 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
729 pdfTable.addCell(pdfPCell);
730 pdfPCell = new PdfPCell(new Paragraph(":"));
731 pdfPCell.setBorder(pdfPCell.NO_BORDER);
732 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
733 pdfTable.addCell(pdfPCell);
734 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronPhoneNumber() != null ? noticeBo.getPatronPhoneNumber() : "")));
735 pdfPCell.setBorder(pdfPCell.NO_BORDER);
736 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
737 pdfTable.addCell(pdfPCell);
738 document.add(pdfTable);
739 paraGraph = new Paragraph();
740 paraGraph.add(Chunk.NEWLINE);
741 document.add(paraGraph);
742
743
744 }
745
746 private void getPdfTemplateBody(Document document, String title, String body) throws Exception {
747
748 if (LOG.isDebugEnabled()){
749 LOG.debug("Body Content of the notice :" + title);
750 }
751 Paragraph paraGraph = new Paragraph();
752 paraGraph.add(new Chunk(title, boldFont));
753 paraGraph.setAlignment(Element.ALIGN_CENTER);
754 paraGraph.add(Chunk.NEWLINE);
755 paraGraph.add(Chunk.NEWLINE);
756 document.add(paraGraph);
757
758
759
760 paraGraph = new Paragraph();
761 paraGraph.add(new Chunk(body, boldFont));
762 paraGraph.setAlignment(Element.ALIGN_CENTER);
763 paraGraph.add(Chunk.NEWLINE);
764 paraGraph.add(Chunk.NEWLINE);
765 document.add(paraGraph);
766 }
767
768 private void getPdfTemplateFooter(OleNoticeBo noticeBo, Document document) throws Exception {
769 if (LOG.isDebugEnabled()){
770 LOG.debug("Footer for the notice : " + noticeBo.getNoticeName() + noticeBo.getItemId());
771 }
772 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
773 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
774 Paragraph paraGraph = new Paragraph();
775 paraGraph.add(new Chunk("Title/item information", boldFont));
776 paraGraph.add(Chunk.NEWLINE);
777 paraGraph.add(Chunk.NEWLINE);
778 document.add(paraGraph);
779 PdfPTable pdfTable = new PdfPTable(3);
780 pdfTable.setWidths(new int[]{20,2,30});
781 PdfPCell pdfPCell;
782 if (!noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)) {
783 pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
784 pdfPCell.setBorder(pdfPCell.NO_BORDER);
785 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
786 pdfTable.addCell(pdfPCell);
787 pdfPCell = new PdfPCell(new Paragraph(":"));
788 pdfPCell.setBorder(pdfPCell.NO_BORDER);
789 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
790 pdfTable.addCell(pdfPCell);
791 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "")));
792 pdfPCell.setBorder(pdfPCell.NO_BORDER);
793 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
794 pdfTable.addCell(pdfPCell);
795 }
796 pdfPCell = new PdfPCell(new Paragraph("Title "));
797 pdfPCell.setBorder(pdfPCell.NO_BORDER);
798 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
799 pdfTable.addCell(pdfPCell);
800 pdfPCell = new PdfPCell(new Paragraph(":"));
801 pdfPCell.setBorder(pdfPCell.NO_BORDER);
802 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
803 pdfTable.addCell(pdfPCell);
804 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getTitle() == null ? "" : noticeBo.getTitle())));
805 pdfPCell.setBorder(pdfPCell.NO_BORDER);
806 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
807 pdfTable.addCell(pdfPCell);
808 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Author ")));
809 pdfPCell.setBorder(pdfPCell.NO_BORDER);
810 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
811 pdfTable.addCell(pdfPCell);
812 pdfPCell = new PdfPCell(new Paragraph(":"));
813 pdfPCell.setBorder(pdfPCell.NO_BORDER);
814 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
815 pdfTable.addCell(pdfPCell);
816 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getAuthor() == null ? "" : noticeBo.getAuthor())));
817 pdfPCell.setBorder(pdfPCell.NO_BORDER);
818 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
819 pdfTable.addCell(pdfPCell);
820 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Volume/Issue/Copy # ")));
821 pdfPCell.setBorder(pdfPCell.NO_BORDER);
822 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
823 pdfTable.addCell(pdfPCell);
824 pdfPCell = new PdfPCell(new Paragraph(":"));
825 pdfPCell.setBorder(pdfPCell.NO_BORDER);
826 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
827 pdfTable.addCell(pdfPCell);
828 if(!noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)){
829 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getVolumeNumber() == null ? "" : noticeBo.getVolumeNumber())));
830 }else{
831 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getVolumeIssueCopyNumber() == null ? "" : noticeBo.getVolumeIssueCopyNumber())));
832 }
833 pdfPCell.setBorder(pdfPCell.NO_BORDER);
834 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
835 pdfTable.addCell(pdfPCell);
836 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Library shelving location ")));
837 pdfPCell.setBorder(pdfPCell.NO_BORDER);
838 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
839 pdfTable.addCell(pdfPCell);
840 pdfPCell = new PdfPCell(new Paragraph(":"));
841 pdfPCell.setBorder(pdfPCell.NO_BORDER);
842 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
843 pdfTable.addCell(pdfPCell);
844 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemShelvingLocation() == null ? "" : noticeBo.getItemShelvingLocation())));
845 pdfPCell.setBorder(pdfPCell.NO_BORDER);
846 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
847 pdfTable.addCell(pdfPCell);
848 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Call # ")));
849 pdfPCell.setBorder(pdfPCell.NO_BORDER);
850 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
851 pdfTable.addCell(pdfPCell);
852 pdfPCell = new PdfPCell(new Paragraph(":"));
853 pdfPCell.setBorder(pdfPCell.NO_BORDER);
854 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
855 pdfTable.addCell(pdfPCell);
856 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemCallNumber() == null ? "" : noticeBo.getItemCallNumber())));
857 pdfPCell.setBorder(pdfPCell.NO_BORDER);
858 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
859 pdfTable.addCell(pdfPCell);
860 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item barcode")));
861 pdfPCell.setBorder(pdfPCell.NO_BORDER);
862 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
863 pdfTable.addCell(pdfPCell);
864 pdfPCell = new PdfPCell(new Paragraph(":"));
865 pdfPCell.setBorder(pdfPCell.NO_BORDER);
866 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
867 pdfTable.addCell(pdfPCell);
868 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemId() == null ? "" : noticeBo.getItemId())));
869 pdfPCell.setBorder(pdfPCell.NO_BORDER);
870 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
871 pdfTable.addCell(pdfPCell);
872 if (noticeBo.getExpiredOnHoldDate() != null) {
873 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Expiration onHoldDate")));
874 pdfPCell.setBorder(pdfPCell.NO_BORDER);
875 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
876 pdfTable.addCell(pdfPCell);
877 pdfPCell = new PdfPCell(new Paragraph(":"));
878 pdfPCell.setBorder(pdfPCell.NO_BORDER);
879 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
880 pdfTable.addCell(pdfPCell);
881 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getExpiredOnHoldDate() == null ? "" : dateFormat.format(noticeBo.getExpiredOnHoldDate()))));
882 pdfPCell.setBorder(pdfPCell.NO_BORDER);
883 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
884 pdfTable.addCell(pdfPCell);
885 }
886 document.add(pdfTable);
887 paraGraph = new Paragraph();
888 paraGraph.add(Chunk.NEWLINE);
889 document.add(paraGraph);
890
891
892
893
894
895
896 if (noticeBo.getNoticeName().equals(OLEConstants.NOTICE_RECALL)) {
897 if (LOG.isDebugEnabled()){
898 LOG.debug("Recall Notice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
899 }
900 pdfTable = new PdfPTable(3);
901 pdfTable.setWidths(new int[]{20,2,30});
902 pdfPCell = new PdfPCell(new Paragraph("Original Due Date"));
903 pdfPCell.setBorder(pdfPCell.NO_BORDER);
904 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
905 pdfTable.addCell(pdfPCell);
906 pdfPCell = new PdfPCell(new Paragraph(":"));
907 pdfPCell.setBorder(pdfPCell.NO_BORDER);
908 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
909 pdfTable.addCell(pdfPCell);
910 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getOriginalDueDate() == null ? "" : sdf.format(noticeBo.getOriginalDueDate()))));
911 pdfPCell.setBorder(pdfPCell.NO_BORDER);
912 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
913 pdfTable.addCell(pdfPCell);
914 pdfPCell = new PdfPCell(new Paragraph(new Chunk("New Due Date")));
915 pdfPCell.setBorder(pdfPCell.NO_BORDER);
916 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
917 pdfTable.addCell(pdfPCell);
918 pdfPCell = new PdfPCell(new Paragraph(":"));
919 pdfPCell.setBorder(pdfPCell.NO_BORDER);
920 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
921 pdfTable.addCell(pdfPCell);
922 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getNewDueDate() == null ? "" : sdf.format(noticeBo.getNewDueDate()))));
923 pdfPCell.setBorder(pdfPCell.NO_BORDER);
924 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
925 pdfTable.addCell(pdfPCell);
926 document.add(pdfTable);
927 paraGraph = new Paragraph();
928 paraGraph.add(Chunk.NEWLINE);
929 document.add(paraGraph);
930 } else if (noticeBo.getNoticeName().equals("OnHold")) {
931 if (LOG.isDebugEnabled()){
932 LOG.debug("OnHold Notice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
933 }
934 pdfTable = new PdfPTable(3);
935 pdfTable.setWidths(new int[]{20,2,30});
936 pdfPCell = new PdfPCell(new Paragraph("Pick Up Location"));
937 pdfPCell.setBorder(pdfPCell.NO_BORDER);
938 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
939 pdfTable.addCell(pdfPCell);
940 pdfPCell = new PdfPCell(new Paragraph(":"));
941 pdfPCell.setBorder(pdfPCell.NO_BORDER);
942 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
943 pdfTable.addCell(pdfPCell);
944 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPickUpLocation() != null ? noticeBo.getPickUpLocation() : "")));
945 pdfPCell.setBorder(pdfPCell.NO_BORDER);
946 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
947 pdfTable.addCell(pdfPCell);
948 pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
949 pdfPCell.setBorder(pdfPCell.NO_BORDER);
950 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
951 pdfTable.addCell(pdfPCell);
952 pdfPCell = new PdfPCell(new Paragraph(":"));
953 pdfPCell.setBorder(pdfPCell.NO_BORDER);
954 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
955 pdfTable.addCell(pdfPCell);
956 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "")));
957 pdfPCell.setBorder(pdfPCell.NO_BORDER);
958 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
959 pdfTable.addCell(pdfPCell);
960 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
961 pdfPCell.setBorder(pdfPCell.NO_BORDER);
962 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
963 pdfTable.addCell(pdfPCell);
964 pdfPCell = new PdfPCell(new Paragraph(":"));
965 pdfPCell.setBorder(pdfPCell.NO_BORDER);
966 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
967 pdfTable.addCell(pdfPCell);
968 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronAddress() != null ? noticeBo.getPatronAddress() : "")));
969 pdfPCell.setBorder(pdfPCell.NO_BORDER);
970 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
971 pdfTable.addCell(pdfPCell);
972 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
973 pdfPCell.setBorder(pdfPCell.NO_BORDER);
974 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
975 pdfTable.addCell(pdfPCell);
976 pdfPCell = new PdfPCell(new Paragraph(":"));
977 pdfPCell.setBorder(pdfPCell.NO_BORDER);
978 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
979 pdfTable.addCell(pdfPCell);
980 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronEmailAddress() != null ? noticeBo.getPatronEmailAddress() : "")));
981 pdfPCell.setBorder(pdfPCell.NO_BORDER);
982 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
983 pdfTable.addCell(pdfPCell);
984 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
985 pdfPCell.setBorder(pdfPCell.NO_BORDER);
986 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
987 pdfTable.addCell(pdfPCell);
988 pdfPCell = new PdfPCell(new Paragraph(":"));
989 pdfPCell.setBorder(pdfPCell.NO_BORDER);
990 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
991 pdfTable.addCell(pdfPCell);
992 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getPatronPhoneNumber() != null ? noticeBo.getPatronPhoneNumber() : "")));
993 pdfPCell.setBorder(pdfPCell.NO_BORDER);
994 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
995 pdfTable.addCell(pdfPCell);
996 document.add(pdfTable);
997 paraGraph = new Paragraph();
998 paraGraph.add(Chunk.NEWLINE);
999 document.add(paraGraph);
1000 pdfTable = new PdfPTable(3);
1001 pdfTable.setWidths(new int[]{20,2,30});
1002 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item Will Be Held until")));
1003 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1004 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1005 pdfTable.addCell(pdfPCell);
1006 pdfPCell = new PdfPCell(new Paragraph(":"));
1007 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1008 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1009 pdfTable.addCell(pdfPCell);
1010 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getExpiredOnHoldDate() != null ? dateFormat.format(noticeBo.getExpiredOnHoldDate().toString()) : "")));
1011 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1012 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1013 pdfTable.addCell(pdfPCell);
1014 document.add(pdfTable);
1015 paraGraph = new Paragraph();
1016 paraGraph.add(Chunk.NEWLINE);
1017 document.add(paraGraph);
1018 } else if (noticeBo.getNoticeName().equals("OverdueNotice")) {
1019 if (LOG.isDebugEnabled()){
1020 LOG.debug("OverdueNotice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
1021 }
1022 pdfTable = new PdfPTable(3);
1023 pdfTable.setWidths(new int[]{20,2,30});
1024 pdfPCell = new PdfPCell(new Paragraph("Item was due"));
1025 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1026 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1027 pdfTable.addCell(pdfPCell);
1028 pdfPCell = new PdfPCell(new Paragraph(":"));
1029 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1030 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1031 pdfTable.addCell(pdfPCell);
1032 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getDueDate() == null ? "" : (sdf.format(noticeBo.getDueDate())))));
1033 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1034 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1035 pdfTable.addCell(pdfPCell);
1036 document.add(pdfTable);
1037 paraGraph = new Paragraph();
1038 paraGraph.add(Chunk.NEWLINE);
1039 document.add(paraGraph);
1040 }
1041
1042 }
1043
1044 public void getPdfFooter(Document document, OutputStream outputStream) throws Exception {
1045 String url = ConfigContext.getCurrentContextConfig().getProperty("ole.fs.url.base");
1046 String myAccountURL = loanProcessor.getParameter(OLEConstants.MY_ACCOUNT_URL);
1047 if(myAccountURL!=null && !myAccountURL.trim().isEmpty()){
1048 ver_15_normal.setColor(Color.blue);
1049 ver_15_normal.setStyle(Font.UNDERLINE);
1050 Anchor anchor = new Anchor("MyAccount", ver_15_normal);
1051 anchor.setName("My Account");
1052 anchor.setReference(myAccountURL);
1053 Paragraph paraGraph = new Paragraph();
1054 paraGraph.add(anchor);
1055 paraGraph.setAlignment(Element.ALIGN_CENTER);
1056 document.add(paraGraph);
1057 }
1058 outputStream.flush();
1059 document.close();
1060 outputStream.close();
1061 }
1062
1063 public List getPdfNoticeForPatron(List<OleNoticeBo> noticeBoList) throws Exception {
1064 return getPdfTemplate(noticeBoList);
1065 }
1066
1067 private List getPdfTemplate(List<OleNoticeBo> noticeBoList) throws Exception {
1068 List templateForNoticeList = new ArrayList();
1069 LOG.debug("In getPdfTemplate()");
1070 try {
1071 Document document = new Document(PageSize.A4);
1072 OutputStream outputStream = null;
1073
1074 List<OleNoticeBo> overDueNoticeList = new ArrayList<OleNoticeBo>();
1075 List<OleNoticeBo> onHoldNoticeList = new ArrayList<OleNoticeBo>();
1076 List<OleNoticeBo> recallNoticeList = new ArrayList<OleNoticeBo>();
1077 List<OleNoticeBo> expiredNoticeList = new ArrayList<OleNoticeBo>();
1078 List<OleNoticeBo> expiredRequiredNoticeList = new ArrayList<OleNoticeBo>();
1079 List<OleNoticeBo> courtesyNoticeList = new ArrayList<OleNoticeBo>();
1080
1081 for (int temp = 0; temp < noticeBoList.size(); temp++) {
1082 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_OVERDUE)) {
1083 overDueNoticeList.add(noticeBoList.get(temp));
1084 }
1085 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_ONHOLD)) {
1086 onHoldNoticeList.add(noticeBoList.get(temp));
1087 }
1088 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)) {
1089 recallNoticeList.add(noticeBoList.get(temp));
1090 }
1091 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_HOLD_COURTESY)) {
1092 expiredNoticeList.add(noticeBoList.get(temp));
1093 }
1094 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.OleDeliverRequest.EXPIRED_REQUEST)) {
1095 expiredRequiredNoticeList.add(noticeBoList.get(temp));
1096 }
1097 if (noticeBoList.get(temp).getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_COURTESY)) {
1098 courtesyNoticeList.add(noticeBoList.get(temp));
1099 }
1100 }
1101 LoanProcessor loanProcessor = getLoanProcessor();
1102
1103 if (overDueNoticeList != null && overDueNoticeList.size() > 0) {
1104 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter(OLEParameterConstants.OVERDUE_TITLE), overDueNoticeList.get(0).getItemId());
1105 getPdfTemplateHeader(overDueNoticeList.get(0), document);
1106 getPdfTemplateBody(document, loanProcessor.getParameter(OLEParameterConstants.OVERDUE_TITLE), loanProcessor.getParameter(OLEParameterConstants.OVERDUE_BODY));
1107 getPdfTemplateFooterList(overDueNoticeList, document);
1108 getPdfFooter(document, outputStream);
1109 }
1110
1111 if (onHoldNoticeList != null && onHoldNoticeList.size() > 0) {
1112 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter(OLEParameterConstants.ONHOLD_TITLE), onHoldNoticeList.get(0).getItemId());
1113 getPdfTemplateHeader(onHoldNoticeList.get(0), document);
1114 getPdfTemplateBody(document, loanProcessor.getParameter(OLEParameterConstants.ONHOLD_TITLE), loanProcessor.getParameter(OLEParameterConstants.ONHOLD_BODY));
1115 for (int onHold = 0; onHold < onHoldNoticeList.size(); onHold++) {
1116 getPdfTemplateFooter(noticeBoList.get(onHold), document);
1117
1118 }
1119 getPdfFooter(document, outputStream);
1120 }
1121
1122 if (recallNoticeList != null && recallNoticeList.size() > 0) {
1123 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter(OLEParameterConstants.RECALL_TITLE), recallNoticeList.get(0).getItemId());
1124 getPdfTemplateHeader(recallNoticeList.get(0), document);
1125 getPdfTemplateBody(document, loanProcessor.getParameter(OLEParameterConstants.RECALL_TITLE), loanProcessor.getParameter(OLEParameterConstants.RECALL_BODY));
1126 for (int recall = 0; recall < recallNoticeList.size(); recall++) {
1127 getPdfTemplateFooter(noticeBoList.get(recall), document);
1128 }
1129 getPdfFooter(document, outputStream);
1130 }
1131
1132 if (expiredNoticeList != null && expiredNoticeList.size() > 0) {
1133 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter(OLEParameterConstants.EXPIRED_TITLE), expiredNoticeList.get(0).getItemId());
1134 getPdfTemplateHeader(expiredNoticeList.get(0), document);
1135 getPdfTemplateBody(document, loanProcessor.getParameter(OLEParameterConstants.EXPIRED_TITLE), loanProcessor.getParameter(OLEParameterConstants.EXPIRED_BODY));
1136 for (int exp = 0; exp < expiredNoticeList.size(); exp++) {
1137 getPdfTemplateFooter(noticeBoList.get(exp), document);
1138 }
1139 getPdfFooter(document, outputStream);
1140 }
1141
1142 if (expiredRequiredNoticeList != null && expiredRequiredNoticeList.size() > 0) {
1143 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter(OLEParameterConstants.EXP_REQ_TITLE), expiredRequiredNoticeList.get(0).getItemId());
1144 getPdfTemplateHeader(expiredRequiredNoticeList.get(0), document);
1145 getPdfTemplateBody(document, loanProcessor.getParameter(OLEParameterConstants.EXP_REQ_TITLE), loanProcessor.getParameter(OLEParameterConstants.EXP_REQ_BODY));
1146 for (int exReq = 0; exReq < expiredRequiredNoticeList.size(); exReq++) {
1147 getPdfTemplateFooter(noticeBoList.get(exReq), document);
1148 }
1149 getPdfFooter(document, outputStream);
1150 }
1151 if (courtesyNoticeList != null && courtesyNoticeList.size() > 0) {
1152 outputStream = getPdfHeader(document, outputStream, loanProcessor.getParameter(OLEParameterConstants.COURTESY_TITLE), courtesyNoticeList.get(0).getItemId());
1153 getPdfTemplateHeader(courtesyNoticeList.get(0), document);
1154 getPdfTemplateBody(document, loanProcessor.getParameter(OLEParameterConstants.COURTESY_TITLE), loanProcessor.getParameter(OLEParameterConstants.COURTESY_BODY));
1155 getPdfTemplateFooterList(courtesyNoticeList, document);
1156 getPdfFooter(document, outputStream);
1157 }
1158
1159 } catch (Exception e) {
1160 LOG.error("Exception in getPdfTemplate", e);
1161 }
1162
1163
1164 return templateForNoticeList;
1165 }
1166
1167
1168 public List getNoticeForPatron(List<OleNoticeBo> noticeBo) throws Exception {
1169 return getTemplate(noticeBo);
1170
1171 }
1172
1173 public Map getSMSForPatron(List<OleNoticeBo> noticeBo) throws Exception {
1174 return getSMSTemplate(noticeBo);
1175 }
1176
1177
1178 public String sendMissingNotice(OleNoticeBo oleNoticeBo) {
1179
1180 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
1181
1182 StringBuffer stringBuffer = new StringBuffer();
1183 stringBuffer.append("<HTML>");
1184 stringBuffer.append("<TITLE>" + oleNoticeBo.getNoticeName() + "</TITLE>");
1185 stringBuffer.append("<HEAD><TR><TD><CENTER>" + oleNoticeBo.getNoticeName() + "</CENTER></TD></TR></HEAD>");
1186 stringBuffer.append("<BODY>");
1187 stringBuffer.append("<TABLE></BR></BR>");
1188 stringBuffer.append("<TR><TD>Circulation Location / Library Name :</TD><TD>" + oleNoticeBo.getCirculationDeskName() + "</TD></TR>");
1189 stringBuffer.append("<TR><TD>PatronName :</TD><TD>" + oleNoticeBo.getPatronName() + "</TD></TR>");
1190 stringBuffer.append("<TR><TD>Address :</TD><TD>" + oleNoticeBo.getPatronAddress() + "</TD></TR>");
1191 stringBuffer.append("<TR><TD>EMAIL :</TD><TD>" + oleNoticeBo.getPatronEmailAddress() + "</TD></TR>");
1192 stringBuffer.append("<TR><TD>PhoneNumber :</TD><TD>" + oleNoticeBo.getPatronPhoneNumber() + "</TD></TR>");
1193 stringBuffer.append("</TABLE>");
1194 stringBuffer.append("<TABLE></BR></BR>");
1195 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
1196 stringBuffer.append("<TABLE width=\"100%\">");
1197 stringBuffer.append("<TR><TD><CENTER>" + oleNoticeBo.getNoticeName() + "</CENTER></TD></TR>");
1198 stringBuffer.append("<TR><TD><p>" + oleNoticeBo.getNoticeSpecificContent() + "</p></TD></TR>");
1199 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");
1200 stringBuffer.append("<TABLE></BR></BR>");
1201 stringBuffer.append("<TR><TD>Title :</TD><TD>" + oleNoticeBo.getTitle() + "</TD></TR>");
1202 stringBuffer.append("<TR><TD>Author :</TD><TD>" + oleNoticeBo.getAuthor() + "</TD></TR>");
1203 stringBuffer.append("<TR><TD>Volume/Issue/Copy # :</TD><TD>" + oleNoticeBo.getVolumeNumber() + "</TD></TR>");
1204 stringBuffer.append("<TR><TD>Library shelvinglocation :</TD><TD>" + oleNoticeBo.getItemShelvingLocation() + "</TD></TR>");
1205 stringBuffer.append("<TR><TD>Call #:</TD><TD>" + oleNoticeBo.getItemCallNumber() + "</TD></TR>");
1206 stringBuffer.append("<TR><TD>Item barcode :</TD><TD>" + oleNoticeBo.getItemId() + "</TD></TR>");
1207 stringBuffer.append("<TR><TD>Check In Date :</TD><TD>" + (oleNoticeBo.getCheckInDate()!=null ? oleNoticeBo.getCheckInDate() : "") + "</TD></TR>");
1208 String missingPieceNote="";
1209 if(oleNoticeBo.getOleItem()!=null&& oleNoticeBo.getOleItem().getMissingPieceFlagNote()!=null){
1210 missingPieceNote=oleNoticeBo.getOleItem().getMissingPieceFlagNote();
1211 }
1212 stringBuffer.append("<TR><TD>Missing Piece Note :</TD><TD>" + missingPieceNote + "</TD></TR>");
1213 stringBuffer.append("</TABLE>");
1214 stringBuffer.append("</BODY>");
1215 stringBuffer.append("</HTML>");
1216 return stringBuffer.toString();
1217 }
1218 public void getPdfPickUpNotice(OleNoticeBo noticeBo) throws Exception{
1219 if (LOG.isDebugEnabled()){
1220 LOG.debug("PickUp notice : " + noticeBo.getNoticeName() + noticeBo.getItemId());
1221 }
1222 Document document = new Document(PageSize.A4);
1223 OutputStream outputStream = null;
1224 outputStream = getPdfHeader(document, outputStream,getLoanProcessor().getParameter(OLEParameterConstants.PICKUP_TITLE), noticeBo.getItemId());
1225 document.setPageCount(3);
1226 PdfPTable pdfTable = new PdfPTable(1);
1227
1228 PdfPCell pdfPCell = new PdfPCell(new Paragraph(Chunk.NEWLINE));
1229 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1230 pdfTable.addCell(pdfPCell);
1231
1232 pdfPCell = new PdfPCell(new Paragraph(new Chunk((noticeBo.getPatronName() != null) ? noticeBo.getPatronName().toString() : "")));
1233 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1234 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1235 pdfTable.addCell(pdfPCell);
1236
1237 pdfPCell = new PdfPCell(new Paragraph(new Chunk((noticeBo.getPatronAddress() != null) ? noticeBo.getPatronAddress().toString() : "")));
1238 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1239 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1240 pdfTable.addCell(pdfPCell);
1241
1242 pdfPCell = new PdfPCell(new Paragraph(new Chunk((noticeBo.getPatronEmailAddress() != null) ? noticeBo.getPatronEmailAddress().toString() : "")));
1243 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1244 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1245 pdfTable.addCell(pdfPCell);
1246
1247 pdfPCell = new PdfPCell(new Paragraph(new Chunk((noticeBo.getPatronPhoneNumber() != null) ? noticeBo.getPatronPhoneNumber().toString() : "")));
1248 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1249 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1250 pdfTable.addCell(pdfPCell);
1251
1252 document.add(pdfTable);
1253
1254 pdfTable = new PdfPTable(1);
1255 pdfTable.setWidths(new int[]{10});
1256
1257 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getNoticeName(),boldFont)));
1258 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1259 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_CENTER);
1260 pdfTable.addCell(pdfPCell);
1261
1262 pdfPCell = new PdfPCell(new Paragraph(Chunk.NEWLINE));
1263 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1264 pdfTable.addCell(pdfPCell);
1265
1266 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getNoticeSpecificContent())));
1267 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1268 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1269 pdfTable.addCell(pdfPCell);
1270
1271 pdfPCell = new PdfPCell(new Paragraph(Chunk.NEWLINE));
1272 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1273 pdfTable.addCell(pdfPCell);
1274
1275 pdfPCell = new PdfPCell(new Paragraph("Thank you."));
1276
1277 Paragraph paraGraph = new Paragraph();
1278 paraGraph.add(Chunk.NEWLINE);
1279 document.add(paraGraph);
1280
1281 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1282 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1283 pdfTable.addCell(pdfPCell);
1284
1285 document.add(pdfTable);
1286
1287 paraGraph = new Paragraph();
1288 paraGraph.add(Chunk.NEWLINE);
1289 document.add(paraGraph);
1290
1291 PdfPTable pdfItemTable = new PdfPTable(3);
1292 pdfItemTable.setWidths(new int[]{10,2,30});
1293
1294 String author=((noticeBo.getAuthor() != null) ? noticeBo.getAuthor().toString() : "");
1295 String title=((noticeBo.getTitle() != null) ? noticeBo.getTitle().toString() : "");
1296 String callNumber=((noticeBo.getItemCallNumber()!=null)?noticeBo.getItemCallNumber().toString():"");
1297
1298 PdfPCell pdfItemCell = new PdfPCell(new Paragraph(new Chunk("Title")));
1299 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1300 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1301 pdfItemTable.addCell(pdfItemCell);
1302
1303 pdfItemCell = new PdfPCell(new Paragraph(new Chunk(":")));
1304 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1305 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1306 pdfItemTable.addCell(pdfItemCell);
1307
1308 pdfItemCell = new PdfPCell(new Paragraph(new Chunk(title)));
1309 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1310 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1311 pdfItemTable.addCell(pdfItemCell);
1312
1313 pdfItemCell = new PdfPCell(new Paragraph(new Chunk("Author")));
1314 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1315 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1316 pdfItemTable.addCell(pdfItemCell);
1317
1318 pdfItemCell = new PdfPCell(new Paragraph(new Chunk(":")));
1319 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1320 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1321 pdfItemTable.addCell(pdfItemCell);
1322
1323 pdfItemCell = new PdfPCell(new Paragraph(new Chunk(author)));
1324 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1325 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1326 pdfItemTable.addCell(pdfItemCell);
1327
1328 pdfItemCell = new PdfPCell(new Paragraph(new Chunk("Call Number")));
1329 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1330 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1331 pdfItemTable.addCell(pdfItemCell);
1332
1333 pdfItemCell = new PdfPCell(new Paragraph(new Chunk(":")));
1334 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1335 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1336 pdfItemTable.addCell(pdfItemCell);
1337
1338 pdfItemCell = new PdfPCell(new Paragraph(new Chunk(callNumber)));
1339 pdfItemCell.setBorder(pdfPCell.NO_BORDER);
1340 pdfItemCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1341 pdfItemTable.addCell(pdfItemCell);
1342
1343 document.add(pdfItemTable);
1344
1345 document.close();
1346 outputStream.close();
1347
1348 }
1349 public String getEmailPickUpNotice(OleNoticeBo noticeBo) throws Exception {
1350 StringBuffer stringBuffer=new StringBuffer();
1351 stringBuffer.append("<TABLE>");
1352 stringBuffer.append("<TR><TD>");
1353 stringBuffer.append("<TABLE>");
1354 stringBuffer.append("<TR><TD COLSPAN='3'>" + ((noticeBo.getPatronName() != null) ? noticeBo.getPatronName().toString() : "") + " </TD></TR>");
1355 stringBuffer.append("<TR><TD COLSPAN='3'>" + ((noticeBo.getPatronAddress() != null) ? noticeBo.getPatronAddress().toString() : "") + " </TD></TR>");
1356 stringBuffer.append("<TR><TD COLSPAN='3'>" + ((noticeBo.getPatronEmailAddress() != null) ? noticeBo.getPatronEmailAddress().toString() : "") + " </TD></TR>");
1357 stringBuffer.append("<TR><TD COLSPAN='3'>" + ((noticeBo.getPatronPhoneNumber() != null) ? noticeBo.getPatronPhoneNumber().toString() : "") + " </TD></TR>");
1358 stringBuffer.append("</TABLE>");
1359 stringBuffer.append("</TD></TR>");
1360
1361 stringBuffer.append("<TR><TD align='center'>");
1362 stringBuffer.append("<B>"+noticeBo.getNoticeName()+"</B>");
1363 stringBuffer.append("</TD></TR>");
1364
1365 stringBuffer.append("<TR><TD align='left'>");
1366 stringBuffer.append("<P>"+noticeBo.getNoticeSpecificContent()+"</P>");
1367 stringBuffer.append("</TD></TR>");
1368
1369 stringBuffer.append("<TR><TD align='left'>");
1370 stringBuffer.append("<P>Thank you .</P>");
1371 stringBuffer.append("</TD></TR>");
1372
1373 stringBuffer.append("<TR><TD>");
1374 String author = ((noticeBo.getAuthor() != null) ? noticeBo.getAuthor().toString() : "");
1375 String title = ((noticeBo.getTitle() != null) ? noticeBo.getTitle().toString() : "");
1376 String callNumber = ((noticeBo.getItemCallNumber() != null) ? noticeBo.getItemCallNumber().toString() : "");
1377 stringBuffer.append("<TR><TD>");
1378 stringBuffer.append("<TABLE>");
1379 stringBuffer.append("<TR><TD COLSPAN='3'> Title : " + title + " </TD></TR>");
1380 stringBuffer.append("<TR><TD COLSPAN='3'> Author : " + author + " </TD></TR>");
1381 stringBuffer.append("<TR><TD COLSPAN='3'> Call Number :" + callNumber + " </TD></TR>");
1382 stringBuffer.append("</TABLE>");
1383 stringBuffer.append("</TD></TR>");
1384 stringBuffer.append("</TABLE>");
1385 return stringBuffer.toString();
1386 }
1387
1388 public String generateMailContentFromPatronBill(OleLoanDocument oleLoanDocument,OlePatronDocument olePatronDocument,String feeTypeName,String fineAmount,PatronBillPayment patronBillPayment ){
1389 StringBuffer contentForSendMail=new StringBuffer();
1390 OleDeliverRequestDocumentHelperServiceImpl oleDeliverRequestDocumentHelperService=new OleDeliverRequestDocumentHelperServiceImpl();
1391 String patronMail="";
1392 String patronAddress="";
1393 String patronPhoneNumber="";
1394 try{
1395 patronMail=oleDeliverRequestDocumentHelperService.getPatronHomeEmailId(olePatronDocument.getEntity().getEntityTypeContactInfos().get(0));
1396 patronAddress=oleDeliverRequestDocumentHelperService.getPatronPreferredAddress(olePatronDocument.getEntity().getEntityTypeContactInfos().get(0));
1397 patronPhoneNumber=oleDeliverRequestDocumentHelperService.getPatronHomePhoneNumber(olePatronDocument.getEntity().getEntityTypeContactInfos().get(0));
1398 }catch(Exception e){
1399 LOG.error("Exception while generating mail content from patron bill",e);
1400 }
1401 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
1402 contentForSendMail.append("<HTML>");
1403 contentForSendMail.append("<TITLE><CENTER><h2>"+ feeTypeName + " Bill </h2></CENTER></TITLE>");
1404 contentForSendMail.append("<HEAD><TR><TD><CENTER><h2>" + feeTypeName + "<h2></CENTER></TD></TR></HEAD>");
1405 contentForSendMail.append("<BODY>");
1406 contentForSendMail.append("<TABLE width=\"100%\">");
1407 contentForSendMail.append("<TR><TD><h3>Patron Details</h3></TD></TR>");
1408 contentForSendMail.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");;
1409 contentForSendMail.append("<TABLE></BR></BR>");
1410 contentForSendMail.append("<TR><TD>PatronName</TD><TD>:</TD><TD>" + olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + olePatronDocument.getEntity().getNames().get(0).getLastName() + "</TD></TR>");
1411 contentForSendMail.append("<TR><TD>Address</TD><TD>:</TD><TD>" + patronAddress + "</TD></TR>");
1412 contentForSendMail.append("<TR><TD>EMAIL</TD><TD>:</TD><TD>" + patronMail + "</TD></TR>");
1413 contentForSendMail.append("<TR><TD>PhoneNumber</TD><TD>:</TD><TD>" + ( patronPhoneNumber!=null ? patronPhoneNumber : "") + "</TD></TR>");
1414 contentForSendMail.append("</TABLE>");
1415 contentForSendMail.append("<TABLE></BR></BR>");
1416 contentForSendMail.append("<TR><TD> </TD><TD> </TD></TR>");
1417 contentForSendMail.append("<TABLE width=\"100%\">");
1418 contentForSendMail.append("<TR><TD><h3>Fine Details</h3></TD></TR>");
1419 contentForSendMail.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");
1420 contentForSendMail.append("<TABLE></BR></BR>");
1421 contentForSendMail.append("<TR><TD>Bill Number</TD><TD>:</TD><TD>" + patronBillPayment.getBillNumber() + "</TD></TR>");
1422 contentForSendMail.append("<TR><TD>Fee Type</TD><TD>:</TD><TD>" + feeTypeName + "</TD></TR>");
1423 contentForSendMail.append("<TR><TD>Fee Amount</TD><TD>:</TD><TD>" +"$"+ fineAmount + "</TD></TR>");
1424 contentForSendMail.append("<TR><TD>Item Barcode</TD><TD>:</TD><TD>" + oleLoanDocument.getItemId() + "</TD></TR>");
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491 String issue = new String(" ");
1492 contentForSendMail.append("<TR><TD>Title</TD><TD>:</TD><TD>" + (oleLoanDocument.getTitle()!=null ? oleLoanDocument.getTitle() : "") + "</TD></TR>");
1493 contentForSendMail.append("<TR><TD>Author</TD><TD>:</TD><TD>" + (oleLoanDocument.getAuthor()!=null ? oleLoanDocument.getAuthor() : "") + "</TD></TR>");
1494 contentForSendMail.append("<TR><TD>Volume/Issue/Copy # </TD><TD>:</TD><TD>" + (oleLoanDocument.getItemVolumeNumber()!=null? oleLoanDocument.getItemVolumeNumber():"") + "/" + issue + "/" + (oleLoanDocument.getItemCopyNumber()!=null? oleLoanDocument.getItemCopyNumber():"")+ "</TD></TR>");
1495 contentForSendMail.append("<TR><TD>Library Shelving Location</TD><TD>:</TD><TD>" + oleLoanDocument.getLocation() + "</TD></TR>");
1496 contentForSendMail.append("<TR><TD>Call Number</TD><TD>:</TD><TD>" + (oleLoanDocument.getItemCallNumber()!=null? oleLoanDocument.getItemCallNumber():"") + "</TD></TR>");
1497 contentForSendMail.append("<TR><TD>Item was Due</TD><TD>:</TD><TD>" + (oleLoanDocument.getLoanDueDate()!=null ? sdf.format(oleLoanDocument.getLoanDueDate()) : "") + "</TD></TR>");
1498 contentForSendMail.append("</TABLE>");
1499 contentForSendMail.append("</BODY>");
1500 contentForSendMail.append("</HTML>");
1501 return contentForSendMail.toString();
1502 }
1503
1504 public void getPdfTemplateFooterList(List<OleNoticeBo> oleNoticeBoList, Document document) throws Exception {
1505
1506 SimpleDateFormat dateFormat = new SimpleDateFormat(OLEConstants.DATEFORMAT);
1507 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
1508 int count = 0;
1509 for (OleNoticeBo noticeBo : oleNoticeBoList) {
1510 if (LOG.isDebugEnabled()){
1511 LOG.debug("Footer for the notice : " + noticeBo.getNoticeName() + noticeBo.getItemId());
1512 }
1513 Paragraph paraGraph = new Paragraph();
1514 if (count == 0) {
1515 paraGraph.add(new Chunk("Title/item information", boldFont));
1516 }
1517 paraGraph.add(Chunk.NEWLINE);
1518 paraGraph.add(Chunk.NEWLINE);
1519 document.add(paraGraph);
1520 PdfPTable pdfTable = new PdfPTable(3);
1521 pdfTable.setWidths(new int[]{20, 2, 30});
1522 PdfPCell pdfPCell;
1523 if (!noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)) {
1524 pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
1525 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1526 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1527 pdfTable.addCell(pdfPCell);
1528 pdfPCell = new PdfPCell(new Paragraph(":"));
1529 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1530 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1531 pdfTable.addCell(pdfPCell);
1532 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "")));
1533 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1534 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1535 pdfTable.addCell(pdfPCell);
1536 }
1537 pdfPCell = new PdfPCell(new Paragraph("Title "));
1538 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1539 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1540 pdfTable.addCell(pdfPCell);
1541 pdfPCell = new PdfPCell(new Paragraph(":"));
1542 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1543 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1544 pdfTable.addCell(pdfPCell);
1545 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getTitle() == null ? "" : noticeBo.getTitle())));
1546 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1547 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1548 pdfTable.addCell(pdfPCell);
1549 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Author ")));
1550 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1551 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1552 pdfTable.addCell(pdfPCell);
1553 pdfPCell = new PdfPCell(new Paragraph(":"));
1554 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1555 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1556 pdfTable.addCell(pdfPCell);
1557 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getAuthor() == null ? "" : noticeBo.getAuthor())));
1558 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1559 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1560 pdfTable.addCell(pdfPCell);
1561 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Volume/Issue/Copy # ")));
1562 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1563 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1564 pdfTable.addCell(pdfPCell);
1565 pdfPCell = new PdfPCell(new Paragraph(":"));
1566 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1567 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1568 pdfTable.addCell(pdfPCell);
1569 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getVolumeNumber() == null ? "" : noticeBo.getVolumeNumber())));
1570 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1571 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1572 pdfTable.addCell(pdfPCell);
1573 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Library shelving location ")));
1574 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1575 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1576 pdfTable.addCell(pdfPCell);
1577 pdfPCell = new PdfPCell(new Paragraph(":"));
1578 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1579 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1580 pdfTable.addCell(pdfPCell);
1581 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemShelvingLocation() == null ? "" : noticeBo.getItemShelvingLocation())));
1582 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1583 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1584 pdfTable.addCell(pdfPCell);
1585 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Call # ")));
1586 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1587 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1588 pdfTable.addCell(pdfPCell);
1589 pdfPCell = new PdfPCell(new Paragraph(":"));
1590 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1591 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1592 pdfTable.addCell(pdfPCell);
1593 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemCallNumber() == null ? "" : noticeBo.getItemCallNumber())));
1594 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1595 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1596 pdfTable.addCell(pdfPCell);
1597 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item barcode")));
1598 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1599 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1600 pdfTable.addCell(pdfPCell);
1601 pdfPCell = new PdfPCell(new Paragraph(":"));
1602 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1603 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1604 pdfTable.addCell(pdfPCell);
1605 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getItemId() == null ? "" : noticeBo.getItemId())));
1606 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1607 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1608 pdfTable.addCell(pdfPCell);
1609 if (noticeBo.getExpiredOnHoldDate() != null) {
1610 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Expiration onHoldDate")));
1611 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1612 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1613 pdfTable.addCell(pdfPCell);
1614 pdfPCell = new PdfPCell(new Paragraph(":"));
1615 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1616 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1617 pdfTable.addCell(pdfPCell);
1618 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getExpiredOnHoldDate() == null ? "" : dateFormat.format(noticeBo.getExpiredOnHoldDate()))));
1619 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1620 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1621 pdfTable.addCell(pdfPCell);
1622 }
1623 document.add(pdfTable);
1624 paraGraph = new Paragraph();
1625 paraGraph.add(Chunk.NEWLINE);
1626 document.add(paraGraph);
1627 if (noticeBo.getNoticeName().equals("OverdueNotice")) {
1628 if (LOG.isDebugEnabled()){
1629 LOG.debug("OverdueNotice Footer Content : " + noticeBo.getNoticeName() + noticeBo.getItemId());
1630 }
1631 pdfTable = new PdfPTable(3);
1632 pdfTable.setWidths(new int[]{20, 2, 30});
1633
1634 pdfPCell = new PdfPCell(new Paragraph("Item was due"));
1635 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1636 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1637 pdfTable.addCell(pdfPCell);
1638 pdfPCell = new PdfPCell(new Paragraph(":"));
1639 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1640 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1641 pdfTable.addCell(pdfPCell);
1642 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getDueDate() == null ? "" : (sdf.format(noticeBo.getDueDate()).toString()))));
1643 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1644 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1645 pdfTable.addCell(pdfPCell);
1646 document.add(pdfTable);
1647 paraGraph = new Paragraph();
1648 paraGraph.add(Chunk.NEWLINE);
1649 document.add(paraGraph);
1650 }
1651 count++;
1652 }
1653 }
1654
1655 public String getOverdueNoticeHTMLContent(OleLoanDocument oleLoanDocument){
1656 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
1657 StringBuffer stringBuffer = new StringBuffer();
1658 try {
1659 stringBuffer.append("<table>");
1660 stringBuffer.append("<TR><TD>Title :</TD><TD>" + (oleLoanDocument.getTitle() != null ? oleLoanDocument.getTitle() : "") + "</TD></TR>");
1661 stringBuffer.append("<TR><TD>Author :</TD><TD>" + (oleLoanDocument.getAuthor() != null ? oleLoanDocument.getAuthor() : "") + "</TD></TR>");
1662 String volume = (String) oleLoanDocument.getEnumeration()!= null && !oleLoanDocument.getEnumeration().equals("") ? oleLoanDocument.getEnumeration() : "";
1663 String issue = new String(" ");
1664 String copyNumber = (String) oleLoanDocument.getItemCopyNumber() != null && !oleLoanDocument.getItemCopyNumber().equals("") ? oleLoanDocument.getItemCopyNumber() : "";
1665 String volumeNumber=volume + "/" + issue + "/" + copyNumber;
1666 stringBuffer.append("<TR><TD>Volume/Issue/Copy Number :</TD><TD>" + (volumeNumber != null ? volumeNumber : "") + "</TD></TR>");
1667 stringBuffer.append("<TR><TD>Item was due :</TD><TD>" + (oleLoanDocument.getLoanDueDate() != null ? sdf.format(oleLoanDocument.getLoanDueDate()).toString() : "") + "</TD></TR>");
1668 stringBuffer.append("<TR><TD>Library shelving location :</TD><TD>" + (itemShelvingLocationName(oleLoanDocument.getItemLocation()) != null ? itemShelvingLocationName(oleLoanDocument.getItemLocation()) : "") + "</TD></TR>");
1669 try {
1670 String callNumber = "";
1671 if (oleLoanDocument.getItemCallNumber() != null && !oleLoanDocument.getItemCallNumber().equals("")) {
1672 callNumber = oleLoanDocument.getItemCallNumber();
1673 }
1674 stringBuffer.append("<TR><TD>Call Number :</TD><TD>" + (callNumber != null ? callNumber : "") + "</TD></TR>");
1675 } catch (Exception e) {
1676 e.printStackTrace();
1677 }
1678 stringBuffer.append("<TR><TD>Item Barcode :</TD><TD>" + (oleLoanDocument.getItemId() != null ? oleLoanDocument.getItemId() : "") + "</TD></TR>");
1679 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
1680 stringBuffer.append("</table>");
1681 }catch (Exception e){
1682 LOG.error("Error---->While generating verdue content for email pdf ");
1683 if(oleLoanDocument!=null){
1684 LOG.error("Error---->Item Barcode "+oleLoanDocument.getItemId());
1685 }
1686 LOG.error(e.getMessage()+e);
1687 }
1688 return stringBuffer.toString();
1689 }
1690 public String getHeaderAndPatronContent(OlePatronDocument olePatronDocument,boolean isOverdue){
1691
1692 StringBuffer stringBuffer = new StringBuffer();
1693 try{
1694 String title = getLoanProcessor().getParameter(OLEParameterConstants.OVERDUE_TITLE);
1695 String body = getLoanProcessor().getParameter(OLEParameterConstants.OVERDUE_BODY);
1696 if(!isOverdue){
1697 title=loanProcessor.getParameter(OLEParameterConstants.COURTESY_TITLE);
1698 body=loanProcessor.getParameter(OLEParameterConstants.COURTESY_BODY);
1699 }
1700 OleDeliverRequestDocumentHelperServiceImpl deliverService = new OleDeliverRequestDocumentHelperServiceImpl();
1701 EntityTypeContactInfoBo entityTypeContactInfoBo = olePatronDocument.getEntity().getEntityTypeContactInfos().get(0);
1702
1703 stringBuffer.append("<HTML>");
1704 stringBuffer.append("<TITLE>" + title + "</TITLE>");
1705 stringBuffer.append("<HEAD></HEAD>");
1706 stringBuffer.append("<BODY>");
1707
1708 try{
1709 stringBuffer.append("<TABLE></BR></BR>");
1710 stringBuffer.append("<TR><TD>Patron Name :</TD><TD>" + olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + olePatronDocument.getEntity().getNames().get(0).getLastName() + "</TD></TR>");
1711 stringBuffer.append("<TR><TD>Address :</TD><TD>" + (deliverService.getPatronPreferredAddress(entityTypeContactInfoBo) != null ? deliverService.getPatronPreferredAddress(entityTypeContactInfoBo) : "") + "</TD></TR>");
1712 stringBuffer.append("<TR><TD>EMAIL :</TD><TD>" + (deliverService.getPatronHomeEmailId(entityTypeContactInfoBo) != null ? deliverService.getPatronHomeEmailId(entityTypeContactInfoBo) : "") + "</TD></TR>");
1713
1714 stringBuffer.append("<TR><TD>Phone Number :</TD><TD>" +(deliverService.getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? deliverService.getPatronHomePhoneNumber(entityTypeContactInfoBo) : "") + "</TD></TR>");
1715 } catch (Exception e){
1716 e.printStackTrace();
1717 }
1718 stringBuffer.append("</TABLE>");
1719
1720 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR>");
1721 stringBuffer.append("<TABLE width=\"100%\">");
1722 stringBuffer.append("<TR><TD><CENTER>" + title + "</CENTER></TD></TR>");
1723 stringBuffer.append("<TR><TD><p>" + body + "</p></TD></TR>");
1724 stringBuffer.append("<TR><TD> </TD><TD> </TD></TR></TABLE>");
1725 }catch (Exception e){
1726 LOG.error("Error---->While generating overdue content for email(Patron Information) ");
1727 }
1728 return stringBuffer.toString();
1729 }
1730
1731 public void getHeaderAndPatronPDFContent(OlePatronDocument olePatronDocument,boolean isOverdue){
1732 Document document = new Document(PageSize.A4);
1733 OutputStream outputStream=null;
1734 try {
1735 String title = getLoanProcessor().getParameter(OLEParameterConstants.OVERDUE_TITLE);
1736 String body = getLoanProcessor().getParameter(OLEParameterConstants.OVERDUE_BODY);
1737 if(!isOverdue){
1738 title=loanProcessor.getParameter(OLEParameterConstants.COURTESY_TITLE);
1739 body=loanProcessor.getParameter(OLEParameterConstants.COURTESY_BODY);
1740 }
1741 outputStream = getPdfHeader(document, outputStream, title, olePatronDocument.getOlePatronId());
1742 OleDeliverRequestDocumentHelperServiceImpl deliverService = new OleDeliverRequestDocumentHelperServiceImpl();
1743 EntityTypeContactInfoBo entityTypeContactInfoBo = olePatronDocument.getEntity().getEntityTypeContactInfos().get(0);
1744 Paragraph paraGraph = new Paragraph();
1745 paraGraph.add(Chunk.NEWLINE);
1746 document.add(paraGraph);
1747 paraGraph = new Paragraph();
1748 paraGraph.add(new Chunk("Patron information", boldFont));
1749 paraGraph.add(Chunk.NEWLINE);
1750 paraGraph.add(Chunk.NEWLINE);
1751 document.add(paraGraph);
1752
1753 PdfPTable pdfTable = new PdfPTable(3);
1754 pdfTable.setWidths(new int[]{20, 2, 30});
1755 PdfPCell pdfPCell = new PdfPCell(new Paragraph("Patron Name"));
1756 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1757 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1758 pdfTable.addCell(pdfPCell);
1759 pdfPCell = new PdfPCell(new Paragraph(":"));
1760 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1761 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1762 pdfTable.addCell(pdfPCell);
1763 pdfPCell = new PdfPCell(new Paragraph(new Chunk(olePatronDocument.getEntity().getNames().get(0).getFirstName() + " " + olePatronDocument.getEntity().getNames().get(0).getLastName())));
1764 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1765 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1766 pdfTable.addCell(pdfPCell);
1767 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
1768 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1769 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1770 pdfTable.addCell(pdfPCell);
1771 pdfPCell = new PdfPCell(new Paragraph(":"));
1772 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1773 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1774 pdfTable.addCell(pdfPCell);
1775 pdfPCell = new PdfPCell(new Paragraph(new Chunk(deliverService.getPatronPreferredAddress(entityTypeContactInfoBo) != null ? deliverService.getPatronPreferredAddress(entityTypeContactInfoBo) : "")));
1776 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1777 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1778 pdfTable.addCell(pdfPCell);
1779 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
1780 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1781 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1782 pdfTable.addCell(pdfPCell);
1783 pdfPCell = new PdfPCell(new Paragraph(":"));
1784 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1785 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1786 pdfTable.addCell(pdfPCell);
1787 pdfPCell = new PdfPCell(new Paragraph(new Chunk(deliverService.getPatronHomeEmailId(entityTypeContactInfoBo) != null ? deliverService.getPatronHomeEmailId(entityTypeContactInfoBo) : "")));
1788 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1789 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1790 pdfTable.addCell(pdfPCell);
1791 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
1792 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1793 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1794 pdfTable.addCell(pdfPCell);
1795 pdfPCell = new PdfPCell(new Paragraph(":"));
1796 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1797 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1798 pdfTable.addCell(pdfPCell);
1799 pdfPCell = new PdfPCell(new Paragraph(new Chunk(deliverService.getPatronHomePhoneNumber(entityTypeContactInfoBo) != null ? deliverService.getPatronHomePhoneNumber(entityTypeContactInfoBo) : "")));
1800 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1801 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1802 pdfTable.addCell(pdfPCell);
1803 document.add(pdfTable);
1804 paraGraph = new Paragraph();
1805 paraGraph.add(Chunk.NEWLINE);
1806 document.add(paraGraph);
1807
1808
1809 getPdfTemplateBody(document, title, body);
1810 paraGraph = new Paragraph();
1811 paraGraph.add(new Chunk("Title/item information", boldFont));
1812 paraGraph.add(Chunk.NEWLINE);
1813 paraGraph.add(Chunk.NEWLINE);
1814 document.add(paraGraph);
1815 this.setOverdueDocument(document);
1816 this.setOverdueOutPutStream(outputStream);
1817 } catch (Exception e) {
1818 LOG.error("Error---->While generating overdue notice pdf (Patron Information) "+e.getMessage()+e);
1819 }
1820
1821 }
1822
1823 public Document getOverdueNoticePDFContent(OleLoanDocument oleLoanDocument, boolean isOverdue, Document document) {
1824 try {
1825 Paragraph paraGraph = new Paragraph();
1826 OleDeliverRequestDocumentHelperServiceImpl deliverService = new OleDeliverRequestDocumentHelperServiceImpl();
1827 SimpleDateFormat sdf = new SimpleDateFormat(OLEConstants.TIMESTAMP);
1828 PdfPTable pdfTable = new PdfPTable(3);
1829 pdfTable.setWidths(new int[]{20, 2, 30});
1830 PdfPCell pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
1831 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1832 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1833 pdfTable.addCell(pdfPCell);
1834 pdfPCell = new PdfPCell(new Paragraph(":"));
1835 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1836 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1837 pdfTable.addCell(pdfPCell);
1838 OleCirculationDesk oleCirculationDesk = deliverService.getOleCirculationDesk(oleLoanDocument.getCirculationLocationId());
1839 pdfPCell = new PdfPCell(new Paragraph(new Chunk(oleCirculationDesk.getCirculationDeskPublicName() != null ? oleCirculationDesk.getCirculationDeskPublicName() : "")));
1840 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1841 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1842 pdfTable.addCell(pdfPCell);
1843
1844 pdfPCell = new PdfPCell(new Paragraph("Title "));
1845 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1846 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1847 pdfTable.addCell(pdfPCell);
1848 pdfPCell = new PdfPCell(new Paragraph(":"));
1849 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1850 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1851 pdfTable.addCell(pdfPCell);
1852 pdfPCell = new PdfPCell(new Paragraph(new Chunk(oleLoanDocument.getTitle() == null ? "" : oleLoanDocument.getTitle())));
1853 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1854 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1855 pdfTable.addCell(pdfPCell);
1856 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Author ")));
1857 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1858 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1859 pdfTable.addCell(pdfPCell);
1860 pdfPCell = new PdfPCell(new Paragraph(":"));
1861 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1862 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1863 pdfTable.addCell(pdfPCell);
1864 pdfPCell = new PdfPCell(new Paragraph(new Chunk(oleLoanDocument.getAuthor() == null ? "" : oleLoanDocument.getAuthor())));
1865 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1866 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1867 pdfTable.addCell(pdfPCell);
1868 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Volume/Issue/Copy # ")));
1869 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1870 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1871 pdfTable.addCell(pdfPCell);
1872 pdfPCell = new PdfPCell(new Paragraph(":"));
1873 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1874 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1875 pdfTable.addCell(pdfPCell);
1876 String volume = (String) oleLoanDocument.getEnumeration() != null && !oleLoanDocument.getEnumeration().equals("") ? oleLoanDocument.getEnumeration() : "";
1877 String issue = new String(" ");
1878 String copyNumber = (String) oleLoanDocument.getItemCopyNumber() != null && !oleLoanDocument.getItemCopyNumber().equals("") ? oleLoanDocument.getItemCopyNumber(): "";
1879 String volumeNumber = volume + "/" + issue + "/" + copyNumber;
1880 pdfPCell = new PdfPCell(new Paragraph(new Chunk(volumeNumber == null ? "" : volumeNumber)));
1881 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1882 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1883 pdfTable.addCell(pdfPCell);
1884 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Library shelving location ")));
1885 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1886 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1887 pdfTable.addCell(pdfPCell);
1888 pdfPCell = new PdfPCell(new Paragraph(":"));
1889 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1890 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1891 pdfTable.addCell(pdfPCell);
1892 pdfPCell = new PdfPCell(new Paragraph(new Chunk(oleLoanDocument.getItemLocation() == null ? "" : oleLoanDocument.getItemLocation())));
1893 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1894 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1895 pdfTable.addCell(pdfPCell);
1896 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Call # ")));
1897 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1898 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1899 pdfTable.addCell(pdfPCell);
1900 pdfPCell = new PdfPCell(new Paragraph(":"));
1901 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1902 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1903 pdfTable.addCell(pdfPCell);
1904 String callNumber = "";
1905 if (oleLoanDocument.getItemCallNumber() != null && !oleLoanDocument.getItemCallNumber().equals("")) {
1906 callNumber = (String) (oleLoanDocument.getItemCallNumber() != null && !oleLoanDocument.getItemCallNumber().equals("") ? oleLoanDocument.getItemCallNumber() : "");
1907 }
1908 pdfPCell = new PdfPCell(new Paragraph(new Chunk(callNumber == null ? "" : callNumber)));
1909 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1910 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1911 pdfTable.addCell(pdfPCell);
1912 pdfPCell = new PdfPCell(new Paragraph(new Chunk("Item barcode")));
1913 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1914 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1915 pdfTable.addCell(pdfPCell);
1916 pdfPCell = new PdfPCell(new Paragraph(":"));
1917 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1918 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1919 pdfTable.addCell(pdfPCell);
1920 pdfPCell = new PdfPCell(new Paragraph(new Chunk(oleLoanDocument.getItemId() == null ? "" : oleLoanDocument.getItemId())));
1921 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1922 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1923 pdfTable.addCell(pdfPCell);
1924 document.add(pdfTable);
1925 paraGraph = new Paragraph();
1926 paraGraph.add(Chunk.NEWLINE);
1927 document.add(paraGraph);
1928
1929 pdfTable = new PdfPTable(3);
1930 pdfTable.setWidths(new int[]{20, 2, 30});
1931
1932 pdfPCell = new PdfPCell(new Paragraph("Item was due"));
1933 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1934 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1935 pdfTable.addCell(pdfPCell);
1936 pdfPCell = new PdfPCell(new Paragraph(":"));
1937 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1938 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
1939 pdfTable.addCell(pdfPCell);
1940 pdfPCell = new PdfPCell(new Paragraph(new Chunk(oleLoanDocument.getLoanDueDate() == null ? "" : (sdf.format(oleLoanDocument.getLoanDueDate()).toString()))));
1941 pdfPCell.setBorder(pdfPCell.NO_BORDER);
1942 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
1943 pdfTable.addCell(pdfPCell);
1944 document.add(pdfTable);
1945 paraGraph = new Paragraph();
1946 paraGraph.add(Chunk.NEWLINE);
1947 document.add(paraGraph);
1948
1949 } catch (Exception e) {
1950 LOG.error("Error---->While generating overdue notice pdf ");
1951 if(oleLoanDocument!=null){
1952 LOG.error("Error---->Item Barcode "+oleLoanDocument.getItemId());
1953 }
1954 LOG.error(e.getMessage()+e);
1955 }
1956 return document;
1957 }
1958
1959 public boolean cleanZeroByteFiles() {
1960 boolean isFileDeleted=false;
1961 String pdfLocationSystemParam = getLoanProcessor().getParameter(OLEParameterConstants.PDF_LOCATION);
1962 if (LOG.isDebugEnabled()) {
1963 LOG.debug("System Parameter for PDF_Location --> " + pdfLocationSystemParam);
1964 }
1965 if (pdfLocationSystemParam == null || pdfLocationSystemParam.trim().isEmpty()) {
1966 pdfLocationSystemParam = ConfigContext.getCurrentContextConfig().getProperty("staging.directory") + "/";
1967 if (LOG.isDebugEnabled()) {
1968 LOG.debug("System Parameter for PDF_Location staging dir--> " + pdfLocationSystemParam);
1969 }
1970 } else {
1971 pdfLocationSystemParam = ConfigContext.getCurrentContextConfig().getProperty("homeDirectory") + "/" + pdfLocationSystemParam + "/";
1972 }
1973 File file=new File(pdfLocationSystemParam);
1974 boolean locationExist = file.exists();
1975 if(locationExist){
1976 try {
1977 File folder = new File(pdfLocationSystemParam);
1978 File[] listOfFiles = folder.listFiles();
1979 for (File file1 : listOfFiles) {
1980 if (file1.isFile() && file1.length()==0) {
1981 file1.delete();
1982 }
1983 }
1984 } catch (Exception e) {
1985
1986 LOG.error("Error in deleting the file"+e.getMessage());
1987 }
1988 }
1989 return isFileDeleted;
1990 }
1991
1992 }