Search in sources :

Example 1 with TSalesforceGetDeletedProperties

use of org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties in project components by Talend.

the class SalesforceGetDeletedUpdatedReaderTestIT method runGetDeletedTest.

protected void runGetDeletedTest(boolean emptySchema) throws Throwable {
    SalesforceGetDeletedUpdatedProperties sgduProperties = createSalesforceGetDeletedUpdatedProperties(emptySchema);
    SalesforceConnectionModuleProperties connProperties = new SalesforceConnectionModuleProperties("foo") {

        @Override
        protected Set<PropertyPathConnector> getAllSchemaPropertiesConnectors(boolean isOutputConnection) {
            // TODO Auto-generated method stub
            return null;
        }
    };
    connProperties.copyValuesFrom(sgduProperties);
    SalesforceServerTimeStampReaderTestIT timeStampReaderTestIT = new SalesforceServerTimeStampReaderTestIT();
    Calendar startDate = timeStampReaderTestIT.getServerTimestamp();
    String randomInsert = createNewRandom();
    int count = 10;
    // Prepare test data
    List<IndexedRecord> outputRowsInsert = makeRows(randomInsert, count, emptySchema);
    outputRowsInsert = writeRows(randomInsert, connProperties, outputRowsInsert, SalesforceOutputProperties.OutputAction.INSERT);
    checkRows(randomInsert, outputRowsInsert, count);
    // Generate updated record
    String randomUpdate = String.valueOf(Integer.parseInt(randomInsert) + 100);
    List<IndexedRecord> outputRowsUpdate = makeUpdateRows(randomUpdate, emptySchema, outputRowsInsert);
    outputRowsUpdate = writeRows(randomUpdate, connProperties, outputRowsUpdate, SalesforceOutputProperties.OutputAction.UPDATE);
    checkRows(randomUpdate, outputRowsUpdate, count);
    try {
        List<IndexedRecord> rows = readRows(connProperties);
        checkRows(randomUpdate, rows, count);
    } finally {
        deleteRows(outputRowsUpdate, connProperties);
    }
    Calendar endDate = timeStampReaderTestIT.getServerTimestamp();
    // Long ms = 60000 - (endDate.getTimeInMillis() - startDate.getTimeInMillis());
    // System.out.println(ms);
    // if (ms > 0) {
    // endDate.setTimeInMillis(startDate.getTimeInMillis()+120000);
    // }
    endDate.setTimeInMillis(endDate.getTimeInMillis() + 180000);
    System.out.println(endDate.getTimeInMillis() - startDate.getTimeInMillis());
    sgduProperties.startDate.setValue(startDate.getTime());
    sgduProperties.endDate.setValue(endDate.getTime());
    // Test get deleted records
    TSalesforceGetDeletedProperties sgdProperties = new TSalesforceGetDeletedProperties("foo");
    sgdProperties.copyValuesFrom(sgduProperties);
    List<IndexedRecord> deletedRows = readDeletedUpdatedRows(sgdProperties);
    checkRows(randomUpdate, deletedRows, count);
// Test get updated records (Can't be test here)
// (Can't be test here)
// TSalesforceGetUpdatedProperties sguProperties = (TSalesforceGetUpdatedProperties)new
// TSalesforceGetUpdatedProperties("foo").init();
// sgdProperties.copyValuesFrom(connProperties);
// List<IndexedRecord> updatedRows = readRows(sgdProperties);
// checkRows(randomUpdate, updatedRows, count);
}
Also used : PropertyPathConnector(org.talend.components.api.component.PropertyPathConnector) IndexedRecord(org.apache.avro.generic.IndexedRecord) TSalesforceGetDeletedProperties(org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties) Calendar(java.util.Calendar) SalesforceGetDeletedUpdatedProperties(org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties) SalesforceConnectionModuleProperties(org.talend.components.salesforce.SalesforceConnectionModuleProperties)

Example 2 with TSalesforceGetDeletedProperties

use of org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties 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

TSalesforceGetDeletedProperties (org.talend.components.salesforce.tsalesforcegetdeleted.TSalesforceGetDeletedProperties)2 Calendar (java.util.Calendar)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)1 SalesforceConnectionModuleProperties (org.talend.components.salesforce.SalesforceConnectionModuleProperties)1 SalesforceGetDeletedUpdatedProperties (org.talend.components.salesforce.SalesforceGetDeletedUpdatedProperties)1 TSalesforceBulkExecProperties (org.talend.components.salesforce.tsalesforcebulkexec.TSalesforceBulkExecProperties)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