Search in sources :

Example 6 with IReverseEngineeringSettings

use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings in project jbosstools-hibernate by jbosstools.

the class CodeGenerationLaunchDelegate 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 JDBCMetaDataConfiguration cfg = new JDBCMetaDataConfiguration();
        final IService service = cc.getHibernateExtension().getHibernateService();
        final IConfiguration cfg = service.newJDBCMetaDataConfiguration();
        Properties properties = configuration.getProperties();
        cfg.setProperties(properties);
        cc.buildWith(cfg, false);
        cfg.setPreferBasicCompositeIds(preferBasicCompositeids);
        cc.execute(new // need to execute in the consoleconfiguration to let it handle classpath stuff!
        Command() {

            public Object execute() {
                // todo: factor this setup of revengstrategy to core
                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();
    }
}
Also used : IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) IReverseEngineeringStrategy(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Properties(java.util.Properties) IOverrideRepository(org.jboss.tools.hibernate.runtime.spi.IOverrideRepository) File(java.io.File) IResource(org.eclipse.core.resources.IResource) IService(org.jboss.tools.hibernate.runtime.spi.IService)

Example 7 with IReverseEngineeringSettings

use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateReverseEngineeringSettings.

@Test
public void testCreateReverseEngineeringSettings() {
    ReverseEngineeringSettings res = new ReverseEngineeringSettings(null);
    IReverseEngineeringSettings facade = facadeFactory.createReverseEngineeringSettings(res);
    Assert.assertSame(res, ((IFacade) facade).getTarget());
}
Also used : IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) ReverseEngineeringSettings(org.hibernate.cfg.reveng.ReverseEngineeringSettings) IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) Test(org.junit.Test)

Example 8 with IReverseEngineeringSettings

use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateReverseEngineeringSettings.

@Test
public void testCreateReverseEngineeringSettings() {
    ReverseEngineeringSettings res = new ReverseEngineeringSettings(null);
    IReverseEngineeringSettings facade = facadeFactory.createReverseEngineeringSettings(res);
    Assert.assertSame(res, ((IFacade) facade).getTarget());
}
Also used : IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) ReverseEngineeringSettings(org.hibernate.cfg.reveng.ReverseEngineeringSettings) IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) Test(org.junit.Test)

Example 9 with IReverseEngineeringSettings

use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateReverseEngineeringSettings.

@Test
public void testCreateReverseEngineeringSettings() {
    ReverseEngineeringSettings res = new ReverseEngineeringSettings(null);
    IReverseEngineeringSettings facade = facadeFactory.createReverseEngineeringSettings(res);
    Assert.assertSame(res, ((IFacade) facade).getTarget());
}
Also used : IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) ReverseEngineeringSettings(org.hibernate.cfg.reveng.ReverseEngineeringSettings) IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) Test(org.junit.Test)

Example 10 with IReverseEngineeringSettings

use of org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateReverseEngineeringSettings.

@Test
public void testCreateReverseEngineeringSettings() {
    ReverseEngineeringSettings res = new ReverseEngineeringSettings(null);
    IReverseEngineeringSettings facade = facadeFactory.createReverseEngineeringSettings(res);
    Assert.assertSame(res, ((IFacade) facade).getTarget());
}
Also used : IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) ReverseEngineeringSettings(org.hibernate.cfg.reveng.ReverseEngineeringSettings) IReverseEngineeringSettings(org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings) Test(org.junit.Test)

Aggregations

IReverseEngineeringSettings (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringSettings)14 ReverseEngineeringSettings (org.hibernate.cfg.reveng.ReverseEngineeringSettings)12 Test (org.junit.Test)12 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)6 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)4 File (java.io.File)2 Properties (java.util.Properties)2 IResource (org.eclipse.core.resources.IResource)2 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)2 IOverrideRepository (org.jboss.tools.hibernate.runtime.spi.IOverrideRepository)2 IService (org.jboss.tools.hibernate.runtime.spi.IService)2