Search in sources :

Example 1 with DatastoreProperties

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);
}
Also used : DatastoreProperties(org.talend.components.common.datastore.DatastoreProperties)

Example 2 with DatastoreProperties

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);
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) DatastoreProperties(org.talend.components.common.datastore.DatastoreProperties) DatasetRuntime(org.talend.components.common.dataset.runtime.DatasetRuntime) DatasetProperties(org.talend.components.common.dataset.DatasetProperties)

Example 3 with DatastoreProperties

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);
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) DatastoreProperties(org.talend.components.common.datastore.DatastoreProperties) ResponseEntity(org.springframework.http.ResponseEntity) HttpStatus(org.springframework.http.HttpStatus) DatastoreRuntime(org.talend.components.common.datastore.runtime.DatastoreRuntime) ValidationResultsDto(org.talend.components.service.rest.dto.ValidationResultsDto) ValidationResult(org.talend.daikon.properties.ValidationResult)

Example 4 with DatastoreProperties

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);
}
Also used : DatastoreProperties(org.talend.components.common.datastore.DatastoreProperties)

Aggregations

DatastoreProperties (org.talend.components.common.datastore.DatastoreProperties)4 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)2 HttpStatus (org.springframework.http.HttpStatus)1 ResponseEntity (org.springframework.http.ResponseEntity)1 DatasetProperties (org.talend.components.common.dataset.DatasetProperties)1 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)1 DatastoreRuntime (org.talend.components.common.datastore.runtime.DatastoreRuntime)1 ValidationResultsDto (org.talend.components.service.rest.dto.ValidationResultsDto)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1