Search in sources :

Example 1 with MarketoSourceOrSinkRuntime

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime in project components by Talend.

the class TMarketoConnectionProperties method validateTestConnection.

public ValidationResult validateTestConnection() {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        ValidationResult vr = sos.validateConnection(this);
        if (vr.getStatus() == ValidationResult.Result.OK) {
            getForm(FORM_WIZARD).setAllowForward(true);
            getForm(FORM_WIZARD).setAllowFinish(true);
        } else {
            getForm(FORM_WIZARD).setAllowForward(false);
        }
        return vr;
    }
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 2 with MarketoSourceOrSinkRuntime

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime in project components by Talend.

the class TMarketoInputProperties method validateFetchCustomObjectSchema.

public ValidationResult validateFetchCustomObjectSchema() {
    ValidationResultMutable vr = new ValidationResultMutable();
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        ValidationResult vConn = sos.validateConnection(this);
        if (!Result.OK.equals(vConn.getStatus())) {
            return vConn;
        }
        try {
            Schema schema = ((MarketoSourceOrSinkSchemaProvider) sos).getSchemaForCustomObject(customObjectName.getValue());
            if (schema == null) {
                vr.setStatus(ValidationResult.Result.ERROR).setMessage(messages.getMessage("error.validation.customobjects.fetchcustomobjectschema", customObjectName.getValue(), "NULL"));
                return vr;
            }
            schemaInput.schema.setValue(schema);
            vr.setStatus(ValidationResult.Result.OK);
        } catch (RuntimeException | IOException e) {
            vr.setStatus(ValidationResult.Result.ERROR).setMessage(messages.getMessage("error.validation.customobjects.fetchcustomobjectschema", customObjectName.getValue(), e.getMessage()));
        }
    }
    return vr;
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) Schema(org.apache.avro.Schema) ValidationResultMutable(org.talend.daikon.properties.ValidationResultMutable) MarketoSourceOrSinkSchemaProvider(org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider) IOException(java.io.IOException) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 3 with MarketoSourceOrSinkRuntime

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime in project components by Talend.

the class TMarketoInputProperties method validateFetchCompoundKey.

public ValidationResult validateFetchCompoundKey() {
    ValidationResultMutable vr = new ValidationResultMutable();
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        ValidationResult vConn = sos.validateConnection(this);
        if (!Result.OK.equals(vConn.getStatus())) {
            return vConn;
        }
        try {
            List<String> keys = ((MarketoSourceOrSinkSchemaProvider) sos).getCompoundKeyFields(customObjectName.getValue());
            if (keys == null) {
                vr.setStatus(ValidationResult.Result.ERROR).setMessage(messages.getMessage("error.validation.customobjects.fetchcompoundkey", customObjectName.getValue(), "NULL"));
                return vr;
            }
            compoundKey.keyName.setValue(keys);
            compoundKey.keyValue.setValue(Arrays.asList(new String[keys.size()]));
            vr.setStatus(ValidationResult.Result.OK);
        } catch (RuntimeException | IOException e) {
            vr.setStatus(ValidationResult.Result.ERROR).setMessage(messages.getMessage("error.validation.customobjects.fetchcompoundkey", customObjectName.getValue(), e.getMessage()));
        }
    }
    return vr;
}
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) MarketoSourceOrSinkSchemaProvider(org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider) PropertyFactory.newString(org.talend.daikon.properties.property.PropertyFactory.newString) IOException(java.io.IOException) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 4 with MarketoSourceOrSinkRuntime

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime in project components by Talend.

the class MarketoCustomObjectsSchemasProperties method beforeFormPresentCustomObjects.

public void beforeFormPresentCustomObjects() throws IOException {
    List<NamedThing> customObjectsNames;
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        customObjectsNames = sos.getSchemaNames(null);
    }
    selectedCustomObjectsNames.setPossibleValues(customObjectsNames);
    getForm(FORM_CUSTOMOBJECTS).setAllowBack(true);
    getForm(FORM_CUSTOMOBJECTS).setAllowFinish(true);
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) NamedThing(org.talend.daikon.NamedThing)

Example 5 with MarketoSourceOrSinkRuntime

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime in project components by Talend.

the class TMarketoConnectionProperties method afterFormFinishWizard.

public ValidationResult afterFormFinishWizard(Repository<Properties> repo) {
    try (SandboxedInstance sandboxedInstance = getSandboxedInstance(RUNTIME_SOURCEORSINK_CLASS, USE_CURRENT_JVM_PROPS)) {
        MarketoSourceOrSinkRuntime sos = (MarketoSourceOrSinkRuntime) sandboxedInstance.getInstance();
        sos.initialize(null, this);
        ValidationResult vr = sos.validateConnection(this);
        if (vr.getStatus() != ValidationResult.Result.OK) {
            return vr;
        }
        try {
            repo.storeProperties(this, this.name.getValue(), repositoryLocation, null);
            return ValidationResult.OK;
        } catch (Exception e) {
            return new ValidationResult(Result.ERROR, e.getMessage());
        }
    }
}
Also used : MarketoComponentDefinition.getSandboxedInstance(org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) MarketoSourceOrSinkRuntime(org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime) ValidationResult(org.talend.daikon.properties.ValidationResult)

Aggregations

MarketoComponentDefinition.getSandboxedInstance (org.talend.components.marketo.MarketoComponentDefinition.getSandboxedInstance)6 MarketoSourceOrSinkRuntime (org.talend.components.marketo.runtime.MarketoSourceOrSinkRuntime)6 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)6 ValidationResult (org.talend.daikon.properties.ValidationResult)4 IOException (java.io.IOException)3 ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)3 MarketoSourceOrSinkSchemaProvider (org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider)2 NamedThing (org.talend.daikon.NamedThing)2 Schema (org.apache.avro.Schema)1 PropertyFactory.newString (org.talend.daikon.properties.property.PropertyFactory.newString)1