Search in sources :

Example 1 with SetElementQualifierCommand

use of com.ramussoft.common.journal.command.SetElementQualifierCommand 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);
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) SetElementQualifierCommand(com.ramussoft.common.journal.command.SetElementQualifierCommand) Qualifier(com.ramussoft.common.Qualifier) ElementEvent(com.ramussoft.common.event.ElementEvent)

Aggregations

Attribute (com.ramussoft.common.Attribute)1 Element (com.ramussoft.common.Element)1 Qualifier (com.ramussoft.common.Qualifier)1 ElementEvent (com.ramussoft.common.event.ElementEvent)1 SetElementQualifierCommand (com.ramussoft.common.journal.command.SetElementQualifierCommand)1 Transaction (com.ramussoft.common.persistent.Transaction)1 ArrayList (java.util.ArrayList)1