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