use of org.pentaho.di.core.database.OracleDatabaseMeta in project pentaho-kettle by pentaho.
the class SynchronizeAfterMerge method init.
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
meta = (SynchronizeAfterMergeMeta) smi;
data = (SynchronizeAfterMergeData) sdi;
if (super.init(smi, sdi)) {
try {
meta.normalizeAllocationFields();
data.realSchemaName = environmentSubstitute(meta.getSchemaName());
if (meta.istablenameInField()) {
if (Utils.isEmpty(meta.gettablenameField())) {
logError(BaseMessages.getString(PKG, "SynchronizeAfterMerge.Log.Error.TableFieldnameEmpty"));
return false;
}
}
data.databaseMeta = meta.getDatabaseMeta();
// if we are using Oracle then set releaseSavepoint to false
if (data.databaseMeta.getDatabaseInterface() instanceof OracleDatabaseMeta) {
data.releaseSavepoint = false;
}
data.commitSize = Integer.parseInt(environmentSubstitute("" + meta.getCommitSize()));
data.batchMode = data.commitSize > 0 && meta.useBatchUpdate();
// Batch updates are not supported on PostgreSQL (and look-a-likes) together with error handling (PDI-366)
//
data.specialErrorHandling = getStepMeta().isDoingErrorHandling() && meta.getDatabaseMeta().supportsErrorHandlingOnBatchUpdates();
data.supportsSavepoints = meta.getDatabaseMeta().getDatabaseInterface().useSafePoints();
if (data.batchMode && data.specialErrorHandling) {
data.batchMode = false;
if (log.isBasic()) {
logBasic(BaseMessages.getString(PKG, "SynchronizeAfterMerge.Log.BatchModeDisabled"));
}
}
if (meta.getDatabaseMeta() == null) {
logError(BaseMessages.getString(PKG, "SynchronizeAfterMerge.Init.ConnectionMissing", getStepname()));
return false;
}
data.db = new Database(this, meta.getDatabaseMeta());
data.db.shareVariablesWith(this);
if (getTransMeta().isUsingUniqueConnections()) {
synchronized (getTrans()) {
data.db.connect(getTrans().getTransactionId(), getPartitionID());
}
} else {
data.db.connect(getPartitionID());
}
data.db.setCommit(meta.getCommitSize());
return true;
} catch (KettleException ke) {
logError(BaseMessages.getString(PKG, "SynchronizeAfterMerge.Log.ErrorOccurredDuringStepInitialize") + ke.getMessage());
}
}
return false;
}
use of org.pentaho.di.core.database.OracleDatabaseMeta in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryCreationHelperTest method testCreateIndexLenghts.
/**
* PDI-10237 test index name length.
*
* @throws KettleException
*/
@Test
public void testCreateIndexLenghts() throws KettleException {
DatabaseMeta meta = mock(DatabaseMeta.class);
when(meta.getStartQuote()).thenReturn("");
when(meta.getEndQuote()).thenReturn("");
when(meta.getQuotedSchemaTableCombination(anyString(), anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[1].toString();
}
});
when(meta.getDatabaseInterface()).thenReturn(new OracleDatabaseMeta());
Database db = mock(Database.class);
when(db.getDatabaseMeta()).thenReturn(meta);
// always return some create sql.
when(db.getDDL(anyString(), any(RowMetaInterface.class), anyString(), anyBoolean(), anyString(), anyBoolean())).thenReturn("### CREATE TABLE;");
when(repository.getDatabase()).thenReturn(db);
when(repository.getDatabaseMeta()).thenReturn(meta);
when(db.getCreateIndexStatement(anyString(), anyString(), any(String[].class), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean())).thenAnswer(lan);
KettleDatabaseRepositoryCreationHelper helper = new KettleDatabaseRepositoryCreationHelper(repository);
PluginRegistry.addPluginType(TwoWayPasswordEncoderPluginType.getInstance());
PluginRegistry.init(false);
String passwordEncoderPluginID = Const.NVL(EnvUtil.getSystemProperty(Const.KETTLE_PASSWORD_ENCODER_PLUGIN), "Kettle");
Encr.init(passwordEncoderPluginID);
List<String> statements = new ArrayList<String>();
helper.createRepositorySchema(null, false, statements, true);
for (String st : statements) {
if (st == null || st.startsWith("#")) {
continue;
}
assertTrue("Index name is not overlenght!: " + st, st.length() <= 30);
}
}
Aggregations