1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.select.batch.service.impl;
17  
18  import org.kuali.ole.module.purap.document.service.OlePurapService;
19  import org.kuali.ole.select.batch.service.VendorToOleExtractService;
20  import org.kuali.ole.sys.OLEConstants;
21  import org.kuali.ole.sys.context.SpringContext;
22  import org.kuali.rice.core.api.config.property.ConfigurationService;
23  
24  import java.io.File;
25  
26  public class VendorToOleExtractServiceImpl implements VendorToOleExtractService {
27      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(VendorToOleExtractServiceImpl.class);
28      protected OlePurapService olePurapService;
29  
30      public OlePurapService getOlePurapService() {
31          if (olePurapService == null) {
32              olePurapService = SpringContext.getBean(OlePurapService.class);
33          }
34          return olePurapService;
35      }
36  
37      public boolean loadVendorToOleEtl() {
38  
39          try {
40              ConfigurationService kualiConfigurationService = SpringContext.getBean(ConfigurationService.class);
41              String directory = kualiConfigurationService.getPropertyValueAsString(OLEConstants.STAGING_DIRECTORY_KEY);
42              String sourcePath = directory + getOlePurapService().getParameter(OLEConstants.SOURCE_FOLDER);
43              String logPath = directory + getOlePurapService().getParameter(OLEConstants.LOG_FOLDER);
44              String destinationPath = directory + getOlePurapService().getParameter(OLEConstants.DESTINATION_FOLDER);
45              String backupFolder = directory + getOlePurapService().getParameter(OLEConstants.BACKUP_FOLDER);
46              String filePath = getClass().getClassLoader().getResource("KualiETLConfig.xml").toString();
47              if (LOG.isDebugEnabled()) {
48                  LOG.debug("-------filePath -------------------" + filePath);
49                  LOG.debug("-----------------ETL Configuration Paths---------------");
50                  LOG.debug("-----sourcePath------" + sourcePath);
51                  LOG.debug("-----logPath------" + logPath);
52                  LOG.debug("-----destinationPath------" + destinationPath);
53                  LOG.debug("-----backUpFolderPath------" + backupFolder);
54              }
55              File file = new File(sourcePath);
56  
57              int position = filePath.indexOf("/");
58              String newFilePath = "";
59              if (directory.contains("local")) {
60                  newFilePath = filePath.substring(position + 1);
61              } else {
62                  newFilePath = "/" + filePath.substring(position + 1);
63              }
64              if (LOG.isDebugEnabled()) {
65                  LOG.debug("-------newFilePath -------------------" + newFilePath);
66              }
67              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};
68              LOG.debug("-------ETL Job Started-------------");
69              
70              
71              LOG.debug("-------ETL Job Completed-----------");
72          } catch (Exception e) {
73              LOG.error("VendorToOleExtractServiceImpl.loadVendorToOleEtl():", e);
74              throw new RuntimeException(e);
75          }
76  
77          return true;
78      }
79  
80  }