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.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
61
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 }