Search in sources :

Example 66 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class SafeStopTest method testDownStreamStepsFinishProcessing.

@Test
public void testDownStreamStepsFinishProcessing() throws KettleException {
    String path = getClass().getResource("/safe-stop-gen-rows.ktr").getPath();
    TransMeta transMeta = new TransMeta(path, new Variables());
    Trans trans = new Trans(transMeta);
    trans.execute(new String[] {});
    trans.safeStop();
    trans.waitUntilFinished();
    assertEquals(trans.getSteps().get(0).step.getLinesWritten(), trans.getSteps().get(2).step.getLinesRead());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) TransMeta(org.pentaho.di.trans.TransMeta) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Example 67 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class CurrentDirectoryResolver method resolveCurrentDirectory.

public VariableSpace resolveCurrentDirectory(VariableSpace parentVariables, RepositoryDirectoryInterface directory, String filename) {
    Variables tmpSpace = new Variables();
    tmpSpace.setParentVariableSpace(parentVariables);
    tmpSpace.initializeVariablesFrom(parentVariables);
    if (directory != null) {
        tmpSpace.setVariable(Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, directory.toString());
        tmpSpace.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, directory.toString());
        tmpSpace.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, directory.toString());
    } else if (filename != null) {
        try {
            FileObject fileObject = KettleVFS.getFileObject(filename, tmpSpace);
            if (!fileObject.exists()) {
                // don't set variables if the file doesn't exist
                return tmpSpace;
            }
            FileName fileName = fileObject.getName();
            // The filename of the transformation
            tmpSpace.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());
            // The directory of the transformation
            FileName fileDir = fileName.getParent();
            tmpSpace.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI());
            tmpSpace.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
            tmpSpace.setVariable(Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, fileDir.getURI());
        } catch (Exception e) {
        }
    }
    return tmpSpace;
}
Also used : Variables(org.pentaho.di.core.variables.Variables) FileName(org.apache.commons.vfs2.FileName) FileObject(org.apache.commons.vfs2.FileObject)

Example 68 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class JobEntryCreateFile method main.

public static void main(String[] args) {
    List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
    new JobEntryCreateFile().check(remarks, null, new Variables(), null, null);
    System.out.printf("Remarks: %s\n", remarks);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface)

Example 69 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class JobEntryDeleteFile method main.

public static void main(String[] args) {
    List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
    new JobEntryDeleteFile().check(remarks, null, new Variables(), null, null);
    System.out.printf("Remarks: %s\n", remarks);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface)

Example 70 with Variables

use of org.pentaho.di.core.variables.Variables in project pentaho-kettle by pentaho.

the class BaseDatabaseMetaTest method testDefaultSettings.

@Test
public void testDefaultSettings() throws Exception {
    // Note - this method should only use native or odbc.
    // The jndi meta is used for mutations of the meta, and it would
    // not be threadsafe in a multi-threaded testing environment
    // (each test run in its own thread).
    assertEquals(-1, nativeMeta.getDefaultDatabasePort());
    assertTrue(nativeMeta.supportsSetCharacterStream());
    assertTrue(nativeMeta.supportsAutoInc());
    assertEquals("", nativeMeta.getLimitClause(5));
    assertEquals(0, nativeMeta.getNotFoundTK(true));
    assertEquals("", nativeMeta.getSQLNextSequenceValue("FOO"));
    assertEquals("", nativeMeta.getSQLCurrentSequenceValue("FOO"));
    assertEquals("", nativeMeta.getSQLSequenceExists("FOO"));
    assertTrue(nativeMeta.isFetchSizeSupported());
    assertFalse(nativeMeta.needsPlaceHolder());
    assertTrue(nativeMeta.supportsSchemas());
    assertTrue(nativeMeta.supportsCatalogs());
    assertTrue(nativeMeta.supportsEmptyTransactions());
    assertEquals("SUM", nativeMeta.getFunctionSum());
    assertEquals("AVG", nativeMeta.getFunctionAverage());
    assertEquals("MIN", nativeMeta.getFunctionMinimum());
    assertEquals("MAX", nativeMeta.getFunctionMaximum());
    assertEquals("COUNT", nativeMeta.getFunctionCount());
    assertEquals("\"", nativeMeta.getStartQuote());
    assertEquals("\"", nativeMeta.getEndQuote());
    assertEquals("FOO.BAR", nativeMeta.getSchemaTableCombination("FOO", "BAR"));
    assertEquals(DatabaseMeta.CLOB_LENGTH, nativeMeta.getMaxTextFieldLength());
    assertEquals(DatabaseMeta.CLOB_LENGTH, nativeMeta.getMaxVARCHARLength());
    assertTrue(nativeMeta.supportsTransactions());
    assertFalse(nativeMeta.supportsSequences());
    assertTrue(nativeMeta.supportsBitmapIndex());
    assertTrue(nativeMeta.supportsSetLong());
    assertArrayEquals(new String[] {}, nativeMeta.getReservedWords());
    assertTrue(nativeMeta.quoteReservedWords());
    assertFalse(nativeMeta.supportsRepository());
    assertArrayEquals(new String[] { "TABLE" }, nativeMeta.getTableTypes());
    assertArrayEquals(new String[] { "VIEW" }, nativeMeta.getViewTypes());
    assertArrayEquals(new String[] { "SYNONYM" }, nativeMeta.getSynonymTypes());
    assertFalse(nativeMeta.useSchemaNameForTableList());
    assertTrue(nativeMeta.supportsViews());
    assertFalse(nativeMeta.supportsSynonyms());
    assertNull(nativeMeta.getSQLListOfProcedures());
    assertNull(nativeMeta.getSQLListOfSequences());
    assertTrue(nativeMeta.supportsFloatRoundingOnUpdate());
    assertNull(nativeMeta.getSQLLockTables(new String[] { "FOO" }));
    assertNull(nativeMeta.getSQLUnlockTables(new String[] { "FOO" }));
    assertTrue(nativeMeta.supportsTimeStampToDateConversion());
    assertTrue(nativeMeta.supportsBatchUpdates());
    assertFalse(nativeMeta.supportsBooleanDataType());
    assertFalse(nativeMeta.supportsTimestampDataType());
    assertTrue(nativeMeta.preserveReservedCase());
    assertTrue(nativeMeta.isDefaultingToUppercase());
    Map<String, String> emptyMap = new HashMap<String, String>();
    assertEquals(emptyMap, nativeMeta.getExtraOptions());
    assertEquals(";", nativeMeta.getExtraOptionSeparator());
    assertEquals("=", nativeMeta.getExtraOptionValueSeparator());
    assertEquals(";", nativeMeta.getExtraOptionIndicator());
    assertTrue(nativeMeta.supportsOptionsInURL());
    assertNull(nativeMeta.getExtraOptionsHelpText());
    assertTrue(nativeMeta.supportsGetBlob());
    assertNull(nativeMeta.getConnectSQL());
    assertTrue(nativeMeta.supportsSetMaxRows());
    assertFalse(nativeMeta.isUsingConnectionPool());
    assertEquals(ConnectionPoolUtil.defaultMaximumNrOfConnections, nativeMeta.getMaximumPoolSize());
    assertEquals(ConnectionPoolUtil.defaultInitialNrOfConnections, nativeMeta.getInitialPoolSize());
    assertFalse(nativeMeta.isPartitioned());
    assertArrayEquals(new PartitionDatabaseMeta[0], nativeMeta.getPartitioningInformation());
    Properties emptyProps = new Properties();
    assertEquals(emptyProps, nativeMeta.getConnectionPoolingProperties());
    assertTrue(nativeMeta.needsToLockAllTables());
    assertTrue(nativeMeta.isStreamingResults());
    assertFalse(nativeMeta.isQuoteAllFields());
    assertFalse(nativeMeta.isForcingIdentifiersToLowerCase());
    assertFalse(nativeMeta.isForcingIdentifiersToUpperCase());
    assertFalse(nativeMeta.isUsingDoubleDecimalAsSchemaTableSeparator());
    assertTrue(nativeMeta.isRequiringTransactionsOnQueries());
    assertEquals("org.pentaho.di.core.database.DatabaseFactory", nativeMeta.getDatabaseFactoryName());
    assertNull(nativeMeta.getPreferredSchemaName());
    assertFalse(nativeMeta.supportsSequenceNoMaxValueOption());
    assertFalse(nativeMeta.requiresCreateTablePrimaryKeyAppend());
    assertFalse(nativeMeta.requiresCastToVariousForIsNull());
    assertFalse(nativeMeta.isDisplaySizeTwiceThePrecision());
    assertTrue(nativeMeta.supportsPreparedStatementMetadataRetrieval());
    assertFalse(nativeMeta.supportsResultSetMetadataRetrievalOnly());
    assertFalse(nativeMeta.isSystemTable("FOO"));
    assertTrue(nativeMeta.supportsNewLinesInSQL());
    assertNull(nativeMeta.getSQLListOfSchemas());
    assertEquals(0, nativeMeta.getMaxColumnsInIndex());
    assertTrue(nativeMeta.supportsErrorHandlingOnBatchUpdates());
    assertTrue(nativeMeta.isExplorable());
    assertNull(nativeMeta.getXulOverlayFile());
    assertTrue(nativeMeta.onlySpaces("   \t   \n  \r   "));
    assertFalse(nativeMeta.isMySQLVariant());
    assertTrue(nativeMeta.canTest());
    assertTrue(nativeMeta.requiresName());
    assertTrue(nativeMeta.releaseSavepoint());
    Variables v = new Variables();
    v.setVariable("FOOVARIABLE", "FOOVALUE");
    DatabaseMeta dm = new DatabaseMeta();
    dm.setDatabaseInterface(nativeMeta);
    assertEquals("", nativeMeta.getDataTablespaceDDL(v, dm));
    assertEquals("", nativeMeta.getIndexTablespaceDDL(v, dm));
    assertFalse(nativeMeta.useSafePoints());
    assertTrue(nativeMeta.supportsErrorHandling());
    assertEquals("'DATA'", nativeMeta.getSQLValue(new ValueMetaString("FOO"), "DATA", null));
    assertEquals("'15'", nativeMeta.getSQLValue(new ValueMetaString("FOO"), "15", null));
    assertEquals("_", nativeMeta.getFieldnameProtector());
    assertEquals("_1ABC_123", nativeMeta.getSafeFieldname("1ABC 123"));
    BaseDatabaseMeta tmpSC = new ConcreteBaseDatabaseMeta() {

        @Override
        public String[] getReservedWords() {
            return new String[] { "SELECT" };
        }
    };
    assertEquals("SELECT_", tmpSC.getSafeFieldname("SELECT"));
    assertEquals("NOMAXVALUE", nativeMeta.getSequenceNoMaxValueOption());
    assertTrue(nativeMeta.supportsAutoGeneratedKeys());
    assertNull(nativeMeta.customizeValueFromSQLType(new ValueMetaString("FOO"), null, 0));
    assertTrue(nativeMeta.fullExceptionLog(new RuntimeException("xxxx")));
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) HashMap(java.util.HashMap) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Variables (org.pentaho.di.core.variables.Variables)119 Test (org.junit.Test)67 TransMeta (org.pentaho.di.trans.TransMeta)31 ArrayList (java.util.ArrayList)25 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)20 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)20 StepMeta (org.pentaho.di.trans.step.StepMeta)18 RowMeta (org.pentaho.di.core.row.RowMeta)17 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)16 VariableSpace (org.pentaho.di.core.variables.VariableSpace)14 Repository (org.pentaho.di.repository.Repository)12 TableView (org.pentaho.di.ui.core.widget.TableView)10 FormAttachment (org.eclipse.swt.layout.FormAttachment)9 FormData (org.eclipse.swt.layout.FormData)9 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)9 Label (org.eclipse.swt.widgets.Label)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)7