Search in sources :

Example 66 with Element

use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.

the class SetElementQualifierCommand method undo.

@Override
public void undo(IEngine iEngine) {
    Element element = iEngine.getElement(elementId);
    Element newElement = new Element(element.getId(), oldQualifierId, element.getName());
    ElementEvent event = new ElementEvent(engine, element, newElement, newQualifierId, true);
    engine.beforeElementDeleted(event);
    iEngine.setElementQualifier(elementId, oldQualifierId);
    engine.elementDeleted(event);
    event = new ElementEvent(engine, element, newElement, oldQualifierId, true);
    engine.elementCreated(event);
    Qualifier oldQualifier = iEngine.getQualifier(oldQualifierId);
    Qualifier newQualifier = iEngine.getQualifier(newQualifierId);
    List<Attribute> attrs = new ArrayList<Attribute>();
    addNotPresentAttributes(oldQualifier.getAttributes(), newQualifier.getAttributes(), attrs);
    addNotPresentAttributes(oldQualifier.getSystemAttributes(), newQualifier.getSystemAttributes(), attrs);
    List<Attribute> as = oldQualifier.getAttributes();
    as.addAll(oldQualifier.getSystemAttributes());
    int i = 0;
    for (Attribute a : as) {
        if (attrs.indexOf(a) >= 0) {
            iEngine.setBinaryAttribute(elementId, a.getId(), data[i]);
            i++;
        }
        Object object = engine.getAttribute(newElement, a);
        if (object != null) {
            AttributeEvent event2 = new AttributeEvent(engine, newElement, a, null, object, true);
            engine.attributeChanged(event2);
        }
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) ElementEvent(com.ramussoft.common.event.ElementEvent) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Example 67 with Element

use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.

the class DeleteElementCommand method redo.

@Override
public void redo(IEngine iEngine) {
    Element old = iEngine.getElement(elementId);
    ElementEvent event = new ElementEvent(engine, old, null, qualifierId, true);
    engine.beforeElementDeleted(event);
    iEngine.deleteElement(elementId);
    engine.elementDeleted(event);
}
Also used : Element(com.ramussoft.common.Element) ElementEvent(com.ramussoft.common.event.ElementEvent)

Example 68 with Element

use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.

the class TransactionStorageCommand method setAttribute.

private void setAttribute(Transaction transaction, IEngine iEngine) {
    Element element = iEngine.getElement(elementId);
    Attribute attribute = iEngine.getAttribute(attributeId);
    Object oldValue = engine.getAttribute(element, attribute);
    iEngine.setBinaryAttribute(elementId, attributeId, transaction);
    Object newValue = engine.getAttribute(element, attribute);
    if (element != null) {
        long qId = engine.getQualifierIdForElement(elementId);
        Qualifier q = engine.getQualifier(qId);
        if (q.getAttributeForName() == attributeId) {
            element.setName((newValue == null) ? "" : newValue.toString());
        }
    }
    AttributeEvent event = new AttributeEvent(engine, element, attribute, oldValue, newValue, true);
    engine.attributeChanged(event);
}
Also used : Attribute(com.ramussoft.common.Attribute) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier) AttributeEvent(com.ramussoft.common.event.AttributeEvent)

Example 69 with Element

use of com.ramussoft.common.Element 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);
}
Also used : Element(com.ramussoft.common.Element) ElementEvent(com.ramussoft.common.event.ElementEvent)

Example 70 with Element

use of com.ramussoft.common.Element in project ramus by Vitaliy-Yakovchuk.

the class TableEditorModel method removeElements.

public void removeElements(List<Element> list) {
    ((Journaled) engine).startUserTransaction();
    for (Element element : list) {
        engine.deleteElement(element.getId());
    }
    ((Journaled) engine).commitUserTransaction();
}
Also used : Journaled(com.ramussoft.common.journal.Journaled) Element(com.ramussoft.common.Element)

Aggregations

Element (com.ramussoft.common.Element)142 Attribute (com.ramussoft.common.Attribute)70 Qualifier (com.ramussoft.common.Qualifier)59 ArrayList (java.util.ArrayList)48 Engine (com.ramussoft.common.Engine)27 SQLException (java.sql.SQLException)14 List (java.util.List)14 Hashtable (java.util.Hashtable)13 Row (com.ramussoft.database.common.Row)12 ElementEvent (com.ramussoft.common.event.ElementEvent)11 HierarchicalPersistent (com.ramussoft.core.attribute.simple.HierarchicalPersistent)11 Eval (com.ramussoft.eval.Eval)9 AttributeEvent (com.ramussoft.common.event.AttributeEvent)8 ElementListPersistent (com.ramussoft.core.attribute.simple.ElementListPersistent)8 Row (com.ramussoft.pb.Row)8 Journaled (com.ramussoft.common.journal.Journaled)7 FunctionPersistent (com.ramussoft.eval.FunctionPersistent)7 Util (com.ramussoft.eval.Util)7 EObject (com.ramussoft.eval.EObject)6 IOException (java.io.IOException)6