Search in sources :

Example 11 with IArtifactCollector

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

the class FacadeFactoryTest method testCreateArtifactCollector.

@Test
public void testCreateArtifactCollector() {
    ArtifactCollector artifactCollector = new ArtifactCollector();
    IArtifactCollector facade = facadeFactory.createArtifactCollector(artifactCollector);
    Assert.assertSame(artifactCollector, ((IFacade) facade).getTarget());
}
Also used : IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) Test(org.junit.Test)

Example 12 with IArtifactCollector

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

the class ServiceImplTest method testNewArtifactCollector.

@Test
public void testNewArtifactCollector() {
    IArtifactCollector artifactCollector = service.newArtifactCollector();
    Assert.assertNotNull(artifactCollector);
    Object target = ((IFacade) artifactCollector).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof ArtifactCollector);
}
Also used : IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Example 13 with IArtifactCollector

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

the class ServiceImplTest method testNewArtifactCollector.

@Test
public void testNewArtifactCollector() {
    IArtifactCollector artifactCollector = service.newArtifactCollector();
    Assert.assertNotNull(artifactCollector);
    Object target = ((IFacade) artifactCollector).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof ArtifactCollector);
}
Also used : IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Example 14 with IArtifactCollector

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

the class ExporterFacadeTest method testSetArtifactCollector.

@Test
public void testSetArtifactCollector() {
    ArtifactCollector ac = new ArtifactCollector();
    IArtifactCollector artifactCollector = new AbstractArtifactCollectorFacade(FACADE_FACTORY, ac) {
    };
    exporterFacade.setArtifactCollector(artifactCollector);
    Assert.assertEquals("setArtifactCollector", methodName);
    Assert.assertArrayEquals(new Object[] { ac }, arguments);
}
Also used : AbstractArtifactCollectorFacade(org.jboss.tools.hibernate.runtime.common.AbstractArtifactCollectorFacade) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) Test(org.junit.Test)

Example 15 with IArtifactCollector

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

the class CodeGenerationLaunchDelegate method runExporters.

private IArtifactCollector runExporters(final ExporterAttributes attributes, final ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final IProgressMonitor monitor) throws CoreException {
    monitor.beginTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_generating_code_for + attributes.getConsoleConfigurationName(), exporterFactories.length + 1);
    if (monitor.isCanceled())
        return null;
    ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
    if (attributes.isReverseEngineer()) {
        monitor.subTask(HibernateConsoleMessages.CodeGenerationLaunchDelegate_reading_jdbc_metadata);
    }
    final IConfiguration cfg = buildConfiguration(attributes, cc, ResourcesPlugin.getWorkspace().getRoot());
    monitor.worked(1);
    if (monitor.isCanceled())
        return null;
    final IService service = cc.getHibernateExtension().getHibernateService();
    return (IArtifactCollector) cc.execute(new Command() {

        public Object execute() {
            IArtifactCollector artifactCollector = service.newArtifactCollector();
            // Global properties
            Properties props = new Properties();
            // $NON-NLS-1$
            props.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled());
            // $NON-NLS-1$
            props.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled());
            for (int i = 0; i < exporterFactories.length; i++) {
                monitor.subTask(exporterFactories[i].getExporterDefinition().getDescription());
                Properties globalProperties = new Properties();
                globalProperties.putAll(props);
                IExporter exporter;
                try {
                    exporter = exporterFactories[i].createConfiguredExporter(cfg, attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties, outputDirectories, artifactCollector, service);
                } catch (CoreException e) {
                    throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_setting_up + exporterFactories[i].getExporterDefinition(), e);
                }
                try {
                    exporter.start();
                } catch (HibernateException he) {
                    throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.CodeGenerationLaunchDelegate_error_while_running + exporterFactories[i].getExporterDefinition().getDescription(), he);
                }
                monitor.worked(1);
            }
            return artifactCollector;
        }
    });
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) CoreException(org.eclipse.core.runtime.CoreException) Command(org.hibernate.console.execution.ExecutionContext.Command) HibernateException(org.jboss.tools.hibernate.runtime.spi.HibernateException) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Properties(java.util.Properties) IService(org.jboss.tools.hibernate.runtime.spi.IService)

Aggregations

IArtifactCollector (org.jboss.tools.hibernate.runtime.spi.IArtifactCollector)27 ArtifactCollector (org.hibernate.tool.hbm2x.ArtifactCollector)20 Test (org.junit.Test)20 AbstractArtifactCollectorFacade (org.jboss.tools.hibernate.runtime.common.AbstractArtifactCollectorFacade)8 CoreException (org.eclipse.core.runtime.CoreException)7 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)6 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)5 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)4 File (java.io.File)3 Properties (java.util.Properties)3 IFile (org.eclipse.core.resources.IFile)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 JavaModelException (org.eclipse.jdt.core.JavaModelException)3 HibernateConsoleRuntimeException (org.hibernate.console.HibernateConsoleRuntimeException)3 HibernateException (org.jboss.tools.hibernate.runtime.spi.HibernateException)3 IExporter (org.jboss.tools.hibernate.runtime.spi.IExporter)3 IHibernateMappingExporter (org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter)3 IService (org.jboss.tools.hibernate.runtime.spi.IService)3 FileNotFoundException (java.io.FileNotFoundException)2 HashSet (java.util.HashSet)2