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 is_voyage_schedule_start_day_and_time_available(voyage_day_and_time): return VoyageLogic.is_voyage_schedule_start_day_and_time_available(voyage_day_and_time)
def get_voyages_by_destination(destination): return VoyageLogic.get_voyages_by_destination(destination)
def get_airplane_voyages(airplane): return VoyageLogic.get_airplane_voyages(airplane)
def get_voyages_by_date(date): return VoyageLogic.get_voyages_by_date(date)
def get_voyages_by_week(week): return VoyageLogic.get_voyages_by_week(week)
def get_completed_voyages():#needs testing return VoyageLogic.get_completed_voyages()
def get_ongoing_voyages(): return VoyageLogic.get_ongoing_voyages()
def change_saved_voyage(saved_voyage, changed_voyage): VoyageLogic.change_saved_voyage(saved_voyage, changed_voyage)
def get_all_voyages(): return VoyageLogic.get_all_voyages()
def save_new_voyage(voyage): VoyageLogic.save_new_voyage(voyage)