use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy in project jbosstools-hibernate by jbosstools.
the class ConsoleExtension method buildConfiguration.
private IConfiguration buildConfiguration(final ExporterAttributes attributes, ConsoleConfiguration cc, IWorkspaceRoot root) {
final boolean reveng = attributes.isReverseEngineer();
final String reverseEngineeringStrategy = attributes.getRevengStrategy();
final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds();
final IResource revengres = PathHelper.findMember(root, attributes.getRevengSettings());
if (reveng) {
IConfiguration configuration = null;
if (cc.hasConfiguration()) {
configuration = cc.getConfiguration();
} else {
configuration = cc.buildWith(null, false);
}
final IConfiguration cfg = hibernateExtension.getHibernateService().newJDBCMetaDataConfiguration();
// final JDBCMetaDataConfiguration cfg = new
// JDBCMetaDataConfiguration();
Properties properties = configuration.getProperties();
cfg.setProperties(properties);
cc.buildWith(cfg, false);
cfg.setPreferBasicCompositeIds(preferBasicCompositeids);
cc.execute(new // need to execute in the
Command() {
// consoleconfiguration to let it handle
// classpath stuff!
public Object execute() {
// todo: factor this setup of revengstrategy to core
IService service = hibernateExtension.getHibernateService();
IReverseEngineeringStrategy res = service.newDefaultReverseEngineeringStrategy();
IOverrideRepository repository = null;
if (revengres != null) {
File file = PathHelper.getLocation(revengres).toFile();
repository = service.newOverrideRepository();
repository.addFile(file);
}
if (repository != null) {
res = repository.getReverseEngineeringStrategy(res);
}
if (reverseEngineeringStrategy != null && reverseEngineeringStrategy.trim().length() > 0) {
res = service.newReverseEngineeringStrategy(reverseEngineeringStrategy, res);
}
IReverseEngineeringSettings qqsettings = service.newReverseEngineeringSettings(res).setDefaultPackageName(attributes.getPackageName()).setDetectManyToMany(attributes.detectManyToMany()).setDetectOneToOne(attributes.detectOneToOne()).setDetectOptimisticLock(attributes.detectOptimisticLock());
res.setSettings(qqsettings);
cfg.setReverseEngineeringStrategy(res);
cfg.readFromJDBC();
cfg.buildMappings();
return null;
}
});
return cfg;
} else {
cc.build();
cc.buildMappings();
return cc.getConfiguration();
}
}
use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
@Override
public IReverseEngineeringStrategy newReverseEngineeringStrategy(String strategyName, IReverseEngineeringStrategy delegate) {
assert delegate instanceof IFacade;
ReverseEngineeringStrategy delegateTarget = (ReverseEngineeringStrategy) ((IFacade) delegate).getTarget();
Object target = newReverseEngineeringStrategy(strategyName, delegateTarget);
return facadeFactory.createReverseEngineeringStrategy(target);
}
use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
@Override
public IReverseEngineeringStrategy newReverseEngineeringStrategy(String strategyName, IReverseEngineeringStrategy delegate) {
assert delegate instanceof IFacade;
ReverseEngineeringStrategy delegateTarget = (ReverseEngineeringStrategy) ((IFacade) delegate).getTarget();
Object target = newReverseEngineeringStrategy(strategyName, delegateTarget);
return facadeFactory.createReverseEngineeringStrategy(target);
}
use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method newReverseEngineeringStrategy.
@Override
public IReverseEngineeringStrategy newReverseEngineeringStrategy(String strategyName, IReverseEngineeringStrategy delegate) {
assert delegate instanceof IFacade;
ReverseEngineeringStrategy delegateTarget = (ReverseEngineeringStrategy) ((IFacade) delegate).getTarget();
Object target = newReverseEngineeringStrategy(strategyName, delegateTarget);
return facadeFactory.createReverseEngineeringStrategy(target);
}
use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy in project jbosstools-hibernate by jbosstools.
the class OverrideRepositoryFacadeTest method testGetReverseEngineeringStrategy.
@Test
public void testGetReverseEngineeringStrategy() throws Exception {
ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy();
IReverseEngineeringStrategy resFacade = FACADE_FACTORY.createReverseEngineeringStrategy(res);
IReverseEngineeringStrategy result = overrideRepositoryFacade.getReverseEngineeringStrategy(resFacade);
DelegatingReverseEngineeringStrategy resultTarget = (DelegatingReverseEngineeringStrategy) ((IFacade) result).getTarget();
Field delegateField = DelegatingReverseEngineeringStrategy.class.getDeclaredField("delegate");
delegateField.setAccessible(true);
Assert.assertSame(res, delegateField.get(resultTarget));
}
Aggregations