Search in sources :

Example 1 with Event

use of com.ramussoft.common.logger.Event in project ramus by Vitaliy-Yakovchuk.

the class ElementEventTableModel method getValueAt.

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    Event event = getEvent(rowIndex);
    switch(columnIndex) {
        case 0:
            return getType(event);
        case 1:
            Long id = (Long) event.getAttribute("attribute_id");
            if (id == null)
                return null;
            Engine engine = getEngine();
            Attribute attribute = engine.getAttribute(id);
            if (attribute == null)
                return null;
            return attribute.getName();
        case 2:
            return event.getOldValue();
        case 3:
            return event.getNewValue();
        case 4:
            return event.eventTime;
        case 5:
            return getUser(event);
        default:
            break;
    }
    return null;
}
Also used : Attribute(com.ramussoft.common.Attribute) Event(com.ramussoft.common.logger.Event) Engine(com.ramussoft.common.Engine)

Example 2 with Event

use of com.ramussoft.common.logger.Event in project ramus by Vitaliy-Yakovchuk.

the class LogPlugin method getActions.

@Override
public Action[] getActions(final TableTabView tableView) {
    return new Action[] { new AbstractAction("EventType.qualifierLog", new ImageIcon(getClass().getResource("/com/ramussoft/client/log/log.png"))) {

        /**
         */
        private static final long serialVersionUID = 8698485078278772063L;

        {
            putValue(LONG_DESCRIPTION, getString("EventType.qualifierLog"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            GUIFramework framework = tableView.getFramework();
            long qId = tableView.getQualifier().getId();
            List<Event> events = ((ILog) framework.getEngine()).getEventsWithParams(new String[] { EngineLogExtension.QUALIFIER_ID }, new Object[] { qId }, 150);
            ElementLogDialog dialog = new ElementLogDialog(events, framework.getEngine());
            dialog.setSize(800, 600);
            dialog.setLocationRelativeTo(null);
            dialog.setTitle(getString("EventType.qualifierLog"));
            Options.loadOptions(dialog);
            dialog.setVisible(true);
            Options.saveOptions(dialog);
        }
    } };
}
Also used : ImageIcon(javax.swing.ImageIcon) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) GUIFramework(com.ramussoft.gui.common.GUIFramework) Event(com.ramussoft.common.logger.Event) ActionEvent(java.awt.event.ActionEvent) ILog(com.ramussoft.common.logger.ILog) AbstractAction(javax.swing.AbstractAction)

Example 3 with Event

use of com.ramussoft.common.logger.Event in project ramus by Vitaliy-Yakovchuk.

the class LogPlugin method modify.

@Override
public Action[] modify(Action[] actions, final TableEditor tableEditor) {
    actions = Arrays.copyOf(actions, actions.length + 1);
    actions[actions.length - 1] = new AbstractAction("Log", new ImageIcon(getClass().getResource("/com/ramussoft/client/log/log.png"))) {

        /**
         */
        private static final long serialVersionUID = 8698485078278772063L;

        {
            putValue(LONG_DESCRIPTION, getString("EventType.qualifierLog"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            GUIFramework framework = tableEditor.getFramework();
            Engine engine = framework.getEngine();
            long qId = StandardAttributesPlugin.getTableQualifierForAttribute(engine, tableEditor.getAttribute()).getId();
            List<Event> events = ((ILog) engine).getEventsWithParams(new String[] { EngineLogExtension.QUALIFIER_ID }, new Object[] { qId }, 750);
            List<Event> events2 = new ArrayList<Event>();
            Attribute attribute = StandardAttributesPlugin.getTableElementIdAttribute(engine);
            Element el = tableEditor.getElement();
            for (Event event : events) {
                Long elementId = (Long) event.getAttribute("element_id");
                if (elementId != null) {
                    Element element = engine.getElement(elementId);
                    if (element != null) {
                        Long l = (Long) engine.getAttribute(element, attribute);
                        if (l != null && l.equals(el.getId()))
                            events2.add(event);
                    }
                }
            }
            ElementLogDialog dialog = new ElementLogDialog(events2, engine);
            dialog.setSize(800, 600);
            dialog.setLocationRelativeTo(null);
            dialog.setTitle(getString("EventType.qualifierLog"));
            Options.loadOptions(dialog);
            dialog.setVisible(true);
            Options.saveOptions(dialog);
        }
    };
    return actions;
}
Also used : ImageIcon(javax.swing.ImageIcon) Attribute(com.ramussoft.common.Attribute) ActionEvent(java.awt.event.ActionEvent) GUIFramework(com.ramussoft.gui.common.GUIFramework) Element(com.ramussoft.common.Element) Event(com.ramussoft.common.logger.Event) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) List(java.util.List) AbstractAction(javax.swing.AbstractAction) Engine(com.ramussoft.common.Engine)

Example 4 with Event

use of com.ramussoft.common.logger.Event in project ramus by Vitaliy-Yakovchuk.

the class EngineFactory method createJournaledEngine.

public Engine createJournaledEngine(DirectoryJournalFactory journalFactory) {
    try {
        JDBCTemplate template = new JDBCTemplate(createNewConnectionA());
        suits = new ArrayList<PluginProvider>();
        suits.add(new SimpleAttributePluginSuit());
        suits.add(new IDEF0PluginProvider());
        Properties ps = getPropeties();
        if (ps != null) {
            String suitNames = ps.getProperty("AdditionalSuits");
            if (suitNames != null)
                PluginFactory.loadAdditionalSuits(suitNames, suits);
            canUndoRedo = !"false".equals(ps.getProperty("CanUndoRedo"));
        }
        suits.addAll(getAdditionalSuits());
        createUniversalPersistentFactory(template, (ps == null) ? null : ps.getProperty("PersistentPluginsProvider"));
        factory = createPluginFactory(suits);
        String prefix = "ramus_";
        impl = new ServerIEngineImpl(0, template, prefix, factory);
        accessor = impl.getAccessor();
        persistentFactory = new PersistentFactory(prefix, factory.getAttributePlugins(), template);
        persistentFactory.rebuild();
        checkIfGroupsExists();
        Engine result;
        Journaled journaled;
        if (cachedData == null) {
            JournaledEngine journaledEngine2 = new JournaledEngine(factory, impl, persistentFactory.getRows(), journalFactory, accessor);
            result = journaledEngine2;
            journaled = journaledEngine2.getJournal();
        } else {
            JournaledEngine engine = new JournaledEngine(factory, impl, persistentFactory.getRows(), journalFactory, accessor) {

                @Override
                protected void initPlugins(PluginFactory pluginFactory, AccessRules accessor) {
                }
            };
            journaled = engine.getJournal();
            CachedEngine cachedEngine = new CachedEngine(engine, cachedData);
            for (Plugin plugin : factory.getPlugins()) plugin.init(cachedEngine, accessor);
            result = cachedEngine;
        }
        EngineLogExtension engineLogExtension = new EngineLogExtension(result, journaled);
        log = new Log(result, journaled) {

            protected Event createEvent(String type, UpdateEventCallback callback) {
                String user = "admin";
                if (impl.getServerAccessRules() != null)
                    user = impl.getServerAccessRules().getUser().getLogin();
                long id = impl.nextValue("qualifiers_log_seq");
                return callback.createEvent(this, id, new Timestamp(System.currentTimeMillis()), type, user, null);
            }
        };
        log.addExtension(engineLogExtension);
        log.addExtension(new StorageLogExtension(new JDBCTemplate(createNewConnection()), prefix));
        return result;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : PersistentFactory(com.ramussoft.core.persistent.PersistentFactory) UniversalPersistentFactory(com.ramussoft.core.persistent.UniversalPersistentFactory) EngineLogExtension(com.ramussoft.common.logger.EngineLogExtension) Log(com.ramussoft.common.logger.Log) ILog(com.ramussoft.common.logger.ILog) PersistentsPluginProvider(com.ramussoft.core.persistent.PersistentsPluginProvider) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) PluginProvider(com.ramussoft.common.PluginProvider) Properties(java.util.Properties) IDEF0PluginProvider(com.ramussoft.idef0.IDEF0PluginProvider) Timestamp(java.sql.Timestamp) SQLException(java.sql.SQLException) UpdateEventCallback(com.ramussoft.common.logger.UpdateEventCallback) Journaled(com.ramussoft.common.journal.Journaled) JDBCTemplate(com.ramussoft.jdbc.JDBCTemplate) SimpleAttributePluginSuit(com.ramussoft.core.attribute.simple.SimpleAttributePluginSuit) JournaledEngine(com.ramussoft.common.journal.JournaledEngine) CachedEngine(com.ramussoft.common.cached.CachedEngine) AccessRules(com.ramussoft.common.AccessRules) Event(com.ramussoft.common.logger.Event) PluginFactory(com.ramussoft.common.PluginFactory) Engine(com.ramussoft.common.Engine) IEngine(com.ramussoft.common.IEngine) JournaledEngine(com.ramussoft.common.journal.JournaledEngine) CachedEngine(com.ramussoft.common.cached.CachedEngine) Plugin(com.ramussoft.common.Plugin) PersistentsPlugin(com.ramussoft.core.persistent.PersistentsPlugin) AbstractPlugin(com.ramussoft.common.AbstractPlugin)

Aggregations

Event (com.ramussoft.common.logger.Event)4 Engine (com.ramussoft.common.Engine)3 Attribute (com.ramussoft.common.Attribute)2 ILog (com.ramussoft.common.logger.ILog)2 GUIFramework (com.ramussoft.gui.common.GUIFramework)2 ActionEvent (java.awt.event.ActionEvent)2 AbstractAction (javax.swing.AbstractAction)2 ImageIcon (javax.swing.ImageIcon)2 AbstractPlugin (com.ramussoft.common.AbstractPlugin)1 AccessRules (com.ramussoft.common.AccessRules)1 Element (com.ramussoft.common.Element)1 IEngine (com.ramussoft.common.IEngine)1 Plugin (com.ramussoft.common.Plugin)1 PluginFactory (com.ramussoft.common.PluginFactory)1 PluginProvider (com.ramussoft.common.PluginProvider)1 CachedEngine (com.ramussoft.common.cached.CachedEngine)1 Journaled (com.ramussoft.common.journal.Journaled)1 JournaledEngine (com.ramussoft.common.journal.JournaledEngine)1 EngineLogExtension (com.ramussoft.common.logger.EngineLogExtension)1 Log (com.ramussoft.common.logger.Log)1