use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class CreateDatabaseWizard method createAndRunDatabaseWizard.
/**
* Shows a wizard that creates a new database connection...
*
* @param shell
* @param props
* @param databases
* @return DatabaseMeta when finished or null when canceled
*/
public DatabaseMeta createAndRunDatabaseWizard(Shell shell, PropsUI props, List<DatabaseMeta> databases) {
DatabaseMeta newDBInfo = new DatabaseMeta();
final CreateDatabaseWizardPage1 page1 = new CreateDatabaseWizardPage1("1", props, newDBInfo, databases);
final CreateDatabaseWizardPageInformix pageifx = new CreateDatabaseWizardPageInformix("ifx", props, newDBInfo);
final CreateDatabaseWizardPageJDBC pagejdbc = new CreateDatabaseWizardPageJDBC("jdbc", props, newDBInfo);
final CreateDatabaseWizardPageOCI pageoci = new CreateDatabaseWizardPageOCI("oci", props, newDBInfo);
final CreateDatabaseWizardPageODBC pageodbc = new CreateDatabaseWizardPageODBC("odbc", props, newDBInfo);
final CreateDatabaseWizardPageOracle pageoracle = new CreateDatabaseWizardPageOracle("oracle", props, newDBInfo);
final CreateDatabaseWizardPageGeneric pageGeneric = new CreateDatabaseWizardPageGeneric("generic", props, newDBInfo);
final CreateDatabaseWizardPage2 page2 = new CreateDatabaseWizardPage2("2", props, newDBInfo);
for (PluginInterface pluginInterface : PluginRegistry.getInstance().getPlugins(DatabasePluginType.class)) {
try {
Object plugin = PluginRegistry.getInstance().loadClass(pluginInterface);
if (plugin instanceof WizardPageFactory) {
WizardPageFactory factory = (WizardPageFactory) plugin;
additionalPages.add(factory.createWizardPage(props, newDBInfo));
}
} catch (KettlePluginException kpe) {
// Don't do anything
}
}
// set to false for safety only
wizardFinished = false;
Wizard wizard = new Wizard() {
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
wizardFinished = true;
return true;
}
/**
* @see org.eclipse.jface.wizard.Wizard#canFinish()
*/
public boolean canFinish() {
return page2.canFinish();
}
};
wizard.addPage(page1);
wizard.addPage(pageoci);
wizard.addPage(pageodbc);
wizard.addPage(pagejdbc);
wizard.addPage(pageoracle);
wizard.addPage(pageifx);
wizard.addPage(pageGeneric);
for (WizardPage page : additionalPages) {
wizard.addPage(page);
}
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 400);
wd.updateSize();
wd.open();
if (!wizardFinished) {
newDBInfo = null;
}
return newDBInfo;
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class GaInputStepMeta method getFields.
@Override
public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) {
// clear the output
r.clear();
// append the outputFields to the output
for (int i = 0; i < outputField.length; i++) {
ValueMetaInterface v;
try {
v = ValueMetaFactory.createValueMeta(outputField[i], outputType[i]);
} catch (KettlePluginException e) {
v = new ValueMetaString(outputField[i]);
}
// that would influence the output
// v.setConversionMask(conversionMask[i]);
v.setOrigin(origin);
r.addValueMeta(v);
}
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class SpoonUiExtenderPluginType method getRelevantExtenders.
public List<SpoonUiExtenderPluginInterface> getRelevantExtenders(Class<?> clazz, String uiEvent) {
PluginRegistry instance = PluginRegistry.getInstance();
List<PluginInterface> pluginInterfaces = instance.getPlugins(SpoonUiExtenderPluginType.class);
List<SpoonUiExtenderPluginInterface> relevantPluginInterfaces = new ArrayList<SpoonUiExtenderPluginInterface>();
if (pluginInterfaces != null) {
for (PluginInterface pluginInterface : pluginInterfaces) {
try {
Object loadClass = instance.loadClass(pluginInterface);
SpoonUiExtenderPluginInterface spoonUiExtenderPluginInterface = (SpoonUiExtenderPluginInterface) loadClass;
Set<String> events = spoonUiExtenderPluginInterface.respondsTo().get(clazz);
if (events != null && events.contains(uiEvent)) {
relevantPluginInterfaces.add(spoonUiExtenderPluginInterface);
}
} catch (KettlePluginException e) {
e.printStackTrace();
}
}
}
return relevantPluginInterfaces;
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class AccessInputMeta method getFields.
@Override
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
int i;
int nr = inputFields == null ? 0 : inputFields.length;
for (i = 0; i < nr; i++) {
AccessInputField field = inputFields[i];
int type = field.getType();
if (type == ValueMetaInterface.TYPE_NONE) {
type = ValueMetaInterface.TYPE_STRING;
}
ValueMetaInterface v;
try {
v = ValueMetaFactory.createValueMeta(space.environmentSubstitute(field.getName()), type);
} catch (KettlePluginException e) {
v = new ValueMetaNone(space.environmentSubstitute(field.getName()));
}
v.setLength(field.getLength());
v.setPrecision(field.getPrecision());
v.setOrigin(name);
v.setConversionMask(field.getFormat());
v.setDecimalSymbol(field.getDecimalSymbol());
v.setGroupingSymbol(field.getGroupSymbol());
v.setCurrencySymbol(field.getCurrencySymbol());
v.setTrimType(field.getTrimType());
r.addValueMeta(v);
}
if (includeFilename) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(filenameField));
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (includeTablename) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(tablenameField));
v.setLength(250);
v.setPrecision(-1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (includeRowNumber) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(rowNumberField));
v.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0);
v.setOrigin(name);
r.addValueMeta(v);
}
if (getShortFileNameField() != null && getShortFileNameField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getShortFileNameField()));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (getExtensionField() != null && getExtensionField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getExtensionField()));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (getPathField() != null && getPathField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getPathField()));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (getSizeField() != null && getSizeField().length() > 0) {
ValueMetaInterface v = new ValueMetaInteger(space.environmentSubstitute(getSizeField()));
v.setOrigin(name);
v.setLength(9);
r.addValueMeta(v);
}
if (isHiddenField() != null && isHiddenField().length() > 0) {
ValueMetaInterface v = new ValueMetaBoolean(space.environmentSubstitute(isHiddenField()));
v.setOrigin(name);
r.addValueMeta(v);
}
if (getLastModificationDateField() != null && getLastModificationDateField().length() > 0) {
ValueMetaInterface v = new ValueMetaDate(space.environmentSubstitute(getLastModificationDateField()));
v.setOrigin(name);
r.addValueMeta(v);
}
if (getUriField() != null && getUriField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getUriField()));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
if (getRootUriField() != null && getRootUriField().length() > 0) {
ValueMetaInterface v = new ValueMetaString(space.environmentSubstitute(getRootUriField()));
v.setLength(100, -1);
v.setOrigin(name);
r.addValueMeta(v);
}
}
use of org.pentaho.di.core.exception.KettlePluginException in project pentaho-kettle by pentaho.
the class AccessInputMeta method getValueMetaAndData.
/**
* Returns kettle type from Microsoft Access database also convert data to prepare kettle value
*
* @param : MS Access column
* @param : destination field name
* @param : MS Access column value
* @return valuemeta and data
*/
public static ValueMetaAndData getValueMetaAndData(Column c, String name, Object data) {
ValueMetaAndData valueMetaData = new ValueMetaAndData();
// get data
Object o = data;
// Get column type
DataType type = c.getType();
int sourceValueType = ValueMetaInterface.TYPE_STRING;
// We have to take of Meta AND data
switch(type) {
case BINARY:
sourceValueType = ValueMetaInterface.TYPE_BINARY;
break;
case BOOLEAN:
sourceValueType = ValueMetaInterface.TYPE_BOOLEAN;
if (o != null) {
o = Boolean.valueOf(o.toString());
}
break;
case DOUBLE:
sourceValueType = ValueMetaInterface.TYPE_NUMBER;
break;
case FLOAT:
sourceValueType = ValueMetaInterface.TYPE_BIGNUMBER;
if (o != null) {
o = new BigDecimal(Float.toString((Float) o));
}
break;
case INT:
sourceValueType = ValueMetaInterface.TYPE_NUMBER;
if (o != null) {
o = Double.parseDouble(o.toString());
}
break;
case BYTE:
sourceValueType = ValueMetaInterface.TYPE_NUMBER;
if (o != null) {
o = Double.parseDouble(o.toString());
}
break;
case LONG:
sourceValueType = ValueMetaInterface.TYPE_INTEGER;
if (o != null) {
Integer i = (Integer) o;
o = i.longValue();
}
break;
case MEMO:
break;
case MONEY:
sourceValueType = ValueMetaInterface.TYPE_BIGNUMBER;
break;
case NUMERIC:
sourceValueType = ValueMetaInterface.TYPE_BIGNUMBER;
break;
case SHORT_DATE_TIME:
sourceValueType = ValueMetaInterface.TYPE_DATE;
break;
default:
// Default it's string
if (o != null) {
o = o.toString();
}
break;
}
ValueMetaInterface sourceValueMeta;
try {
sourceValueMeta = ValueMetaFactory.createValueMeta(name == null ? c.getName() : name, sourceValueType);
} catch (KettlePluginException e) {
sourceValueMeta = new ValueMetaNone(name == null ? c.getName() : name);
}
sourceValueMeta.setLength(c.getLength(), c.getPrecision());
// set value meta data and return it
valueMetaData.setValueMeta(sourceValueMeta);
if (o != null) {
valueMetaData.setValueData(o);
}
return valueMetaData;
}
Aggregations