Search in sources :

Example 1 with IBigQueryDatasetRuntime

use of org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime in project components by Talend.

the class BigQueryDatasetProperties method beforeBqDataset.

public ValidationResult beforeBqDataset() {
    BigQueryDatasetDefinition definition = new BigQueryDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IBigQueryDatasetRuntime runtime = (IBigQueryDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        List<NamedThing> datasets = new ArrayList<>();
        for (String dataset : runtime.listDatasets()) {
            datasets.add(new SimpleNamedThing(dataset, dataset));
        }
        bqDataset.setPossibleValues(datasets);
        return ValidationResult.OK;
    } catch (Exception e) {
        return new ValidationResult(new ComponentException(e));
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) IBigQueryDatasetRuntime(org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ValidationResult(org.talend.daikon.properties.ValidationResult) ComponentException(org.talend.components.api.exception.ComponentException) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException)

Example 2 with IBigQueryDatasetRuntime

use of org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime in project components by Talend.

the class BigQueryDatasetProperties method beforeTableName.

public void beforeTableName() {
    BigQueryDatasetDefinition definition = new BigQueryDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IBigQueryDatasetRuntime runtime = (IBigQueryDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        List<NamedThing> tables = new ArrayList<>();
        for (String table : runtime.listTables()) {
            tables.add(new SimpleNamedThing(table, table));
        }
        this.tableName.setPossibleValues(tables);
    } catch (Exception e) {
        TalendRuntimeException.build(CommonErrorCodes.UNEXPECTED_EXCEPTION).setAndThrow(e.getMessage());
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) IBigQueryDatasetRuntime(org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ComponentException(org.talend.components.api.exception.ComponentException) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException)

Aggregations

ArrayList (java.util.ArrayList)2 ComponentException (org.talend.components.api.exception.ComponentException)2 IBigQueryDatasetRuntime (org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime)2 NamedThing (org.talend.daikon.NamedThing)2 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)2 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)2 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)2 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)2 ValidationResult (org.talend.daikon.properties.ValidationResult)1