View Javadoc
1   package org.kuali.ole.batch.controller;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.apache.log4j.Logger;
5   import org.kuali.ole.DataCarrierService;
6   import org.kuali.ole.OLEConstants;
7   import org.kuali.ole.OLEPropertyConstants;
8   import org.kuali.ole.batch.bo.OLEBatchProcessJobDetailsBo;
9   import org.kuali.ole.batch.bo.OLEBatchProcessScheduleBo;
10  import org.kuali.ole.batch.document.OLEBatchProcessDefinitionDocument;
11  import org.kuali.ole.batch.form.OLEBatchProcessDefinitionForm;
12  import org.kuali.ole.batch.helper.OLEBatchProcessDataHelper;
13  import org.kuali.ole.batch.helper.OLESchedulerHelper;
14  import org.kuali.ole.batch.keyvalue.*;
15  import org.kuali.ole.batch.rule.OLEBatchProcessRule;
16  import org.kuali.ole.batch.service.OLEBatchSchedulerService;
17  import org.kuali.ole.select.document.OLEInvoiceIngestLoadReport;
18  import org.kuali.rice.core.api.config.property.ConfigContext;
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  import org.kuali.rice.krad.service.BusinessObjectService;
21  import org.kuali.rice.krad.service.KRADServiceLocator;
22  import org.kuali.rice.krad.uif.UifConstants;
23  import org.kuali.rice.krad.uif.UifParameters;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  import org.kuali.rice.krad.util.KRADConstants;
26  import org.kuali.rice.krad.web.controller.UifControllerBase;
27  import org.kuali.rice.krad.web.form.UifFormBase;
28  import org.springframework.stereotype.Controller;
29  import org.springframework.validation.BindingResult;
30  import org.springframework.web.bind.annotation.ModelAttribute;
31  import org.springframework.web.bind.annotation.RequestMapping;
32  import org.springframework.web.multipart.MultipartFile;
33  import org.springframework.web.servlet.ModelAndView;
34  
35  import javax.servlet.http.HttpServletRequest;
36  import javax.servlet.http.HttpServletResponse;
37  import java.sql.Timestamp;
38  import java.util.*;
39  
40  /**
41   * Created with IntelliJ IDEA.
42   * User: adityas
43   * Date: 7/12/13
44   * Time: 8:32 PM
45   * To change this template use File | Settings | File Templates.
46   */
47  @Controller
48  @RequestMapping(value = "/oleBatchProcessDefinitionController")
49  public class OLEBatchProcessDefinitionController extends UifControllerBase {
50  
51      protected static final Logger LOG = Logger.getLogger(OLEBatchProcessDefinitionController.class);
52      @Override
53      protected UifFormBase createInitialForm(HttpServletRequest request) {
54          OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = new OLEBatchProcessDefinitionForm();
55          return oleBatchProcessDefinitionForm;
56      }
57  
58      private OLEBatchProcessDataHelper oleBatchProcessDataHelper;
59      private OLEBatchProcessRule oleBatchProcessRule;
60      private BusinessObjectService businessObjectService;
61  
62      public OLEBatchProcessRule getOleBatchProcessRule() {
63          if (oleBatchProcessRule == null) {
64              oleBatchProcessRule = new OLEBatchProcessRule();
65          }
66          return oleBatchProcessRule;
67      }
68  
69      private OLEBatchProcessDataHelper getOLEBatchProcessDataHelper() {
70  
71          if (oleBatchProcessDataHelper == null) {
72              oleBatchProcessDataHelper = OLEBatchProcessDataHelper.getInstance();
73          }
74          return oleBatchProcessDataHelper;
75      }
76  
77      @RequestMapping(params = "methodToCall=startBatch")
78      public ModelAndView startBatch(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
79                                 HttpServletRequest request, HttpServletResponse response) throws Exception {
80          OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
81          oleBatchProcessDefinitionForm.setDocument(new OLEBatchProcessDefinitionDocument());
82          ModelAndView modelAndView = super.start(form, result, request, response);
83          boolean isValidated = getOleBatchProcessRule().canPerformBatchImport(GlobalVariables.getUserSession().getPrincipalId())
84                  || getOleBatchProcessRule().canPerformBatchExport(GlobalVariables.getUserSession().getPrincipalId())
85                  || getOleBatchProcessRule().canPerformBatchDelete(GlobalVariables.getUserSession().getPrincipalId());
86          if(!isValidated) {
87            GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.OLEBatchProcess.ERROR_AUTHORIZATION);
88            ((OLEBatchProcessDefinitionForm) form).setPermissionFlag(false);
89          }
90          OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
91          oleBatchProcessDefinitionDocument.setChunkSize(10000);
92          oleBatchProcessDefinitionDocument.setMaxRecordsInFile(100000);
93          oleBatchProcessDefinitionDocument.setMaxNumberOfThreads(10);
94          return modelAndView;
95      }
96  
97  
98      @RequestMapping(params = "methodToCall=runNowRoute")
99      public ModelAndView runNowRoute(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
100                                     HttpServletRequest request, HttpServletResponse response) throws Exception {
101         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
102         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
103         buildProcessDefinitionDocument(oleBatchProcessDefinitionDocument);
104         oleBatchProcessDefinitionForm.setDocument(oleBatchProcessDefinitionDocument);
105 
106 
107         boolean isValid = getOleBatchProcessRule().canPerformBatchImport(GlobalVariables.getUserSession().getPrincipalId())
108                 || getOleBatchProcessRule().canPerformBatchExport(GlobalVariables.getUserSession().getPrincipalId())
109                 || getOleBatchProcessRule().canPerformBatchDelete(GlobalVariables.getUserSession().getPrincipalId());
110         if (!isValid) {
111             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.OLEBatchProcess.ERROR_AUTHORIZATION);
112             return getUIFModelAndView(oleBatchProcessDefinitionForm);
113         }
114 
115         if (oleBatchProcessDefinitionDocument.getBatchProcessId() != null)
116             return getUIFModelAndView(oleBatchProcessDefinitionForm);
117         boolean isValidated = getOleBatchProcessRule().batchValidations(oleBatchProcessDefinitionForm);
118         if (!isValidated) {
119             return getUIFModelAndView(oleBatchProcessDefinitionForm);
120         }
121         MultipartFile ingestedFile1 = null;
122         MultipartFile ingestedFile2 = null;
123         MultipartFile ingestedFile3 = null;
124         String bytesInIngestedFile1 = "";
125         String bytesInIngestedFile2 = "";
126         String bytesInIngestedFile3 = "";
127         if (StringUtils.isNotBlank(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
128             if (oleBatchProcessDefinitionDocument.getBatchProcessType().equals(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
129                 ingestedFile1 = oleBatchProcessDefinitionDocument.getMarcFile();
130                 ingestedFile2 = oleBatchProcessDefinitionDocument.getEdiFile();
131             } else if (oleBatchProcessDefinitionDocument.getBatchProcessType().equals(OLEConstants.OLEBatchProcess.SERIAL_RECORD_IMPORT)) {
132                 if (oleBatchProcessDefinitionDocument.getInputFormat().equalsIgnoreCase("xml")) {
133                     ingestedFile1 = oleBatchProcessDefinitionDocument.getIngestedFile();
134                 } else {
135                     ingestedFile1 = oleBatchProcessDefinitionDocument.getSerialRecordDocumentFile();
136                     ingestedFile2 = oleBatchProcessDefinitionDocument.getSerialRecordTypeFile();
137                     ingestedFile3 = oleBatchProcessDefinitionDocument.getSerialRecordHistoryFile();
138                 }
139             } else if (oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)) {
140                 ingestedFile1 = oleBatchProcessDefinitionDocument.getIngestedFile();
141             } else {
142                 ingestedFile1 = oleBatchProcessDefinitionDocument.getIngestedFile();
143             }
144         }
145         if(ingestedFile1 != null) {
146             bytesInIngestedFile1 = new String(ingestedFile1.getBytes());
147         }
148         if(ingestedFile2 != null) {
149             bytesInIngestedFile2 = new String(ingestedFile2.getBytes());
150         }
151         if(ingestedFile3 != null) {
152             bytesInIngestedFile3 = new String(ingestedFile3.getBytes());
153         }
154         if (oleBatchProcessDefinitionDocument.getBatchProcessType() != null && oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_INVOICE) && !oleBatchProcessDefinitionDocument.isContinueImportFlag()) {
155             String fileName = ingestedFile1.getOriginalFilename();
156             List<OLEInvoiceIngestLoadReport> oleInvoiceIngestLoadReportList = (List<OLEInvoiceIngestLoadReport>) getBusinessObjectService().findAll(OLEInvoiceIngestLoadReport.class);
157             if (oleInvoiceIngestLoadReportList != null && oleInvoiceIngestLoadReportList.size() > 0) {
158                 List<String> fileNames = new ArrayList<>();
159                 for (OLEInvoiceIngestLoadReport oleInvoiceIngestLoadReport : oleInvoiceIngestLoadReportList) {
160                     fileNames.add(oleInvoiceIngestLoadReport.getFileName());
161                 }
162                 if (fileNames != null && fileNames.size() > 0) {
163                     if (fileNames.contains(fileName)) {
164                         oleBatchProcessDefinitionDocument.setFileFlag(true);
165                         return getUIFModelAndView(oleBatchProcessDefinitionForm);
166                     } else {
167 
168                     }
169                 }
170             }
171         }
172         oleBatchProcessDefinitionDocument.setUser(GlobalVariables.getUserSession().getPrincipalName());
173         oleBatchProcessDefinitionDocument.setLinkToJob(true);
174         saveJob(oleBatchProcessDefinitionForm);
175         getBusinessObjectService().save(oleBatchProcessDefinitionDocument);
176         String jobName = null;
177         if (oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList() != null && oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().size() > 0) {
178             OLEBatchProcessJobDetailsBo jobDetailsBo = oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0);
179             jobName = jobDetailsBo.getJobId();
180             jobDetailsBo.setJobName(oleBatchProcessDefinitionDocument.getBatchProcessName());
181             KRADServiceLocator.getBusinessObjectService().save(jobDetailsBo);
182         }
183         if (!oleBatchProcessDefinitionDocument.getBatchProcessType().equals(OLEConstants.OLEBatchProcess.CLAIM_REPORT) && oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList() != null && oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().size() > 0) {
184             // for order import
185             if (oleBatchProcessDefinitionDocument.getBatchProcessType().equals(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
186                 if (oleBatchProcessDefinitionDocument.getEdiFile() == null) {
187                     createBatchProcessJobFile(oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0), ingestedFile1, null, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_JOB, bytesInIngestedFile1, bytesInIngestedFile2);
188                 } else {
189                     createBatchProcessJobFile(oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0), ingestedFile1, ingestedFile2, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_JOB, bytesInIngestedFile1, bytesInIngestedFile2);
190                 }
191             }
192             // for serial record import
193             else if (oleBatchProcessDefinitionDocument.getBatchProcessType().equals(OLEConstants.OLEBatchProcess.SERIAL_RECORD_IMPORT)) {
194                 if (oleBatchProcessDefinitionDocument.getInputFormat().equalsIgnoreCase("xml")) {
195                     createBatchProcessJobFile(oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0), ingestedFile1, null, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_JOB, bytesInIngestedFile1, bytesInIngestedFile2);
196                 } else {
197                     createBatchProcessJobFile(oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0), ingestedFile1, ingestedFile2, ingestedFile3, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_JOB, bytesInIngestedFile1, bytesInIngestedFile2, bytesInIngestedFile3);
198                 }
199             } else if (oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)) {
200                 if (oleBatchProcessDefinitionDocument.getLoadIdFromFile().equalsIgnoreCase("true")) {
201                     createBatchProcessJobFile(oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0), ingestedFile1, null, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_JOB, bytesInIngestedFile1, bytesInIngestedFile2);
202                 }
203             }
204             // for other than   serial record import & Order Import
205             else {
206                 createBatchProcessJobFile(oleBatchProcessDefinitionDocument.getOleBatchProcessJobDetailsBoList().get(0), ingestedFile1, null, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_JOB, bytesInIngestedFile1, bytesInIngestedFile2);
207             }
208 
209         }
210         if (jobName != null) {
211             runJobNow(jobName);
212         }
213         oleBatchProcessDefinitionDocument.setAfterSubmitFlag(true);
214         oleBatchProcessDefinitionForm.setNavigationBatchProcessId(oleBatchProcessDefinitionDocument.getBatchProcessId());
215         return getUIFModelAndView(oleBatchProcessDefinitionForm);
216     }
217 
218     /**
219      * This method saves the job
220      * @param
221      */
222     private OLEBatchProcessJobDetailsBo saveJob(UifFormBase form) {
223         Timestamp timestamp = new Timestamp(new Date().getTime());
224         OLEBatchProcessJobDetailsBo oleBatchProcessJobDetailsBo = new OLEBatchProcessJobDetailsBo();
225         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
226         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
227         String profileName = oleBatchProcessDefinitionDocument.getBatchProcessProfileName();
228         if (oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
229             if(oleBatchProcessDefinitionDocument.getEdiFile() != null) {
230                 MultipartFile marcFile = oleBatchProcessDefinitionDocument.getMarcFile();
231                 MultipartFile ediFile = oleBatchProcessDefinitionDocument.getEdiFile();
232                 oleBatchProcessJobDetailsBo.setUploadFileName(marcFile.getOriginalFilename() + "," + ediFile.getOriginalFilename());
233                 oleBatchProcessDefinitionDocument.setUploadFileName(marcFile.getOriginalFilename() + "," + ediFile.getOriginalFilename());
234                 oleBatchProcessDefinitionDocument.setMarcFileName(marcFile.getOriginalFilename());
235                 oleBatchProcessDefinitionDocument.setEdiFileName(ediFile.getOriginalFilename());
236             }
237             else{
238                 MultipartFile ingestFile = oleBatchProcessDefinitionDocument.getMarcFile();
239                 oleBatchProcessJobDetailsBo.setUploadFileName(ingestFile.getOriginalFilename());
240                 oleBatchProcessDefinitionDocument.setUploadFileName(ingestFile.getOriginalFilename());
241                 oleBatchProcessDefinitionDocument.setMarcFileName(ingestFile.getOriginalFilename());
242             }
243         } else if (oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.SERIAL_RECORD_IMPORT)) {
244             if (oleBatchProcessDefinitionDocument.getInputFormat().equalsIgnoreCase("xml")) {
245                 MultipartFile ingestFile = oleBatchProcessDefinitionDocument.getIngestedFile();
246                 oleBatchProcessJobDetailsBo.setUploadFileName(ingestFile.getOriginalFilename());
247                 oleBatchProcessDefinitionDocument.setUploadFileName(ingestFile.getOriginalFilename());
248             } else {
249                 MultipartFile documentFile = oleBatchProcessDefinitionDocument.getSerialRecordDocumentFile();
250                 MultipartFile typeFile = oleBatchProcessDefinitionDocument.getSerialRecordTypeFile();
251                 MultipartFile historyFile = oleBatchProcessDefinitionDocument.getSerialRecordHistoryFile();
252                 oleBatchProcessJobDetailsBo.setUploadFileName((documentFile != null ? documentFile.getOriginalFilename() + "," : "")
253                         + (typeFile != null ? typeFile.getOriginalFilename() + "," : "")
254                         + (historyFile != null ? historyFile.getOriginalFilename() : ""));
255                 oleBatchProcessDefinitionDocument.setSerialRecordDocumentFileName(documentFile != null ? documentFile.getOriginalFilename() : null);
256                 oleBatchProcessDefinitionDocument.setSerialRecordTypeFileName(typeFile != null ? typeFile.getOriginalFilename() : null);
257                 oleBatchProcessDefinitionDocument.setSerialRecordHistoryFileName(historyFile != null ? historyFile.getOriginalFilename() : null);
258             }
259             oleBatchProcessDefinitionDocument.setOutputFormat(oleBatchProcessDefinitionDocument.getInputFormat());
260         } else if (oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT) && oleBatchProcessDefinitionDocument.getLoadIdFromFile().equalsIgnoreCase("true")) {
261             MultipartFile ingestFile = oleBatchProcessDefinitionDocument.getIngestedFile();
262             oleBatchProcessJobDetailsBo.setUploadFileName(ingestFile.getOriginalFilename());
263             oleBatchProcessDefinitionDocument.setUploadFileName(ingestFile.getOriginalFilename());
264         } else if (!oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)
265                 && !oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.CLAIM_REPORT)
266                 && !oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.SERIAL_RECORD_IMPORT)) {
267             MultipartFile ingestFile = oleBatchProcessDefinitionDocument.getIngestedFile();
268             oleBatchProcessJobDetailsBo.setUploadFileName(ingestFile.getOriginalFilename());
269             oleBatchProcessDefinitionDocument.setUploadFileName(ingestFile.getOriginalFilename());
270         }
271         oleBatchProcessJobDetailsBo.setCreateTime(timestamp);
272         if (oleBatchProcessDefinitionDocument.isScheduleFlag()) {
273             oleBatchProcessJobDetailsBo.setStatus(OLEConstants.OLEBatchProcess.JOB_STATUS_SCHEDULED);
274             //   oleBatchProcessJobDetailsBo.setStatus(profileName + " " + OLEConstants.OLEBatchProcess.JOB_STATUS_SCHEDULED);
275         } else {
276             oleBatchProcessJobDetailsBo.setStatus(OLEConstants.OLEBatchProcess.JOB_STATUS_RUNNING);
277             // oleBatchProcessJobDetailsBo.setStatus(profileName + " " + OLEConstants.OLEBatchProcess.JOB_STATUS_RUNNING);
278         }
279         String loginUser = GlobalVariables.getUserSession().getPrincipalName();
280         oleBatchProcessJobDetailsBo.setUserName(loginUser);
281         oleBatchProcessJobDetailsBo.setBatchProfileName(profileName);
282         oleBatchProcessJobDetailsBo.setBatchProcessType(oleBatchProcessDefinitionDocument.getBatchProcessType());
283         List<OLEBatchProcessJobDetailsBo> oleBatchProcessJobDetailsBos = new ArrayList<OLEBatchProcessJobDetailsBo>();
284         oleBatchProcessJobDetailsBos.add(oleBatchProcessJobDetailsBo);
285         oleBatchProcessDefinitionDocument.setOleBatchProcessJobDetailsBoList(oleBatchProcessJobDetailsBos);
286         oleBatchProcessJobDetailsBo.setStartTime(timestamp);
287         DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE);
288         dataCarrierService.addData("oleBatchProcessJobDetailsBo",oleBatchProcessJobDetailsBo);
289         return oleBatchProcessJobDetailsBo;
290     }
291 
292     private void saveSchedule(OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm) {
293         // OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm)form;
294         Timestamp timestamp = new Timestamp(new Date().getTime());
295         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
296 
297         oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().setScheduleType(oleBatchProcessDefinitionDocument.getScheduleType());
298         oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().setOneTimeOrRecurring(oleBatchProcessDefinitionDocument.getOneTimeOrRecurring());
299         OLEBatchProcessScheduleBo oleBatchProcessScheduleBo = oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo();
300         if (oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
301             if(oleBatchProcessDefinitionDocument.getEdiFile() != null) {
302                 MultipartFile marcFile = oleBatchProcessDefinitionDocument.getMarcFile();
303                 MultipartFile ediFile = oleBatchProcessDefinitionDocument.getEdiFile();
304                 oleBatchProcessScheduleBo.setUploadFileName(marcFile.getOriginalFilename() + "," + ediFile.getOriginalFilename());
305                 oleBatchProcessDefinitionDocument.setUploadFileName(marcFile.getOriginalFilename() + "," + ediFile.getOriginalFilename());
306                 oleBatchProcessDefinitionDocument.setMarcFileName(marcFile.getOriginalFilename());
307                 oleBatchProcessDefinitionDocument.setEdiFileName(ediFile.getOriginalFilename());
308             }
309             else{
310                 MultipartFile ingestFile = oleBatchProcessDefinitionDocument.getMarcFile();
311                 oleBatchProcessScheduleBo.setUploadFileName(ingestFile.getOriginalFilename());
312                 oleBatchProcessDefinitionDocument.setMarcFileName(ingestFile.getOriginalFilename());
313             }
314         } else if ((oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT) && oleBatchProcessDefinitionDocument.getLoadIdFromFile().equalsIgnoreCase(String.valueOf(Boolean.TRUE))) || !oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)) {
315             MultipartFile ingestFile = oleBatchProcessDefinitionDocument.getIngestedFile();
316             oleBatchProcessScheduleBo.setUploadFileName(ingestFile.getOriginalFilename());
317             oleBatchProcessDefinitionDocument.setUploadFileName(ingestFile.getOriginalFilename());
318         }
319         oleBatchProcessScheduleBo.setCreateTime(timestamp);
320         String loginUser = GlobalVariables.getUserSession().getPrincipalName();
321         oleBatchProcessScheduleBo.setUserName(loginUser);
322         String cronExpression = null;
323         if (!oleBatchProcessDefinitionDocument.getCronOrSchedule().equals(OLEConstants.OLEBatchProcess.PROVIDED_CRON)) {
324             OLESchedulerHelper oleSchedulerHelper = OLESchedulerHelper.getInstance();
325             cronExpression = oleSchedulerHelper.getCronExpression(oleBatchProcessScheduleBo);
326         } else {
327             cronExpression = oleBatchProcessDefinitionDocument.getEnteredCronExp();
328         }
329         boolean validCronExpression = org.quartz.CronExpression.isValidExpression(cronExpression);
330         if (!validCronExpression) {
331             GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, OLEConstants.OLEBatchProcess.ERROR_CRON_EXPRESSION);
332             return;
333         }
334         oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().setCronExpression(cronExpression);
335         oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().setWeekDays(oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().getWeekDays());
336         oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().setBatchProcessType(oleBatchProcessDefinitionDocument.getBatchProcessType());
337         List<OLEBatchProcessScheduleBo> oleBatchProcessScheduleBos = new ArrayList<OLEBatchProcessScheduleBo>();
338         oleBatchProcessScheduleBos.add(oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo());
339         oleBatchProcessDefinitionDocument.setOleBatchProcessScheduleBoList(oleBatchProcessScheduleBos);
340     }
341 
342     @RequestMapping(params = "methodToCall=route")
343     public ModelAndView route(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
344                               HttpServletRequest request, HttpServletResponse response) {
345         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
346         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
347         buildProcessDefinitionDocument(oleBatchProcessDefinitionDocument);
348         oleBatchProcessDefinitionForm.setDocument(oleBatchProcessDefinitionDocument);
349         boolean isValidated = getOleBatchProcessRule().batchValidations(oleBatchProcessDefinitionForm);
350         if (!isValidated) {
351             return getUIFModelAndView(oleBatchProcessDefinitionForm);
352         }
353         oleBatchProcessDefinitionDocument.setUser(GlobalVariables.getUserSession().getPrincipalName());
354         if (!oleBatchProcessDefinitionDocument.isRunNowFlag()) {
355             saveSchedule(oleBatchProcessDefinitionForm);
356             boolean updateDocFlag = false;
357             if (oleBatchProcessDefinitionDocument.getBatchProcessId() != null) {
358                 updateDocFlag = true;
359                 if (oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo() != null) {
360                     rescheduleJob(oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().getScheduleId(), oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBo().getCronExpression());
361                 }
362             }
363 
364             try {
365                 getBusinessObjectService().save(oleBatchProcessDefinitionDocument);
366                 if (oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBoList() != null && oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBoList().size() > 0 && !updateDocFlag) {
367                     if (oleBatchProcessDefinitionDocument.getBatchProcessType().equals(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT)) {
368                         createBatchProcessSchedulerFile(oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBoList().get(0), oleBatchProcessDefinitionDocument.getMarcFile(), oleBatchProcessDefinitionDocument.getEdiFile(), oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_SCHEDULE);
369                     } else if ((oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT) && oleBatchProcessDefinitionDocument.getLoadIdFromFile().equalsIgnoreCase(String.valueOf(Boolean.TRUE))) || !oleBatchProcessDefinitionDocument.getBatchProcessType().equalsIgnoreCase(OLEConstants.OLEBatchProcess.BATCH_EXPORT)) {
370                         createBatchProcessSchedulerFile(oleBatchProcessDefinitionDocument.getOleBatchProcessScheduleBoList().get(0), oleBatchProcessDefinitionDocument.getIngestedFile(), null, oleBatchProcessDefinitionDocument.getBatchProcessType(), OLEConstants.OLEBatchProcess.PROFILE_SCHEDULE);
371                     }
372                 }
373             } catch (Exception e) {
374                 LOG.error("Error when scheduling the job :" + e);
375             }
376             OLEBatchProcessScheduleBo scheduleBo = ((OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument()).getOleBatchProcessScheduleBo();
377             try {
378                 addToBatchScheduler(scheduleBo.getScheduleId(), scheduleBo.getCronExpression());
379             } catch (Exception e) {
380                 throw new RuntimeException(e);
381             }
382             oleBatchProcessDefinitionDocument.setRescheduleFlag(true);
383             oleBatchProcessDefinitionDocument.setAfterSubmitFlag(true);
384         }
385         return getUIFModelAndView(oleBatchProcessDefinitionForm);
386     }
387 
388     @RequestMapping(params = "methodToCall=save")
389     public ModelAndView save(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
390                              HttpServletRequest request, HttpServletResponse response) throws Exception {
391         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
392         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
393         boolean isValidated = getOleBatchProcessRule().batchValidations(oleBatchProcessDefinitionForm);
394         if (!isValidated) {
395             return getUIFModelAndView(oleBatchProcessDefinitionForm);
396         }
397         getBusinessObjectService().save(oleBatchProcessDefinitionDocument);
398         return getUIFModelAndView(oleBatchProcessDefinitionForm);
399     }
400 
401     @RequestMapping(params = "methodToCall=clear")
402     public ModelAndView clear(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
403                               HttpServletRequest request, HttpServletResponse response) {
404         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
405         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
406         oleBatchProcessDefinitionDocument.setScheduleFlag(false);
407         oleBatchProcessDefinitionDocument.setBatchProcessName("");
408         oleBatchProcessDefinitionDocument.setBatchProcessProfileName("");
409         oleBatchProcessDefinitionDocument.setBatchProcessType("");
410         oleBatchProcessDefinitionDocument.setBatchProcessKRMSProfile("");
411         oleBatchProcessDefinitionDocument.setChunkSize(0);
412         return getUIFModelAndView(oleBatchProcessDefinitionForm);
413     }
414 
415     /**
416      * Ads the scheduled record id as the jobName and sets the trigger for the cronExpression supplied
417      * @param jobName
418      * @param cronExpression
419      */
420     private void addToBatchScheduler(String jobName, String cronExpression) throws Exception {
421         OLEBatchSchedulerService schedulerService = GlobalResourceLoader.getService("oleSchedulerService");
422         schedulerService.initializeJobsForModule(jobName);
423         schedulerService.initializeTriggersForModule(jobName, cronExpression);
424     }
425 
426     /**
427      * Runs the process for the profile selected and takes the scheduled record id as the job name
428      *
429      * @param jobName
430      */
431     private void runJobNow(String jobName) {
432         OLEBatchSchedulerService schedulerService = GlobalResourceLoader.getService("oleSchedulerService");
433         try {
434             schedulerService.startJob(jobName);
435         } catch (Exception e) {
436             LOG.error("Error while starting job with job id :: "+jobName);
437         }
438     }
439 
440    /* private String getBatchProcessFilePath(String batchProceesType) {
441 
442         String batchProcessLocation = getOLEBatchProcessDataHelper().getBatchProcessFilePath(batchProceesType);
443         return batchProcessLocation;
444     }*/
445 
446     private void createBatchProcessJobFile(OLEBatchProcessJobDetailsBo batchProcessJobDetailsBo, MultipartFile ingestFile1, MultipartFile ingestFile2, String batchProceesType, String jobType, String bytesInIngestedFile1, String bytesInIngestedFile2) throws Exception {
447         if (ingestFile2 == null) {
448             String ingestFileName = batchProcessJobDetailsBo.getJobId() + jobType + "_" + ingestFile1.getOriginalFilename();
449             getOLEBatchProcessDataHelper().createBatchProcessFile(batchProceesType, ingestFileName, bytesInIngestedFile1, batchProcessJobDetailsBo.getJobId());
450         } else {
451 
452             String mrcFileName = batchProcessJobDetailsBo.getJobId() + jobType + "_" + ingestFile1.getOriginalFilename();
453             String ediFileName = batchProcessJobDetailsBo.getJobId() + jobType + "_" + ingestFile2.getOriginalFilename();
454             if(ediFileName != null){
455                 getOLEBatchProcessDataHelper().createBatchProcessFile(batchProceesType, mrcFileName, ediFileName, bytesInIngestedFile1, bytesInIngestedFile2 ,batchProcessJobDetailsBo.getJobId() );
456             }
457            /* else {
458                 getOLEBatchProcessDataHelper().createBatchProcessFile(batchProceesType, mrcFileName, new String(ingestFile1.getBytes()), new String(ingestFile2.getBytes()));
459             }*/
460 
461         }
462 
463     }
464 
465     private void createBatchProcessJobFile(OLEBatchProcessJobDetailsBo batchProcessJobDetailsBo, MultipartFile ingestFile1, MultipartFile ingestFile2, MultipartFile ingestFile3, String batchProceesType, String jobType, String bytesInIngestedFile1, String bytesInIngestedFile2, String bytesInIngestedFile3) throws Exception {
466         if (ingestFile1 != null || ingestFile2 != null || ingestFile3 != null) {
467             String documentFileName = ingestFile1 != null ? batchProcessJobDetailsBo.getJobId() + jobType + "_" + ingestFile1.getOriginalFilename() : null;
468             String typeFileName = ingestFile2 != null ? batchProcessJobDetailsBo.getJobId() + jobType + "_" + ingestFile2.getOriginalFilename() : null;
469             String historyFileName = ingestFile3 != null ? batchProcessJobDetailsBo.getJobId() + jobType + "_" + ingestFile3.getOriginalFilename() : null;
470             getOLEBatchProcessDataHelper().createBatchProcessFile(batchProceesType, documentFileName, typeFileName, historyFileName, bytesInIngestedFile1, bytesInIngestedFile2, bytesInIngestedFile3, batchProcessJobDetailsBo.getJobId());
471         }
472     }
473 
474     private void createBatchProcessSchedulerFile(OLEBatchProcessScheduleBo oleBatchProcessScheduleBo, MultipartFile ingestFile1, MultipartFile ingestFile2, String batchProceesType, String jobType) throws Exception {
475         if (ingestFile2 == null && ingestFile1!=null) {
476             String ingestFileName = oleBatchProcessScheduleBo.getScheduleId() + jobType + "_" + ingestFile1.getOriginalFilename();
477             getOLEBatchProcessDataHelper().createBatchProcessFile(batchProceesType, ingestFileName, new String(ingestFile1.getBytes()), oleBatchProcessScheduleBo.getScheduleId());
478         }
479         else  if (ingestFile2 != null && ingestFile1!=null) {
480             String mrcFileName = oleBatchProcessScheduleBo.getScheduleId() + jobType + "_" + ingestFile1.getOriginalFilename();
481             String ediFileName = oleBatchProcessScheduleBo.getScheduleId() + jobType + "_" + ingestFile2.getOriginalFilename();
482             getOLEBatchProcessDataHelper().createBatchProcessFile(batchProceesType, mrcFileName, ediFileName, new String(ingestFile1.getBytes()), new String(ingestFile2.getBytes()) , oleBatchProcessScheduleBo.getScheduleId());
483 
484         }
485 
486     }
487 
488 
489     @RequestMapping(params = "methodToCall=reschedule")
490     public ModelAndView reschedule(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
491                                    HttpServletRequest request, HttpServletResponse response) throws Exception {
492         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
493         String batchProcessId = request.getParameter("batchProcessId");
494         if (batchProcessId != null) {
495             Map batchProcessMap = new HashMap();
496             batchProcessMap.put("batchProcessId", batchProcessId);
497             List<OLEBatchProcessDefinitionDocument> oleBatchProcessDefinitionDocuments = (List<OLEBatchProcessDefinitionDocument>) getBusinessObjectService().findMatching(OLEBatchProcessDefinitionDocument.class, batchProcessMap);
498             if (oleBatchProcessDefinitionDocuments.size() > 0) {
499                 OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
500                 oleBatchProcessDefinitionDocument.setRescheduleFlag(false);
501                 if(OLEConstants.OLEBatchProcess.ORDER_RECORD_IMPORT.equals(oleBatchProcessDefinitionDocument.getBatchProcessType()) && oleBatchProcessDefinitionDocument.getUploadFileName()!=null) {
502                     String[] fileNames = oleBatchProcessDefinitionDocument.getUploadFileName().split(",");
503                     if(fileNames.length == 2) {
504                         oleBatchProcessDefinitionDocument.setMarcFileName(fileNames[0]);
505                         oleBatchProcessDefinitionDocument.setEdiFileName(fileNames[1]);
506                     }
507                     else {
508                         oleBatchProcessDefinitionDocument.setMarcFileName(fileNames[0]);
509                     }
510                 }
511                 if (oleBatchProcessDefinitionDocument.getCronOrSchedule() != null) {
512                     List<OLEBatchProcessScheduleBo> oleBatchProcessScheduleBoList = (List<OLEBatchProcessScheduleBo>) getBusinessObjectService().findMatching(OLEBatchProcessScheduleBo.class, batchProcessMap);
513                     if (oleBatchProcessScheduleBoList != null && oleBatchProcessScheduleBoList.size() > 0) {
514                         oleBatchProcessDefinitionDocument.setOleBatchProcessScheduleBo(oleBatchProcessScheduleBoList.get(0));
515                         oleBatchProcessDefinitionDocument.setScheduleFlag(true);
516                     }
517                 }
518             }
519         }
520 
521         return getUIFModelAndView(oleBatchProcessDefinitionForm);
522     }
523 
524     private void rescheduleJob(String scheduleId, String cronExp) {
525         OLEBatchSchedulerService schedulerService = GlobalResourceLoader.getService("oleSchedulerService");
526         try {
527             schedulerService.rescheduleJob(scheduleId, cronExp);
528         } catch (Exception e) {
529             LOG.error("Error while removing job with schedule id :: " + scheduleId);
530         }
531     }
532 
533     @RequestMapping(params = "methodToCall=close")
534     public ModelAndView close(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
535                                       HttpServletRequest request, HttpServletResponse response) throws Exception {
536         String baseUrl = ConfigContext.getCurrentContextConfig().getProperty(OLEPropertyConstants.OLE_URL_BASE);
537         String url = baseUrl + "/portal.do";
538         Properties props = new Properties();
539         props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH);
540         if (StringUtils.isNotBlank(form.getReturnFormKey())) {
541             props.put(UifParameters.FORM_KEY, form.getReturnFormKey());
542         }
543         return performRedirect(form, url, props);
544     }
545 
546     @RequestMapping(params = "methodToCall=populateField")
547     public ModelAndView populateField(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
548                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
549         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
550 
551         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
552         oleBatchProcessDefinitionForm.setBatchProcessType(oleBatchProcessDefinitionDocument.getProcessTypeHidden());
553         oleBatchProcessDefinitionDocument.setBatchProcessType(oleBatchProcessDefinitionDocument.getProcessTypeHidden());
554         oleBatchProcessDefinitionDocument.setBatchProcessProfileName(oleBatchProcessDefinitionDocument.getProcessNameHidden());
555 
556         buildProcessDefinitionDocument(oleBatchProcessDefinitionDocument);
557         oleBatchProcessDefinitionForm.setDocument(oleBatchProcessDefinitionDocument);
558         return super.refresh(form,result,request,response);
559     }
560 
561     @RequestMapping(params = "methodToCall=refreshPageView")
562     public ModelAndView refreshPageView(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
563                                       HttpServletRequest request, HttpServletResponse response) throws Exception {
564 
565         return super.refresh(form,result,request,response);
566     }
567 
568 
569     @RequestMapping(params = "methodToCall=profileId")
570     public ModelAndView profileId(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
571                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
572         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
573         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
574         buildProcessDefinitionDocument(oleBatchProcessDefinitionDocument);
575         oleBatchProcessDefinitionForm.setDocument(oleBatchProcessDefinitionDocument);
576         return super.refresh(form,result,request,response);
577     }
578 
579     private void buildProcessDefinitionDocument(OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument) {
580         if (OLEConstants.OLEBatchProcess.BATCH_BIB_IMPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
581             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessBibImportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
582         } else if (OLEConstants.OLEBatchProcess.BATCH_INVOICE.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
583             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessInvoiceImportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
584         } else if (OLEConstants.OLEBatchProcess.BATCH_ORDER_IMPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
585             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessOrderImportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
586             oleBatchProcessDefinitionDocument.setBatchProcessKRMSProfile(OLEBatchProcessOrderImportProfileValueFinder.getKrmsValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
587             oleBatchProcessDefinitionDocument.setMarcOnly(OLEBatchProcessOrderImportProfileValueFinder.getMarcValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
588         } else if (OLEConstants.OLEBatchProcess.PATRON_IMPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
589             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessPatronImportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
590         } else if (OLEConstants.OLEBatchProcess.CLAIM_REPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
591             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessClaimImportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
592         } else if (OLEConstants.OLEBatchProcess.SERIAL_RECORD_IMPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
593             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessSerialRecordProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
594         } else if (OLEConstants.OLEBatchProcess.LOCATION_IMPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
595             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessLocationImportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
596         } else if (OLEConstants.OLEBatchProcess.BATCH_DELETE.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
597             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessBatchDeleteProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
598         } else if (OLEConstants.OLEBatchProcess.BATCH_EXPORT.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getBatchProcessType())) {
599             oleBatchProcessDefinitionDocument.setBatchProcessProfileId(OLEBatchProcessBatchExportProfileValueFinder.getValue(oleBatchProcessDefinitionDocument.getBatchProcessProfileName()));
600             oleBatchProcessDefinitionDocument.getLoadIdFromFile();
601         }
602     }
603 
604     public BusinessObjectService getBusinessObjectService() {
605         if(businessObjectService == null){
606             businessObjectService = KRADServiceLocator.getBusinessObjectService();
607         }
608         return businessObjectService;
609     }
610 
611     @RequestMapping(params = "methodToCall=scheduleOrRunNow")
612     public ModelAndView scheduleOrRunNow(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
613                                   HttpServletRequest request, HttpServletResponse response) throws Exception {
614         OLEBatchProcessDefinitionForm oleBatchProcessDefinitionForm = (OLEBatchProcessDefinitionForm) form;
615         OLEBatchProcessDefinitionDocument oleBatchProcessDefinitionDocument = (OLEBatchProcessDefinitionDocument) oleBatchProcessDefinitionForm.getDocument();
616         if(OLEConstants.OLEBatchProcess.BATCH_PROCESS_SCHEDULED.equalsIgnoreCase(oleBatchProcessDefinitionDocument.getRunNowOrSchedule())){
617             oleBatchProcessDefinitionDocument.setScheduleFlag(true);
618             oleBatchProcessDefinitionDocument.setRescheduleFlag(false);
619             oleBatchProcessDefinitionDocument.setRunNowFlag(false);
620         } else {
621             oleBatchProcessDefinitionDocument.setScheduleFlag(false);
622             oleBatchProcessDefinitionDocument.setRunNowFlag(true);
623         }
624         return super.refresh(form,result,request,response);
625     }
626 
627 }