Interface PackageOperations


public interface PackageOperations
  • Method Details

    • insertPackage

      int insertPackage(int districtFrom, int districtTo, String userName, int packageType, BigDecimal weight)
      Parameters:
      districtFrom - departing district.
      districtTo - arrival district.
      userName - of sender.
      packageType - - see project documentation.
      weight - - see project documentation.
      Returns:
      primary key of newly inserted row. In case of failure, return -1.
    • insertTransportOffer

      int insertTransportOffer(String couriersUserName, int packageId, BigDecimal pricePercentage)
      Used for creating new transport offer. If the price percentage is null, then that should be randomly generated (in bounds of +/-10%).
      Parameters:
      couriersUserName - who is submitting an offer.
      packageId - -
      pricePercentage - - explanation given above.
      Returns:
      primary key of newly inserted offer. In case of failure, return -1.
    • acceptAnOffer

      boolean acceptAnOffer(int offerId)
      Parameters:
      offerId - for the accepted offer.
      Returns:
      success of the operation.
    • getAllOffers

      List<Integer> getAllOffers()
      Returns:
      List of primary keys of all offers.
    • getAllOffersForPackage

      List<PackageOperations.Pair<Integer,BigDecimal>> getAllOffersForPackage(int packageId)
      Get all offers for specific package.
      Parameters:
      packageId - - id of a package.
      Returns:
      List of PackageOperations.Pair<Integer,BigDecimal> where first param is id of offer and second one is percentage that courier has given.
    • deletePackage

      boolean deletePackage(int packageId)
      Parameters:
      packageId - of a package to be deleted.
      Returns:
      success of operation.
    • changeWeight

      boolean changeWeight(int packageId, BigDecimal newWeight)
      Parameters:
      packageId - -
      newWeight - -
      Returns:
      success of operation.
    • changeType

      boolean changeType(int packageId, int newType)
      Parameters:
      packageId - -
      newType - -
      Returns:
      success of operation.
    • getDeliveryStatus

      Integer getDeliveryStatus(int packageId)
      Parameters:
      packageId - -
      Returns:
      - see project documentation for information about status types. - null for no such package.
    • getPriceOfDelivery

      BigDecimal getPriceOfDelivery(int packageId)
      Parameters:
      packageId - -
      Returns:
      price of the delivery. If it's not yet calculated, return null.
    • getAcceptanceTime

      Date getAcceptanceTime(int packageId)
      Acceptance time for a delivery (package), is time when an offer for that delivery has been accepted.
      Parameters:
      packageId - -
      Returns:
      Date - time of acceptance. If it is not yet accepted, return null.
    • getAllPackagesWithSpecificType

      List<Integer> getAllPackagesWithSpecificType(int type)
      Parameters:
      type - of package to be returned.
      Returns:
      List of packages primary keys.
    • getAllPackages

      List<Integer> getAllPackages()
      Returns:
      List of all packages within the system.
    • getDrive

      List<Integer> getDrive(String courierUsername)
      This method should return all package ids that are bundled together as a single drive. Return only packages that are not delivered yet.
      Parameters:
      courierUsername - -
      Returns:
      List of all package ids for current drive of courier. If there is no current drive, then return null.
    • driveNextPackage

      int driveNextPackage(String courierUserName)
      This method invocation starts a drive of deliveries. If drive has already started, then drive next delivery according to the given algorithm (see project documentation).\n So each time this method is called, if there are pending packages, one of them is delivered.\n
      Parameters:
      courierUserName - - username of courier delivering packages.
      Returns:
      packageId of a delivered package,\n -1 if there is nothing to drive for the given courier,\n -2 any other case.