Search in sources :

Example 1 with LogProgressMonitor

use of org.apache.hop.core.LogProgressMonitor in project hop by apache.

the class HopImport method run.

@Override
public void run() {
    try {
        log = new LogChannel("HopImport");
        if (listPluginTypes != null && listPluginTypes) {
            printPluginTypes();
            return;
        }
        if (!validateOptions()) {
            cmd.usage(System.err);
            return;
        }
        hopImport = loadImportPlugin();
        if (hopImport == null) {
            return;
        }
        log.logDetailed("Start of Hop Import");
        // Set the options...
        // 
        hopImport.setValidateInputFolder(inputFolderName);
        hopImport.setValidateOutputFolder(outputFolderName);
        hopImport.setKettlePropertiesFilename(kettlePropertiesFilename);
        hopImport.setJdbcPropertiesFilename(jdbcPropertiesFilename);
        hopImport.setSharedXmlFilename(sharedXmlFilename);
        if (skippingExistingTargetFiles != null) {
            log.logBasic("Import is " + (skippingExistingTargetFiles ? "" : "not ") + "skipping existing target files");
            hopImport.setSkippingExistingTargetFiles(skippingExistingTargetFiles);
        }
        if (skippingHiddenFilesAndFolders != null) {
            log.logBasic("Import is " + (skippingHiddenFilesAndFolders ? "" : "not ") + "skipping hidden files and folders");
            hopImport.setSkippingHiddenFilesAndFolders(skippingHiddenFilesAndFolders);
        }
        if (skippingFolders != null) {
            log.logBasic("Import is " + (skippingFolders ? "" : "not ") + "skipping sub-folders");
            hopImport.setSkippingFolders(skippingFolders);
        }
        hopImport.setTargetConfigFilename(targetConfigFilename);
        // Allow plugins to modify the elements loaded so far, before a pipeline or workflow is even
        // loaded
        // 
        ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopImportStart.id, this);
        // Handle the options of the configuration plugins
        // 
        Map<String, Object> mixins = cmd.getMixins();
        for (String key : mixins.keySet()) {
            Object mixin = mixins.get(key);
            if (mixin instanceof IConfigOptions) {
                IConfigOptions configOptions = (IConfigOptions) mixin;
                configOptions.handleOption(log, this, variables);
            }
        }
        // Text version of a progress monitor...
        // 
        IProgressMonitor monitor = new LogProgressMonitor(log);
        // Run the import...
        // 
        hopImport.runImport(monitor);
        // Print the report...
        // 
        log.logBasic(Const.CR);
        log.logBasic(hopImport.getImportReport());
        ExtensionPointHandler.callExtensionPoint(log, variables, HopExtensionPoint.HopImportEnd.id, this);
    } catch (Exception e) {
        throw new ExecutionException(cmd, "There was an error during import", e);
    }
}
Also used : IConfigOptions(org.apache.hop.core.config.plugin.IConfigOptions) IProgressMonitor(org.apache.hop.core.IProgressMonitor) ILogChannel(org.apache.hop.core.logging.ILogChannel) LogChannel(org.apache.hop.core.logging.LogChannel) ExecutionException(picocli.CommandLine.ExecutionException) LogProgressMonitor(org.apache.hop.core.LogProgressMonitor) HopException(org.apache.hop.core.exception.HopException) ParameterException(picocli.CommandLine.ParameterException) ExecutionException(picocli.CommandLine.ExecutionException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 IProgressMonitor (org.apache.hop.core.IProgressMonitor)1 LogProgressMonitor (org.apache.hop.core.LogProgressMonitor)1 IConfigOptions (org.apache.hop.core.config.plugin.IConfigOptions)1 HopException (org.apache.hop.core.exception.HopException)1 ILogChannel (org.apache.hop.core.logging.ILogChannel)1 LogChannel (org.apache.hop.core.logging.LogChannel)1 ExecutionException (picocli.CommandLine.ExecutionException)1 ParameterException (picocli.CommandLine.ParameterException)1