def remove(self, movieId): movie = MovieControler.remove(self, movieId) if self.__undoController.newOperation() == False: return redo = FunctionCall(self.remove, movieId) undo = FunctionCall(self.add, movie.entityId, movie.entityName, movie.entityDescription, movie.entityGenre) self.__undoController.addOperation(Operation(undo, redo))
def update(self, clientId, clientName): client = self.get_repository().find_by_id(int(clientId)) ClientControler.update(self, clientId, clientName) self.__undoController.newOperation() redo = FunctionCall(self.update, clientId, clientName) undo = FunctionCall(self.update, clientId, client.entityName) self.__undoController.addOperation(Operation(undo, redo))
def remove(self, clientId): client = ClientControler.remove(self, clientId) clientName = client.entityName if self.__undoController.newOperation() == False: return redo = FunctionCall(self.remove, clientId) undo = FunctionCall(self.add, client.entityId, clientName) self.__undoController.addOperation(Operation(undo, redo))
def returnMovie(self, movieId): rent = RentalControler.returnMovie(self, movieId) if self.__undoController.newOperation() == False: return undo = FunctionCall(rent.set_returned_date, None) redo = FunctionCall(rent.set_returned_date, rent.returnedDate) operation = Operation(undo, redo) self.__undoController.addOperation(operation)
def remove(self, rentalId): rent = RentalControler.remove(self, rentalId) Rental.rentalCounter -= 1 #Don't put that "if self.__undoController.newOperation() == False:" here!!! undo = FunctionCall(self.add, rent.entityId, rent.movieId, rent.clientId, rent.rentedDate, rent.dueDate, rent.returnedDate) redo = FunctionCall(self.remove, rentalId) operation = Operation(undo, redo) self.__undoController.addOperation(operation)
def add(self, rentalId, movieId, clientId, rentedDate, dueDate, returnedDate): rent = RentalControler.add(self, rentalId, movieId, clientId, rentedDate, dueDate, returnedDate) if self.__undoController.newOperation() == False: return undo = FunctionCall(self.remove, rent.entityId) redo = FunctionCall(self.add, rentalId, movieId, clientId, rentedDate, dueDate, returnedDate) operation = Operation(undo, redo) self.__undoController.addOperation(operation)
def add(self, clientId, clientName): ClientControler.add(self, clientId, clientName) #We make a new operation if self.__undoController.newOperation() == False: return #We define undo and redo redo = FunctionCall(self.add, clientId, clientName) undo = FunctionCall(self.remove, clientId) #We put them together operation = Operation(undo, redo) #Add operation object to undoController self.__undoController.addOperation(operation)
def add(self, movieId, movieTitle, movieDescription, movieGenre): MovieControler.add(self, movieId, movieTitle, movieDescription, movieGenre) #We make a new operation if self.__undoController.newOperation() == False: return #We define undo and redo redo = FunctionCall(self.add, movieId, movieTitle, movieDescription, movieGenre) undo = FunctionCall(self.remove, movieId) #We put them together operation = Operation(undo, redo) #Add operation object to undoController self.__undoController.addOperation(operation)
def update(self, movieId, tag, valueUpdate): movie = self.get_repository().find_by_id(movieId) movieName = movie.entityName movieDescription = movie.entityDescription movieGenre = movie.entityGenre MovieControler.update(self, movieId, tag, valueUpdate) if self.__undoController.newOperation() == False: return self.__undoController.newOperation() redo = FunctionCall(self.update, movieId, tag, valueUpdate) undo = FunctionCall( self.update, movieId, tag, (lambda x: movieName if tag == "movieTitle" else movieDescription if tag == "movieDescription" else movieGenre)(movie)) self.__undoController.addOperation(Operation(undo, redo))