Beispiel #1
0
    def getAirplanesByDate(self, datetime_object):
        '''Returns a list with tuples with airplanes that are flying on a date
           and information about the voyage they're in.
           Returns None if there are no voyages on the date'''

        # Gets a list of all airplanes NanAir has
        airplane_list = self.getAirplanes()

        # Returns a list of voyages on a date, returns None if there are
        # no voyages on that date
        voyages_on_date_list = VoyageLL().getVoyageInDateRange(
            datetime_object, datetime_object)
        airplanes_on_date_info_list = []

        if voyages_on_date_list != None:
            # Go through all voyages on the date and match it with an airplane
            for voyage in voyages_on_date_list:
                # If the voyage hasn't been assigned to an airplane,
                # go to the next voyage
                if voyage.getAircraftID() != 'empty':
                    for airplane in airplane_list:
                        if voyage.getAircraftID(
                        ) == airplane.get_planeInsignia():
                            # Add the airplane and information tuple to the list of airplanes
                            # that are in use that day
                            airplanes_on_date_info_list.append((airplane,\
                                voyage.getDestination().getDestinationName(),\
                                    voyage.getDepartureTime(),voyage.getArrivalTimeOut(),\
                                        voyage.getArrivalTimeHome(),voyage.getFlightNumbers()))

        else:
            # All airplanes are free if there's no voyage at the date
            return None

        # All airplanes are free if the airplanes on date info list is empty
        if len(airplanes_on_date_info_list) != 0:
            return airplanes_on_date_info_list
        else:
            return None
Beispiel #2
0
 def showPlanesForNewVoyage(self, depart_time, arrival_time):
     '''Returns a list of class instances of those planes
     that are available at a certain time.'''
     return VoyageLL().getAvailablePlanes(depart_time, arrival_time)
Beispiel #3
0
 def checkDestInput(self, dest_input):
     '''Checks if destination code input is correct. 
     Returns True if it is correct, otherwise False.'''
     return VoyageLL().checkDestInput(dest_input)
Beispiel #4
0
 def get_voyage_duration(self, voyage):
     '''Returns a tuple of hours, minutes of a 
     round trip to a destination inputted by user.'''
     return VoyageLL().getVoyageDuration(voyage)
Beispiel #5
0
 def get_all_voyages_in_date_range(self, start_date, end_date):
     '''Returns a list of instances of all voyages in a specific
     time range inputted by user.'''
     return VoyageLL().getVoyageInDateRange(start_date, end_date)
Beispiel #6
0
class LLAPI():
    def __init__(self):
        self.__ioAPI = IOAPI()
        self.destLL = DestinationLL(self.__ioAPI)
        self.voyLL = VoyageLL(self.__ioAPI)
        self.plaLL = PlaneLL(self.__ioAPI)
        self.empLL = EmployeeLL(self.__ioAPI)

    def getDestinationHeader(self, list_of_destination):
        return self.destLL.getDestinationHeader(list_of_destination)

    def getDestinationValue(self, list_of_destination):
        return self.destLL.getDestinationValue(list_of_destination)

    def getDestinations(self):
        return self.destLL.getDestination()

    def createDestination(self, dest):
        return self.destLL.storeDestinationToFile(dest)

    def getDestinationsContactInfo(self):
        return self.destLL.getDestinationsContactInfo()

    def updateContactInfo(self, line_index, row_index, updated_info):
        return self.destLL.updateContactInfo(line_index, row_index,
                                             updated_info)

    def createVoyage(self, voyage):
        return self.voyLL.createVoyage(voyage)

    def getVoyages(self):
        return self.voyLL.getVoyages()

    def getFullyStaffedVoyages(self):
        return self.voyLL.getFullyStaffedVoyages()

    def getVoyagesWeek(self, first_day_of_week):
        return self.voyLL.getVoyagesWeek(first_day_of_week)

    def getVoyagesDay(self, date):
        return self.voyLL.getVoyagesDay(date)

    def getVoyageHeader(self, voyage_list):
        return self.voyLL.getVoyageHeader(voyage_list)

    def getVoyageValue(self, voyage_list):
        return self.voyLL.getVoyageValue(voyage_list)

    def createPlane(self, plane):
        return self.plaLL.createPlane(plane)

    def getPlanes(self):
        return self.plaLL.getPlanes()

    def getPlaneType(self, registration):
        return self.plaLL.getPlaneType(registration)

    def getPlaneType_list(self):
        return self.plaLL.getPlaneType_list()

    def getAvailablePlanes(self, date, totalTime):
        return self.plaLL.getAvailablePlanes(date, totalTime)

    def createEmployee(self, employee):
        return self.empLL.createEmployee(employee)

    def getEmployees(self):
        return self.empLL.getEmployees()

    def updateEmployee(self, line_index, row_index, updated_info):
        return self.empLL.updateEmployee(line_index, row_index, updated_info)

    def getEmployeeHeader(self, employee_list):
        return self.empLL.getEmployeeHeader(employee_list)

    def getEmployeeValue(self, employee_list):
        return self.empLL.getEmployeeValue(employee_list)

    def getPilotsOrFAs(self, empType):
        return self.empLL.getPilotsOrFAs(empType)

    def getSpecificEmployee(self, emp_id=''):
        return self.empLL.getSpecificEmployee(emp_id)

    def getAvailabilityOfPilots(self, date, listType):
        return self.empLL.getAvailabiltyOfPilots(date, listType)

    def getAvailabiltyOfFAs(self, date, listType):
        return self.empLL.getAvailabiltyOfFAs(date, listType)

    def getAvailabilityOfAll(self, date, listType):
        return self.empLL.getAvailabilityOfAll(date, listType)

    def getChosenEmployee(self, id_list, emp_id):
        return self.empLL.getChosenEmployee(id_list, emp_id)

    def getUnmannedVoyages(self):
        return self.voyLL.getUnmannedVoyages()

    def availablePilotsWithSpecificLicense(self, time, aircraftType):
        return self.empLL.availablePilotsWithSpecificLicense(
            time, aircraftType)

    def storeCrewToFile(self, voyage):
        self.voyLL.storeCrewToFile(voyage)

    def getPlaneStatus(self, dateTime):
        return self.plaLL.getPlaneStatus(dateTime)

    def createDestinationObject(self, destination_str):
        return self.destLL.createDestinationObject(destination_str)

    def checkDateTime(self, dateTime):
        return self.voyLL.checkDateTime(dateTime)
Beispiel #7
0
 def get_upcoming_voyages(self):
     '''Returns a list of all upcoming voyages'''
     return VoyageLL().getUpcomingVoyages()
Beispiel #8
0
 def checkIfTakenDate(self, time_datetime):
     '''Checks if a voyage is registered at an inputted time. 
     Returns True if date is taken, otherwise False.'''
     return VoyageLL().checkIfTakenTime(time_datetime)
Beispiel #9
0
 def change_voyage(self, voyage):
     '''Adds changed info of an existing voyage chosen by user to file. '''
     return VoyageLL().changeVoyageFile(voyage)
Beispiel #10
0
 def __init__(self, ioAPI_in):
     self.__ioAPI_in = ioAPI_in
     self.voyLL = VoyageLL(ioAPI_in)
Beispiel #11
0
class PlaneLL():
    def __init__(self, ioAPI_in):
        self.__ioAPI_in = ioAPI_in
        self.voyLL = VoyageLL(ioAPI_in)

    def createPlane(self, plane):
        return self.__ioAPI_in.storePlaneToFile(plane)

    def getPlanes(self):
        return self.__ioAPI_in.loadPlanesFromFile()

    def getPlaneType_list(self):
        return self.__ioAPI_in.loadPlaneTypesFromFile()

    def getPlaneType(self, registration):
        plane_list = self.__ioAPI_in.loadPlanesFromFile()
        for plane in plane_list:
            if plane['planeInsignia'] == registration:
                return plane['planeTypeId']

    def getAvailablePlanes(self, departureDateTime, totalTime):
        arrivalDateTime = departureDateTime + totalTime
        plane_list = self.getPlanes(
        )  # Starting with all planes available -> unavailable will be removed
        voyage_list = self.__ioAPI_in.loadVoyagesFromFile()
        available_planes_list = []
        voyages_on_same_time_list = []
        for voyage in voyage_list:
            voyage_departure = datetime.datetime.strptime(
                voyage['Departure'], '%Y-%m-%dT%H:%M:%S')
            voyage_arrival = datetime.datetime.strptime(
                voyage['Arrival'], '%Y-%m-%dT%H:%M:%S')
            if (departureDateTime <= voyage_departure <= arrivalDateTime)\
                or (departureDateTime <= voyage_arrival <= arrivalDateTime):
                voyages_on_same_time_list.append(voyage)
        unavailable_planes = []
        for voyage in voyages_on_same_time_list:
            unavailable_planes.append(voyage['Aircraft'])

        for plane in plane_list:
            if plane['planeInsignia'] not in unavailable_planes:
                available_planes_list.append(plane)

        return available_planes_list

    def getPlaneStatus(self, dateTime):
        planesWorking_list, planesNotWorking_list = self.getPlanesWorking(
            dateTime)
        working_odict = collections.OrderedDict()
        planesNotInAir = []
        allPlanes_status = []
        for plane in planesNotWorking_list:
            working_odict = collections.OrderedDict()
            working_odict['Aircraft ID'] = plane['planeInsignia']
            working_odict['Plane Type'] = plane['planeTypeId']
            working_odict['Current Flight Number'] = 'Not in flight'
            working_odict['Destination'] = 'N/A'
            planesNotInAir.append(working_odict)
        self.getPlaneInfo(planesNotInAir)
        planesInAir = self.getPlaneWorkingState(dateTime, planesWorking_list)
        for plane in planesInAir:
            allPlanes_status.append(plane)
        for plane in planesNotInAir:
            allPlanes_status.append(plane)
        return allPlanes_status

    def getPlaneWorkingState(self, dateTime, planesWorking_list):
        planesInAir = []
        working_odict = collections.OrderedDict()
        flightsOnDay = self.getFlightsOnDay(dateTime)
        for plane in planesWorking_list:
            for flight in flightsOnDay:
                flightDeparture = datetime.datetime.strptime(
                    flight['departure'], "%Y-%m-%dT%H:%M:%S")
                flightArrival = datetime.datetime.strptime(
                    flight['arrival'], "%Y-%m-%dT%H:%M:%S")
                if flight['aircraftID'] == plane['planeInsignia'] and \
                    flightDeparture <= dateTime <= flightArrival:
                    working_odict = collections.OrderedDict()
                    working_odict['Aircraft ID'] = plane['planeInsignia']
                    working_odict['Plane Type'] = plane['planeTypeId']
                    working_odict['Current Flight Number'] = flight[
                        'flightNumber']
                    working_odict['Destination'] = flight['arrivingAt']
                    planesInAir.append(working_odict)
        self.getPlaneInfo(planesInAir)
        return planesInAir

    def getPlaneInfo(self, planesInAir):
        planeTypes = self.__ioAPI_in.loadPlaneTypesFromFile()
        for plane in planesInAir:
            for planeType in planeTypes:
                if plane['Plane Type'] == planeType['planeTypeId']:
                    plane['Seats'] = planeType['capacity']

    def getFlightsOnDay(self, dateTime):
        allFlights = self.__ioAPI_in.loadRoutesFromFile()
        flightsOnDay = []
        for flight in allFlights:
            if flight['departure'][:10] == str(dateTime.date()):
                flightsOnDay.append(flight)
        return flightsOnDay

    def getPlanesWorking(self, dateTime):
        self.voyageOnDay_list = self.voyLL.getVoyagesDay(dateTime)
        plane_list = self.__ioAPI_in.loadPlanesFromFile()
        planesNotWorking_list = []
        planesWorking_list = []
        for plane in plane_list:
            for voyage in self.voyageOnDay_list:
                voy_departure = datetime.datetime.strptime(
                    voyage['Departure'], "%Y-%m-%dT%H:%M:%S")
                voy_arrival = datetime.datetime.strptime(
                    voyage['Arrival'], "%Y-%m-%dT%H:%M:%S")
                if plane['planeInsignia'] == voyage[
                        'Aircraft'] and voy_departure <= dateTime <= voy_arrival:
                    planesWorking_list.append(plane)
                else:
                    planesNotWorking_list.append(plane)
        return planesWorking_list, planesNotWorking_list
Beispiel #12
0
class MainLL:
    '''Instances of all sub LL classes created so that MainLL has access to all
       functions within them. The MainLL class functionality is only to be the link 
       between the UI layer and appropriate LL classes. Therefore the MainLL class
       is only function calls'''
    def __init__(self):
        self.staffObject = StaffLL()
        self.airplaneObject = AirplaneLL()
        self.destinationObject = DestinationLL()
        self.voyageObject = VoyageLL()

    def getAllStaffLL(self):
        return self.staffObject.getAllStaff()

    def getStaffByIDLL(self, ssn):
        return self.staffObject.getStaffByID(ssn)

    def getAirplanesLL(self):
        return self.airplaneObject.getAirplanes()

    def getAirplaneByIdLL(self, ID):
        return self.airplaneObject.getAirplaneByID(ID)

    def getVoyageLL(self):
        return self.voyageObject.listVoyage()

    def getAllPilotsLL(self):
        return self.staffObject.getAllPilots()

    def getLicenseDictLL(self):
        return self.airplaneObject.getLicenseDict()

    def getAllCabinCrewLL(self):
        return self.staffObject.getAllCabinCrew()

    def addAirplaneLL(self, newAirplane):
        return self.airplaneObject.addAirplane(newAirplane)

    def getAirplaneStatusLL(self, date, time):
        return self.airplaneObject.getAirplaneStatus(date, time)

    def getStaffDataLL(self, dataList):
        return self.staffObject.getStaffData(dataList)

    def addNewStaffLL(self, newEmployee):
        return self.staffObject.addNewStaff(newEmployee)

    def getAllDestinationsLL(self):
        return self.destinationObject.getDestination()

    def addNewDestinationLL(self, newDestination):
        return self.destinationObject.addNewDestination(newDestination)

    def addNewVoyageLL(self, newFlight):
        return self.voyageObject.addVoyages(newFlight)

    def updateVoyageLL(self, dataList, staffList):
        return self.voyageObject.updateVoyage(dataList, staffList)

    def updateDestinationLL(self, dataList):
        return self.destinationObject.updateDestination(dataList)

    def addLicenseLL(self, dataList):
        return self.airplaneObject.addLicense(dataList)

    def workScheduleLL(self, workDay):
        return self.staffObject.getWorkSchedule(workDay)

    def workScheduleAvailableLL(self, workDay):
        return self.staffObject.getWorkSchedlueAvailable(workDay)

    def generateFlightNumberLL(self, flight):
        return self.voyageObject.generateFlightNumber(flight)

    def availableDatesLL(self):
        return self.voyageObject.availableDates()

    def workWeekLL(self, dataList):
        return self.voyageObject.getWorkWeek(dataList)

    def getAvailableFlightAttendantsLL(self, flight):
        return self.voyageObject.findAvailableFlightAttendants(flight)

    def getAvailableFlightServiceManagersLL(self, flight):
        return self.voyageObject.findAvailableFlightServiceManagers(flight)

    def getAvailableCoPilotsLL(self, flight):
        return self.voyageObject.findAvailableCoPilots(flight)

    def getAvailableCaptainsLL(self, flight):
        return self.voyageObject.findAvailableCaptains(flight)

    def errorCheckDateLL(self, flight):
        return self.voyageObject.errorCheckDate(flight)

    def flightCollisionLL(self, flight):
        return self.voyageObject.flightCollision(flight)

    def findArrivalTimeLL(self, flight):
        return self.voyageObject.findArrivalTime(flight)

    def findAvalibleAirplanesLL(self, flight):
        return self.voyageObject.findAvalibleAirplanes(flight)

    def generateSecondFlightLL(self, flight):
        return self.voyageObject.generateSecondFlight(flight)

    def generadeDestinationIdLL(self):
        return self.destinationObject.generadeDestinationId()
Beispiel #13
0
 def __init__(self):
     self.staffObject = StaffLL()
     self.airplaneObject = AirplaneLL()
     self.destinationObject = DestinationLL()
     self.voyageObject = VoyageLL()
Beispiel #14
0
 def __init__(self):
     self.__ioAPI = IOAPI()
     self.destLL = DestinationLL(self.__ioAPI)
     self.voyLL = VoyageLL(self.__ioAPI)
     self.plaLL = PlaneLL(self.__ioAPI)
     self.empLL = EmployeeLL(self.__ioAPI)
Beispiel #15
0
 def checkPlaneInput(self, plane, list_of_planes):
     '''Checks if inputted plane exists in list of 
     available planes inputted by user.
     Returns true if it exists, otherwise False.'''
     return VoyageLL().checkPlaneInput(plane, list_of_planes)
Beispiel #16
0
 def getOneVoyage(self, voyage_id):
     '''Returns a class instance of voyage with an 
     inputted ID, if it does not exist, None is returned.'''
     return VoyageLL().getOneVoyage(voyage_id)
Beispiel #17
0
 def getArrivalTime(self, departure_datetime, dest):
     '''Finds the arrival time home based on destination and departure time'''
     return VoyageLL().findArrivalTimeHome(departure_datetime, dest)
Beispiel #18
0
 def get_status_of_voyage(self, voyage_instance):
     '''Returns status of voyage at the current time'''
     return VoyageLL().getVoyageStatus(voyage_instance)
Beispiel #19
0
 def getCompletedVoyagesInRange(self, start_datetime, end_datetime):
     '''Gets a list of completed voyages in a date range'''
     return VoyageLL().getCompletedVoyagesInRange(start_datetime,
                                                  end_datetime)
Beispiel #20
0
 def changeSoldSeats(self, voyage, a_str, new_seats_str):
     '''Changes sold seats in a voyage'''
     return VoyageLL().changeSoldSeats(voyage, a_str, new_seats_str)
Beispiel #21
0
 def add_voyage(self, destination, time, plane):
     '''Takes in destination, departure time and plane name and 
     registers a new voyage to file.'''
     return VoyageLL().addVoyage(destination, time, plane)