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