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());
}
}
}
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);
}
}
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());
}
}
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();
}
}
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;
}
Aggregations