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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations