Search in sources :

Example 56 with SandboxedInstance

use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.

the class TMarketoConnectionProperties method afterFormFinishWizard.

public ValidationResult afterFormFinishWizard(Repository<Properties> repo) {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        ValidationResult vr = sos.validateConnection(this);
        if (vr.getStatus() != ValidationResult.Result.OK) {
            return vr;
        }
        try {
            repo.storeProperties(this, this.name.getValue(), repositoryLocation, null);
            return ValidationResult.OK;
        } catch (Exception e) {
            return new ValidationResult(Result.ERROR, e.getMessage());
        }
    }
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 57 with SandboxedInstance

use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.

the class KinesisDatasetRuntimeTestIT method listStreams.

// Can't use localstack to list streams by region
@Test
public void listStreams() {
    KinesisDatasetProperties props = getDatasetForListStreams(getDatastore(), KinesisRegion.DEFAULT, null);
    RuntimeInfo ri = def.getRuntimeInfo(props);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        IKinesisDatasetRuntime runtime = (IKinesisDatasetRuntime) si.getInstance();
        runtime.initialize(null, props);
        Set<String> streams = runtime.listStreams();
        // no exception is ok
        assertTrue(true);
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) KinesisDatasetProperties(org.talend.components.kinesis.KinesisDatasetProperties) IKinesisDatasetRuntime(org.talend.components.kinesis.runtime.IKinesisDatasetRuntime) Test(org.junit.Test)

Example 58 with SandboxedInstance

use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.

the class KinesisInputRuntimeTestIT method testRuntime.

@Test
public void testRuntime() {
    KinesisInputProperties props = new KinesisInputProperties("KinesisInput");
    RuntimeInfo ri = def.getRuntimeInfo(ExecutionEngine.BEAM, props, ConnectorTopology.OUTGOING);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        Assert.assertEquals("KinesisInputRuntime", si.getInstance().getClass().getSimpleName());
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) KinesisInputProperties(org.talend.components.kinesis.input.KinesisInputProperties) Test(org.junit.Test)

Example 59 with SandboxedInstance

use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.

the class KinesisDatasetProperties method afterRegion.

public void afterRegion() {
    refreshLayout(getForm(Form.MAIN));
    KinesisDatasetDefinition definition = new KinesisDatasetDefinition();
    RuntimeInfo ri = definition.getRuntimeInfo(this);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        IKinesisDatasetRuntime runtime = (IKinesisDatasetRuntime) si.getInstance();
        runtime.initialize(null, this);
        this.streamName.setPossibleValues(new ArrayList<String>(runtime.listStreams()));
    } catch (Exception e) {
        TalendRuntimeException.build(ComponentsErrorCode.IO_EXCEPTION, e).throwIt();
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException) IKinesisDatasetRuntime(org.talend.components.kinesis.runtime.IKinesisDatasetRuntime)

Example 60 with SandboxedInstance

use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.

the class MarketoCustomObjectsSchemasProperties method afterFormFinishCustomObjects.

public ValidationResult afterFormFinishCustomObjects(Repository<Properties> repo) throws Exception {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        try {
            String repoLoc = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
            String storeId;
            for (NamedThing nl : selectedCustomObjectsNames.getValue()) {
                String customObjectId = nl.getName();
                storeId = nl.getName().replaceAll("-", "_").replaceAll(" ", "_");
                MarketoComponentWizardBaseProperties customObjectProps = new MarketoComponentWizardBaseProperties(customObjectId);
                customObjectProps.init();
                customObjectProps.connection = connection;
                customObjectProps.inputOperation.setValue(InputOperation.CustomObject);
                customObjectProps.outputOperation.setValue(OutputOperation.syncCustomObjects);
                customObjectProps.customObjectAction.setValue(CustomObjectAction.get);
                customObjectProps.customObjectSyncAction.setValue(CustomObjectSyncAction.createOrUpdate);
                customObjectProps.schemaInput.schema.setValue(sos.getEndpointSchema(null, customObjectId));
                customObjectProps.customObjectName.setValue(nl.getName());
                repo.storeProperties(customObjectProps, storeId, repoLoc, "schemaInput.schema");
            }
        } catch (Exception e) {
            ValidationResultMutable vr = new ValidationResultMutable();
            vr.setStatus(Result.ERROR);
            vr.setMessage(e.getMessage());
            return vr;
        }
    }
    return ValidationResult.OK;
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) NamedThing(org.talend.daikon.NamedThing) IOException(java.io.IOException)

Aggregations

SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)66 Test (org.junit.Test)30 ValidationResult (org.talend.daikon.properties.ValidationResult)30 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)28 Schema (org.apache.avro.Schema)20 IndexedRecord (org.apache.avro.generic.IndexedRecord)18 ArrayList (java.util.ArrayList)12 ComponentException (org.talend.components.api.exception.ComponentException)12 TJDBCRowDefinition (org.talend.components.jdbc.tjdbcrow.TJDBCRowDefinition)10 TJDBCRowProperties (org.talend.components.jdbc.tjdbcrow.TJDBCRowProperties)10 NamedThing (org.talend.daikon.NamedThing)9 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)8 SalesforceDefinition.getSandboxedInstance (org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance)8 SalesforceRuntimeSourceOrSink (org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)8 ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)8 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)7 IOException (java.io.IOException)6 MarketoComponentDefinition.getSandboxedInstance (org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance)6 MarketoSourceOrSinkRuntime (org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime)6 WriteOperation (org.talend.components.api.component.runtime.WriteOperation)5