use of org.jboss.tools.hibernate.runtime.spi.IDatabaseCollector in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateDatabaseCollector.
@Test
public void testCreateDatabaseCollector() {
DatabaseCollector databaseCollector = (DatabaseCollector) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { DatabaseCollector.class }, new TestInvocationHandler());
IDatabaseCollector facade = facadeFactory.createDatabaseCollector(databaseCollector);
Assert.assertSame(databaseCollector, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IDatabaseCollector in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewDatabaseCollector.
@Test
public void testNewDatabaseCollector() {
IJDBCReader jdbcReader = FACADE_FACTORY.createJDBCReader(JDBCReaderFactory.newJDBCReader(new Configuration().getProperties(), new DefaultReverseEngineeringStrategy(), new StandardServiceRegistryBuilder().build()));
IDatabaseCollector databaseCollectorFacade = service.newDatabaseCollector(jdbcReader);
Assert.assertNotNull(databaseCollectorFacade);
DatabaseCollector databaseCollector = (DatabaseCollector) ((IFacade) databaseCollectorFacade).getTarget();
Assert.assertNotNull(databaseCollector);
}
use of org.jboss.tools.hibernate.runtime.spi.IDatabaseCollector in project jbosstools-hibernate by jbosstools.
the class LazyDatabaseSchemaWorkbenchAdapter method getChildren.
public Object[] getChildren(Object o, final IProgressMonitor monitor) {
LazyDatabaseSchema dbs = getLazyDatabaseSchema(o);
dbs.setConnected(false);
dbs.setErrorFlag(false);
ConsoleConfiguration consoleConfiguration = dbs.getConsoleConfiguration();
Object[] res;
try {
IDatabaseCollector db = readDatabaseSchema(monitor, consoleConfiguration, dbs.getReverseEngineeringStrategy());
List<TableContainer> result = new ArrayList<TableContainer>();
Iterator<Map.Entry<String, List<ITable>>> qualifierEntries = db.getQualifierEntries();
while (qualifierEntries.hasNext()) {
Map.Entry<String, List<ITable>> entry = qualifierEntries.next();
result.add(new TableContainer(entry.getKey(), entry.getValue()));
}
res = toArray(result.iterator(), Object.class, new Comparator<Object>() {
public int compare(Object arg0, Object arg1) {
return getName(arg0).compareTo(getName(arg1));
}
private String getName(Object o) {
String result = null;
try {
// $NON-NLS-1$
Method m = o.getClass().getMethod("getName", new Class[] {});
result = (String) m.invoke(o, new Object[] {});
} catch (Exception e) {
throw new RuntimeException(e);
}
return result;
}
});
dbs.setConnected(true);
} catch (Exception e) {
HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.LazyDatabaseSchemaWorkbenchAdapter_problems_while_reading_database_schema, e);
String out = NLS.bind(HibernateConsoleMessages.LazyDatabaseSchemaWorkbenchAdapter_reading_schema_error, e.getMessage());
res = new Object[] { out };
dbs.setErrorFlag(true);
}
return res;
}
Aggregations