use of org.talend.components.common.datastore.DatastoreProperties in project components by Talend.
the class PropertiesControllerImpl method getDatasetProperties.
@Override
public String getDatasetProperties(String formName, UiSpecsPropertiesDto propertiesContainer) {
String definitionName = propertiesContainer.getDefinitionName();
DatastoreDefinition<DatastoreProperties> datastoreDefinition = propertiesHelpers.getDataStoreDefinition(definitionName);
notNull(datastoreDefinition, "Could not find connection definition of name %s", definitionName);
DatastoreProperties properties = propertiesHelpers.propertiesFromDto(propertiesContainer);
DatasetProperties<?> datasetProperties = datastoreDefinition.createDatasetProperties(properties);
return datasetProperties == null ? "{}" : jsonSerializationHelper.toJson(formName, datasetProperties);
}
use of org.talend.components.common.datastore.DatastoreProperties in project components by Talend.
the class RuntimeControllerImpl method useDatasetRuntime.
private <//
T> //
T useDatasetRuntime(//
final DatasetDefinition<DatasetProperties<DatastoreProperties>> datasetDefinition, //
DatasetProperties datasetProperties, Function<DatasetRuntime<DatasetProperties<DatastoreProperties>>, T> consumer) {
try (SandboxedInstance instance = RuntimeUtil.createRuntimeClass(datasetDefinition.getRuntimeInfo(datasetProperties), datasetProperties.getClass().getClassLoader())) {
DatasetRuntime<DatasetProperties<DatastoreProperties>> datasetRuntimeInstance = (DatasetRuntime<DatasetProperties<DatastoreProperties>>) instance.getInstance();
datasetRuntimeInstance.initialize(null, datasetProperties);
return consumer.apply(datasetRuntimeInstance);
}
}
use of org.talend.components.common.datastore.DatastoreProperties in project components by Talend.
the class RuntimeControllerImpl method doValidateDatastoreConnection.
private ResponseEntity<ValidationResultsDto> doValidateDatastoreConnection(DatastoreProperties properties) {
DatastoreDefinition<DatastoreProperties> definition = propertiesHelpers.getFirstDefinitionFromProperties(properties);
try (SandboxedInstance instance = RuntimeUtil.createRuntimeClass(definition.getRuntimeInfo(properties), properties.getClass().getClassLoader())) {
DatastoreRuntime<DatastoreProperties> datastoreRuntime = (DatastoreRuntime) instance.getInstance();
datastoreRuntime.initialize(null, properties);
Iterable<ValidationResult> healthChecks = datastoreRuntime.doHealthChecks(null);
ValidationResultsDto response = new ValidationResultsDto(healthChecks == null ? emptyList() : newArrayList(healthChecks));
HttpStatus httpStatus = response.getStatus() == ValidationResult.Result.OK ? HttpStatus.OK : HttpStatus.BAD_REQUEST;
return new ResponseEntity<>(response, httpStatus);
}
}
use of org.talend.components.common.datastore.DatastoreProperties in project components by Talend.
the class PropertiesControllerImpl method getDatasetProperties.
@Override
public String getDatasetProperties(String formName, SerPropertiesDto propertiesContainer) {
DatastoreProperties properties = propertiesHelpers.propertiesFromDto(propertiesContainer);
DatastoreDefinition<DatastoreProperties> datastoreDefinition = propertiesHelpers.getFirstDefinitionFromProperties(properties);
DatasetProperties<?> datasetProperties = datastoreDefinition.createDatasetProperties(properties);
return datasetProperties == null ? "{}" : jsonSerializationHelper.toJson(formName, datasetProperties);
}
Aggregations