Package rs.etf.sab.operations
Interface PackageOperations
public interface PackageOperations
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptAnOffer
(int offerId) boolean
changeType
(int packageId, int newType) boolean
changeWeight
(int packageId, BigDecimal newWeight) boolean
deletePackage
(int packageId) int
driveNextPackage
(String courierUserName) This method invocation starts a drive of deliveries.getAcceptanceTime
(int packageId) Acceptance time for a delivery (package), is time when an offer for that delivery has been accepted.getAllOffersForPackage
(int packageId) Get all offers for specific package.getAllPackagesWithSpecificType
(int type) getDeliveryStatus
(int packageId) This method should return all package ids that are bundled together as a single drive.getPriceOfDelivery
(int packageId) int
insertPackage
(int districtFrom, int districtTo, String userName, int packageType, BigDecimal weight) int
insertTransportOffer
(String couriersUserName, int packageId, BigDecimal pricePercentage) Used for creating new transport offer.
-
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
Used for creating new transport offer. If the price percentage isnull
, 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
- Returns:
List
of primary keys of all offers.
-
getAllOffersForPackage
Get all offers for specific package.- Parameters:
packageId
- - id of a package.- Returns:
List
ofPackageOperations.Pair<Integer,
where first param is id of offer and second one is percentage that courier has given.BigDecimal>
-
deletePackage
boolean deletePackage(int packageId) - Parameters:
packageId
- of a package to be deleted.- Returns:
- success of operation.
-
changeWeight
- Parameters:
packageId
- -newWeight
- -- Returns:
- success of operation.
-
changeType
boolean changeType(int packageId, int newType) - Parameters:
packageId
- -newType
- -- Returns:
- success of operation.
-
getDeliveryStatus
- Parameters:
packageId
- -- Returns:
- - see project documentation for information about status types.
-
null
for no such package.
-
getPriceOfDelivery
- Parameters:
packageId
- -- Returns:
- price of the delivery. If it's not yet calculated, return
null
.
-
getAcceptanceTime
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, returnnull
.
-
getAllPackagesWithSpecificType
- Parameters:
type
- of package to be returned.- Returns:
List
of packages primary keys.
-
getAllPackages
- Returns:
List
of all packages within the system.
-
getDrive
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 returnnull
.
-
driveNextPackage
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.
-