- Clone this repo locally.
- Follow Installation steps
From within the repos root directory execute the following which will pull dependencies, run unit tests, and build the jar in the ./target directory.
mvn clean package
You can then run the jar via the following command.
java -jar target/parking-System-1.0-SNAPSHOT-jar-with-dependencies.jar
To run unit tests alone you can execute the following.
mvn test
- Working on deployment of the code
- Change the UI
The org.parking.model package contains all the Java classes that represent entities in our database. Each class corresponds to a table in the database and includes fields that map to the columns within the table.
The Citation class models the details of a parking citation. It stores information about the citation number, the associated vehicle, the parking lot name where the citation was issued, the category of the violation, the fee charged, payment status, and the date and time when the citation was issued.
int number: Unique identifier for the citation.Vehicle vehicle: The vehicle associated with the citation.String lotName: The name of the parking lot where the citation was issued.String category: The category of the violation.Double fee: The fee charged for the violation.String paymentStatus: The payment status of the citation fee.Date citationDate: The date when the citation was issued.Time citationTime: The time when the citation was issued.
The Driver class encapsulates the information of an individual in our database.
String name: The full name of the driver.String id: The unique identifier for the driver.String status: The current status of the driver, only 'E', 'S', 'V' are allowed.
The Vehicle class represents a vehicle's attributes in the system. It holds information regarding the vehicle's license number, org.parking.model, color, manufacturer, and year of manufacture.
String license: The vehicle's license plate number, acting as a unique identifier.String org.parking.model: The org.parking.model of the vehicle.String color: The color of the vehicle.String manufacturer: The manufacturer of the vehicle.int year: The year the vehicle was manufactured.
The ParkingLot class represents a parking lot within the system. It contains the parking lot's name and address.
String name: The name of the parking lot.String address: The physical address of the parking lot.
The Zone class is designed to represent a specific zone within a parking lot.
String id: The identifier for the zone.String lotName: The name of the parking lot to which the zone belongs.
The Space class defines a parking space within a parking lot. It captures the parking space's number, type, occupancy status, zone identifier, and the lot name it belongs to.
int number: The number assigned to the parking space, serving as a unique identifier within a parking lot zone.String type: The type of parking space (e.g., handicapped, compact, regular).boolean status: The occupancy status of the parking space, wherefalseindicates occupied andtrueindicates available.String zoneID: The identifier of the zone within the parking lot in which the parking space is located.String lotName: The name of the parking lot in which the parking space is located.
The Permit class represents a parking permit within the system. It includes information about the permit's ID, type, the zone it's valid for, the ID of the individual or vehicle it's associated with, the vehicle's license number, the type of parking space it permits, and the valid dates and times.
String permitID: The unique identifier for the permit.String permitType: The type of permit issued.String zoneID: The identifier of the zone where the permit is valid.String associatedID: The identifier of the driver associated with the permit.String carLicenseNum: The license number of the vehicle associated with the permit.String spaceType: The type of parking space allowed by the permit.Date startDate: The start date from which the permit is valid.Date expirationDate: The expiration date of the permit's validity.Time expirationTime: The expiration time.
The implementation of Service classes follows the pattern of defining an interface and its concrete implementations. This approach decouples the org.parking.service's contract from its implementation, allowing for greater flexibility and ease of testing.
The DBServiceoutlines the methods required for establishing a connection to the database and for properly closing database resources.
Connection connectAndReturnConnection() throws SQLException: Establishes a connection to the database and returns theConnectionobject. It throws anSQLExceptionif a connection cannot be established.void close(Connection connection, Statement statement, ResultSet result): Closes the database connection and releases theStatementandResultSetresources. It ensures that all database connections are closed properly to prevent resource leaks.
The CitationsService declares methods for retrieving, creating, updating, deleting, and appealing citations.
Collection<Citation> getAll() throws SQLException: Retrieves a collection of allCitationobjects from the database.Citation getByNumber(int number) throws SQLException: Fetches a singleCitationby its unique number.void createCitation(Citation citation, Boolean createVehicle) throws SQLException: Creates a newCitation, and optionally a newVehiclerecord ifcreateVehicleistrue.void updateCitation(Citation citation) throws SQLException: Updates an existingCitationin the database.void deleteCitationByNumber(int number) throws SQLException: Deletes aCitationfrom the database based on its number.boolean appealCitation(int number): Submits an appeal for aCitationidentified by its number. Returnstrueif the appeal is successful.
The DriversService includes methods to read all driver entries, retrieve by ID, create new records, update existing ones, and delete drivers from the database.
-
Collection<Driver> getAll() throws SQLException: Retrieves allDriverentities from the database. If there's an issue with the database access, it throws anSQLException. -
Driver getById(String id) throws SQLException: Obtains a singleDriverentity using the unique identifier (id). If theDriveris not found, it returnsnull. AnSQLExceptionis thrown in case of SQL errors during the process. -
boolean create(Driver driver) throws SQLException: Attempts to create a newDriverrecord in the database. It returnstrueif the operation is successful,falseotherwise. AnSQLExceptionis thrown in case of SQL errors during the process. -
boolean update(Driver driver) throws SQLException: Updates the details of an existingDriverin the database. It returnstrueif the update is successful,falseotherwise. AnSQLExceptionis thrown if there's an error during the update. -
boolean delete(String id) throws SQLException: Removes aDriverentity from the database using the given identifier (id). It returnstrueif the deletion is successful,falseotherwise. AnSQLExceptionis thrown in case of SQL errors.
The VehicleService defines the methods necessary to retrieve all vehicle records, obtain a vehicle by its license number, and perform create, update, and delete operations on vehicle records.
-
Collection<Vehicle> getAll() throws SQLException: Retrieves all vehicle records from the database. Throws anSQLExceptionif a database access error occurs. -
Vehicle getByLicense(String license) throws SQLException: Fetches a single vehicle from the database using the vehicle's license number as a search criterion. Returnsnullif the vehicle does not exist. Any SQL errors encountered will result in anSQLException. -
boolean create(Vehicle vehicle) throws SQLException: Adds a new vehicle record to the database using the information from the providedVehicleobject. Returnstrueif the operation is successful,falseif it fails. Any SQL errors encountered will result in anSQLException. -
boolean update(Vehicle vehicle) throws SQLException: Updates an existing vehicle's information in the database based on the data in the providedVehicleobject. Returnstrueif the update is successful,falseotherwise. Throws anSQLExceptionin the event of SQL errors. -
boolean delete(String license) throws SQLException: Deletes a vehicle record from the database using the provided license number. Returnstrueif the deletion is successful,falseif it fails. AnSQLExceptionis thrown if SQL errors occur during the operation.
The ParkingLotService provides methods for retrieving all parking lot entries, fetching a specific parking lot by name, and performing create, update, and delete operations on parking lot records.
-
Collection<ParkingLot> getAll(): Retrieves all parking lot records from the database. Returns a collection ofParkingLotobjects. -
ParkingLot getParkingLot(String name): Obtains a singleParkingLotobject from the database based on the parking lot's name. If the parking lot does not exist, this method may returnnull. -
boolean createParkingLot(ParkingLot lot): Attempts to add a new parking lot record to the database. Returnstrueif the creation is successful,falseotherwise. -
boolean updateParkingLot(String name, ParkingLot lot): Updates the details of an existing parking lot in the database. Thenameparameter is used to identify the parking lot to be updated. Returnstrueif the update is successful,falseotherwise. -
boolean deleteParkingLot(String name): Removes a parking lot record from the database using the parking lot's name as an identifier. Returnstrueif the deletion is successful,falseif it fails.
The ZoneService includes methods for retrieving all zones, fetching specific zones by identifiers, creating new zones, updating existing zones, and deleting zones.
-
Collection<Zone> getAll(): Retrieves all zones from the database. -
Zone getZone(String id, String lotName): Fetches a specific zone using its identifier and the name of the parking lot it belongs to. Returnnullif the zone does not exist. -
Collection<Zone> getZonesById(String id): Retrieves all zones matching theidacross all parking lots. -
Collection<Zone> getZonesByLotName(String lotName): Retrieves all zones within a specific parking lot. -
boolean createZone(Zone zone): Attempts to create a new zone record in the database. Returnstrueif the operation is successful,falseotherwise. -
boolean updateZone(Zone originalZone, Zone updatedZone): Updates an existing zone with new information. UsesoriginalZoneto identify the zone to be updated and applies the changes fromupdatedZone. -
boolean deleteZone(Zone zone): Removes a zone record from the database. Returnstrueif the deletion is successful,falseotherwise. -
boolean assignZoneToParkingLot(String oldLot, String zoneID, String newLot): Changes the parking lot association of an existing zone identified byzoneIDfromoldLottonewLot. Returnstrueif the reassignment is successful,falseotherwise. -
boolean createLotAndZone(String address, String lotName, String zoneID): Creates a new parking lot with the specified address and lot name, and a new zone with the given zone identifier within this parking lot. Returnstrueif both the lot and zone are successfully created,falseotherwise.
The PermitsService offers methods for retrieving, entering, updating, and deleting permit information, as well as associating method required for the project.
-
Collection<Permit> getPermitInfo(String permitID) throws SQLException: Retrieves detailed information for a specific permit based on the permit ID. Return an empty collection if there is no permit associated with thepermitID. -
void enterPermitInfo(Permit permit) throws SQLException: Enters new permit information into the database. -
void updatePermitInfo(String permitID, String permitType, String zoneID, String spaceType, Date startDate, Date expirationDate, Time expirationTime) throws SQLException: Updates existing permit information identified by the permit ID.permitID,associatedID, andcarLicenseNumare not allowed to be updated. -
void deletePermitInfo(String permitID) throws SQLException: Deletes permit information from the database based on the permit ID. -
int getPermitsNumberForDriver(String associatedID) throws SQLException: Retrieves the number of permits associated with a specific driver, identified by their associated ID. -
void assignPermitToDriver(String permitID, String permitType, String zoneID, String spaceType, Date startDate, Date expirationDate, Time expirationTime, Driver driver, Vehicle vehicle) throws SQLException: Assigns a permit to a driver and vehicle with the specified details. -
int getVehicleNumberofPermit(String permitID) throws SQLException: Retrieves the number of vehicles associated with a specific permit ID. -
void removeVehicleFromPermit(String permitID, String carLicenseNum) throws SQLException: Removes a vehicle from a permit based on the permit ID and vehicle's license number. -
void addVehicleToPermit(String permitID, String newCarLicenseNum) throws SQLException: Adds a vehicle to a permit using the vehicle's new license number and the permit ID. -
void addVehicleToPermitForEmployee(Permit permit, String newCarLicenseNum) throws SQLException: Adds a new vehicle to a permit associated with an employee, this method will create a new tuple in database -
Collection<Permit> getPermitPerCarLicense(String carLicenseNum) throws SQLException: Retrieves a collection of permits associated with a particular vehicle license number.
The menu classes in this application adopt the same design pattern as the org.parking.service classes, defining interfaces and their specific implementations. This strategy separates the operational interfaces from their execution, increasing the system's flexibility and facilitating easier testing.
Upon starting the application, users are greeted with a main menu offering several options:
- Information Processing
- Maintaining permits and vehicle information for each driver
- Generating and maintaining citations
- Reports
- Exit
Users can:
- Enter, update, or delete information about drivers, parking lots, zones, spaces, vehicles, and permits.
- Assign zones to a parking lot.
- Assign types to specific parking spaces.
- Appeal citations.
- Return to the previous menu.
Each entity within the parking management system has a dedicated menu for data manipulation:
- DriverMenu: Manage driver information, including Create, Update, and Delete.
- ParkingLotMenu:Manage parking lot information, including Create, Update, and Delete.
- ZoneMenu: Manage zone information, including Create, Update, and Delete.
- SpaceMenu: Manage parking space information, including Create, Update, and Delete.
- VehicleMenu: Manage vehicle information, including Create, Update, and Delete.
- PermitMenu: Manager parking information, including Create, Update, and Delete.
This menu is for permit and vehicle management, enabling users to:
- Assign permits to drivers.
- Enter and update permit information.
- Remove vehicles from permits.
- Add vehicles to permits.
- Manage vehicle inventory within the system.
The CitationsMenu is for handling of citations by providing the means to:
- Generate new citations.
- Maintain existing citation records.
- Retrieve all citations or search by citation number.
- Delete citations based on their unique number.
This menu offers report generation tools to:
- Compile citation data across various parameters.
- Report on citation distribution by zone and time range.
- List zones within each parking lot.
- Identify vehicles currently in violation.
- Count employees with permits in a given zone.
- Retrieve permit details via ID or phone number.
- Find available spaces by type in a specific parking lot.