use of org.pentaho.di.trans.steps.tableoutput.TableOutputMeta in project pentaho-kettle by pentaho.
the class JobGenerator method generateTimeTransformation.
private TransMeta generateTimeTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) throws KettleException {
// We actually load the transformation from a template and then slightly modify it.
//
String filename = "/org/pentaho/di/resources/Generate time dimension.ktr";
InputStream inputStream = getClass().getResourceAsStream(filename);
TransMeta transMeta = new TransMeta(inputStream, Spoon.getInstance().rep, true, new Variables(), null);
// Find the table output step and inject the target table name and database...
//
StepMeta stepMeta = transMeta.findStep("TARGET");
if (stepMeta != null) {
TableOutputMeta meta = (TableOutputMeta) stepMeta.getStepMetaInterface();
meta.setDatabaseMeta(databaseMeta);
String phTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME);
meta.setTableName(phTable);
}
return transMeta;
}
use of org.pentaho.di.trans.steps.tableoutput.TableOutputMeta in project pentaho-kettle by pentaho.
the class PluginRegistryIT method testPluginRegistry.
public void testPluginRegistry() throws KettlePluginException {
PluginRegistry registry = PluginRegistry.getInstance();
assertNotNull("Registry singleton was not found!", registry);
// PluginRegistry.init() may have already been called, our test path will be different
// for each case. If it has not been called, try to register the type and plugin. If
// it has been called, simply verify the plugin type and plugin have been registered.
Class<? extends PluginTypeInterface> pluginTypeClass = StepPluginType.class;
Object pluginClass = new TableInputMeta();
List<PluginInterface> inputPluginsAtTestStart = registry.getPluginsByCategory(pluginTypeClass, PLUGIN_INPUT_CATEGORY);
int numInputPluginsAtStart = inputPluginsAtTestStart.size();
List<PluginInterface> outputPluginsAtTestStart = registry.getPluginsByCategory(pluginTypeClass, PLUGIN_OUTPUT_CATEGORY);
int numOutputPluginsAtStart = outputPluginsAtTestStart.size();
try {
registry.getPluginType(pluginTypeClass);
} catch (KettlePluginException kpe) {
// Register a new plugin type...
registry.registerPluginType(pluginTypeClass);
}
// See if the plugin is there...
try {
registry.getPluginType(pluginTypeClass);
} catch (KettlePluginException kpe) {
fail(pluginTypeClass.getName() + " expected in the PluginRegistry but was not found!");
}
PluginInterface plugin = registry.getPlugin(pluginTypeClass, pluginClass);
Map<Class<?>, String> classMap = new HashMap<Class<?>, String>();
PluginInterface tableInputPlugin = plugin;
int numInputPluginsRegistered = 0;
if (plugin == null) {
// Register a single step plugin
//
classMap.put(StepMetaInterface.class, "org.pentaho.di.trans.steps.tableinput.TableInputMeta");
tableInputPlugin = new Plugin(new String[] { TABLE_INPUT_PLUGIN_ID }, pluginTypeClass, StepMetaInterface.class, PLUGIN_INPUT_CATEGORY, TABLE_INPUT_PLUGIN_NAME, TABLE_INPUT_PLUGIN_DESCRIPTION, TABLE_INPUT_PLUGIN_IMAGE_FILE_NAME, false, true, classMap, new ArrayList<String>(), // No error help file
null, // pluginFolder
null, // documentation URL
null, // cases URL
null, // forum URL
null);
registry.registerPlugin(pluginTypeClass, tableInputPlugin);
numInputPluginsRegistered++;
}
// Verify the plugin has been registered
PluginInterface verify = registry.getPlugin(pluginTypeClass, TABLE_INPUT_PLUGIN_ID);
assertNotNull("A plugin was not found in the plugin registry", verify);
assertEquals("A different plugin then expected was retrieved from the plugin registry", verify, tableInputPlugin);
pluginClass = new TableOutputMeta();
plugin = registry.getPlugin(pluginTypeClass, pluginClass);
PluginInterface tableOutputPlugin = plugin;
int numOutputPluginsRegistered = 0;
if (plugin == null) {
// Register a second step plugin
//
classMap = new HashMap<Class<?>, String>();
classMap.put(StepMetaInterface.class, "org.pentaho.di.trans.steps.tableoutput.TableOutputMeta");
tableOutputPlugin = new Plugin(new String[] { TABLE_OUTPUT_PLUGIN_ID }, pluginTypeClass, StepMetaInterface.class, PLUGIN_OUTPUT_CATEGORY, TABLE_OUTPUT_PLUGIN_NAME, TABLE_OUTPUT_PLUGIN_DESCRIPTION, TABLE_OUTPUT_PLUGIN_IMAGE_FILE_NAME, false, true, classMap, new ArrayList<String>(), // No error help file
null, // pluginFolder
null, // documentation URL
null, // cases URL
null, // forum URL
null);
registry.registerPlugin(pluginTypeClass, tableOutputPlugin);
numOutputPluginsRegistered++;
}
// Verify the plugin has been registered
verify = registry.getPlugin(pluginTypeClass, TABLE_OUTPUT_PLUGIN_ID);
assertNotNull("A plugin was not found in the plugin registry", verify);
assertEquals("A different plugin then expected was retrieved from the plugin registry", verify, tableOutputPlugin);
// Get a list by category...
//
List<PluginInterface> inputPlugins = registry.getPluginsByCategory(pluginTypeClass, PLUGIN_INPUT_CATEGORY);
assertEquals("Exactly one plugin expected in the step plugin input category", numInputPluginsAtStart + numInputPluginsRegistered, inputPlugins.size());
assertTrue("Input plugins list should contain the table input step", inputPlugins.contains(tableInputPlugin));
assertFalse("Input plugins list should not contain the table output step", inputPlugins.contains(tableOutputPlugin));
List<PluginInterface> outputPlugins = registry.getPluginsByCategory(pluginTypeClass, PLUGIN_OUTPUT_CATEGORY);
assertEquals("Exactly one plugin expected in the step plugin output category", numOutputPluginsAtStart + numOutputPluginsRegistered, outputPlugins.size());
assertTrue("Output plugins list should contain the table output step", outputPlugins.contains(tableOutputPlugin));
assertFalse("Output plugins list should not contain the table input step", outputPlugins.contains(tableInputPlugin));
// List the categories...
//
List<String> categories = registry.getCategories(pluginTypeClass);
assertTrue("The input category was expected in the categories list", categories.contains(PLUGIN_INPUT_CATEGORY));
assertTrue("The output category was expected in the categories list", categories.contains(PLUGIN_OUTPUT_CATEGORY));
// Now have a little bit of class loading fun: load the main class of the plugin
//
Object object = registry.loadClass(tableInputPlugin, StepMetaInterface.class);
assertNotNull(object);
// The same but now explicitly asking for the main class
//
Object object2 = registry.loadClass(tableOutputPlugin, StepMetaInterface.class);
assertNotNull(object2);
try {
registry.loadClass(tableInputPlugin, String.class);
fail("A String class type can't be used when loading a step class");
} catch (Exception e) {
// OK!
}
}
use of org.pentaho.di.trans.steps.tableoutput.TableOutputMeta in project data-access by pentaho.
the class StagingTransformGenerator method addTableOutputStep.
protected StepMeta addTableOutputStep(TransMeta transMeta, String tableOutputStepName, String modelName) {
TableOutputMeta tableOutputMeta = new TableOutputMeta();
tableOutputMeta.setCommitSize(1000);
tableOutputMeta.setIgnoreErrors(true);
tableOutputMeta.setPartitioningEnabled(false);
tableOutputMeta.setSchemaName(AgileHelper.getSchemaName());
tableOutputMeta.setTableName(getTableName());
tableOutputMeta.setUseBatchUpdate(false);
StepMeta tableOutputStepMeta = new StepMeta(tableOutputStepName, tableOutputStepName, tableOutputMeta);
transMeta.addStep(tableOutputStepMeta);
return tableOutputStepMeta;
}
Aggregations