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