use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class SalesforceDatasetProperties method retrieveModuleFields.
private void retrieveModuleFields() throws IOException {
// refresh the module list
if (sourceType.getValue() == SourceType.MODULE_SELECTION && StringUtils.isNotEmpty(moduleName.getValue())) {
Consumer consumer = new Consumer() {
@Override
public void accept(SalesforceRuntimeSourceOrSink runtime) throws IOException {
List<NamedThing> moduleNames = runtime.getSchemaNames(null);
moduleName.setPossibleNamedThingValues(filter(moduleNames));
Schema schema = runtime.getEndpointSchema(null, moduleName.getValue());
List<NamedThing> columns = new ArrayList<>();
for (Schema.Field field : schema.getFields()) {
columns.add(new SimpleNamedThing(field.name(), field.name()));
}
selectColumnIds.setPossibleValues(columns);
}
};
runtimeTask(consumer);
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink 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);
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class SalesforceModuleListProperties method beforeFormPresentMain.
public void beforeFormPresentMain() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, this);
ValidationResult vr = ss.validate(null);
if (vr.getStatus() == ValidationResult.Result.OK) {
try {
moduleNames = ss.getSchemaNames(null);
} catch (Exception ex) {
throw new ComponentException(ExceptionUtil.exceptionToValidationResult(ex));
}
selectedModuleNames.setPossibleValues(moduleNames);
getForm(Form.MAIN).setAllowBack(true);
getForm(Form.MAIN).setAllowFinish(true);
} else {
throw new ComponentException(vr);
}
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class TSalesforceInputProperties method validateGuessSchema.
public ValidationResult validateGuessSchema() {
ValidationResultMutable validationResult = new ValidationResultMutable();
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS)) {
SalesforceRuntimeSourceOrSink salesforceSourceOrSink = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
salesforceSourceOrSink.initialize(null, this);
Schema schema = ((SalesforceSchemaHelper<Schema>) salesforceSourceOrSink).guessSchema(query.getValue());
module.main.schema.setValue(schema);
validationResult.setStatus(ValidationResult.Result.OK);
} catch (TalendRuntimeException tre) {
String errorMessage = getI18nMessage("errorMessage.validateGuessSchemaSoqlError", tre.getMessage());
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
} catch (RuntimeException e1) {
String errorMessage = getI18nMessage("errorMessage.validateGuessSchemaRuntimeError", e1.getMessage());
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
} catch (IOException e2) {
String errorMessage = getI18nMessage("errorMessage.validateGuessSchemaConnectionError", e2.getMessage());
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
}
return validationResult;
}
Aggregations