Search in sources :

Example 66 with Qualifier

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

the class JournaledEngine method deleteQualifier.

@Override
public void deleteQualifier(long id) {
    Qualifier qualifier = getQualifier(id);
    deligate.deleteQualifier(id);
    synchronized (swithJournalLock) {
        journal.store(new DeleteQualifierCommand(this, qualifier));
    }
    QualifierEvent event = new QualifierEvent(this, qualifier, null);
    qualifierDeleted(event);
}
Also used : DeleteQualifierCommand(com.ramussoft.common.journal.command.DeleteQualifierCommand) Qualifier(com.ramussoft.common.Qualifier) QualifierEvent(com.ramussoft.common.event.QualifierEvent)

Example 67 with Qualifier

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

the class JournaledEngine method updateQualifier.

@Override
public void updateQualifier(Qualifier qualifier) {
    Qualifier old = getQualifier(qualifier.getId());
    QualifierEvent event = new QualifierEvent(this, old, qualifier);
    beforeQualifierUpdated(event);
    event = new QualifierEvent(this, old, qualifier);
    UpdateQualifierCommand command = new UpdateQualifierCommand(this, old, qualifier);
    deligate.updateQualifier(qualifier);
    synchronized (swithJournalLock) {
        journal.store(command);
    }
    updateElementNames(old, qualifier);
    qualifierUpdated(event);
}
Also used : Qualifier(com.ramussoft.common.Qualifier) QualifierEvent(com.ramussoft.common.event.QualifierEvent) UpdateQualifierCommand(com.ramussoft.common.journal.command.UpdateQualifierCommand)

Example 68 with Qualifier

use of com.ramussoft.common.Qualifier 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 69 with Qualifier

use of com.ramussoft.common.Qualifier 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 70 with Qualifier

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

the class DeleteQualifierCommand method readBody.

@Override
public void readBody(BinaryDataInput input) throws IOException {
    qualifier = new Qualifier();
    loadQualifier(input, qualifier);
    system = input.readBoolean();
}
Also used : Qualifier(com.ramussoft.common.Qualifier)

Aggregations

Qualifier (com.ramussoft.common.Qualifier)157 Attribute (com.ramussoft.common.Attribute)72 Element (com.ramussoft.common.Element)59 ArrayList (java.util.ArrayList)45 Engine (com.ramussoft.common.Engine)22 Row (com.ramussoft.database.common.Row)17 Row (com.ramussoft.pb.Row)14 List (java.util.List)12 Hashtable (java.util.Hashtable)11 QualifierEvent (com.ramussoft.common.event.QualifierEvent)10 ResultSet (java.sql.ResultSet)9 SQLException (java.sql.SQLException)9 AttributeType (com.ramussoft.common.AttributeType)8 RowSet (com.ramussoft.database.common.RowSet)8 DataPlugin (com.ramussoft.pb.DataPlugin)8 NFunction (com.ramussoft.pb.data.negine.NFunction)8 AttributeEvent (com.ramussoft.common.event.AttributeEvent)7 Journaled (com.ramussoft.common.journal.Journaled)7 RowMapper (com.ramussoft.jdbc.RowMapper)7 IEngine (com.ramussoft.common.IEngine)6