Search in sources :

Example 11 with Transaction

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

the class DeleteAttributeCommand method readBody.

@Override
public void readBody(BinaryDataInput input) throws IOException {
    attribute = new Attribute();
    properties = new Transaction();
    int c = input.readInt();
    for (int i = 0; i < c; i++) try {
        properties.getSave().add(TransactionStorageCommand.loadPersistent(engine, input));
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    loadAttribute(input, attribute);
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction) Attribute(com.ramussoft.common.Attribute)

Example 12 with Transaction

use of com.ramussoft.common.persistent.Transaction 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)

Example 13 with Transaction

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

the class DeleteElementCommand method readBody.

@Override
public void readBody(BinaryDataInput input) throws IOException {
    qualifierId = input.readLong();
    elementId = input.readLong();
    int size = input.readInt();
    data = new Transaction[size];
    for (int i = 0; i < size; i++) {
        Transaction transaction = new Transaction();
        transaction.setRemoveBranchInfo(input.readBoolean());
        data[i] = transaction;
        int size2 = input.readInt();
        for (int j = 0; j < size2; j++) {
            try {
                transaction.getSave().add(TransactionStorageCommand.loadPersistent(engine, input));
            } catch (InstantiationException e) {
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction)

Example 14 with Transaction

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

the class TransactionStorageCommand method undo.

@Override
public void undo(IEngine iEngine) {
    Transaction transaction = new Transaction();
    copy(delete, transaction.getSave());
    copy(save, transaction.getDelete());
    copy(updateOld, transaction.getUpdate());
    transaction.setRemoveBranchInfo(removeBranchInfo);
    setAttribute(transaction, iEngine);
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction)

Example 15 with Transaction

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

the class UpdateQualifierCommand method readBody.

@Override
public void readBody(BinaryDataInput input) throws IOException {
    oldQualifier = new Qualifier();
    newQualifier = new Qualifier();
    loadQualifier(input, oldQualifier);
    loadQualifier(input, newQualifier);
    initDeletedAttributes();
    for (Attribute attribute : deletedAttributes) {
        Hashtable<Long, Transaction> hash = new Hashtable<Long, Transaction>();
        hashtable.put(attribute.getId(), hash);
        int size1 = input.readInt();
        for (int i = 0; i < size1; i++) {
            Transaction transaction = new Transaction();
            Long key = input.readLong();
            int size2 = input.readInt();
            for (int j = 0; j < size2; j++) {
                try {
                    transaction.getSave().add(TransactionStorageCommand.loadPersistent(engine, input));
                } catch (InstantiationException e) {
                    throw new RuntimeException(e);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
            hash.put(key, transaction);
        }
    }
}
Also used : Transaction(com.ramussoft.common.persistent.Transaction) Attribute(com.ramussoft.common.Attribute) Hashtable(java.util.Hashtable) Qualifier(com.ramussoft.common.Qualifier)

Aggregations

Transaction (com.ramussoft.common.persistent.Transaction)21 Attribute (com.ramussoft.common.Attribute)9 Persistent (com.ramussoft.common.persistent.Persistent)6 ArrayList (java.util.ArrayList)6 Element (com.ramussoft.common.Element)5 FindObject (com.ramussoft.common.attribute.FindObject)5 SQLException (java.sql.SQLException)5 JDBCCallback (com.ramussoft.jdbc.JDBCCallback)4 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 Qualifier (com.ramussoft.common.Qualifier)3 Hashtable (java.util.Hashtable)3 ElementEvent (com.ramussoft.common.event.ElementEvent)2 PersistentField (com.ramussoft.common.persistent.PersistentField)2 PersistentRow (com.ramussoft.common.persistent.PersistentRow)2 PersistentWrapper (com.ramussoft.common.persistent.PersistentWrapper)2 List (java.util.List)2 Engine (com.ramussoft.common.Engine)1 IEngine (com.ramussoft.common.IEngine)1 AbstractAttributeConverter (com.ramussoft.common.attribute.AbstractAttributeConverter)1