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