use of com.ramussoft.common.journal.command.Command in project ramus by Vitaliy-Yakovchuk.
the class Journal method redoUserTransaction.
@Override
public void redoUserTransaction() {
int counter = 0;
try {
Command command = redo();
counter++;
if (!(command instanceof StartUserTransactionCommand)) {
throw new Exception("Command is not user transaction");
}
while (!(redo() instanceof EndUserTransactionCommand)) {
counter++;
}
} catch (Exception e) {
e.printStackTrace();
while (counter > 0) {
counter--;
undo();
}
}
}
use of com.ramussoft.common.journal.command.Command in project ramus by Vitaliy-Yakovchuk.
the class Journal method readPrev.
private Command readPrev() throws IOException {
Command.moveCommandStart(accessFile);
long pos = accessFile.getFilePointer();
Command res = readCommand();
accessFile.seek(pos);
return res;
}
use of com.ramussoft.common.journal.command.Command in project ramus by Vitaliy-Yakovchuk.
the class Journal method undoUserTransaction.
@Override
public void undoUserTransaction() {
int counter = 0;
try {
Command command = undo();
counter++;
if (!(command instanceof EndUserTransactionCommand)) {
throw new Exception("Command is not user transaction");
}
while (!((command = undo()) instanceof StartUserTransactionCommand)) {
counter++;
}
} catch (Exception e) {
e.printStackTrace();
while (counter > 0) {
counter--;
redo();
}
}
}
use of com.ramussoft.common.journal.command.Command in project ramus by Vitaliy-Yakovchuk.
the class InternetHookJournal method redo.
@Override
public Command redo() {
Command command = super.redo();
onRepeat(command);
return command;
}
use of com.ramussoft.common.journal.command.Command in project ramus by Vitaliy-Yakovchuk.
the class InternetHookJournal method undo.
@Override
public Command undo() {
Command undo = super.undo();
if (undo instanceof StartUserTransactionCommand) {
try {
long cursor = getPointer();
byte[] bs = new byte[(int) (this.cursor - cursor)];
accessFile.read(bs);
accessFile.seek(cursor);
this.cursor = cursor;
onUndo(bs);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return undo;
}
Aggregations