use of org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime 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