use of org.openntf.domino.WrapperFactory in project org.openntf.domino by OpenNTF.
the class AbstractSessionFactory method wrapSession.
protected Session wrapSession(final lotus.domino.Session raw, final boolean selfCreated) {
WrapperFactory wf = Factory.getWrapperFactory();
org.openntf.domino.Session sess = wf.fromLotus(raw, Session.SCHEMA, wf);
sess.setNoRecycle(!selfCreated);
Fixes[] fixes = Factory.getThreadConfig().fixes;
if (fixes != null) {
for (Fixes fix : fixes) {
if (fix.isKhan()) {
sess.setFixEnable(fix, true);
}
}
}
sess.setAutoMime(Factory.getThreadConfig().autoMime);
sess.setConvertMIME(false);
if (selfCreated && currentApiPath_ != null) {
Database db = sess.getCurrentDatabase();
if (db == null) {
db = sess.getDatabase(currentApiPath_);
setCurrentDatabase(sess, db);
}
}
return sess;
}
use of org.openntf.domino.WrapperFactory in project org.openntf.domino by OpenNTF.
the class DominoJUnitRunner method beforeTest.
@Override
protected void beforeTest(final FrameworkMethod method) {
try {
String runAs = getRunAs(method);
String db = getDatabase(method);
Factory.initThread(Factory.STRICT_THREAD_CONFIG);
if (runAs == null) {
Factory.setSessionFactory(new NativeSessionFactory(db), SessionType.CURRENT);
Factory.setSessionFactory(new SessionFullAccessFactory(db), SessionType.CURRENT_FULL_ACCESS);
} else {
Factory.setSessionFactory(new NamedSessionFactory(db, runAs), SessionType.CURRENT);
Factory.setSessionFactory(new SessionFullAccessFactory(db, runAs), SessionType.CURRENT_FULL_ACCESS);
}
TestEnv.session = Factory.getSession(SessionType.CURRENT);
TestEnv.database = TestEnv.session.getCurrentDatabase();
if (db != null) {
assertNotNull(TestEnv.database);
}
if (isRunLegacy(method)) {
WrapperFactory wf = Factory.getWrapperFactory();
TestEnv.session = wf.toLotus(TestEnv.session);
TestEnv.database = wf.toLotus(TestEnv.database);
}
} catch (NotesException ne) {
ne.printStackTrace();
fail(ne.toString());
}
}
use of org.openntf.domino.WrapperFactory in project org.openntf.domino by OpenNTF.
the class DominoJUnitRunner method afterTest.
@Override
protected void afterTest(final FrameworkMethod method) {
WrapperFactory wf = Factory.getWrapperFactory();
wf.recycle(TestEnv.database);
wf.recycle(TestEnv.session);
TestEnv.session = null;
TestEnv.database = null;
Factory.termThread();
}
use of org.openntf.domino.WrapperFactory in project org.openntf.domino by OpenNTF.
the class NotesJUnitRunner method afterTest.
@Override
protected void afterTest(final FrameworkMethod method) {
// TODO Auto-generated method stub
WrapperFactory wf = Factory.getWrapperFactory();
wf.recycle(TestEnv.database);
wf.recycle(TestEnv.session);
TestEnv.session = null;
TestEnv.database = null;
}
use of org.openntf.domino.WrapperFactory in project org.openntf.domino by OpenNTF.
the class FormulaContextNotes method evaluateNative.
/**
* does a native evaluate. This is needed for all functions that are too complex to implement in java or the algorithm is unknown
*
* @param formula
* the formula to evaluate
* @param params
* the parameters are mapped to the field p1, p2 and so on
* @return the value
*/
@SuppressWarnings("nls")
public ValueHolder evaluateNative(final String formula, final ValueHolder... params) {
Database db = getDatabase();
if (db == null)
throw new UnsupportedOperationException("No database set: Can't evaluate Lotus native formula");
Session session = db.getAncestorSession();
WrapperFactory wf = session.getFactory();
lotus.domino.Document rawDocument = wf.toLotus(getDocument());
Document tmpDoc = null;
if (params.length > 0) {
tmpDoc = db.createDocument();
rawDocument = session.getFactory().toLotus(tmpDoc);
// fill the document
for (int i = 0; i < params.length; i++) {
try {
// $NON-NLS-1$
tmpDoc.replaceItemValue("p" + (i + 1), params[i].toList());
} catch (EvaluateException e) {
return params[i];
}
}
} else {
rawDocument = wf.toLotus(getDocument());
}
try {
log_.warning("Evaluating native formula: '" + formula + "' This may affect performance");
lotus.domino.Session rawSession = wf.toLotus(session);
Vector<?> v = rawSession.evaluate(formula, rawDocument);
Vector<Object> wrapped = wf.wrapColumnValues(v, session);
rawSession.recycle(v);
return ValueHolder.valueOf(wrapped);
} catch (NotesException e) {
log_.warning("NotesException: " + e.text);
if (e.text.contains("Could not evaluate formula:"))
return ValueHolder.valueOf(new EvaluateException(-1, -1, e));
return ValueHolder.valueOf(new RuntimeException(e));
}
}
Aggregations