use of com.ramussoft.common.event.ElementEvent in project ramus by Vitaliy-Yakovchuk.
the class CreateElementCommand method redo.
@Override
public void redo(IEngine iEngine) {
Element element = iEngine.createElement(qualifierId, elementId);
ElementEvent event = new ElementEvent(engine, null, element, qualifierId, true);
engine.elementCreated(event);
}
use of com.ramussoft.common.event.ElementEvent in project ramus by Vitaliy-Yakovchuk.
the class ElementListPlugin method init.
@Override
public void init(Engine engine, AccessRules accessor) {
super.init(engine, accessor);
if (!StandardAttributesPlugin.isDisableAutoupdate(engine))
engine.addElementListener(null, new ElementAdapter() {
@Override
public void beforeElementDeleted(ElementEvent event) {
if (event.isJournaled())
return;
long id = event.getQualifierId();
Qualifier q = event.getEngine().getQualifier(id);
cleanAttribute(q.getAttributes(), event);
cleanAttribute(q.getSystemAttributes(), event);
super.beforeElementDeleted(event);
}
private void cleanAttribute(List<Attribute> attributes, ElementEvent event) {
for (Attribute a : attributes) {
if (isMyType(a)) {
event.getEngine().setAttribute(event.getOldElement(), a, new ArrayList<Persistent>(0));
}
}
}
});
}
use of com.ramussoft.common.event.ElementEvent in project ramus by Vitaliy-Yakovchuk.
the class TcpClientEngine method setEngine.
public void setEngine(Engine engine) {
this.engine = engine;
engine.addElementListener(null, new ElementAdapter() {
@Override
public void elementCreated(ElementEvent event) {
qualifirsForElements.put(event.getNewElement().getId(), event.getNewElement().getQualifierId());
}
@Override
public void elementDeleted(ElementEvent event) {
qualifirsForElements.remove(event.getOldElement().getId());
}
});
}
use of com.ramussoft.common.event.ElementEvent in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method setElementQualifier.
@Override
public void setElementQualifier(long elementId, long qualifierId) {
qualifirsForElements.remove(elementId);
Element element = getElement(elementId);
Qualifier current = getQualifier(element.getQualifierId());
Qualifier newQualifier = getQualifier(qualifierId);
final List<Attribute> attrs = new ArrayList<Attribute>();
addNotPresentAttributes(current.getAttributes(), newQualifier.getAttributes(), attrs);
addNotPresentAttributes(current.getSystemAttributes(), newQualifier.getSystemAttributes(), attrs);
Transaction[] data = getAttributesWhatWillBeDeleted(elementId, attrs);
ElementEvent event = new ElementEvent(this, element, new Element(element.getId(), qualifierId, element.getName()), element.getQualifierId());
beforeElementDeleted(event);
deligate.setElementQualifier(elementId, qualifierId);
synchronized (swithJournalLock) {
journal.store(new SetElementQualifierCommand(this, element.getQualifierId(), qualifierId, elementId, data));
}
elementDeleted(event);
event = new ElementEvent(this, element, new Element(element.getId(), qualifierId, element.getName()), qualifierId);
qualifirsForElements.remove(element.getId());
elementCreated(event);
}
use of com.ramussoft.common.event.ElementEvent in project ramus by Vitaliy-Yakovchuk.
the class JournaledEngine method registerCreation.
private Element registerCreation(long qualifierId, Element element) {
synchronized (swithJournalLock) {
journal.store(new CreateElementCommand(this, qualifierId, element.getId()));
}
ElementEvent event = new ElementEvent(this, null, element, qualifierId);
elementCreated(event);
return element;
}
Aggregations