use of com.ramussoft.common.IEngine in project ramus by Vitaliy-Yakovchuk.
the class RamusService method close.
public void close() {
if (myThread != null)
server.getLogins().remove(myThread);
Engine engine = userEngineFactory.getJournaledEngine();
if (engine instanceof CachedEngine) {
((CachedEngine) engine).removeBranchCache();
}
IEngine deligate = engine.getDeligate();
if (deligate instanceof IEngineImpl) {
try {
((IEngineImpl) deligate).getTemplate().close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (directoryJournalFactory != null) {
directoryJournalFactory.close();
delete(directoryJournalFactory.getDirectory());
}
}
use of com.ramussoft.common.IEngine in project ramus by Vitaliy-Yakovchuk.
the class EngineFactory method createPluginFactory.
protected PluginFactory createPluginFactory(List<PluginProvider> list) {
ArrayList<Plugin> plugins = new ArrayList<Plugin>();
for (PluginProvider suit : list) {
plugins.addAll(suit.getPlugins());
}
plugins.add(new AbstractPlugin() {
@Override
public String getName() {
return "Log";
}
@Override
public Class getFunctionalInterface() {
return ILog.class;
}
@Override
public Object createFunctionalInterfaceObject(Engine engine, IEngine iEngine) {
return log;
}
});
PluginFactory factory = new PluginFactory(plugins);
return factory;
}
use of com.ramussoft.common.IEngine in project ramus by Vitaliy-Yakovchuk.
the class BaseImporter method main.
/**
* @param args
*/
public static void main(final String[] args) {
if (args.length == 0) {
System.err.println("Enter input file as parameter");
return;
}
MemoryDatabase database = new MemoryDatabase() {
@Override
protected Collection<? extends PluginProvider> getAdditionalSuits() {
ArrayList<PluginProvider> ps = new ArrayList<PluginProvider>(1);
ps.add(new IDEF0PluginProvider());
return ps;
}
@Override
protected File getFile() {
return new File(args[0]);
}
@Override
public Connection createConnection() throws SQLException {
return EngineFactory.createNewConnection();
}
@Override
protected String getJournalDirectoryName(String tmp) {
return null;
}
};
EngineFactory factory = new EngineFactory();
Engine s = database.getEngine(null);
IEngine d = factory.getEngine();
for (String streamName : s.getStreamNames()) {
byte[] bs = s.getStream(streamName);
if (bs == null) {
System.err.println("WARNING: stream " + streamName + " not found in the source");
} else
d.setStream(streamName, bs);
}
try {
((FileIEngineImpl) (database.getEngine(null).getDeligate())).close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.ramussoft.common.IEngine in project ramus by Vitaliy-Yakovchuk.
the class CurrencyPlugin method getAttributeConverter.
@Override
public AttributeConverter getAttributeConverter() {
return new SimpleAttributeConverter() {
@SuppressWarnings("unchecked")
@Override
public List<Persistent>[] toPersistens(Object object, long elementId, long attributeId, IEngine engine) {
if (elementId < 0) {
if (object == null)
return new List[] { new ArrayList(0) };
else {
List list = new ArrayList(1);
list.add(object);
return new List[] { list };
}
}
return super.toPersistens(object, elementId, attributeId, engine);
}
public Object toObject(java.util.List<Persistent>[] persistents, long elementId, long attributeId, IEngine engine) {
if (elementId < 0) {
List<Persistent> list = persistents[0];
if (list.size() == 0)
return null;
else
return list.get(0);
}
return super.toObject(persistents, elementId, attributeId, engine);
}
@Override
protected Persistent toPersistent(Object value) {
CurrencyPersistent cp = new CurrencyPersistent();
cp.setValue(((Number) value).doubleValue());
return cp;
}
@Override
protected Object toObject(Persistent persistent) {
return ((CurrencyPersistent) persistent).getValue();
}
};
}
use of com.ramussoft.common.IEngine in project ramus by Vitaliy-Yakovchuk.
the class AbstractTemplate method close.
@Override
public void close() {
if (dataPlugin != null) {
IEngine i = dataPlugin.getEngine().getDeligate();
((FileIEngineImpl) i).setClearSessionPath(false);
try {
((FileIEngineImpl) i).close();
((FileIEngineImpl) i).getConnection().close();
} catch (Exception e) {
e.printStackTrace();
}
dataPlugin = null;
}
}
Aggregations