Search in sources :

Example 6 with ValidationResultMutable

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;
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) SalesforceDefinition.getSandboxedInstance(org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)

Example 7 with ValidationResultMutable

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;
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) SalesforceDefinition.getSandboxedInstance(org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException) SalesforceSchemaHelper(org.talend.components.salesforce.schema.SalesforceSchemaHelper) Schema(org.apache.avro.Schema) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)

Example 8 with ValidationResultMutable

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;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable)

Example 9 with ValidationResultMutable

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;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties)

Example 10 with ValidationResultMutable

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;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)41 IOException (java.io.IOException)11 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)8 ValidationResult (org.talend.daikon.properties.ValidationResult)7 SQLException (java.sql.SQLException)5 Schema (org.apache.avro.Schema)5 MarketoComponentDefinition.getSandboxedInstance (org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance)3 MarketoSourceOrSinkRuntime (org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime)3 SalesforceDefinition.getSandboxedInstance (org.talend.components.salesforce.SalesforceDefinition.getSandboxedInstance)3 SalesforceRuntimeSourceOrSink (org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink)3 User (com.google.api.services.drive.model.User)2 File (java.io.File)2 GeneralSecurityException (java.security.GeneralSecurityException)2 Connection (java.sql.Connection)2 MarketoSourceOrSinkSchemaProvider (org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider)2 TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)2 LeadSelector (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)2 SalesforceSchemaHelper (org.talend.components.salesforce.schema.SalesforceSchemaHelper)2 NamedThing (org.talend.daikon.NamedThing)2 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)2