use of org.hibernate.tool.api.reveng.RevengStrategy in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method collectDatabaseTables.
@Override
public Map<String, List<ITable>> collectDatabaseTables(Properties properties, IReverseEngineeringStrategy strategy, final IProgressListener progressListener) {
StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(properties).build();
MetadataBuildingOptionsImpl metadataBuildingOptions = new MetadataBuildingOptionsImpl(serviceRegistry);
BootstrapContextImpl bootstrapContext = new BootstrapContextImpl(serviceRegistry, metadataBuildingOptions);
metadataBuildingOptions.setBootstrapContext(bootstrapContext);
InFlightMetadataCollectorImpl metadataCollector = new InFlightMetadataCollectorImpl(bootstrapContext, metadataBuildingOptions);
RevengDialect mdd = RevengDialectFactory.createMetaDataDialect(serviceRegistry.getService(JdbcServices.class).getDialect(), properties);
RevengStrategy revengStrategy = (RevengStrategy) ((IFacade) strategy).getTarget();
DatabaseReader reader = DatabaseReader.create(properties, revengStrategy, mdd, serviceRegistry);
MetadataBuildingContext metadataBuildingContext = new MetadataBuildingContextRootImpl("JBoss Tools", bootstrapContext, metadataBuildingOptions, metadataCollector);
RevengMetadataCollector revengMetadataCollector = new RevengMetadataCollector(metadataBuildingContext);
reader.readDatabaseSchema(revengMetadataCollector);
Map<String, List<ITable>> result = new HashMap<String, List<ITable>>();
for (Table table : revengMetadataCollector.getTables()) {
String qualifier = "";
if (table.getCatalog() != null) {
qualifier += table.getCatalog();
}
if (table.getSchema() != null) {
if (!"".equals(qualifier)) {
qualifier += ".";
}
qualifier += table.getSchema();
}
List<ITable> list = result.get(qualifier);
if (list == null) {
list = new ArrayList<ITable>();
result.put(qualifier, list);
}
list.add(facadeFactory.createTable(table));
}
return result;
}
use of org.hibernate.tool.api.reveng.RevengStrategy in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateReverseEngineeringStrategy.
@Test
public void testCreateReverseEngineeringStrategy() {
RevengStrategy res = (RevengStrategy) Proxy.newProxyInstance(facadeFactory.getClassLoader(), new Class[] { RevengStrategy.class }, new TestInvocationHandler());
IReverseEngineeringStrategy facade = facadeFactory.createReverseEngineeringStrategy(res);
assertTrue(facade instanceof ReverseEngineeringStrategyFacadeImpl);
assertSame(res, ((IFacade) facade).getTarget());
}
use of org.hibernate.tool.api.reveng.RevengStrategy in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testSetReverseEngineeringStrategy.
@Test
public void testSetReverseEngineeringStrategy() {
JdbcMetadataConfiguration configuration = new JdbcMetadataConfiguration();
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
RevengStrategy reverseEngineeringStrategy = new DefaultStrategy();
IReverseEngineeringStrategy strategyFacade = FACADE_FACTORY.createReverseEngineeringStrategy(reverseEngineeringStrategy);
assertNotSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
configurationFacade.setReverseEngineeringStrategy(strategyFacade);
assertSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
}
use of org.hibernate.tool.api.reveng.RevengStrategy in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeImpl method setReverseEngineeringStrategy.
@Override
public void setReverseEngineeringStrategy(IReverseEngineeringStrategy res) {
if (getTarget() instanceof JdbcMetadataConfiguration) {
RevengStrategy revengStrategy = (RevengStrategy) ((IFacade) res).getTarget();
((JdbcMetadataConfiguration) getTarget()).setReverseEngineeringStrategy(revengStrategy);
}
}
Aggregations