use of com.ramussoft.common.event.AttributeEvent in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method deleteAttribute.
@Override
public void deleteAttribute(long id) {
Attribute attribute = getAttribute(id);
DeleteAttributeCommand command = new DeleteAttributeCommand(this, attribute);
AttributeEvent event = new AttributeEvent(this, null, attribute, attribute, null);
beforeAttributeDeleted(event);
deligate.deleteAttribute(id);
synchronized (swithJournalLock) {
journal.store(command);
}
attributeDeleted(event);
}
use of com.ramussoft.common.event.AttributeEvent in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method registerCreation.
private Attribute registerCreation(Attribute attribute) {
synchronized (swithJournalLock) {
journal.store(new CreateAttributeCommand(this, attribute));
}
AttributeEvent event = new AttributeEvent(this, null, attribute, null, attribute);
attributeCreated(event);
return attribute;
}
use of com.ramussoft.common.event.AttributeEvent in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method updateAttribute.
@Override
public void updateAttribute(Attribute attribute) {
Attribute old = getAttribute(attribute.getId());
deligate.updateAttribute(attribute);
synchronized (swithJournalLock) {
journal.store(new UpdateAttributeCommand(this, old, attribute));
}
AttributeEvent event = new AttributeEvent(this, null, attribute, old, attribute);
for (AttributeListener listener : attributeListeners) {
listener.attributeUpdated(event);
}
}
use of com.ramussoft.common.event.AttributeEvent in project ramus by Vitaliy-Yakovchuk.
the class DeleteElementCommand method undo.
@Override
public void undo(IEngine iEngine) {
Qualifier qualifier = iEngine.getQualifier(qualifierId);
Element element = iEngine.createElement(qualifierId, elementId);
ElementEvent event = new ElementEvent(engine, null, element, qualifierId, true);
engine.elementCreated(event);
List<Attribute> attrs = qualifier.getAttributes();
attrs.addAll(qualifier.getSystemAttributes());
int i = 0;
for (Attribute attr : attrs) {
iEngine.setBinaryAttribute(elementId, attr.getId(), data[i]);
Object object = engine.getAttribute(element, attr);
if ((attr.getId() == qualifier.getAttributeForName()) && (object != null)) {
element.setName(object.toString());
}
AttributeEvent event2 = new AttributeEvent(engine, element, attr, null, object, true);
engine.attributeChanged(event2);
i++;
}
}
use of com.ramussoft.common.event.AttributeEvent in project ramus by Vitaliy-Yakovchuk.
the class UpdateQualifierCommand method undo.
@Override
public void undo(IEngine iEngine) {
iEngine.updateQualifier(oldQualifier);
QualifierEvent event = new QualifierEvent(engine, newQualifier, oldQualifier, true);
for (Attribute attribute : deletedAttributes) {
for (Entry<Long, Transaction> entry : hashtable.get(attribute.getId()).entrySet()) {
iEngine.setBinaryAttribute(entry.getKey(), attribute.getId(), entry.getValue());
Element element = iEngine.getElement(entry.getKey());
AttributeEvent event2 = new AttributeEvent(engine, element, attribute, null, engine.getAttribute(element, attribute), true);
engine.attributeChanged(event2);
}
}
if (oldQualifier.getAttributeForName() != newQualifier.getAttributeForName())
getEngine().updateElementNames(newQualifier, oldQualifier);
engine.qualifierUpdated(event);
}
Aggregations