Search in sources :

Example 6 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.

the class SalesforceInputTestIT method testTypeForQuery.

@Test
public void testTypeForQuery() throws Exception {
    SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForQuery();
    SalesforceDataprepSource source = new SalesforceDataprepSource();
    source.initialize(null, properties);
    source.validate(null);
    try (Reader reader = source.createReader(null)) {
        int count = 3;
        for (boolean available = reader.start(); available; available = reader.advance()) {
            IndexedRecord record = (IndexedRecord) reader.getCurrent();
            assertEquals(String.class, record.get(0).getClass());
            assertEquals(String.class, record.get(1).getClass());
            if ((count--) < 1) {
                break;
            }
        }
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) Reader(org.talend.components.api.component.runtime.Reader) Test(org.junit.Test)

Example 7 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.

the class SalesforceDatasetRuntime method getSample.

@Override
public void getSample(int limit, Consumer<IndexedRecord> consumer) {
    SalesforceDataprepSource sds = new SalesforceDataprepSource();
    SalesforceInputProperties properties = new SalesforceInputProperties("model");
    properties.setDatasetProperties(dataset);
    throwExceptionIfValidationResultIsError(sds.initialize(container, properties));
    throwExceptionIfValidationResultIsError(sds.validate(container));
    SalesforceBulkQueryReader reader = (SalesforceBulkQueryReader) sds.createReader(container);
    reader.setLimit(limit);
    ReaderDataProvider<IndexedRecord> readerDataProvider = new ReaderDataProvider<>(reader, limit, consumer);
    readerDataProvider.retrieveData();
}
Also used : ReaderDataProvider(org.talend.components.api.component.runtime.ReaderDataProvider) IndexedRecord(org.apache.avro.generic.IndexedRecord) SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties)

Example 8 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.

the class TSalesforceInputDefinitionTest method setUp.

@Before
public void setUp() {
    definition = new TSalesforceInputDefinition();
    properties = new SalesforceInputProperties("root");
    properties.init();
}
Also used : SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) Before(org.junit.Before)

Example 9 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties 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);
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) SalesforceDefinition.getSandboxedInstance(org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink) SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties)

Example 10 with SalesforceInputProperties

use of org.talend.components.salesforce.dataprep.SalesforceInputProperties in project components by Talend.

the class SalesforceDatastoreRuntime method doHealthChecks.

@Override
public Iterable<ValidationResult> doHealthChecks(RuntimeContainer container) {
    SalesforceDataprepSource sds = new SalesforceDataprepSource();
    SalesforceInputProperties properties = new SalesforceInputProperties("model");
    SalesforceDatasetProperties dataset = new SalesforceDatasetProperties("dataset");
    // set the sourcetype to soql to prevent loading of all modules during health check
    dataset.sourceType.setValue(SalesforceDatasetProperties.SourceType.SOQL_QUERY);
    properties.setDatasetProperties(dataset);
    dataset.setDatastoreProperties(datastore);
    sds.initialize(container, properties);
    ValidationResult result = sds.validate(container);
    return Arrays.asList(result);
}
Also used : SalesforceInputProperties(org.talend.components.salesforce.dataprep.SalesforceInputProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) SalesforceDatasetProperties(org.talend.components.salesforce.dataset.SalesforceDatasetProperties)

Aggregations

SalesforceInputProperties (org.talend.components.salesforce.dataprep.SalesforceInputProperties)17 Reader (org.talend.components.api.component.runtime.Reader)9 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 Test (org.junit.Test)8 IOException (java.io.IOException)5 SalesforceDatasetProperties (org.talend.components.salesforce.dataset.SalesforceDatasetProperties)4 ComponentException (org.talend.components.api.exception.ComponentException)3 SalesforceDatastoreProperties (org.talend.components.salesforce.datastore.SalesforceDatastoreProperties)3 SalesforceInputDefinition (org.talend.components.salesforce.dataprep.SalesforceInputDefinition)2 SalesforceDatastoreDefinition (org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 ReaderDataProvider (org.talend.components.api.component.runtime.ReaderDataProvider)1 ComponentProperties (org.talend.components.api.properties.ComponentProperties)1 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)1 SalesforceDefinition.getSandboxedInstance (org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance)1 SalesforceRuntimeSourceOrSink (org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1