Search in sources :

Example 81 with TransMeta

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

the class JobExecutionConfiguration method getUsedArguments.

public void getUsedArguments(JobMeta jobMeta, String[] commandLineArguments, IMetaStore metaStore) {
    for (JobEntryCopy jobEntryCopy : jobMeta.jobcopies) {
        if (jobEntryCopy.isTransformation()) {
            JobEntryTrans jobEntryTrans = (JobEntryTrans) jobEntryCopy.getEntry();
            try {
                TransMeta transMeta = jobEntryTrans.getTransMeta(repository, metaStore, jobMeta);
                Map<String, String> map = transMeta.getUsedArguments(commandLineArguments);
                for (String key : map.keySet()) {
                    String value = map.get(key);
                    if (!arguments.containsKey(key)) {
                        arguments.put(key, value);
                    }
                }
            } catch (KettleException ke) {
            // suppress exceptions at this time - we will let the runtime report on any errors
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TransMeta(org.pentaho.di.trans.TransMeta)

Example 82 with TransMeta

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

the class SalesforceInputDialog method preview.

// Preview the data
private void preview() {
    try {
        SalesforceInputMeta oneMeta = new SalesforceInputMeta();
        getInfo(oneMeta);
        // check if the path is given
        TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
        EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "SalesforceInputDialog.NumberRows.DialogTitle"), BaseMessages.getString(PKG, "SalesforceInputDialog.NumberRows.DialogMessage"));
        int previewSize = numberDialog.open();
        if (previewSize > 0) {
            TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(shell, previewMeta, new String[] { wStepname.getText() }, new int[] { previewSize });
            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(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();
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "SalesforceInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "SalesforceInputDialog.ErrorPreviewingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransPreviewProgressDialog(org.pentaho.di.ui.trans.dialog.TransPreviewProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) SalesforceInputMeta(org.pentaho.di.trans.steps.salesforceinput.SalesforceInputMeta) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) Trans(org.pentaho.di.trans.Trans)

Example 83 with TransMeta

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

the class SalesforceInputTest method doConversions.

@Test
public void doConversions() throws Exception {
    StepMeta stepMeta = new StepMeta();
    String name = "test";
    stepMeta.setName(name);
    StepDataInterface stepDataInterface = Mockito.mock(StepDataInterface.class);
    int copyNr = 0;
    TransMeta transMeta = Mockito.mock(TransMeta.class);
    Trans trans = Mockito.mock(Trans.class);
    Mockito.when(transMeta.findStep(Mockito.eq(name))).thenReturn(stepMeta);
    SalesforceInput salesforceInput = new SalesforceInput(stepMeta, stepDataInterface, copyNr, transMeta, trans);
    SalesforceInputMeta meta = new SalesforceInputMeta();
    SalesforceInputData data = new SalesforceInputData();
    data.outputRowMeta = Mockito.mock(RowMeta.class);
    Mockito.when(data.outputRowMeta.getValueMeta(Mockito.eq(0))).thenReturn(new ValueMetaBinary());
    data.convertRowMeta = Mockito.mock(RowMeta.class);
    Mockito.when(data.convertRowMeta.getValueMeta(Mockito.eq(0))).thenReturn(new ValueMetaString());
    Field metaField = salesforceInput.getClass().getDeclaredField("meta");
    metaField.setAccessible(true);
    metaField.set(salesforceInput, meta);
    Field dataField = salesforceInput.getClass().getDeclaredField("data");
    dataField.setAccessible(true);
    dataField.set(salesforceInput, data);
    Object[] outputRowData = new Object[1];
    byte[] binary = { 0, 1, 0, 1, 1, 1 };
    salesforceInput.doConversions(outputRowData, 0, new String(Base64.encode(binary)));
    Assert.assertArrayEquals(binary, (byte[]) outputRowData[0]);
    binary = new byte[0];
    salesforceInput.doConversions(outputRowData, 0, new String(Base64.encode(binary)));
    Assert.assertArrayEquals(binary, (byte[]) outputRowData[0]);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepMeta(org.pentaho.di.trans.step.StepMeta) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) Field(java.lang.reflect.Field) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Example 84 with TransMeta

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

the class S3CsvInputDialog method preview.

// Preview the data
private void preview() {
    // Create the XML input step
    S3CsvInputMeta oneMeta = new S3CsvInputMeta();
    getInfo(oneMeta);
    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(transMeta, oneMeta, wStepname.getText());
    EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), Messages.getString("S3CsvInputDialog.PreviewSize.DialogTitle"), Messages.getString("S3CsvInputDialog.PreviewSize.DialogMessage"));
    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, Messages.getString("System.Dialog.PreviewError.Title"), Messages.getString("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) Trans(org.pentaho.di.trans.Trans)

Example 85 with TransMeta

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

the class PurRepository_RepositoryDirectory_IT method setup.

@Before
public void setup() throws Exception {
    transMeta = new TransMeta();
    transMeta.setName("Test");
    transMeta.setRepositoryDirectory(purRepository.getDefaultSaveDirectory(transMeta));
    final Calendar date = Calendar.getInstance();
    date.setTimeInMillis(0);
    purRepository.save(transMeta, "test", date, null, false);
    createPurRepository();
    defaultSaveDirectory = purRepository.getDefaultSaveDirectory(transMeta);
    purRepository.createRepositoryDirectory(defaultSaveDirectory, "test dir");
    defaultSaveDirectory = purRepository.getDefaultSaveDirectory(transMeta);
}
Also used : Calendar(java.util.Calendar) TransMeta(org.pentaho.di.trans.TransMeta) Before(org.junit.Before)

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