Пример #1
0
 def add_person(self, id, name, phone_no, address):
     new_prs = Person(id, name, phone_no, address)
     acts = self.__act_repo.find_all()
     Acts = []
     for act in acts:
         if id in act.prsids:
             Acts.append(act)
     UndoManager.register_operation(self, UndoHandler.ADD_PERSON, acts, id,
                                    name, phone_no, address)
     self.__repository.save(new_prs)
 def update_activity_by_id(self, id, prsids, date, time, description):
     entity = self.__repository.find_by_id(id)
     UndoManager.register_operation(self, UndoHandler.UPDATE_ACTIVITY,
                                    entity.id, entity.prsids, entity.date,
                                    entity.time, entity.description, prsids,
                                    date, time, description)
     entity.prsids = prsids
     entity.date = date
     entity.time = time
     entity.description = description
     self.__repository.update(entity)
Пример #3
0
    def update_person_by_id(self, id, name, phone_no, address):
        entity = self.__repository.find_by_id(id)

        UndoManager.register_operation(self, UndoHandler.UPDATE_PERSON, id,
                                       entity.name, entity.phone_no,
                                       entity.address, name, phone_no, address)

        entity.name = name
        entity.phone_no = phone_no
        entity.address = address
        self.__repository.update(entity)
Пример #4
0
 def delete_person(self, id):
     activities = self.__act_repo.find_all()
     prs = self.__repository.find_by_id(id)
     acts = []
     for item in activities:
         if id in item.prsids:
             item.prsids.remove(id)
             acts.append(item)
     UndoManager.register_operation(self, UndoHandler.DELETE_PERSON, acts,
                                    prs.id, prs.name, prs.phone_no,
                                    prs.address)
     self.__repository.delete_by_id(id)
Пример #5
0
    def generate_entities(self):
        number_of_entities = 100
        addresses = [
            "Plopilor", "Regele Ferdinand", "Dragos VOda", "Calea Baciului",
            "Magnoliei", "Memorandumului", "Universitatii", "21 Decembrie",
            "Eroilor", "A.I. Cuza"
        ]
        phone_numbers = [
            "0747191247", "0746185625", "0732754624", "0711111111",
            "0799999999", "0712345678"
        ]
        first_names = [
            "Ioana", "Alex", "Vlad", "Dargos", "Bogdan", "Maria", "Andreea",
            "Denisa", "Madalina", "Tudor", "Iulian", "Cristian", "Alin"
        ]
        last_names = [
            "Harangus", "Jercan", "Pop", "Ionescu", "Tanase", "Rusescu",
            "Atanasoaiei", "Medan", "Petcu"
        ]
        descriptions = [
            "Film", "Theatre", "Dinner", "Lunch", "Business meeting", "Doctor",
            "Project", "Team building", "Lectures", "Video games", "Party",
            "Stroll"
        ]
        for i in range(0, number_of_entities):
            address = random.choice(addresses)
            name = random.choice(first_names) + " " + random.choice(last_names)
            phone_number = random.choice(phone_numbers)

            self.__person_service.add_person(i, name, phone_number, address)

            year = random.randint(2018, 2066)
            month = random.randint(1, 12)
            day = random.randint(1, 28)
            hour = random.randint(1, 12)
            minute = random.randint(0, 59)
            date = datetime.date(year, month, day)
            time = datetime.time(hour, minute)

            nb_of_people = random.randint(1, 5)
            prsids = []
            for i in range(0, nb_of_people):
                id = random.randint(
                    0,
                    len(self.__person_service.get_all_people()) - 1)
                prsids.append(id)

            self.__activity_service.add_activity(prsids, date, time,
                                                 random.choice(descriptions))
        UndoManager.clear_op()
 def delete_activity(self, id):
     act = self.__repository.find_by_id(id)
     UndoManager.register_operation(self, UndoHandler.DELETE_ACTIVITY, id,
                                    act.prsids, act.date, act.time,
                                    act.description)
     self.__repository.delete_by_id(id)
 def add_activity(self, prsids, date, time, description):
     id = self.__repository.current_id()
     new_act = Activity(id, prsids, date, time, description)
     UndoManager.register_operation(self, UndoHandler.ADD_ACTIVITY, id,
                                    prsids, date, time, description)
     self.__repository.save(new_act)
Пример #8
0
 def __ui_undo(self):
     UndoManager.undo()