Search in sources :

Example 11 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl 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();
    }
}
Also used : FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) ArrayList(java.util.ArrayList) IEngine(com.ramussoft.common.IEngine) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) PluginProvider(com.ramussoft.common.PluginProvider) IOException(java.io.IOException) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) MemoryDatabase(com.ramussoft.database.MemoryDatabase) File(java.io.File) Engine(com.ramussoft.common.Engine) IEngine(com.ramussoft.common.IEngine)

Example 12 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl 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)

Example 13 with FileIEngineImpl

use of com.ramussoft.core.impl.FileIEngineImpl 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;
    }
}
Also used : FileIEngineImpl(com.ramussoft.core.impl.FileIEngineImpl) IEngine(com.ramussoft.common.IEngine)

Aggregations

FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)13 IOException (java.io.IOException)11 MemoryDatabase (com.ramussoft.database.MemoryDatabase)7 Engine (com.ramussoft.common.Engine)5 ArrayList (java.util.ArrayList)5 Journaled (com.ramussoft.common.journal.Journaled)4 ZipException (java.util.zip.ZipException)4 IEngine (com.ramussoft.common.IEngine)3 PluginFactory (com.ramussoft.common.PluginFactory)3 PluginProvider (com.ramussoft.common.PluginProvider)3 ModelParaleler (com.ramussoft.idef0.ModelParaleler)3 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)3 File (java.io.File)3 AccessRules (com.ramussoft.common.AccessRules)2 FileMinimumVersionException (com.ramussoft.core.impl.FileMinimumVersionException)2 AbstractGUIPluginFactory (com.ramussoft.gui.common.AbstractGUIPluginFactory)2 IDEF0PluginProvider (com.ramussoft.idef0.IDEF0PluginProvider)2 DataPlugin (com.ramussoft.pb.DataPlugin)2 LoadFromParalelDialog (com.ramussoft.pb.idef.frames.LoadFromParalelDialog)2 SQLException (java.sql.SQLException)2