Beispiel #1
0
    def initialize():
        all_voyages = VoyageLogic.get_all_voyages()

        current_date_and_time = datetime.datetime.now()

        for voyage in all_voyages:
            previous_state_of_voyage = voyage.get_state()

            airplane = voyage.get_airplane()

            employees_in_voyage = voyage.get_pilots() + voyage.get_flight_attendants()

            StateLogic.__update_state_of_voyage(voyage, current_date_and_time)

            state_of_voyage = voyage.get_state()

            if airplane:
                #Update the airplanes state
                StateLogic.__update_state_of_entity(airplane, state_of_voyage)

            #Update the states of all the employees
            for employee in employees_in_voyage:
                StateLogic.__update_state_of_entity(employee, state_of_voyage)


            if previous_state_of_voyage != state_of_voyage:
                DataAPI.change_saved_voyage(voyage, voyage)
                DataAPI.change_saved_airplane(airplane, airplane)
 
                __pilot_count = len(voyage.get_pilots())
                for i, employee in enumerate(employees_in_voyage):
                    if i < __pilot_count:
                        DataAPI.change_saved_pilot(employee,employee)
                    else:
                        DataAPI.change_saved_flight_attendant(employee,employee)
 def change_saved_flight_attendant(saved_flight_attendant, changed_flight_attendant):
     DataAPI.change_saved_flight_attendant(saved_flight_attendant, changed_flight_attendant)