Search in sources :

Example 81 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewSpecialRootClass.

@Test
public void testNewSpecialRootClass() {
    IProperty property = service.newProperty();
    IPersistentClass pc = service.newRootClass();
    property.setPersistentClass(pc);
    IPersistentClass specialRootClass = service.newSpecialRootClass(property);
    Assert.assertNotNull(specialRootClass);
    Object target = ((IFacade) specialRootClass).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof RootClass);
    Assert.assertSame(property, specialRootClass.getProperty());
}
Also used : RootClass(org.hibernate.mapping.RootClass) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.Test)

Example 82 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewAnnotationConfiguration.

@Test
public void testNewAnnotationConfiguration() {
    IConfiguration configuration = service.newAnnotationConfiguration();
    Assert.assertNotNull(configuration);
    Object target = ((IFacade) configuration).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof Configuration);
}
Also used : JdbcMetadataConfiguration(org.jboss.tools.hibernate.runtime.v_5_3.internal.util.JdbcMetadataConfiguration) Configuration(org.hibernate.cfg.Configuration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Example 83 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class AbstractFacadeFactory method createFullTextSession.

@Override
public IFullTextSession createFullTextSession(ISessionFactory sessionFactory) {
    ISession session = sessionFactory.openSession();
    Object targetSession = ((IFacade) session).getTarget();
    Object targetFullTextSession = Util.invokeMethod(getSearchClass(), "getFullTextSession", new Class[] { getSessionClass() }, new Object[] { targetSession });
    return new AbstractFullTextSessionFacade(this, targetFullTextSession) {
    };
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade)

Example 84 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class AbstractHSearchService method doAnalyze.

// @Override
// public String doAnalyze(String text, String analyzerClassName) {
// Analyzer analyzer = (Analyzer)((IFacade)getAnalyzerByName(analyzerClassName)).getTarget();
// if (analyzer == null) {
// return "";
// }
// 
// try {
// TokenStream stream = analyzer.tokenStream("field", new StringReader(text));
// CharTermAttribute termAtt = stream.addAttribute(CharTermAttribute.class);
// stream.reset();
// StringBuilder result = new StringBuilder();
// while (stream.incrementToken()) {
// result.append(termAtt.toString() + "\n");
// }
// 
// stream.end();
// stream.close();
// return result.toString();
// } catch (IOException e) {
// e.printStackTrace();
// return "";
// }
// }
@Override
public String doAnalyze(String text, String analyzerClassName) {
    try {
        Object analyzer = ((IFacade) getAnalyzerByName(analyzerClassName)).getTarget();
        if (analyzer == null) {
            return "";
        }
        Object tokenStream = Util.invokeMethod(analyzer, "tokenStream", new Class[] { Class.forName("java.lang.String"), Class.forName("java.io.Reader") }, new Object[] { "field", new StringReader(text) });
        Object termAtt = Util.invokeMethod(tokenStream, "addAttribute", new Class[] { Class.class }, new Object[] { Class.forName("org.apache.lucene.analysis.tokenattributes.CharTermAttribute", true, getFacadeFactory().getClassLoader()) });
        Util.invokeMethod(tokenStream, "reset", new Class[] {}, new Object[] {});
        StringBuilder result = new StringBuilder();
        while ((Boolean) Util.invokeMethod(tokenStream, "incrementToken", new Class[] {}, new Object[] {})) {
            result.append(termAtt.toString() + " ");
        }
        Util.invokeMethod(tokenStream, "end", new Class[] {}, new Object[] {});
        Util.invokeMethod(tokenStream, "close", new Class[] {}, new Object[] {});
        return result.toString();
    } catch (Exception e) {
        e.printStackTrace();
        return "Exception happened while analyzing " + e.getMessage();
    }
}
Also used : StringReader(java.io.StringReader) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade)

Example 85 with IFacade

use of org.jboss.tools.hibernate.runtime.common.IFacade in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method newSchemaExport.

@Override
public ISchemaExport newSchemaExport(IConfiguration hcfg) {
    ISchemaExport result = null;
    if (hcfg instanceof IFacade) {
        SchemaExport schemaExport = new SchemaExport((Configuration) ((IFacade) hcfg).getTarget());
        result = facadeFactory.createSchemaExport(schemaExport);
    }
    return result;
}
Also used : ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) ISchemaExport(org.jboss.tools.hibernate.runtime.spi.ISchemaExport) SchemaExport(org.hibernate.tool.hbm2ddl.SchemaExport)

Aggregations

IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)188 Test (org.junit.Test)156 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)60 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)40 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)29 Configuration (org.hibernate.cfg.Configuration)20 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)20 RootClass (org.hibernate.mapping.RootClass)19 Table (org.hibernate.mapping.Table)15 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)13 File (java.io.File)12 PersistentClass (org.hibernate.mapping.PersistentClass)12 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)12 ISessionFactory (org.jboss.tools.hibernate.runtime.spi.ISessionFactory)12 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)11 Field (java.lang.reflect.Field)9 JDBCReader (org.hibernate.cfg.reveng.JDBCReader)9 IJDBCReader (org.jboss.tools.hibernate.runtime.spi.IJDBCReader)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8