Search in sources :

Example 1 with Partitioner

use of org.pentaho.di.trans.Partitioner in project pentaho-kettle by pentaho.

the class SpoonStepsDelegate method getPartitionerDialog.

public StepDialogInterface getPartitionerDialog(StepMeta stepMeta, StepPartitioningMeta partitioningMeta, TransMeta transMeta) throws KettleException {
    Partitioner partitioner = partitioningMeta.getPartitioner();
    String dialogClassName = partitioner.getDialogClassName();
    Class<?> dialogClass;
    Class<?>[] paramClasses = new Class<?>[] { Shell.class, StepMeta.class, StepPartitioningMeta.class, TransMeta.class };
    Object[] paramArgs = new Object[] { spoon.getShell(), stepMeta, partitioningMeta, transMeta };
    Constructor<?> dialogConstructor;
    try {
        dialogClass = partitioner.getClass().getClassLoader().loadClass(dialogClassName);
        dialogConstructor = dialogClass.getConstructor(paramClasses);
        return (StepDialogInterface) dialogConstructor.newInstance(paramArgs);
    } catch (Exception e) {
        // try the old way for compatibility
        Method method;
        try {
            Class<?>[] sig = new Class<?>[] { Shell.class, StepMetaInterface.class, TransMeta.class };
            method = stepMeta.getClass().getDeclaredMethod("getDialog", sig);
            if (method != null) {
                return (StepDialogInterface) method.invoke(stepMeta, new Object[] { spoon.getShell(), stepMeta, transMeta });
            }
        } catch (Throwable ignored) {
        }
        throw new KettleException(e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) TransMeta(org.pentaho.di.trans.TransMeta) Method(java.lang.reflect.Method) StepPartitioningMeta(org.pentaho.di.trans.step.StepPartitioningMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) Partitioner(org.pentaho.di.trans.Partitioner)

Aggregations

Method (java.lang.reflect.Method)1 Shell (org.eclipse.swt.widgets.Shell)1 KettleException (org.pentaho.di.core.exception.KettleException)1 Partitioner (org.pentaho.di.trans.Partitioner)1 TransMeta (org.pentaho.di.trans.TransMeta)1 StepDialogInterface (org.pentaho.di.trans.step.StepDialogInterface)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)1