use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateSchemaExport.
@Test
public void testCreateSchemaExport() {
Configuration configuration = new Configuration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
SchemaExport schemaExport = new SchemaExport();
ISchemaExport facade = facadeFactory.createSchemaExport(schemaExport);
Assert.assertTrue(facade instanceof SchemaExportFacadeImpl);
Assert.assertSame(schemaExport, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.
the class SchemaExportFacadeTest method testGetExceptions.
@SuppressWarnings("unchecked")
@Test
public void testGetExceptions() throws Throwable {
SchemaExport schemaExport = new SchemaExport();
ISchemaExport schemaExportFacade = new SchemaExportFacadeImpl(FACADE_FACTORY, schemaExport);
Assert.assertTrue(schemaExportFacade.getExceptions().isEmpty());
schemaExport.getExceptions().add(new HibernateException("blah"));
Assert.assertFalse(schemaExportFacade.getExceptions().isEmpty());
}
use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateSchemaExport.
@Test
public void testCreateSchemaExport() {
SchemaExport schemaExport = new SchemaExport();
ISchemaExport facade = facadeFactory.createSchemaExport(schemaExport);
Assert.assertTrue(facade instanceof SchemaExportFacadeImpl);
Assert.assertSame(schemaExport, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.
the class ServiceImplTest method testNewSchemaExport.
@Test
public void testNewSchemaExport() {
IConfiguration configuration = service.newDefaultConfiguration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
ISchemaExport schemaExport = service.newSchemaExport(configuration);
Assert.assertNotNull(schemaExport);
}
use of org.jboss.tools.hibernate.runtime.spi.ISchemaExport in project jbosstools-hibernate by jbosstools.
the class SchemaExportAction method doRun.
public void doRun() {
for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
Object node = i.next();
if (!(node instanceof ConsoleConfiguration)) {
continue;
}
final ConsoleConfiguration config = (ConsoleConfiguration) node;
try {
config.execute(new Command() {
public Object execute() {
final IConfiguration cfg = config.getConfiguration();
if (cfg == null) {
return null;
}
String out = NLS.bind(HibernateConsoleMessages.SchemaExportAction_sure_run_schemaexport, config.getName());
boolean res = openWarningYesNoDlg(viewer.getControl().getShell(), HibernateConsoleMessages.SchemaExportAction_run_schemaexport, out);
if (!res) {
return null;
}
IService service = config.getHibernateExtension().getHibernateService();
ISchemaExport export = service.newSchemaExport(cfg);
export.create();
if (!export.getExceptions().isEmpty()) {
Iterator<Throwable> iterator = export.getExceptions().iterator();
int cnt = 1;
while (iterator.hasNext()) {
Throwable element = iterator.next();
String outStr = NLS.bind(HibernateConsoleMessages.SchemaExportAction_errornum_while_performing_schemaexport, cnt++);
HibernateConsolePlugin.getDefault().logErrorMessage(outStr, element);
}
HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), NLS.bind(HibernateConsoleMessages.SchemaExportAction_error_while_performing_schemaexport, cnt - 1), (Throwable) null);
}
return null;
}
});
// todo: should we do it here or should
viewer.refresh(node);
// the view just react to config being
// build ?
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), HibernateConsoleMessages.SchemaExportAction_exception_running_schemaexport, he);
}
}
}
Aggregations