View Javadoc
1   package org.kuali.ole.select.maintenance;
2   
3   import org.kuali.ole.OLEParameterConstants;
4   import org.kuali.ole.deliver.batch.OleMailer;
5   import org.kuali.ole.deliver.processor.LoanProcessor;
6   import org.kuali.ole.select.bo.OLEClaimNoticeBo;
7   import org.kuali.rice.core.api.mail.EmailBody;
8   import org.kuali.rice.core.api.mail.EmailFrom;
9   import org.kuali.rice.core.api.mail.EmailSubject;
10  import org.kuali.rice.core.api.mail.EmailTo;
11  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
12  import org.kuali.rice.krad.bo.DocumentHeader;
13  import org.kuali.rice.krad.maintenance.MaintainableImpl;
14  import org.kuali.rice.krad.maintenance.MaintenanceLock;
15  
16  import java.util.Collections;
17  import java.util.List;
18  
19  /**
20   * Created with IntelliJ IDEA.
21   * User: vivekb
22   * Date: 1/2/14
23   * Time: 6:42 PM
24   * To change this template use File | Settings | File Templates.
25   */
26  public class OLEClaimNoticeMaintenanceImpl extends MaintainableImpl {
27  
28      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OLEClaimNoticeMaintenanceImpl.class);
29  
30  
31      @Override
32      public void doRouteStatusChange(DocumentHeader documentHeader) {
33           LOG.debug("doRouteStatusChange() starting");
34          super.doRouteStatusChange(documentHeader);
35  
36          try {
37              if (documentHeader.getWorkflowDocument().isFinal()) {
38                  OLEClaimNoticeBo oleClaimNoticeBo = (OLEClaimNoticeBo) this.getDataObject();
39                  OleMailer oleMail= GlobalResourceLoader.getService("oleMailer");
40                  if(oleClaimNoticeBo.getMailAddress()!=null && !oleClaimNoticeBo.getMailAddress().isEmpty()){
41                      LoanProcessor loanProcessor = new LoanProcessor();
42                      String fromMail = loanProcessor.getParameter(OLEParameterConstants.NOTICE_FROM_MAIL);
43                      oleMail.sendEmail(new EmailFrom(fromMail),new EmailTo(oleClaimNoticeBo.getMailAddress()), new EmailSubject("Claim Report"), new EmailBody(claimReportNotice(oleClaimNoticeBo)), true);
44                      if (LOG.isInfoEnabled()){
45                          LOG.info("Mail send successfully to "+oleClaimNoticeBo.getMailAddress());
46                      }
47                  }
48              }
49          } catch (Exception e) {
50              LOG.error("Exception saving routing data while saving document with id " + getDocumentNumber(), e);
51          }
52          LOG.debug("doRouteStatusChange() ending");
53      }
54  
55      public String claimReportNotice(OLEClaimNoticeBo oleClaimNoticeBo ) {
56  
57          StringBuffer stringBuffer = new StringBuffer();
58          stringBuffer.append("<HTML>");
59          stringBuffer.append("<TITLE>" + oleClaimNoticeBo.getTitle() + "</TITLE>");
60          stringBuffer.append("<HEAD><TR><TD><CENTER>" + oleClaimNoticeBo.getTitle() + "</CENTER></TD></TR></HEAD>");
61          stringBuffer.append("<BODY>");
62          stringBuffer.append("<TABLE></BR></BR>");
63          stringBuffer.append("<TR><TD>Name of the Sender :</TD><TD>" + oleClaimNoticeBo.getNameOfTheSender() + "</TD></TR>");
64          stringBuffer.append("<TR><TD>Name of the Vendor :</TD><TD>" + oleClaimNoticeBo.getNameOfTheVendor() + "</TD></TR>");
65          stringBuffer.append("<TR><TD>Claim Date :</TD><TD>" + oleClaimNoticeBo.getClaimDate() + "</TD></TR>");
66          stringBuffer.append("<TR><TD>Claim Count :</TD><TD>" + oleClaimNoticeBo.getClaimCount() + "</TD></TR>");
67          stringBuffer.append("<TR><TD>Claim Type :</TD><TD>" + oleClaimNoticeBo.getClaimTypeName() + "</TD></TR>");
68          stringBuffer.append("<TR><TD>Title :</TD><TD>" + oleClaimNoticeBo.getTitle() + "</TD></TR>");
69          stringBuffer.append("<TR><TD>Place of publication :</TD><TD>" + oleClaimNoticeBo.getPlaceOfPublication() + "</TD></TR>");
70          stringBuffer.append("<TR><TD>Publication :</TD><TD>" + oleClaimNoticeBo.getPublication() + "</TD></TR>");
71          stringBuffer.append("<TR><TD>Publication Date :</TD><TD>" + oleClaimNoticeBo.getPublicationDate() + "</TD></TR>");
72          stringBuffer.append("<TR><TD>Enumeration :</TD><TD>" + oleClaimNoticeBo.getEnumeration() + "</TD></TR>");
73          stringBuffer.append("<TR><TD>Chronology :</TD><TD>" + oleClaimNoticeBo.getChronology() + "</TD></TR>");
74          stringBuffer.append("<TR><TD>Vendor's Library Account Number :</TD><TD>" + oleClaimNoticeBo.getVendorsLibraryAcctNum() + "</TD></TR>");
75          stringBuffer.append("<TR><TD>Vendor Account Number :</TD><TD>" + oleClaimNoticeBo.getVendorOrderNumber() + "</TD></TR>");
76          stringBuffer.append("<TR><TD>Vendor Title Number :</TD><TD>" + oleClaimNoticeBo.getVendorTitleNumber() + "</TD></TR>");
77          stringBuffer.append("<TR><TD>Unbound Location :</TD><TD>" + oleClaimNoticeBo.getUnboundLocation() + "</TD></TR>");
78          stringBuffer.append("</TABLE>");
79          stringBuffer.append("</BODY>");
80          stringBuffer.append("</HTML>");
81          return stringBuffer.toString();
82  
83      }
84  
85      @Override
86      public List<MaintenanceLock> generateMaintenanceLocks() {
87          return Collections.emptyList();
88      }
89  
90  }