Search in sources :

Example 36 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable 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;
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) NamedThing(org.talend.daikon.NamedThing) IOException(java.io.IOException)

Example 37 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class MarkLogicConnectionProperties method validateTestConnection.

public ValidationResult validateTestConnection() {
    ValidationResult vr;
    try (SandboxedInstance sandbox = SandboxInstanceFactory.createSandboxedInstance(RuntimeInfoProvider.getCommonRuntimeInfo(MarkLogicDatastoreDefinition.DATASTORE_RUNTIME), MarkLogicConnectionProperties.class.getClassLoader(), false)) {
        DatastoreRuntime<MarkLogicConnectionProperties> datastoreRuntime = (DatastoreRuntime<MarkLogicConnectionProperties>) sandbox.getInstance();
        datastoreRuntime.initialize(null, this);
        ValidationResultMutable vrm = new ValidationResultMutable(datastoreRuntime.doHealthChecks(null).iterator().next());
        if (vrm.getStatus() == ValidationResult.Result.OK) {
            vrm.setMessage(getI18nMessage("messages.connectionSuccessful"));
            getForm(WIZARD).setAllowFinish(true);
        } else {
            getForm(WIZARD).setAllowFinish(false);
        }
        vr = vrm;
    } catch (Exception e) {
        vr = new ValidationResult(Result.ERROR, e.getMessage());
    }
    return vr;
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) DatastoreRuntime(org.talend.components.common.datastore.runtime.DatastoreRuntime) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 38 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class MarkLogicBulkLoad method initialize.

@Override
public ValidationResult initialize(RuntimeContainer container, Properties properties) {
    ValidationResultMutable validationResult = new ValidationResultMutable();
    if (properties instanceof MarkLogicBulkLoadProperties) {
        bulkLoadProperties = (MarkLogicBulkLoadProperties) properties;
        if (isRequiredPropertiesMissed()) {
            validationResult.setStatus(ValidationResult.Result.ERROR);
            validationResult.setMessage(MESSAGES.getMessage("error.missedProperties"));
        }
    } else {
        validationResult.setStatus(ValidationResult.Result.ERROR);
        validationResult.setMessage(MESSAGES.getMessage("error.wrongProperties"));
    }
    return validationResult;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) MarkLogicBulkLoadProperties(org.talend.components.marklogic.tmarklogicbulkload.MarkLogicBulkLoadProperties)

Example 39 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable in project components by Talend.

the class ExceptionUtil method exceptionToValidationResult.

public static ValidationResult exceptionToValidationResult(Exception ex) {
    ValidationResultMutable vr = new ValidationResultMutable();
    // FIXME - do a better job here
    vr.setMessage(ex.getMessage());
    vr.setStatus(ValidationResult.Result.ERROR);
    return vr;
}
Also used : ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable)

Example 40 with ValidationResultMutable

use of org.talend.daikon.properties.ValidationResultMutable 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;
}
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) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException) Schema(org.apache.avro.Schema) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) SalesforceRuntimeSourceOrSink(org.talend.components.salesforce.common.SalesforceRuntimeSourceOrSink) 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