use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class CreateOrEditElementListDialog method onOk.
@Override
protected void onOk() {
if (!isOk()) {
JOptionPane.showMessageDialog(this, GlobalResourcesManager.getString("SomeNeededPreferenciesAreNotSeted"));
return;
}
((Journaled) engine).startUserTransaction();
Attribute attribute = getAttribute();
if (attribute == null)
attribute = engine.createAttribute(getAttributeType());
attribute.setName(nameField.getText());
editor.apply(attribute, engine, rules);
engine.updateAttribute(attribute);
Qualifier q1 = editor.getQualifier1();
Qualifier q2 = editor.getQualifier2();
q1.getAttributes().add(attribute);
q2.getAttributes().add(attribute);
engine.updateQualifier(q1);
engine.updateQualifier(q2);
((Journaled) engine).commitUserTransaction();
super.onOk();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class ElistTableModel method setValueAt.
@Override
public void setValueAt(Object value, int rowIndex, int columnIndex) {
Element element = left.getElement(rowIndex);
List<ElementListPersistent> list = data.get(element);
Element c = top.getElement(columnIndex);
ElementListPersistent p = new ElementListPersistent();
if (revert) {
p.setElement1Id(c.getId());
p.setElement2Id(element.getId());
} else {
p.setElement1Id(element.getId());
p.setElement2Id(c.getId());
}
if (value != null) {
if (value instanceof Boolean) {
if ((Boolean) value)
list.add(p);
else
list.remove(p);
} else {
int index = list.indexOf(p);
p.setConnectionType(value.toString());
if (p.getConnectionType().length() == 0) {
if (index >= 0)
list.remove(index);
} else {
if (index >= 0)
list.get(index).setConnectionType(value.toString());
else
list.add(p);
}
}
} else {
list.remove(p);
}
((Journaled) engine).startUserTransaction();
engine.setAttribute(element, attribute, new ArrayList(list));
((Journaled) engine).commitUserTransaction();
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class SetFormulaDialog method onOk.
@Override
protected void onOk() {
if (editor.getText().equals("")) {
info.setFormula(null);
((Journaled) engine).startUserTransaction();
engine.setCalculateInfo(info);
((Journaled) engine).commitUserTransaction();
super.onOk();
return;
}
Util utils = Util.getUtils(engine);
try {
try {
info.setFormula(utils.compile(editor.getText(), engine.getElement(info.getElementId()), engine.getAttribute(info.getAttributeId())));
} catch (UnknownValuesException e) {
StringBuffer sb = new StringBuffer();
sb.append("<html><body>");
for (String value : e.getValues()) {
sb.append(MessageFormat.format(GlobalResourcesManager.getString("Eval.UnknowValue"), value));
sb.append("<br>");
}
sb.append("</body></html>");
JOptionPane.showMessageDialog(null, sb.toString());
}
Eval eval = new Eval(info.getFormula());
List<String> rec = new ArrayList<String>();
for (String function : eval.getFunctions()) if (!utils.isFunctionExists(function)) {
JOptionPane.showMessageDialog(null, MessageFormat.format(GlobalResourcesManager.getString("Eval.UnknowFunction"), function));
return;
}
rec.add(utils.toValue(info.getElementId(), info.getAttributeId()));
if (recCheck(rec, eval, utils)) {
JOptionPane.showMessageDialog(null, GlobalResourcesManager.getString("Recursive.Link"));
} else {
((Journaled) engine).startUserTransaction();
engine.setCalculateInfo(info);
((Journaled) engine).commitUserTransaction();
super.onOk();
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, MessageFormat.format(GlobalResourcesManager.getString("Eval.Error"), editor.getText()));
return;
}
}
use of com.ramussoft.common.journal.Journaled 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);
}
}
use of com.ramussoft.common.journal.Journaled in project ramus by Vitaliy-Yakovchuk.
the class QualifierPreferencesPanel method ok.
public boolean ok() {
if (box.getSelectedItem() == null) {
JOptionPane.showMessageDialog(this, GlobalResourcesManager.getString("Error.SetAttributeForName"));
return false;
}
String[] errors = new String[] {};
for (QualifierSetupEditor editor : editors) {
String[] add = editor.getErrors();
int start = errors.length;
errors = Arrays.copyOf(errors, errors.length + add.length);
for (int i = start; i < errors.length; i++) {
errors[i] = add[i - start];
}
}
if (errors.length > 0) {
StringBuffer sb = new StringBuffer();
sb.append("<html><body>");
for (String error : errors) {
sb.append(error);
sb.append("<br>");
}
sb.append("</body></html>");
JOptionPane.showMessageDialog(this, sb.toString());
return false;
}
if (engine instanceof Journaled) {
((Journaled) engine).startUserTransaction();
}
engine.setAttribute(element, attribute, attributeEditor.getValue());
long id = (Long) engine.getAttribute(element, (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.QUALIFIER_ID));
Qualifier qualifier = engine.getQualifier(id);
updateAttributesInOrder(attributeOrderEditPanel.getAttributes());
qualifier.setAttributes(attributeOrderEditPanel.getAttributes());
if (box.getSelectedItem() == null) {
qualifier.setAttributeForName(-1l);
} else {
Attribute attributeId = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_ID);
Long id2 = (Long) engine.getAttribute((Element) box.getSelectedItem(), attributeId);
Attribute a = engine.getAttribute(id2);
qualifier.setAttributeForName(a.getId());
}
engine.updateQualifier(qualifier);
IconPersistent selectedValue = open.getSelectedValue();
if (selectedValue != null)
IconFactory.setOpenIcon(engine, selectedValue, qualifier);
selectedValue = leaf.getSelectedValue();
if (selectedValue != null)
IconFactory.setLeafIcon(engine, selectedValue, qualifier);
selectedValue = closed.getSelectedValue();
if (selectedValue != null)
IconFactory.setClosedIcon(engine, selectedValue, qualifier);
for (QualifierSetupEditor editor : editors) {
editor.save(engine, qualifier);
}
if (engine instanceof Journaled) {
((Journaled) engine).commitUserTransaction();
}
return true;
}
Aggregations