def client_ctrl_update(self, clientId, newClient): oldClient = ClientsController.client_searchById(self, clientId) ClientsController.client_ctrl_update(self, clientId, newClient) undo = FunctionCall(self.client_ctrl_update, clientId, oldClient) redo = FunctionCall(self.client_ctrl_update, clientId, newClient) self._undoController.add_operationList([Operation(undo, redo)])
def rental_ctrl_add(self, rental): RentalsController.rental_ctrl_add(self, rental) undo = FunctionCall(self.rental_ctrl_remove, rental) redo = FunctionCall(self.rental_ctrl_add, rental) self._undoController.add_operationList([Operation(undo, redo)])
def client_ctrl_add(self, client): ClientsController.client_ctrl_add(self, client) undo = FunctionCall(self.client_ctrl_remove, client.getId()) redo = FunctionCall(self.client_ctrl_add, client) self._undoController.add_operationList([Operation(undo, redo)])
def book_ctrl_add(self, book): BooksController.book_ctrl_add(self, book) '''Adding operation to undo controller ''' undo = FunctionCall(self.book_ctrl_remove, book.getbookId()) redo = FunctionCall(self.book_ctrl_add, book) operation = Operation(undo, redo) #adding operation to undoController controller operationsList = [] operationsList.append(operation) self._undoController.add_operationList(operationsList)
def client_ctrl_remove(self, clientId): client = ClientsController.client_searchById(self, clientId) rentalsList = self._rentalsController.filter_rentals( None, client, None) ClientsController.client_ctrl_remove(self, clientId) self._rentalsController.rental_ctr_removeByClient(client) undo = FunctionCall(self.client_ctrl_add, client) redo = FunctionCall(self.client_ctrl_remove, clientId) opList = [] opList.append(Operation(undo, redo)) for rental in rentalsList: undoRental = FunctionCall(self._rentalsController.rental_ctrl_add, rental) redoRental = FunctionCall( self._rentalsController.rental_ctrl_remove, rental) newOp = Operation(undoRental, redoRental) opList.append(newOp) self._undoController.add_operationList(opList)
def book_ctrl_update(self, bookId, args): book = BooksController.book_SearchById(self, bookId) originalArgs = [ book.gettitle(), book.getdescription(), book.getauthor() ] BooksController.book_ctrl_update(self, bookId, args) undo = FunctionCall(self.book_ctrl_update, bookId, originalArgs) redo = FunctionCall(self.book_ctrl_update, bookId, args) operationsList = [Operation(undo, redo)] self._undoController.add_operationList(operationsList)
def book_ctrl_remove(self, bookId): book = BooksController.book_SearchById(self, bookId) rentalsList = self._rentalsController.filter_rentals(book) #remove book entry and rentals of the book BooksController.book_ctrl_remove(self, bookId) self._rentalsController.rental_ctrl_removeByBookId(bookId) undo = FunctionCall(self.book_ctrl_add, book) redo = FunctionCall(self.book_ctrl_remove, bookId) operation = Operation(undo, redo) operationsList = [] operationsList.append(operation) for rental in rentalsList: undoRental = FunctionCall(self._rentalsController.rental_ctrl_add, rental) redoRental = FunctionCall( self._rentalsController.rental_ctrl_remove, rental) newOp = Operation(undoRental, redoRental) operationsList.append(newOp) self._undoController.add_operationList(operationsList)