Search in sources :

Example 1 with MarketoSourceOrSinkSchemaProvider

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider 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 2 with MarketoSourceOrSinkSchemaProvider

use of org.talend.components.marketo.runtime.MarketoSourceOrSinkSchemaProvider 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)

Aggregations

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