public static synchronized void addSpecialCommand(Command command) { AndroidTransaction transaction = new AndroidTransaction(); transaction.getCommands().add(command); ObjectContainer sess = Database.OpenDB(); sess.store(transaction); sess.commit(); }
public static synchronized void CancelTransaction(String ErrorTittle, String ErroMessage) { if (Opened) { Opened = false; TransactionCanceled = true; transaction.setErrorTittle(ErrorTittle); transaction.addErrorMessage(ErroMessage); session.rollback(); } }
public static synchronized boolean StopTransaction() { if (Opened && !isCanceled()) { try { session.store(transaction); session.commit(); } catch (Exception e) { CancelTransaction("Finishing transaction error", "error in storing transaction"); Opened = false; return false; } for (Command c : transaction.getCommands()) if (c.getTargetLayer().toString().equals(CommandTargetLayer.VIEW.toString())) ((ModelMusts) c.getSource()) .notifyObjectListener( c.getSource(), c.getType(), c.getoldObjectID(), c.getoldObject(), c.getObject(), c.getoldNeiborID(), c.getOldNeibor(), c.getNeibor()); Opened = false; return true; } else Opened = false; return false; }
public synchronized List<Command> getTransactionCommands(AndroidTransaction transaction) { return transaction.getCommands(); }
public static synchronized void AddCommand(Command command) { if (Opened) { transaction.getCommands().add(command); } }
public static synchronized void ShowErrorMessage(Activity activity) { UtilNavigate.showWarning( activity, transaction.getErrorTittle(), transaction.getErrorMessage().toString()); }