use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.
the class TableFacadeTest method testGetSubselect.
@Test
public void testGetSubselect() {
Table table = new Table();
ITable tableFacade = FACADE_FACTORY.createTable(table);
Assert.assertNull(tableFacade.getSubselect());
table.setSubselect("foo");
Assert.assertEquals("foo", tableFacade.getSubselect());
}
use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.
the class TableFacadeTest method testGetPrimaryKey.
@Test
public void testGetPrimaryKey() {
Table table = new Table();
PrimaryKey primaryKey = new PrimaryKey(table);
ITable tableFacade = FACADE_FACTORY.createTable(table);
Assert.assertNull(tableFacade.getPrimaryKey());
table.setPrimaryKey(primaryKey);
IPrimaryKey primaryKeyFacade = tableFacade.getPrimaryKey();
Assert.assertSame(primaryKey, ((IFacade) primaryKeyFacade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.
the class TableFacadeTest method testHasDenormalizedTables.
@Test
public void testHasDenormalizedTables() throws Exception {
Table table = new Table();
ITable tableFacade = FACADE_FACTORY.createTable(table);
Assert.assertFalse(tableFacade.hasDenormalizedTables());
Method method = Table.class.getDeclaredMethod("setHasDenormalizedTables", new Class[] {});
method.setAccessible(true);
method.invoke(table, new Object[] {});
Assert.assertTrue(tableFacade.hasDenormalizedTables());
}
use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.
the class TableFilterView method toggle.
protected void toggle(boolean exclude) {
ConsoleConfiguration cc = getConsoleConfiguration();
if (cc == null)
return;
ISelection selection = viewer.getSelection();
if (!selection.isEmpty()) {
StructuredSelection ss = (StructuredSelection) selection;
Iterator<?> iterator = ss.iterator();
while (iterator.hasNext()) {
Object sel = iterator.next();
ITableFilter filter = null;
if (sel instanceof ITable) {
ITable table = (ITable) sel;
filter = revEngDef.createTableFilter(cc);
if (StringHelper.isNotEmpty(table.getName())) {
filter.setMatchName(table.getName());
}
if (StringHelper.isNotEmpty(table.getCatalog())) {
filter.setMatchCatalog(table.getCatalog());
}
if (StringHelper.isNotEmpty(table.getSchema())) {
filter.setMatchSchema(table.getSchema());
}
filter.setExclude(Boolean.valueOf(exclude));
} else if (sel instanceof TableContainer) {
// assume its a
// schema!
TableContainer tc = (TableContainer) sel;
filter = revEngDef.createTableFilter(cc);
String schema = tc.getName();
if (schema == null || "".equals(schema)) {
// $NON-NLS-1$
// $NON-NLS-1$
filter.setMatchCatalog(".*");
// $NON-NLS-1$
filter.setMatchSchema(".*");
} else {
// fake catalog handling
String catalog = StringHelper.qualifier(schema);
schema = StringHelper.unqualify(schema);
// $NON-NLS-1$ //$NON-NLS-2$
filter.setMatchCatalog("".equals(catalog) ? ".*" : catalog);
// $NON-NLS-1$ //$NON-NLS-2$
filter.setMatchSchema("".equals(schema) ? ".*" : schema);
}
// $NON-NLS-1$
filter.setMatchName(".*");
filter.setExclude(Boolean.valueOf(exclude));
} else if (sel instanceof IColumn) {
// we ignore column since at the moment we dont know which table is there.
return;
} else {
filter = revEngDef.createTableFilter(cc);
filter.setExclude(Boolean.valueOf(exclude));
}
if (filter != null)
revEngDef.addTableFilter(filter);
}
} else {
ITableFilter filter = revEngDef.createTableFilter(cc);
// $NON-NLS-1$
filter.setMatchName(".*");
filter.setExclude(Boolean.valueOf(exclude));
revEngDef.addTableFilter(filter);
}
}
use of org.jboss.tools.hibernate.runtime.spi.ITable in project jbosstools-hibernate by jbosstools.
the class ColumnNameHandler method attributeCompletionProposals.
public ICompletionProposal[] attributeCompletionProposals(IJavaProject javaProject, Node node, String attributeName, String start, int offset) {
List columns = new ArrayList();
HibernateNature nature = HibernateNature.getHibernateNature(javaProject);
if (nature != null) {
String nearestTableName = extractor.getNearestTableName(node);
if (nearestTableName != null) {
ITable table = nature.getTable(nearestTableName);
if (table != null) {
Iterator tableMappings = table.getColumnIterator();
while (tableMappings.hasNext()) {
IColumn column = (IColumn) tableMappings.next();
if (column.getName().toUpperCase().startsWith(start.toUpperCase())) {
columns.add(column);
}
}
}
}
}
List proposals = new ArrayList();
for (Iterator iter = columns.iterator(); iter.hasNext(); ) {
IColumn element = (IColumn) iter.next();
proposals.add(new CompletionProposal(element.getName(), offset, start.length(), element.getName().length(), null, null, null, null));
}
return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
}
Aggregations