Search in sources :

Example 76 with TransMeta

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

the class XulDatabaseExplorerController method dataProfile.

public void dataProfile() {
    if (model.getTable() == null) {
        return;
    }
    Shell dbShell = (Shell) dbExplorerDialog.getRootObject();
    try {
        TransProfileFactory profileFactory = new TransProfileFactory(this.model.getDatabaseMeta(), getSchemaAndTable(this.model));
        TransMeta transMeta = profileFactory.generateTransformation(new LoggingObject(model.getTable()));
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(dbShell, transMeta, new String[] { TransProfileFactory.RESULT_STEP_NAME }, new int[] { 25000 });
        progressDialog.open();
        if (!progressDialog.isCancelled()) {
            Trans trans = progressDialog.getTrans();
            String loggingText = progressDialog.getLoggingText();
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(dbShell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
            PreviewRowsDialog prd = new PreviewRowsDialog(dbShell, transMeta, SWT.NONE, TransProfileFactory.RESULT_STEP_NAME, progressDialog.getPreviewRowsMeta(TransProfileFactory.RESULT_STEP_NAME), progressDialog.getPreviewRows(TransProfileFactory.RESULT_STEP_NAME), loggingText);
            prd.open();
        }
    } catch (Exception e) {
        new ErrorDialog(this.dbExplorerDialog.getShell(), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Title"), BaseMessages.getString(PKG, "DatabaseExplorerDialog.UnexpectedProfilingError.Message"), e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) TransProfileFactory(org.pentaho.di.trans.TransProfileFactory) LoggingObject(org.pentaho.di.core.logging.LoggingObject) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) Trans(org.pentaho.di.trans.Trans) XulException(org.pentaho.ui.xul.XulException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 77 with TransMeta

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

the class XMLInputStreamDialog method preview.

// Preview the data
private void preview() {
    // execute a complete preview transformation in the background.
    // This is how we do it...
    // 
    XMLInputStreamMeta oneMeta = new XMLInputStreamMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "XMLInputStreamDialog.Dialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "XMLInputStreamDialog.Dialog.EnterPreviewSize.Message"));
    int previewSize = numberDialog.open();
    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
        progressDialog.open();
        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();
        if (!progressDialog.isCancelled()) {
            if (trans.getResult() != null && trans.getResult().getNrErrors() > 0) {
                EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            }
        }
        PreviewRowsDialog prd = new PreviewRowsDialog(shell, transMeta, SWT.NONE, wStepname.getText(), progressDialog.getPreviewRowsMeta(wStepname.getText()), progressDialog.getPreviewRows(wStepname.getText()), loggingText);
        prd.open();
    }
}
Also used : TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) XMLInputStreamMeta(org.pentaho.di.trans.steps.xmlinputstream.XMLInputStreamMeta) Trans(org.pentaho.di.trans.Trans)

Example 78 with TransMeta

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

the class XMLJoinMeta method getFields.

public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    ValueMetaInterface v = new ValueMeta(this.getValueXMLfield(), ValueMetaInterface.TYPE_STRING);
    v.setOrigin(name);
    TransMeta transMeta = (TransMeta) space;
    try {
        // source fields.
        for (String fieldName : transMeta.getStepFields(transMeta.findStep(getSourceXMLstep()), null, null).getFieldNames()) {
            row.removeValueMeta(fieldName);
        }
    } catch (KettleValueException e) {
    // Pass
    }
    row.addValueMeta(v);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 79 with TransMeta

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

the class MissingPluginTransIT method testForPluginMissingStep.

/**
 * Given a transformation having a step which's plugin is missing in current Kettle installation.
 * When this transformation is executed, then execution should fail.
 */
@Test
public void testForPluginMissingStep() throws Exception {
    InputStream is = new FileInputStream(new File(this.getClass().getResource("missing_plugin_trans.ktr").getFile()));
    TransMeta transMeta = new TransMeta(is, null, false, null, null);
    Trans trans = new Trans(transMeta);
    LogChannelInterface log = mock(LogChannelInterface.class);
    trans.setLog(log);
    try {
        trans.prepareExecution(null);
        fail();
    } catch (KettleException e) {
        verify(log, times(1)).logError("Step [JSON Input.0] failed to initialize!");
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TransMeta(org.pentaho.di.trans.TransMeta) File(java.io.File) Trans(org.pentaho.di.trans.Trans) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 80 with TransMeta

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

the class TransformationHasNoDisabledHopsImportRule method verifyRule.

@Override
public List<ImportValidationFeedback> verifyRule(Object subject) {
    List<ImportValidationFeedback> feedback = new ArrayList<ImportValidationFeedback>();
    if (!isEnabled()) {
        return feedback;
    }
    if (!(subject instanceof TransMeta)) {
        return feedback;
    }
    TransMeta transMeta = (TransMeta) subject;
    for (int i = 0; i < transMeta.nrTransHops(); i++) {
        TransHopMeta hop = transMeta.getTransHop(i);
        if (!hop.isEnabled()) {
            feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.ERROR, "There is a disabled hop in the transformation."));
        }
    }
    if (feedback.isEmpty()) {
        feedback.add(new ImportValidationFeedback(this, ImportValidationResultType.APPROVAL, "All hops are enabled in this transformation."));
    }
    return feedback;
}
Also used : ImportValidationFeedback(org.pentaho.di.imp.rule.ImportValidationFeedback) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Aggregations

TransMeta (org.pentaho.di.trans.TransMeta)710 Test (org.junit.Test)289 StepMeta (org.pentaho.di.trans.step.StepMeta)234 Trans (org.pentaho.di.trans.Trans)214 KettleException (org.pentaho.di.core.exception.KettleException)150 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)136 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)117 TransHopMeta (org.pentaho.di.trans.TransHopMeta)115 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)109 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)106 StepInterface (org.pentaho.di.trans.step.StepInterface)76 RowStepCollector (org.pentaho.di.trans.RowStepCollector)73 JobMeta (org.pentaho.di.job.JobMeta)69 ArrayList (java.util.ArrayList)57 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)54 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)51 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)50 InjectorMeta (org.pentaho.di.trans.steps.injector.InjectorMeta)49 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)49 TransPreviewProgressDialog (org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog)49