use of org.jboss.tools.hibernate.runtime.spi.ITableFilter in project jbosstools-hibernate by jbosstools.
the class ReverseEngineeringEditor method getLazyDatabaseSchema.
public LazyDatabaseSchema getLazyDatabaseSchema() {
try {
ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(getConsoleConfigurationName());
if (configuration == null) {
configuration = askForConsoleConfiguration();
if (configuration == null) {
return null;
} else {
setConsoleConfigurationName(configuration.getName());
}
}
org.hibernate.eclipse.console.model.ITableFilter[] tableFilters = getReverseEngineeringDefinition().getTableFilters();
IService service = configuration.getHibernateExtension().getHibernateService();
IOverrideRepository repository = service.newOverrideRepository();
boolean hasIncludes = false;
for (int i = 0; i < tableFilters.length; i++) {
org.hibernate.eclipse.console.model.ITableFilter filter = tableFilters[i];
ITableFilter tf = service.newTableFilter();
tf.setExclude(filter.getExclude());
if (filter.getExclude() != null && !filter.getExclude().booleanValue()) {
hasIncludes = true;
}
tf.setMatchCatalog(filter.getMatchCatalog());
tf.setMatchName(filter.getMatchName());
tf.setMatchSchema(filter.getMatchSchema());
repository.addTableFilter(tf);
}
ITableFilter tf = service.newTableFilter();
tf.setExclude(Boolean.FALSE);
// $NON-NLS-1$
tf.setMatchCatalog(".*");
// $NON-NLS-1$
tf.setMatchSchema(".*");
// $NON-NLS-1$
tf.setMatchName(".*");
repository.addTableFilter(tf);
String dialogId = ReverseEngineeringEditor.class.getName();
if (tableFilters.length == 0 && OptionalMessageDialog.isDialogEnabled(dialogId)) {
int returnCode = OptionalMessageDialog.open(dialogId, getContainer().getShell(), MapperMessages.ReverseEngineeringEditor_no_filters_defined, null, MapperMessages.ReverseEngineeringEditor_no_filters_has_been_defined, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
if (returnCode == Window.CANCEL)
return null;
}
LazyDatabaseSchema lazyDatabaseSchema = new LazyDatabaseSchema(configuration, repository.getReverseEngineeringStrategy(service.newDefaultReverseEngineeringStrategy()));
return lazyDatabaseSchema;
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(getContainer().getShell(), MapperMessages.ReverseEngineeringEditor_error_while_refreshing_databasetree, he);
return null;
}
}
use of org.jboss.tools.hibernate.runtime.spi.ITableFilter in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateTableFilter.
@Test
public void testCreateTableFilter() {
TableFilter tableFilter = new TableFilter();
ITableFilter facade = facadeFactory.createTableFilter(tableFilter);
Assert.assertSame(tableFilter, ((IFacade) facade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.ITableFilter in project jbosstools-hibernate by jbosstools.
the class TableFilterFacadeTest method testGetMatchSchema.
@Test
public void testGetMatchSchema() {
TableFilter tableFilter = new TableFilter();
ITableFilter tableFilterFacade = FACADE_FACTORY.createTableFilter(tableFilter);
Assert.assertNotEquals("foo", tableFilterFacade.getMatchSchema());
tableFilter.setMatchSchema("foo");
Assert.assertEquals("foo", tableFilterFacade.getMatchSchema());
}
use of org.jboss.tools.hibernate.runtime.spi.ITableFilter in project jbosstools-hibernate by jbosstools.
the class TableFilterFacadeTest method testSetMatchSchema.
@Test
public void testSetMatchSchema() {
TableFilter tableFilter = new TableFilter();
ITableFilter tableFilterFacade = FACADE_FACTORY.createTableFilter(tableFilter);
Assert.assertNotEquals("foo", tableFilter.getMatchSchema());
tableFilterFacade.setMatchSchema("foo");
Assert.assertEquals("foo", tableFilter.getMatchSchema());
}
use of org.jboss.tools.hibernate.runtime.spi.ITableFilter in project jbosstools-hibernate by jbosstools.
the class TableFilterFacadeTest method testGetExclude.
@Test
public void testGetExclude() {
TableFilter tableFilter = new TableFilter();
ITableFilter tableFilterFacade = FACADE_FACTORY.createTableFilter(tableFilter);
Assert.assertNull(tableFilterFacade.getExclude());
tableFilter.setExclude(true);
Assert.assertTrue(tableFilterFacade.getExclude());
}
Aggregations