use of org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator in project pentaho-kettle by pentaho.
the class OraBulkLoaderMetaTest method setUp.
@Before
public void setUp() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("schemaName", "tableName", "sqlldr", "controlFile", "dataFile", "logFile", "badFile", "discardFile", "commitSize", "bindSize", "readSize", "maxErrors", "loadMethod", "loadAction", "encoding", "characterSetName", "directPath", "eraseFiles", "dbNameOverride", "failOnWarning", "failOnError", "parallel", "altRecordTerm", "fieldTable", "fieldStream", "dateMask", "databaseMeta");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("schemaName", "getSchemaName");
put("tableName", "getTableName");
put("sqlldr", "getSqlldr");
put("controlFile", "getControlFile");
put("dataFile", "getDataFile");
put("logFile", "getLogFile");
put("badFile", "getBadFile");
put("discardFile", "getDiscardFile");
put("commitSize", "getCommitSize");
put("bindSize", "getBindSize");
put("readSize", "getReadSize");
put("maxErrors", "getMaxErrors");
put("loadMethod", "getLoadMethod");
put("loadAction", "getLoadAction");
put("encoding", "getEncoding");
put("characterSetName", "getCharacterSetName");
put("directPath", "isDirectPath");
put("eraseFiles", "isEraseFiles");
put("dbNameOverride", "getDbNameOverride");
put("failOnWarning", "isFailOnWarning");
put("failOnError", "isFailOnError");
put("parallel", "isParallel");
put("altRecordTerm", "getAltRecordTerm");
put("fieldTable", "getFieldTable");
put("fieldStream", "getFieldStream");
put("dateMask", "getDateMask");
put("databaseMeta", "getDatabaseMeta");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("schemaName", "setSchemaName");
put("tableName", "setTableName");
put("sqlldr", "setSqlldr");
put("controlFile", "setControlFile");
put("dataFile", "setDataFile");
put("logFile", "setLogFile");
put("badFile", "setBadFile");
put("discardFile", "setDiscardFile");
put("commitSize", "setCommitSize");
put("bindSize", "setBindSize");
put("readSize", "setReadSize");
put("maxErrors", "setMaxErrors");
put("loadMethod", "setLoadMethod");
put("loadAction", "setLoadAction");
put("encoding", "setEncoding");
put("characterSetName", "setCharacterSetName");
put("directPath", "setDirectPath");
put("eraseFiles", "setEraseFiles");
put("dbNameOverride", "setDbNameOverride");
put("failOnWarning", "setFailOnWarning");
put("failOnError", "setFailOnError");
put("parallel", "setParallel");
put("altRecordTerm", "setAltRecordTerm");
put("fieldTable", "setFieldTable");
put("fieldStream", "setFieldStream");
put("dateMask", "setDateMask");
put("databaseMeta", "setDatabaseMeta");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
FieldLoadSaveValidator<String[]> datemaskArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new DateMaskLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("fieldTable", stringArrayLoadSaveValidator);
attrValidatorMap.put("fieldStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("dateMask", datemaskArrayLoadSaveValidator);
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
// typeValidatorMap.put( int[].class.getCanonicalName(), new PrimitiveIntArrayLoadSaveValidator( new IntLoadSaveValidator(), 1 ) );
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator in project pentaho-kettle by pentaho.
the class InsertUpdateMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
List<String> attributes = Arrays.asList("schemaName", "tableName", "databaseMeta", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "update", "commitSize", "updateBypassed");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("schemaName", "getSchemaName");
put("tableName", "getTableName");
put("databaseMeta", "getDatabaseMeta");
put("keyStream", "getKeyStream");
put("keyLookup", "getKeyLookup");
put("keyCondition", "getKeyCondition");
put("keyStream2", "getKeyStream2");
put("updateLookup", "getUpdateLookup");
put("updateStream", "getUpdateStream");
put("update", "getUpdate");
put("commitSize", "getCommitSizeVar");
put("updateBypassed", "isUpdateBypassed");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("schemaName", "setSchemaName");
put("tableName", "setTableName");
put("databaseMeta", "setDatabaseMeta");
put("keyStream", "setKeyStream");
put("keyLookup", "setKeyLookup");
put("keyCondition", "setKeyCondition");
put("keyStream2", "setKeyStream2");
put("updateLookup", "setUpdateLookup");
put("updateStream", "setUpdateStream");
put("update", "setUpdate");
put("commitSize", "setCommitSize");
put("updateBypassed", "setUpdateBypassed");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("keyStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyCondition", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyStream2", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
attrValidatorMap.put("update", new ArrayLoadSaveValidator<Boolean>(new BooleanLoadSaveValidator(), 5));
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
typeValidatorMap.put(boolean[].class.getCanonicalName(), new PrimitiveBooleanArrayLoadSaveValidator(new BooleanLoadSaveValidator(), 3));
loadSaveTester = new LoadSaveTester(InsertUpdateMeta.class, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator in project pentaho-kettle by pentaho.
the class LoadSaveTester method createValidatorMapAndInvokeSetters.
@Override
@SuppressWarnings("unchecked")
protected Map<String, FieldLoadSaveValidator<?>> createValidatorMapAndInvokeSetters(List<String> attributes, T metaToSave) {
Map<String, FieldLoadSaveValidator<?>> validatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
for (String attribute : attributes) {
Getter<?> getter = manipulator.getGetter(attribute);
@SuppressWarnings("rawtypes") Setter setter = manipulator.getSetter(attribute);
FieldLoadSaveValidator<?> validator = fieldLoadSaveValidatorFactory.createValidator(getter);
try {
Object testValue = validator.getTestObject();
setter.set(metaToSave, testValue);
if (validator instanceof DatabaseMetaLoadSaveValidator) {
addDatabase((DatabaseMeta) testValue);
validateStepUsesDatabaseMeta(metaToSave, (DatabaseMeta) testValue);
}
} catch (Exception e) {
throw new RuntimeException("Unable to invoke setter for " + attribute, e);
}
validatorMap.put(attribute, validator);
}
return validatorMap;
}
use of org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator in project pentaho-kettle by pentaho.
the class DynamicSQLRowMetaTest method setUpLoadSave.
@Before
public void setUpLoadSave() throws Exception {
KettleEnvironment.init();
PluginRegistry.init(false);
List<String> attributes = Arrays.asList("sql", "SQLFieldName", "rowLimit", "outerJoin", "variableReplace", "databaseMeta");
Map<String, String> getterMap = new HashMap<String, String>();
Map<String, String> setterMap = new HashMap<String, String>();
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, getterMap, setterMap, attrValidatorMap, typeValidatorMap);
}
use of org.pentaho.di.trans.steps.loadsave.validator.DatabaseMetaLoadSaveValidator in project pentaho-kettle by pentaho.
the class UpdateMetaTest method setUp.
@Before
public void setUp() throws KettleException {
KettleEnvironment.init();
PluginRegistry.init(false);
TransMeta transMeta = new TransMeta();
transMeta.setName("delete1");
Map<String, String> vars = new HashMap<String, String>();
vars.put("max.sz", "10");
transMeta.injectVariables(vars);
umi = new UpdateMeta();
ud = new UpdateData();
PluginRegistry plugReg = PluginRegistry.getInstance();
String deletePid = plugReg.getPluginId(StepPluginType.class, umi);
stepMeta = new StepMeta(deletePid, "delete", umi);
Trans trans = new Trans(transMeta);
transMeta.addStep(stepMeta);
mockHelper = new StepMockHelper<>("Update", UpdateMeta.class, UpdateData.class);
Mockito.when(mockHelper.logChannelInterfaceFactory.create(Mockito.any(), Mockito.any(LoggingObjectInterface.class))).thenReturn(mockHelper.logChannelInterface);
upd = new Update(stepMeta, ud, 1, transMeta, trans);
upd.copyVariablesFrom(transMeta);
List<String> attributes = Arrays.asList("schemaName", "tableName", "commitSize", "errorIgnored", "ignoreFlagField", "skipLookup", "useBatchUpdate", "keyStream", "keyLookup", "keyCondition", "keyStream2", "updateLookup", "updateStream", "databaseMeta");
Map<String, String> getterMap = new HashMap<String, String>() {
{
put("schemaName", "getSchemaName");
put("tableName", "getTableName");
put("commitSize", "getCommitSizeVar");
put("errorIgnored", "isErrorIgnored");
put("ignoreFlagField", "getIgnoreFlagField");
put("skipLookup", "isSkipLookup");
put("useBatchUpdate", "useBatchUpdate");
put("keyStream", "getKeyStream");
put("keyLookup", "getKeyLookup");
put("keyCondition", "getKeyCondition");
put("keyStream2", "getKeyStream2");
put("updateLookup", "getUpdateLookup");
put("updateStream", "getUpdateStream");
put("databaseMeta", "getDatabaseMeta");
}
};
Map<String, String> setterMap = new HashMap<String, String>() {
{
put("schemaName", "setSchemaName");
put("tableName", "setTableName");
put("commitSize", "setCommitSize");
put("errorIgnored", "setErrorIgnored");
put("ignoreFlagField", "setIgnoreFlagField");
put("skipLookup", "setSkipLookup");
put("useBatchUpdate", "setUseBatchUpdate");
put("keyStream", "setKeyStream");
put("keyLookup", "setKeyLookup");
put("keyCondition", "setKeyCondition");
put("keyStream2", "setKeyStream2");
put("updateLookup", "setUpdateLookup");
put("updateStream", "setUpdateStream");
put("databaseMeta", "setDatabaseMeta");
}
};
FieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator = new ArrayLoadSaveValidator<String>(new StringLoadSaveValidator(), 5);
Map<String, FieldLoadSaveValidator<?>> attrValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
attrValidatorMap.put("keyStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyCondition", stringArrayLoadSaveValidator);
attrValidatorMap.put("keyStream2", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateLookup", stringArrayLoadSaveValidator);
attrValidatorMap.put("updateStream", stringArrayLoadSaveValidator);
attrValidatorMap.put("databaseMeta", new DatabaseMetaLoadSaveValidator());
Map<String, FieldLoadSaveValidator<?>> typeValidatorMap = new HashMap<String, FieldLoadSaveValidator<?>>();
loadSaveTester = new LoadSaveTester(testMetaClass, attributes, new ArrayList<String>(), new ArrayList<String>(), getterMap, setterMap, attrValidatorMap, typeValidatorMap, this);
}
Aggregations