Search in sources :

Example 6 with AttributeEvent

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);
}
Also used : DeleteAttributeCommand(com.ramussoft.common.journal.command.DeleteAttributeCommand) Attribute(com.ramussoft.common.Attribute) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Example 7 with AttributeEvent

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;
}
Also used : CreateAttributeCommand(com.ramussoft.common.journal.command.CreateAttributeCommand) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Example 8 with AttributeEvent

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);
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) AttributeListener(com.ramussoft.common.event.AttributeListener) AttributeEvent(com.ramussoft.common.event.AttributeEvent) UpdateAttributeCommand(com.ramussoft.common.journal.command.UpdateAttributeCommand)

Example 9 with AttributeEvent

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++;
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) ElementEvent(com.ramussoft.common.event.ElementEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Example 10 with AttributeEvent

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);
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction) Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) QualifierEvent(com.ramussoft.common.event.QualifierEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Aggregations

AttributeEvent (com.ramussoft.common.event.AttributeEvent)18 Attribute (com.ramussoft.common.Attribute)11 Element (com.ramussoft.common.Element)8 Qualifier (com.ramussoft.common.Qualifier)7 ElementEvent (com.ramussoft.common.event.ElementEvent)5 ElementAttributeListener (com.ramussoft.common.event.ElementAttributeListener)4 AttributeType (com.ramussoft.common.AttributeType)3 AttributeListener (com.ramussoft.common.event.AttributeListener)3 ElementAdapter (com.ramussoft.common.event.ElementAdapter)3 QualifierEvent (com.ramussoft.common.event.QualifierEvent)3 ArrayList (java.util.ArrayList)3 Engine (com.ramussoft.common.Engine)2 IEngine (com.ramussoft.common.IEngine)2 QualifierAdapter (com.ramussoft.common.event.QualifierAdapter)2 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)2 JDBCTemplate (com.ramussoft.jdbc.JDBCTemplate)2 RowMapper (com.ramussoft.jdbc.RowMapper)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 CalculateInfo (com.ramussoft.common.CalculateInfo)1