View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.select.batch.service.impl;
17  
18  import org.kuali.ole.select.batch.service.VendorToOleExtractService;
19  import org.kuali.ole.sys.OLEConstants;
20  import org.kuali.ole.sys.context.SpringContext;
21  import org.kuali.rice.core.api.config.property.ConfigurationService;
22  
23  import java.io.File;
24  
25  public class VendorToOleExtractServiceImpl implements VendorToOleExtractService {
26      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(VendorToOleExtractServiceImpl.class);
27  
28      public boolean loadVendorToOleEtl() {
29  
30          try {
31              ConfigurationService kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
32              String directory = kualiConfigurationService.getPropertyValueAsString(OLEConstants.STAGING_DIRECTORY_KEY);
33              String sourcePath = directory + kualiConfigurationService.getPropertyValueAsString("kualietl.sourcefolder");
34              String logPath = directory + kualiConfigurationService.getPropertyValueAsString("kualietl.etllogfolder");
35              String destinationPath = directory + kualiConfigurationService.getPropertyValueAsString("kualietl.destinationfolder");
36              String backupFolder = directory + kualiConfigurationService.getPropertyValueAsString("kualietl.backupfolder");
37              String filePath = getClass().getClassLoader().getResource("KualiETLConfig.xml").toString();
38              if (LOG.isDebugEnabled()) {
39                  LOG.debug("-------filePath -------------------" + filePath);
40                  LOG.debug("-----------------ETL Configuration Paths---------------");
41                  LOG.debug("-----sourcePath------" + sourcePath);
42                  LOG.debug("-----logPath------" + logPath);
43                  LOG.debug("-----destinationPath------" + destinationPath);
44                  LOG.debug("-----backUpFolderPath------" + backupFolder);
45              }
46              File file = new File(sourcePath);
47  
48              int position = filePath.indexOf("/");
49              String newFilePath = "";
50              if (directory.contains("local")) {
51                  newFilePath = filePath.substring(position + 1);
52              } else {
53                  newFilePath = "/" + filePath.substring(position + 1);
54              }
55              if (LOG.isDebugEnabled()) {
56                  LOG.debug("-------newFilePath -------------------" + newFilePath);
57              }
58              String[] args = {"--context_param COMMAND_LINE_CONFIG_FILE_NAME=" + newFilePath, "--context_param COMMAND_LINE_SOUCE_FILE_PATH=" + sourcePath, "--context_param COMMAND_LINE_LOG_FILE_PATH=" + logPath, "--context_param COMMAND_LINE_DESTINATION_FILE_PATH=" + destinationPath, "--context_param COMMAND_LINE_BACKUP_FOLDER_PATH=" + backupFolder};
59              LOG.debug("-------ETL Job Started-------------");
60              // kuali.kualimainjob_0_1.KualiMainJob kualiMainJob = new kuali.kualimainjob_0_1.KualiMainJob();
61              // kualiMainJob.runJobInTOS(args);
62              LOG.debug("-------ETL Job Completed-----------");
63          } catch (Exception e) {
64              LOG.error("VendorToOleExtractServiceImpl.loadVendorToOleEtl():", e);
65              throw new RuntimeException(e);
66          }
67  
68          return true;
69      }
70  
71  }