use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceModuleListProperties method afterFormFinishMain.
public ValidationResult afterFormFinishMain(Repository<Properties> repo) throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, this);
ValidationResult vr = ss.validate(null);
if (vr.getStatus() != ValidationResult.Result.OK) {
return vr;
}
String connRepLocation = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
for (NamedThing nl : selectedModuleNames.getValue()) {
String moduleId = nl.getName();
SalesforceModuleProperties modProps = new SalesforceModuleProperties(moduleId);
modProps.connection = connection;
modProps.init();
Schema schema = ss.getEndpointSchema(null, moduleId);
modProps.moduleName.setValue(moduleId);
modProps.main.schema.setValue(schema);
repo.storeProperties(modProps, nl.getName(), connRepLocation, "main.schema");
}
return ValidationResult.OK;
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class TSalesforceInputProperties method validateGuessQuery.
public ValidationResult validateGuessQuery() {
ValidationResultMutable validationResult = new ValidationResultMutable();
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS)) {
SalesforceRuntimeSourceOrSink salesforceSourceOrSink = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
salesforceSourceOrSink.initialize(null, this);
Schema schema = module.main.schema.getValue();
String moduleName = module.moduleName.getValue();
if (!schema.getFields().isEmpty()) {
String soqlQuery = ((SalesforceSchemaHelper<Schema>) salesforceSourceOrSink).guessQuery(schema, moduleName);
query.setValue(soqlQuery);
validationResult.setStatus(ValidationResult.Result.OK);
} else {
String errorMessage = getI18nMessage("errorMessage.validateGuessQueryError");
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
query.setValue("");
}
} catch (TalendRuntimeException tre) {
validationResult.setStatus(ValidationResult.Result.ERROR);
validationResult.setMessage(getI18nMessage("errorMessage.validateGuessQuerySoqlError", tre.getMessage()));
}
return validationResult;
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceDatasetProperties method runtimeTask.
private void runtimeTask(Consumer task) throws IOException {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(DATAPREP_SOURCE_CLASS)) {
SalesforceRuntimeSourceOrSink runtime = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
SalesforceInputProperties properties = new SalesforceInputProperties("model");
properties.setDatasetProperties(this);
throwExceptionIfValidationResultIsError(runtime.initialize(null, properties));
throwExceptionIfValidationResultIsError(runtime.validate(null));
task.accept(runtime);
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class JDBCConnectionTestIT method testDynamicLibLoad.
// we want to test the dynamic library loading with the field driverPath, but fail, so seems that no way to test it
// now
@Ignore
@Test
public void testDynamicLibLoad() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = DBTestUtils.createCommonJDBCConnectionProperties(allSetting, definition);
// the maven path below is a library at my local repository, you can change it to any jdbc driver which exists in your
// maven repository for running the test. I can't use derby for test as i have added the derby dependency in the pom file.
properties.connection.driverTable.drivers.setValue(Arrays.asList("mvn:org.talend.libraries/mysql-connector-java-5.1.30-bin/6.0.0"));
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(ExecutionEngine.DI, properties, ConnectorTopology.NONE);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, definition.getClass().getClassLoader())) {
sandboxedInstance.getInstance();
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e) {
Assert.fail("can't find the jdbc driver class, fail to load the library");
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class JdbcInputOutputRuntimeTest method testBasic.
@Test
public void testBasic() {
JDBCInputProperties inputProperties = new JDBCInputProperties("input");
inputProperties.init();
inputProperties.setDatasetProperties(JdbcDatasetRuntimeTest.createDatasetProperties());
JDBCInputDefinition inputDefinition = new JDBCInputDefinition();
RuntimeInfo inputRI = inputDefinition.getRuntimeInfo(ExecutionEngine.BEAM, inputProperties, ConnectorTopology.OUTGOING);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(inputRI, getClass().getClassLoader())) {
assertThat(si.getInstance().getClass().getCanonicalName(), is(JDBCInputDefinition.BEAM_RUNTIME));
}
inputRI = inputDefinition.getRuntimeInfo(ExecutionEngine.DI, inputProperties, ConnectorTopology.OUTGOING);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(inputRI, getClass().getClassLoader())) {
assertThat(si.getInstance().getClass().getCanonicalName(), is(JDBCInputDefinition.DI_RUNTIME));
}
JDBCOutputProperties outputProperties = new JDBCOutputProperties("output");
outputProperties.init();
outputProperties.setDatasetProperties(JdbcDatasetRuntimeTest.createDatasetProperties());
JDBCOutputDefinition outputDefinition = new JDBCOutputDefinition();
RuntimeInfo outputRI = outputDefinition.getRuntimeInfo(ExecutionEngine.BEAM, outputProperties, ConnectorTopology.INCOMING);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(outputRI, getClass().getClassLoader())) {
assertThat(si.getInstance().getClass().getCanonicalName(), is(JDBCOutputDefinition.BEAM_RUNTIME));
}
}
Aggregations