Search in sources :

Example 11 with TSalesforceBulkExecProperties

use of org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecProperties in project components by Talend.

the class SalesforceBulkExecReader method start.

@Override
public boolean start() throws IOException {
    TSalesforceBulkExecProperties sprops = (TSalesforceBulkExecProperties) properties;
    bulkRuntime = new SalesforceBulkRuntime(((SalesforceSource) getCurrentSource()).connect(container).bulkConnection);
    bulkRuntime.setConcurrencyMode(sprops.bulkProperties.concurrencyMode.getValue());
    bulkRuntime.setAwaitTime(sprops.bulkProperties.waitTimeCheckBatchState.getValue());
    try {
        // We only support CSV file for bulk output
        bulkRuntime.executeBulk(sprops.module.moduleName.getStringValue(), sprops.outputAction.getValue(), sprops.upsertKeyColumn.getStringValue(), "csv", sprops.bulkFilePath.getStringValue(), sprops.bulkProperties.bytesToCommit.getValue(), sprops.bulkProperties.rowsToCommit.getValue());
        if (bulkRuntime.getBatchCount() > 0) {
            batchIndex = 0;
            currentBatchResult = bulkRuntime.getBatchLog(0);
            resultIndex = 0;
            boolean startable = currentBatchResult.size() > 0;
            if (startable) {
                countData();
            }
            return startable;
        }
        return false;
    } catch (AsyncApiException | ConnectionException e) {
        throw new IOException(e);
    }
}
Also used : IOException(java.io.IOException) AsyncApiException(com.sforce.async.AsyncApiException) ConnectionException(com.sforce.ws.ConnectionException) TSalesforceBulkExecProperties(org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecProperties)

Example 12 with TSalesforceBulkExecProperties

use of org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecProperties in project components by Talend.

the class SalesforceSource method createReader.

@Override
public BoundedReader createReader(RuntimeContainer adaptor) {
    if (properties instanceof TSalesforceInputProperties) {
        TSalesforceInputProperties sfInProperties = (TSalesforceInputProperties) properties;
        boolean isBulk = TSalesforceInputProperties.QueryMode.Bulk.equals(sfInProperties.queryMode.getValue());
        sfInProperties.connection.bulkConnection.setValue(isBulk);
        if (isBulk) {
            return new SalesforceBulkQueryInputReader(adaptor, this, sfInProperties);
        } else {
            return new SalesforceInputReader(adaptor, this, sfInProperties);
        }
    } else if (properties instanceof TSalesforceGetServerTimestampProperties) {
        return new SalesforceServerTimeStampReader(adaptor, this, (TSalesforceGetServerTimestampProperties) properties);
    } else if (properties instanceof TSalesforceGetDeletedProperties) {
        return new SalesforceGetDeletedReader(adaptor, this, (TSalesforceGetDeletedProperties) properties);
    } else if (properties instanceof TSalesforceGetUpdatedProperties) {
        return new SalesforceGetUpdatedReader(adaptor, this, (TSalesforceGetUpdatedProperties) properties);
    } else if (properties instanceof TSalesforceBulkExecProperties) {
        ((TSalesforceBulkExecProperties) properties).connection.bulkConnection.setValue(true);
        return new SalesforceBulkExecReader(adaptor, this, (TSalesforceBulkExecProperties) properties);
    }
    return null;
}
Also used : TSalesforceGetDeletedProperties(org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties) TSalesforceGetServerTimestampProperties(org.talend.components.salesforce.tsalesforcegetservertimestamp.TSalesforceGetServerTimestampProperties) TSalesforceInputProperties(org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties) TSalesforceGetUpdatedProperties(org.talend.components.salesforce.tsalesforcegetupdated.TSalesforceGetUpdatedProperties) TSalesforceBulkExecProperties(org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecProperties)

Aggregations

TSalesforceBulkExecProperties (org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecProperties)12 Test (org.junit.Test)6 IndexedRecord (org.apache.avro.generic.IndexedRecord)5 TSalesforceBulkExecDefinition (org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecDefinition)5 TSalesforceOutputBulkProperties (org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkProperties)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Reader (org.talend.components.api.component.runtime.Reader)4 DataRejectException (org.talend.components.api.exception.DataRejectException)4 TSalesforceOutputBulkDefinition (org.talend.components.salesforce.tsalesforceoutputbulk.TSalesforceOutputBulkDefinition)4 AsyncApiException (com.sforce.async.AsyncApiException)2 ConnectionException (com.sforce.ws.ConnectionException)2 IOException (java.io.IOException)2 ComponentException (org.talend.components.api.exception.ComponentException)1 TSalesforceGetDeletedProperties (org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties)1 TSalesforceGetServerTimestampProperties (org.talend.components.salesforce.tsalesforcegetservertimestamp.TSalesforceGetServerTimestampProperties)1 TSalesforceGetUpdatedProperties (org.talend.components.salesforce.tsalesforcegetupdated.TSalesforceGetUpdatedProperties)1 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)1 TSalesforceOutputBulkExecProperties (org.talend.components.salesforce.tsalesforceoutputbulkexec.TSalesforceOutputBulkExecProperties)1