use of org.talend.components.api.component.runtime.SourceOrSink in project components by Talend.
the class SalesforceRuntimeTestUtil method initWriter.
private Writer<?> initWriter(TSalesforceOutputBulkDefinition definition, TSalesforceOutputBulkProperties modelProperties) throws IOException {
// simulate to generate the runtime code
TSalesforceOutputBulkProperties runtimeProperties = (TSalesforceOutputBulkProperties) definition.createRuntimeProperties();
// pass all the value from the ui model
runtimeProperties.schema.schema.setValue(modelProperties.schema.schema.getValue());
runtimeProperties.bulkFilePath.setValue(modelProperties.bulkFilePath.getStringValue());
runtimeProperties.append.setValue(modelProperties.append.getValue());
runtimeProperties.ignoreNull.setValue(modelProperties.ignoreNull.getValue());
Object obj = modelProperties.upsertRelationTable.columnName.getValue();
if (obj != null && obj instanceof List && !((List<?>) obj).isEmpty()) {
runtimeProperties.upsertRelationTable.columnName.setValue(modelProperties.upsertRelationTable.columnName.getValue());
runtimeProperties.upsertRelationTable.lookupFieldExternalIdName.setValue(modelProperties.upsertRelationTable.lookupFieldExternalIdName.getValue());
runtimeProperties.upsertRelationTable.lookupFieldModuleName.setValue(modelProperties.upsertRelationTable.lookupFieldModuleName.getValue());
runtimeProperties.upsertRelationTable.lookupRelationshipFieldName.setValue(modelProperties.upsertRelationTable.lookupRelationshipFieldName.getValue());
runtimeProperties.upsertRelationTable.polymorphic.setValue(modelProperties.upsertRelationTable.polymorphic.getValue());
}
SourceOrSink source_sink = new SalesforceBulkFileSink();
source_sink.initialize(null, runtimeProperties);
ValidationResult result = source_sink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
Sink sink = (Sink) source_sink;
WriteOperation<?> writeOperation = sink.createWriteOperation();
writeOperation.initialize(null);
Writer<?> writer = writeOperation.createWriter(null);
writer.open("component_instance_id");
return writer;
}
use of org.talend.components.api.component.runtime.SourceOrSink in project components by Talend.
the class SalesforceProxyTestIT method testProxy.
@Test
public void testProxy() {
TSalesforceConnectionDefinition definition = (TSalesforceConnectionDefinition) getComponentService().getComponentDefinition(TSalesforceConnectionDefinition.COMPONENT_NAME);
SalesforceConnectionProperties properties = (SalesforceConnectionProperties) definition.createRuntimeProperties();
properties.bulkConnection.setValue(true);
properties.userPassword.userId.setValue(userId);
properties.userPassword.password.setValue(password);
properties.userPassword.securityKey.setValue(securityKey);
SourceOrSink sourceOrSink = new SalesforceSourceOrSink();
sourceOrSink.initialize(null, properties);
org.talend.daikon.properties.ValidationResult vr = sourceOrSink.validate(null);
Assert.assertEquals(ValidationResult.Result.OK, vr.getStatus());
}
use of org.talend.components.api.component.runtime.SourceOrSink in project components by Talend.
the class TSnowflakeCloseDefinitionTest method testGetRuntime.
/**
* Check {@link TSnowflakeCloseDefinition#getRuntimeInfo(ExecutionEngine, ComponentProperties, ConnectorTopology)} returns instance of {@link SnowflakeCloseSourceOrSink}
*/
@Test
public void testGetRuntime() {
RuntimeInfo runtimeInfo = snowflakeCloseDefinition.getRuntimeInfo(ExecutionEngine.DI, null, ConnectorTopology.NONE);
SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, snowflakeCloseDefinition.getClass().getClassLoader());
SourceOrSink source = (SourceOrSink) sandboxedInstance.getInstance();
assertThat(source, is(instanceOf(SnowflakeCloseSourceOrSink.class)));
}
use of org.talend.components.api.component.runtime.SourceOrSink in project components by Talend.
the class JDBCTableSelectionModule method beforeTablename.
public ValidationResult beforeTablename() throws IOException {
JdbcRuntimeInfo jdbcRuntimeInfo = new JdbcRuntimeInfo(connection, "org.talend.components.jdbc.runtime.JDBCSource");
try (SandboxedInstance sandboxI = RuntimeUtil.createRuntimeClass(jdbcRuntimeInfo, connection.getClass().getClassLoader())) {
SourceOrSink ss = (SourceOrSink) sandboxI.getInstance();
ss.initialize(null, (ComponentProperties) connection);
List<NamedThing> tablenames = ss.getSchemaNames(null);
tablename.setPossibleNamedThingValues(tablenames);
} catch (ComponentException ex) {
return ex.getValidationResult();
}
return ValidationResult.OK;
}
use of org.talend.components.api.component.runtime.SourceOrSink in project components by Talend.
the class SalesforceRuntimeTestUtil method initWriter.
private Writer initWriter(TSalesforceOutputBulkDefinition definition, TSalesforceOutputBulkProperties modelProperties) throws IOException {
// simulate to generate the runtime code
TSalesforceOutputBulkProperties runtimeProperties = (TSalesforceOutputBulkProperties) definition.createRuntimeProperties();
// pass all the value from the ui model
runtimeProperties.schema.schema.setValue(modelProperties.schema.schema.getValue());
runtimeProperties.bulkFilePath.setValue(modelProperties.bulkFilePath.getStringValue());
runtimeProperties.append.setValue(modelProperties.append.getValue());
runtimeProperties.ignoreNull.setValue(modelProperties.ignoreNull.getValue());
Object obj = modelProperties.upsertRelationTable.columnName.getValue();
if (obj != null && obj instanceof List && !((List) obj).isEmpty()) {
runtimeProperties.upsertRelationTable.columnName.setValue(modelProperties.upsertRelationTable.columnName.getValue());
runtimeProperties.upsertRelationTable.lookupFieldExternalIdName.setValue(modelProperties.upsertRelationTable.lookupFieldExternalIdName.getValue());
runtimeProperties.upsertRelationTable.lookupFieldModuleName.setValue(modelProperties.upsertRelationTable.lookupFieldModuleName.getValue());
runtimeProperties.upsertRelationTable.lookupRelationshipFieldName.setValue(modelProperties.upsertRelationTable.lookupRelationshipFieldName.getValue());
runtimeProperties.upsertRelationTable.polymorphic.setValue(modelProperties.upsertRelationTable.polymorphic.getValue());
}
SourceOrSink source_sink = new SalesforceBulkFileSink();
source_sink.initialize(null, runtimeProperties);
ValidationResult result = source_sink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
Sink sink = (Sink) source_sink;
WriteOperation writeOperation = sink.createWriteOperation();
writeOperation.initialize(null);
Writer writer = writeOperation.createWriter(null);
writer.open("component_instance_id");
return writer;
}
Aggregations