use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class SalesforceModuleProperties method beforeModuleName.
// consider beforeActivate and beforeRender (change after to afterActivate)
public ValidationResult beforeModuleName() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, getEffectiveConnection());
ValidationResult vr = ss.validate(null);
if (vr.getStatus() == ValidationResult.Result.OK) {
try {
List<NamedThing> moduleNames = ss.getSchemaNames(null);
moduleName.setPossibleNamedThingValues(moduleNames);
} catch (Exception ex) {
return ExceptionUtil.exceptionToValidationResult(ex);
}
} else {
return vr;
}
return ValidationResult.OK;
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class SalesforceModuleProperties method afterModuleName.
public ValidationResult afterModuleName() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, getEffectiveConnection());
ValidationResult vr = ss.validate(null);
if (vr.getStatus() == ValidationResult.Result.OK) {
try {
Schema schema = ss.getEndpointSchema(null, moduleName.getStringValue());
main.schema.setValue(schema);
moduleName.setPossibleValues(Collections.emptyList());
} catch (Exception ex) {
throw new ComponentException(ExceptionUtil.exceptionToValidationResult(ex));
}
} else {
throw new ComponentException(vr);
}
return ValidationResult.OK;
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class SalesforceConnectionProperties method validateTestConnection.
public ValidationResult validateTestConnection() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, SalesforceConnectionProperties.this);
ValidationResultMutable vr = new ValidationResultMutable(ss.validate(null));
if (vr.getStatus() == ValidationResult.Result.OK) {
vr.setMessage(MESSAGES.getMessage("connection.success"));
getForm(FORM_WIZARD).setAllowForward(true);
} else {
getForm(FORM_WIZARD).setAllowForward(false);
}
return vr;
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class SalesforceModuleListProperties method afterFormFinishMain.
public ValidationResult afterFormFinishMain(Repository<Properties> repo) 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) {
return vr;
}
String connRepLocation = repo.storeProperties(connection, connection.name.getValue(), repositoryLocation, null);
for (NamedThing nl : selectedModuleNames.getValue()) {
String moduleId = nl.getName();
SalesforceModuleProperties modProps = new SalesforceModuleProperties(moduleId);
modProps.connection = connection;
modProps.init();
Schema schema = ss.getEndpointSchema(null, moduleId);
modProps.moduleName.setValue(moduleId);
modProps.main.schema.setValue(schema);
repo.storeProperties(modProps, nl.getName(), connRepLocation, "main.schema");
}
return ValidationResult.OK;
}
}
use of org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink in project components by Talend.
the class TSalesforceInputProperties method validateGuessQuery.
public ValidationResult validateGuessQuery() {
ValidationResultMutable validationResult = new ValidationResultMutable();
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS)) {
SalesforceRuntimeSourceOrSink salesforceSourceOrSink = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
salesforceSourceOrSink.initialize(null, this);
Schema schema = module.main.schema.getValue();
String moduleName = module.moduleName.getValue();
if (!schema.getFields().isEmpty()) {
String soqlQuery = ((SalesforceSchemaHelper<Schema>) salesforceSourceOrSink).guessQuery(schema, moduleName);
query.setValue(soqlQuery);
validationResult.setStatus(ValidationResult.Result.OK);
} else {
String errorMessage = getI18nMessage("errorMessage.validateGuessQueryError");
validationResult.setStatus(ValidationResult.Result.ERROR).setMessage(errorMessage);
query.setValue("");
}
} catch (TalendRuntimeException tre) {
validationResult.setStatus(ValidationResult.Result.ERROR);
validationResult.setMessage(getI18nMessage("errorMessage.validateGuessQuerySoqlError", tre.getMessage()));
}
return validationResult;
}
Aggregations