Search in sources :

Example 6 with Journaled

use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.

the class TreeModel method valueForPathChanged.

@Override
public void valueForPathChanged(TreePath path, Object newValue) {
    Object o = path.getLastPathComponent();
    Row row = (Row) o;
    ((Journaled) row.getEngine()).startUserTransaction();
    row.setName(String.valueOf(newValue));
    ((Journaled) row.getEngine()).commitUserTransaction();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Row(com.ramussoft.database.common.Row)

Example 7 with Journaled

use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.

the class TableEditorModel method removeElements.

public void removeElements(List<Element> list) {
    ((Journaled) engine).startUserTransaction();
    for (Element element : list) {
        engine.deleteElement(element.getId());
    }
    ((Journaled) engine).commitUserTransaction();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Element(com.ramussoft.common.Element)

Example 8 with Journaled

use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.

the class XMLReportEditorView method save.

public void save() {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    try {
        disableUpdates = true;
        editorView.saveReportToStream(stream);
        ((Journaled) framework.getEngine()).startUserTransaction();
        framework.getEngine().setUndoableStream(getXMLReportPath(), stream.toByteArray());
        ((Journaled) framework.getEngine()).commitUserTransaction();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(framework.getMainFrame(), e.getLocalizedMessage());
        e.printStackTrace();
    } finally {
        disableUpdates = false;
    }
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 9 with Journaled

use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.

the class Application method patchData.

/*
     * Create all needed system qualifiers and attributes.
	 */
private void patchData(Engine engine) {
    Journaled journal = (Journaled) engine;
    journal.startUserTransaction();
    Attribute textAttribute1 = createAttribute(TEXT_ATTRIBUTE1, new AttributeType("Core", "Text"), engine);
    Attribute textAttribute2 = createAttribute(TEXT_ATTRIBUTE2, new AttributeType("Core", "Text"), engine);
    Attribute doubleAttribute1 = createAttribute(DOUBLE_ATTRIBUTE1, new AttributeType("Core", "Double"), engine);
    Qualifier qualifier1 = engine.getSystemQualifier(QUALIFIER1);
    if (qualifier1 == null) {
        qualifier1 = engine.createSystemQualifier();
        qualifier1.getAttributes().add(textAttribute1);
        qualifier1.getAttributes().add(textAttribute2);
        qualifier1.getAttributes().add(doubleAttribute1);
        qualifier1.setName(QUALIFIER1);
        engine.updateQualifier(qualifier1);
    }
    journal.commitUserTransaction();
    // User will not be able to undo these changes.
    journal.setNoUndoPoint();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Attribute(com.ramussoft.common.Attribute) AttributeType(com.ramussoft.common.AttributeType) Qualifier(com.ramussoft.common.Qualifier)

Example 10 with Journaled

use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.

the class LightClient method getEngine.

@Override
protected Engine getEngine(PluginFactory factory, PersistentFactory persistentFactory) {
    try {
        Journal journal = new Journal(null, -1l);
        journal.setEnable(false);
        final JournaledEngine journaledEngine = new JournaledEngine(factory, impl, persistentFactory.getRows(), new DirectoryJournalFactory(null), accessor);
        Engine engine = (Engine) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { Engine.class, Journaled.class }, new InvocationHandler() {

            private Journaled journaled = new Journaled() {

                boolean started = false;

                @Override
                public void undoUserTransaction() {
                }

                @Override
                public void startUserTransaction() {
                    started = true;
                }

                @Override
                public void setNoUndoPoint() {
                }

                @Override
                public void setEnable(boolean b) {
                }

                @Override
                public void rollbackUserTransaction() {
                    started = false;
                }

                @Override
                public void removeJournalListener(JournalListener listener) {
                }

                @Override
                public void redoUserTransaction() {
                }

                @Override
                public boolean isUserTransactionStarted() {
                    return started;
                }

                @Override
                public boolean isEnable() {
                    return false;
                }

                @Override
                public JournalListener[] getJournalListeners() {
                    return new JournalListener[] {};
                }

                @Override
                public void commitUserTransaction() {
                    started = false;
                }

                @Override
                public void close() {
                }

                @Override
                public boolean canUndo() {
                    return false;
                }

                @Override
                public boolean canRedo() {
                    return false;
                }

                @Override
                public void addJournalListener(JournalListener listener) {
                }

                @Override
                public long getBranch() {
                    return -1l;
                }
            };

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                if (method.getDeclaringClass().equals(Journaled.class))
                    return method.invoke(journaled, args);
                return method.invoke(journaledEngine, args);
            }
        });
        return engine;
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : DirectoryJournalFactory(com.ramussoft.common.journal.DirectoryJournalFactory) JournalListener(com.ramussoft.common.journal.event.JournalListener) Journal(com.ramussoft.common.journal.Journal) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) Journaled(com.ramussoft.common.journal.Journaled) JournaledEngine(com.ramussoft.common.journal.JournaledEngine) Engine(com.ramussoft.common.Engine) IEngine(com.ramussoft.common.IEngine) JournaledEngine(com.ramussoft.common.journal.JournaledEngine)

Aggregations

Journaled (com.ramussoft.common.journal.Journaled)34 Engine (com.ramussoft.common.Engine)9 Attribute (com.ramussoft.common.Attribute)7 Element (com.ramussoft.common.Element)7 Qualifier (com.ramussoft.common.Qualifier)7 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 Row (com.ramussoft.database.common.Row)5 DataPlugin (com.ramussoft.pb.DataPlugin)5 FileIEngineImpl (com.ramussoft.core.impl.FileIEngineImpl)4 NDataPlugin (com.ramussoft.pb.data.negine.NDataPlugin)4 AttributeType (com.ramussoft.common.AttributeType)3 MemoryDatabase (com.ramussoft.database.MemoryDatabase)3 TreeTableNode (com.ramussoft.gui.qualifier.table.TreeTableNode)3 ModelParaleler (com.ramussoft.idef0.ModelParaleler)3 Function (com.ramussoft.pb.Function)3 Row (com.ramussoft.pb.Row)3 TreePath (javax.swing.tree.TreePath)3 AccessRules (com.ramussoft.common.AccessRules)2 IEngine (com.ramussoft.common.IEngine)2