use of org.talend.daikon.NamedThing 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());
}
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class AzureStorageConnectionWizardTest method testWizard.
@Test
public void testWizard() throws Throwable {
final List<RepoProps> repoProps = new ArrayList<>();
Repository repo = new TestRepository(repoProps);
getComponentService().setRepository(repo);
Set<ComponentWizardDefinition> wizards = getComponentService().getTopLevelComponentWizards();
int count = 0;
ComponentWizardDefinition wizardDef = null;
for (ComponentWizardDefinition wizardDefinition : wizards) {
if (wizardDefinition instanceof AzureStorageConnectionWizardDefinition) {
wizardDef = wizardDefinition;
count++;
}
}
assertEquals(1, count);
assertEquals("Create an Azure Storage Connection", wizardDef.getMenuItemName());
ComponentWizard wiz = getComponentService().getComponentWizard(AzureStorageConnectionWizardDefinition.COMPONENT_WIZARD_NAME, "nodeAzureStorage");
assertNotNull(wiz);
assertEquals("nodeAzureStorage", wiz.getRepositoryLocation());
List<Form> forms = wiz.getForms();
Form connFormWizard = forms.get(0);
assertEquals("Wizard", connFormWizard.getName());
assertFalse(connFormWizard.isAllowBack());
assertFalse(connFormWizard.isAllowForward());
assertFalse(connFormWizard.isAllowFinish());
// Main from SalesforceModuleListProperties
assertEquals("Container", forms.get(1).getName());
assertEquals("Queue", forms.get(2).getName());
assertEquals("Table", forms.get(3).getName());
assertEquals("Azure Storage Connection Settings", connFormWizard.getTitle());
assertEquals("Fill in fields to configure connection.", connFormWizard.getSubtitle());
TAzureStorageConnectionProperties connProps = (TAzureStorageConnectionProperties) connFormWizard.getProperties();
connProps.setupProperties();
Object image = getComponentService().getWizardPngImage(AzureStorageConnectionWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.TREE_ICON_16X16);
assertNotNull(image);
image = getComponentService().getWizardPngImage(AzureStorageConnectionWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.WIZARD_BANNER_75X66);
assertNotNull(image);
// Check the non-top-level wizard
// check password i18n
assertEquals("Name", connProps.getProperty("name").getDisplayName());
connProps.name.setValue("connName");
connProps.accountName.setValue("demo");
connProps.accountKey.setValue("demo");
// check name i18n
// $NON-NLS-1$
NamedThing nameProp = connFormWizard.getWidget("name").getContent();
assertEquals("Name", nameProp.getDisplayName());
connProps = (TAzureStorageConnectionProperties) PropertiesTestUtils.checkAndValidate(getComponentService(), connFormWizard, "testConnection", connProps);
assertFalse(connFormWizard.isAllowForward());
Form modForm = forms.get(1);
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class GoogleDriveDataSource method getSchemaNames.
@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
List<NamedThing> schemas = new ArrayList<>();
schemas.add(new SimpleNamedThing(SCHEMA_NAME, SCHEMA_NAME));
return schemas;
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class JDBCSourceOrSink method getSchemaNames.
@Override
public List<NamedThing> getSchemaNames(RuntimeContainer runtime) throws IOException {
List<NamedThing> result = new ArrayList<>();
try (Connection conn = connect(runtime)) {
DatabaseMetaData dbMetaData = conn.getMetaData();
Set<String> tableTypes = getAvailableTableTypes(dbMetaData);
String database_schema = getDatabaseSchema();
try (ResultSet resultset = dbMetaData.getTables(null, database_schema, null, tableTypes.toArray(new String[0]))) {
while (resultset.next()) {
String tablename = resultset.getString("TABLE_NAME");
if (tablename == null) {
tablename = resultset.getString("SYNONYM_NAME");
}
result.add(new SimpleNamedThing(tablename, tablename));
}
}
} catch (Exception e) {
throw CommonUtils.newComponentException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e, ExceptionContext.withBuilder().put("message", e.getMessage()).build());
}
return result;
}
use of org.talend.daikon.NamedThing in project components by Talend.
the class JDBCInputTestIT method testGetSchemaNames.
@Test
public void testGetSchemaNames() throws Exception {
TJDBCInputDefinition definition = new TJDBCInputDefinition();
TJDBCInputProperties properties = DBTestUtils.createCommonJDBCInputProperties(allSetting, definition);
properties.main.schema.setValue(DBTestUtils.createTestSchema(tablename));
properties.tableSelection.tablename.setValue(tablename);
properties.sql.setValue(DBTestUtils.getSQL(tablename));
JDBCSource source = DBTestUtils.createCommonJDBCSource(properties);
List<NamedThing> schemaNames = source.getSchemaNames(null);
assertTrue(schemaNames != null);
assertTrue(!schemaNames.isEmpty());
boolean exists = false;
for (NamedThing name : schemaNames) {
if (tablename.equals(name.getName().toUpperCase())) {
exists = true;
break;
}
}
assertTrue(exists);
}
Aggregations