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