Search in sources :

Example 11 with MemoryDatabase

use of com.ramussoft.database.MemoryDatabase in project ramus by Vitaliy-Yakovchuk.

the class InternetServer method loadAllData.

public byte[] loadAllData() {
    synchronized (saveLock) {
        MemoryDatabase database = new MemoryDatabase() {

            @Override
            protected void loadSuits(List<PluginProvider> suits) {
                suits.addAll(engineFactory.getSuits());
            }

            @Override
            protected File getFile() {
                return null;
            }

            @Override
            public Connection createConnection() throws SQLException {
                return engineFactory.createConnection();
            }

            @Override
            protected String getJournalDirectoryName(String tmp) {
                return null;
            }

            @Override
            protected FileIEngineImpl createFileIEngine(PluginFactory factory) throws ClassNotFoundException, ZipException, IOException {
                return new FileIEngineImpl(0, template, factory, null);
            }
        };
        Engine s = database.getEngine(null);
        FileIEngineImpl impl = (FileIEngineImpl) s.getDeligate();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        ZipOutputStream out;
        try {
            out = impl.writeToStream(stream);
            out.close();
            return stream.toByteArray();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ZipOutputStream(java.util.zip.ZipOutputStream) MemoryDatabase(com.ramussoft.database.MemoryDatabase) ArrayList(java.util.ArrayList) List(java.util.List) PluginFactory(com.ramussoft.common.PluginFactory) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Engine(com.ramussoft.common.Engine)

Aggregations

MemoryDatabase (com.ramussoft.database.MemoryDatabase)11 IOException (java.io.IOException)8 Engine (com.ramussoft.common.Engine)7 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)7 ArrayList (java.util.ArrayList)6 PluginProvider (com.ramussoft.common.PluginProvider)5 AccessRules (com.ramussoft.common.AccessRules)4 PluginFactory (com.ramussoft.common.PluginFactory)4 Journaled (com.ramussoft.common.journal.Journaled)3 ModelParaleler (com.ramussoft.idef0.ModelParaleler)3 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)3 File (java.io.File)3 IEngine (com.ramussoft.common.IEngine)2 IDEF0PluginProvider (com.ramussoft.idef0.IDEF0PluginProvider)2 DataPlugin (com.ramussoft.pb.DataPlugin)2 LoadFromParalelDialog (com.ramussoft.pb.idef.frames.LoadFromParalelDialog)2 ZipException (java.util.zip.ZipException)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 Qualifier (com.ramussoft.common.Qualifier)1 DirectoryJournalFactory (com.ramussoft.common.journal.DirectoryJournalFactory)1