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());
}
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);
}
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) {
};
}
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();
}
}
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;
}
Aggregations