View Javadoc
1   package org.kuali.ole.deliver.notice.executors;
2   
3   import org.apache.commons.collections.CollectionUtils;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.OLEParameterConstants;
6   import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
7   import org.kuali.ole.deliver.notice.bo.OleNoticeContentConfigurationBo;
8   import org.kuali.ole.deliver.notice.noticeFormatters.RequestEmailContentFormatter;
9   import org.kuali.ole.deliver.notice.noticeFormatters.RequestExpirationEmailContentFormatter;
10  import org.kuali.ole.deliver.service.OleDeliverRequestDocumentHelperServiceImpl;
11  
12  import java.util.HashMap;
13  import java.util.List;
14  import java.util.Map;
15  
16  /**
17   * Created by maheswarang on 6/24/15.
18   */
19  public class HoldExpirationNoticesExecutor extends RequestNoticesExecutor {
20  
21      public HoldExpirationNoticesExecutor(Map requestMap) {
22          super(requestMap);
23      }
24  
25      public OleDeliverRequestDocumentHelperServiceImpl getOleDeliverRequestHelperService(){
26          return new OleDeliverRequestDocumentHelperServiceImpl();
27      }
28  
29      @Override
30      public RequestEmailContentFormatter getRequestEmailContentFormatter() {
31          if(requestEmailContentFormatter == null){
32          requestEmailContentFormatter =  new RequestExpirationEmailContentFormatter();
33          }return requestEmailContentFormatter;
34          }
35  
36      @Override
37      public boolean isValidRequestToSendNotice(OleDeliverRequestBo oleDeliverRequestBo) {
38          return true;
39      }
40  
41      @Override
42      protected void postProcess() {
43          getOleDeliverRequestHelperService().deleteExpiredOnHoldNotices(deliverRequestBos);
44          //To do create the request history record and delete the record from the request table
45      }
46  
47      @Override
48      public void setOleNoticeContentConfigurationBo() {
49          List<OleNoticeContentConfigurationBo> oleNoticeContentConfigurationBoList = null;
50          Map<String,String> noticeConfigurationMap = new HashMap<String,String>();
51          noticeConfigurationMap.put("noticeType",OLEConstants.NOTICE_HOLD_COURTESY);
52          noticeConfigurationMap.put("noticeName", noticeContentConfigName);
53          oleNoticeContentConfigurationBoList= (List<OleNoticeContentConfigurationBo>)getBusinessObjectService().findMatching(OleNoticeContentConfigurationBo.class,noticeConfigurationMap);
54          if(CollectionUtils.isNotEmpty(oleNoticeContentConfigurationBoList)){
55              oleNoticeContentConfigurationBo = oleNoticeContentConfigurationBoList.get(0);
56          }else{
57              oleNoticeContentConfigurationBo = new OleNoticeContentConfigurationBo();
58              oleNoticeContentConfigurationBo.setNoticeType(getType());
59              oleNoticeContentConfigurationBo.setNoticeTitle(getTitle());
60              oleNoticeContentConfigurationBo.setNoticeBody(getBody());
61              oleNoticeContentConfigurationBo.setNoticeFooterBody("");
62          }
63      }
64  
65      @Override
66      public String getTitle() {
67          String title = getParameterResolverInstance().getParameter(OLEConstants.APPL_ID, OLEConstants
68                  .DLVR_NMSPC, OLEConstants.DLVR_CMPNT,
69                  OLEParameterConstants
70                          .EXPIRED_TITLE);
71          return title;
72      }
73  
74      @Override
75      public String getBody() {
76          String body = getParameterResolverInstance().getParameter(OLEConstants.APPL_ID_OLE, OLEConstants
77                  .DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.OleDeliverRequest.EXP_HOLD_NOTICE_CONTENT);
78          return body;
79      }
80  
81      @Override
82      public String getType() {
83          return OLEConstants.NOTICE_HOLD_COURTESY;
84      }
85  }