Search in sources :

Example 1 with SalesforceBulkFileSink

use of org.talend.components.salesforce.runtime.SalesforceBulkFileSink 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;
}
Also used : TSalesforceOutputBulkProperties(org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties) SourceOrSink(org.talend.components.api.component.runtime.SourceOrSink) Sink(org.talend.components.api.component.runtime.Sink) SourceOrSink(org.talend.components.api.component.runtime.SourceOrSink) SalesforceBulkFileSink(org.talend.components.salesforce.runtime.SalesforceBulkFileSink) WriteOperation(org.talend.components.api.component.runtime.WriteOperation) SObject(com.sforce.soap.partner.sobject.SObject) ArrayList(java.util.ArrayList) List(java.util.List) SalesforceBulkFileSink(org.talend.components.salesforce.runtime.SalesforceBulkFileSink) ValidationResult(org.talend.daikon.properties.ValidationResult) Writer(org.talend.components.api.component.runtime.Writer)

Aggregations

SObject (com.sforce.soap.partner.sobject.SObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Sink (org.talend.components.api.component.runtime.Sink)1 SourceOrSink (org.talend.components.api.component.runtime.SourceOrSink)1 WriteOperation (org.talend.components.api.component.runtime.WriteOperation)1 Writer (org.talend.components.api.component.runtime.Writer)1 SalesforceBulkFileSink (org.talend.components.salesforce.runtime.SalesforceBulkFileSink)1 TSalesforceOutputBulkProperties (org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1