예제 #1
0
    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))
예제 #2
0
    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))
예제 #3
0
    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))
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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))