use of org.talend.daikon.properties.ValidationResultMutable 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.daikon.properties.ValidationResultMutable 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;
}
use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.
the class SnowflakeSourceOrSink method exceptionToValidationResult.
public static ValidationResult exceptionToValidationResult(Exception ex) {
ValidationResultMutable vr = new ValidationResultMutable();
vr.setMessage(ex.getMessage());
vr.setStatus(ValidationResult.Result.ERROR);
return vr;
}
use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.
the class SnowflakeSourceOrSink method validateConnectionProperties.
protected static ValidationResultMutable validateConnectionProperties(SnowflakeProvideConnectionProperties properties) {
ValidationResultMutable vr = new ValidationResultMutable();
vr.setStatus(Result.OK);
SnowflakeConnectionProperties connectionProperties = properties.getConnectionProperties();
StringBuilder missingProperties = new StringBuilder();
if (StringUtils.isEmpty(connectionProperties.account.getValue())) {
missingProperties.append("'Account', ");
}
if (StringUtils.isEmpty(connectionProperties.userPassword.password.getValue())) {
missingProperties.append("'Password', ");
}
if (StringUtils.isEmpty(connectionProperties.userPassword.userId.getValue())) {
missingProperties.append("'UserID', ");
}
if (StringUtils.isEmpty(connectionProperties.schemaName.getValue())) {
missingProperties.append("'Schema', ");
}
if (StringUtils.isEmpty(connectionProperties.db.getValue())) {
missingProperties.append("'Database', ");
}
if (!missingProperties.toString().isEmpty()) {
vr.setStatus(Result.ERROR);
vr.setMessage(i18nMessages.getMessage("error.requiredPropertyIsEmpty", missingProperties.toString().substring(0, missingProperties.length() - 2)));
}
return vr;
}
use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.
the class SnowflakeSourceOrSink method validate.
@Override
public ValidationResult validate(RuntimeContainer container) {
try {
createConnection(container);
} catch (IllegalArgumentException e) {
ValidationResultMutable vr = new ValidationResultMutable();
vr.setMessage(e.getMessage().concat(SnowflakeConstants.INCORRECT_SNOWFLAKE_ACCOUNT_MESSAGE));
vr.setStatus(ValidationResult.Result.ERROR);
return vr;
} catch (Exception ex) {
return exceptionToValidationResult(ex);
}
ValidationResultMutable vr = new ValidationResultMutable();
vr.setStatus(Result.OK);
vr.setMessage(SnowflakeConstants.CONNECTION_SUCCESSFUL_MESSAGE);
return vr;
}
Aggregations