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());
}
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;
}
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);
}
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);
}
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")));
}
Aggregations