Search in sources :

Example 1 with IPlugin

use of org.apache.hop.core.plugins.IPlugin in project hop by apache.

the class DatabaseMeta method findIDatabase.

/**
 * Search for the right type of IDatabase object and return it.
 *
 * @param databaseTypeDesc the type of IDatabase to look for (id or description)
 * @return The requested IDatabase
 * @throws HopDatabaseException when the type could not be found or referenced.
 */
private static final IDatabase findIDatabase(String databaseTypeDesc) throws HopDatabaseException {
    PluginRegistry registry = PluginRegistry.getInstance();
    IPlugin plugin = registry.getPlugin(DatabasePluginType.class, databaseTypeDesc);
    if (plugin == null) {
        plugin = registry.findPluginWithName(DatabasePluginType.class, databaseTypeDesc);
    }
    if (plugin == null) {
        throw new HopDatabaseException("database type with plugin id [" + databaseTypeDesc + "] couldn't be found!");
    }
    return getIDatabaseMap().get(plugin.getIds()[0]);
}
Also used : PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) HopDatabaseException(org.apache.hop.core.exception.HopDatabaseException) IPlugin(org.apache.hop.core.plugins.IPlugin)

Example 2 with IPlugin

use of org.apache.hop.core.plugins.IPlugin in project hop by apache.

the class DatabaseMetaObjectFactory method createObject.

@Override
public Object createObject(String id, Object parentObject) throws HopException {
    PluginRegistry registry = PluginRegistry.getInstance();
    IPlugin plugin = registry.findPluginWithId(DatabasePluginType.class, id);
    IDatabase iDatabase = (IDatabase) registry.loadClass(plugin);
    return iDatabase;
}
Also used : PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) IPlugin(org.apache.hop.core.plugins.IPlugin)

Example 3 with IPlugin

use of org.apache.hop.core.plugins.IPlugin in project hop by apache.

the class HopSearch method main.

public static void main(String[] args) {
    HopSearch hopSearch = new HopSearch();
    try {
        HopEnvironment.init();
        // Also register the search plugin type (usually only done for the GUI)
        // We don't want to load these in HopEnvironmnent.init() because for now it would
        // only be useful in Hop GUI and Hop Search.  There is no need to slow down
        // Hop Run or Hop Server with this.
        // 
        PluginRegistry registry = PluginRegistry.getInstance();
        SearchableAnalyserPluginType searchableAnalyserPluginType = SearchableAnalyserPluginType.getInstance();
        registry.addPluginType(searchableAnalyserPluginType);
        searchableAnalyserPluginType.searchPlugins();
        CommandLine cmd = new CommandLine(hopSearch);
        List<IPlugin> configPlugins = registry.getPlugins(ConfigPluginType.class);
        for (IPlugin configPlugin : configPlugins) {
            // Load only the plugins of the "search" category
            if (ConfigPlugin.CATEGORY_SEARCH.equals(configPlugin.getCategory())) {
                IConfigOptions configOptions = registry.loadClass(configPlugin, IConfigOptions.class);
                cmd.addMixin(configPlugin.getIds()[0], configOptions);
            }
        }
        hopSearch.setCmd(cmd);
        CommandLine.ParseResult parseResult = cmd.parseArgs(args);
        if (CommandLine.printHelpIfRequested(parseResult)) {
            System.exit(1);
        } else {
            hopSearch.run();
            System.exit(0);
        }
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        hopSearch.cmd.usage(System.err);
        System.exit(9);
    } catch (ExecutionException e) {
        System.err.println("Error found during execution!");
        System.err.println(Const.getStackTracker(e));
        System.exit(1);
    } catch (Exception e) {
        System.err.println("General error found, something went horribly wrong!");
        System.err.println(Const.getStackTracker(e));
        System.exit(2);
    }
}
Also used : CommandLine(picocli.CommandLine) IConfigOptions(org.apache.hop.core.config.plugin.IConfigOptions) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) ParameterException(picocli.CommandLine.ParameterException) ExecutionException(picocli.CommandLine.ExecutionException) HopException(org.apache.hop.core.exception.HopException) ParameterException(picocli.CommandLine.ParameterException) ExecutionException(picocli.CommandLine.ExecutionException) IPlugin(org.apache.hop.core.plugins.IPlugin)

Example 4 with IPlugin

use of org.apache.hop.core.plugins.IPlugin in project hop by apache.

the class HopImport method main.

public static void main(String[] args) {
    HopImport hopImport = new HopImport();
    try {
        // Create the command line options...
        // 
        CommandLine cmd = new CommandLine(hopImport);
        // Initialize the Hop environment: load plugins and more
        // 
        HopEnvironment.init();
        // Picks up the system settings in the variables
        // 
        hopImport.buildVariableSpace();
        // Now add run configuration plugins...
        // 
        List<IPlugin> configPlugins = PluginRegistry.getInstance().getPlugins(ConfigPluginType.class);
        for (IPlugin configPlugin : configPlugins) {
            // Load only the plugins of the "import" category
            if (ConfigPlugin.CATEGORY_IMPORT.equals(configPlugin.getCategory())) {
                IConfigOptions configOptions = PluginRegistry.getInstance().loadClass(configPlugin, IConfigOptions.class);
                cmd.addMixin(configPlugin.getIds()[0], configOptions);
            }
        }
        hopImport.setCmd(cmd);
        // This will calculate the option values and put them in HopRun or the plugin classes
        // 
        CommandLine.ParseResult parseResult = cmd.parseArgs(args);
        if (CommandLine.printHelpIfRequested(parseResult)) {
            System.exit(1);
        } else {
            // now run!
            // 
            hopImport.run();
            if (hopImport != null && hopImport.isFinishedWithoutError()) {
                System.exit(0);
            } else {
                System.exit(1);
            }
        }
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        hopImport.cmd.usage(System.err);
        System.exit(9);
    } catch (ExecutionException e) {
        System.err.println("Error found during execution!");
        System.err.println(Const.getStackTracker(e));
        System.exit(1);
    } catch (Exception e) {
        System.err.println("General error found, something went horribly wrong!");
        System.err.println(Const.getStackTracker(e));
        System.exit(2);
    }
}
Also used : CommandLine(picocli.CommandLine) IConfigOptions(org.apache.hop.core.config.plugin.IConfigOptions) ParameterException(picocli.CommandLine.ParameterException) ExecutionException(picocli.CommandLine.ExecutionException) HopException(org.apache.hop.core.exception.HopException) ParameterException(picocli.CommandLine.ParameterException) ExecutionException(picocli.CommandLine.ExecutionException) IOException(java.io.IOException) IPlugin(org.apache.hop.core.plugins.IPlugin)

Example 5 with IPlugin

use of org.apache.hop.core.plugins.IPlugin in project hop by apache.

the class HopImport method printPluginTypes.

private void printPluginTypes() {
    System.err.println("Here are the available import plugins:");
    for (IPlugin importPlugin : PluginRegistry.getInstance().getPlugins(ImportPluginType.class)) {
        System.err.println("  - " + importPlugin.getIds()[0]);
        System.err.println("    Name: " + importPlugin.getName());
        System.err.println("    Description: " + importPlugin.getDescription());
        System.err.println("    Documentation URL: " + importPlugin.getDocumentationUrl());
    }
}
Also used : IPlugin(org.apache.hop.core.plugins.IPlugin)

Aggregations

IPlugin (org.apache.hop.core.plugins.IPlugin)72 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)39 HopException (org.apache.hop.core.exception.HopException)29 ArrayList (java.util.ArrayList)12 HopPluginException (org.apache.hop.core.exception.HopPluginException)10 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)7 IConfigOptions (org.apache.hop.core.config.plugin.IConfigOptions)6 IVariables (org.apache.hop.core.variables.IVariables)6 ExecutionException (picocli.CommandLine.ExecutionException)5 ParameterException (picocli.CommandLine.ParameterException)5 IOException (java.io.IOException)4 Method (java.lang.reflect.Method)4 CommandLine (picocli.CommandLine)4 HashMap (java.util.HashMap)3 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)3 Point (org.apache.hop.core.gui.Point)3 ILogChannel (org.apache.hop.core.logging.ILogChannel)3 UnknownParamException (org.apache.hop.core.parameters.UnknownParamException)3 NotePadMeta (org.apache.hop.core.NotePadMeta)2 HopDatabaseException (org.apache.hop.core.exception.HopDatabaseException)2