use of org.apache.hop.core.config.plugin.IConfigOptions 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);
}
}
use of org.apache.hop.core.config.plugin.IConfigOptions 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);
}
}
use of org.apache.hop.core.config.plugin.IConfigOptions 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);
}
}
use of org.apache.hop.core.config.plugin.IConfigOptions in project hop by apache.
the class HopServer method main.
public static void main(String[] args) {
String[] arguments = Stream.of(args).flatMap(a -> Stream.of(a.split("(?=--)"))).filter(a -> !a.isEmpty()).toArray(String[]::new);
HopServer hopServer = new HopServer();
try {
// Create the command line options...
//
picocli.CommandLine cmd = new picocli.CommandLine(hopServer);
// Apply the system properties to the JVM
//
hopServer.applySystemProperties();
// Initialize the Hop environment: load plugins and more
//
HopClientEnvironment.getInstance().setClient(HopClientEnvironment.ClientType.SERVER);
HopEnvironment.init();
// Picks up the system settings in the variables
//
hopServer.buildVariableSpace();
// Clear the jar file cache so that we don't waste memory...
//
JarCache.getInstance().clear();
// Set up the metadata to use
//
hopServer.metadataProvider = HopMetadataUtil.getStandardHopMetadataProvider(hopServer.variables);
// Now add server configuration plugins...
//
List<IPlugin> configPlugins = PluginRegistry.getInstance().getPlugins(ConfigPluginType.class);
for (IPlugin configPlugin : configPlugins) {
// Load only the plugins of the "run" category
if (ConfigPlugin.CATEGORY_SERVER.equals(configPlugin.getCategory())) {
IConfigOptions configOptions = PluginRegistry.getInstance().loadClass(configPlugin, IConfigOptions.class);
cmd.addMixin(configPlugin.getIds()[0], configOptions);
}
}
hopServer.setCmd(cmd);
// Add optional metadata folder (legacy)
//
hopServer.addMetadataFolderProvider();
// This will calculate the option values and put them in HopRun or the plugin classes
//
picocli.CommandLine.ParseResult parseResult = cmd.parseArgs(arguments);
if (picocli.CommandLine.printHelpIfRequested(parseResult)) {
printExtraUsageExamples();
System.exit(1);
} else {
hopServer.run();
// If we exit now it's because the server was stopped and this is not an error
//
System.exit(0);
}
} catch (picocli.CommandLine.ParameterException e) {
System.err.println(e.getMessage());
hopServer.cmd.usage(System.err);
printExtraUsageExamples();
System.exit(9);
} catch (picocli.CommandLine.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);
}
}
use of org.apache.hop.core.config.plugin.IConfigOptions in project hop by apache.
the class HopConfig method main.
public static void main(String[] args) {
HopConfig hopConfig = new HopConfig();
try {
HopEnvironment.init();
CommandLine cmd = new CommandLine(hopConfig);
List<IPlugin> configPlugins = PluginRegistry.getInstance().getPlugins(ConfigPluginType.class);
for (IPlugin configPlugin : configPlugins) {
// Load only the plugins of the "config" category
if (ConfigPlugin.CATEGORY_CONFIG.equals(configPlugin.getCategory())) {
IConfigOptions configOptions = PluginRegistry.getInstance().loadClass(configPlugin, IConfigOptions.class);
cmd.addMixin(configPlugin.getIds()[0], configOptions);
}
}
hopConfig.setCmd(cmd);
CommandLine.ParseResult parseResult = cmd.parseArgs(args);
if (CommandLine.printHelpIfRequested(parseResult)) {
System.exit(1);
} else {
hopConfig.run();
System.exit(0);
}
} catch (ParameterException e) {
System.err.println(e.getMessage());
hopConfig.cmd.usage(System.err);
e.getCommandLine().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);
}
}
Aggregations