Search in sources :

Example 1 with ITableFilter

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;
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LazyDatabaseSchema(org.hibernate.eclipse.console.workbench.LazyDatabaseSchema) IOverrideRepository(org.jboss.tools.hibernate.runtime.spi.IOverrideRepository) IService(org.jboss.tools.hibernate.runtime.spi.IService)

Example 2 with ITableFilter

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());
}
Also used : ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) TableFilter(org.hibernate.cfg.reveng.TableFilter) ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) Test(org.junit.Test)

Example 3 with ITableFilter

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());
}
Also used : ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) TableFilter(org.hibernate.cfg.reveng.TableFilter) ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) Test(org.junit.Test)

Example 4 with ITableFilter

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());
}
Also used : ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) TableFilter(org.hibernate.cfg.reveng.TableFilter) ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) Test(org.junit.Test)

Example 5 with ITableFilter

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());
}
Also used : ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) TableFilter(org.hibernate.cfg.reveng.TableFilter) ITableFilter(org.jboss.tools.hibernate.runtime.spi.ITableFilter) Test(org.junit.Test)

Aggregations

ITableFilter (org.jboss.tools.hibernate.runtime.spi.ITableFilter)85 TableFilter (org.hibernate.cfg.reveng.TableFilter)84 Test (org.junit.Test)84 Field (java.lang.reflect.Field)8 List (java.util.List)8 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)4 CoreException (org.eclipse.core.runtime.CoreException)1 PartInitException (org.eclipse.ui.PartInitException)1 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)1 LazyDatabaseSchema (org.hibernate.eclipse.console.workbench.LazyDatabaseSchema)1 IOverrideRepository (org.jboss.tools.hibernate.runtime.spi.IOverrideRepository)1 IService (org.jboss.tools.hibernate.runtime.spi.IService)1