This project implements a web API for managing schedules. It supports JSON and XML responses and can handle various queries related to assignments, substitutes, and schools.
- JSON and XML Support: The API can return responses in both JSON and XML formats.
- Database Integration: Uses SQLite to store and retrieve schedule data.
- Query Support: Supports four types of queries:
- List all assignments.
- List assignments for a specific teacher.
- List assignments for a specific date.
- List assignments for a specific teacher on a specific date.
- Java Development Kit (JDK): Version 11 or higher.
- SQLite: The database file (
vikarie.db) is included in the project.
.
├── check_g_or_vg.sh # Script to check for G or VG requirements
├── clean.sh # Script to clean up build artifacts
├── compile_servlet_and_start_winstone.sh # Script to compile and run the server
├── winstone.jar # Winstone servlet container
└── www
└── WEB-INF
├── classes # Compiled Java classes
│ └── se
│ └── yrgo
│ └── schedule
│ ├── AccessException.java
│ ├── Assignment.java
│ ├── Assignments.java
│ ├── AssignmentsFactory.java
│ ├── DBHelper.java
│ ├── DatabaseAssignments.java
│ ├── Formatter.java
│ ├── FormatterFactory.java
│ ├── HtmlFormatter.java
│ ├── JsonFormatter.java
│ ├── ParamParser.java
│ ├── ScheduleServlet.java
│ ├── School.java
│ ├── Substitute.java
│ └── XmlFormatter.java
├── lib # Required JAR files
│ ├── org.json.jar
│ └── sqlite-jdbc-3.48.0.0.jar
├── resources # Database file
│ └── vikarie.db
└── web.xml # Web application configuration file
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-nameRun the following script to compile the code and start the Winstone server:
./compile_servlet_and_start_winstone.shThe server will start on port 9090 (HTTP) and 9009 (AJP13).
You can test the API using curl or a web browser.
-
Get all assignments in JSON format:
curl -X GET "http://localhost:9090/v1?format=json" -
Get assignments for a specific date in XML format:
curl -X GET "http://localhost:9090/v1?format=xml&day=2018-01-16" -
Get assignments for a specific teacher:
curl -X GET "http://localhost:9090/v1?format=json&teacher_id=1" -
Get assignments for a specific teacher on a specific date:
curl -X GET "http://localhost:9090/v1?format=xml&teacher_id=1&day=2018-01-16"
To verify the API responses, you can query the SQLite database directly:
sqlite3 www/WEB-INF/resources/vikarie.dbExample query:
SELECT day, name, school_name, address
FROM schedule
JOIN substitute ON schedule.substitute_id = substitute.substitute_id
JOIN school ON schedule.school_id = school.school_id
WHERE day = '2018-01-16 08:00:00';-
Scripts:
compile_servlet_and_start_winstone.sh: Compiles and starts the server.clean.sh: Cleans up build artifacts.check_g_or_vg.sh: Checks for G or VG requirements.
-
JAR Files:
winstone.jar: Winstone servlet container.org.json.jar: JSON library.sqlite-jdbc-3.48.0.0.jar: SQLite JDBC driver.
-
Source Code:
- All Java files under
www/WEB-INF/classes/se/yrgo/schedule/.
- All Java files under
-
Database:
vikarie.db: SQLite database file.
-
Configuration:
web.xml: Web application configuration file.
- IDE-specific files (e.g.,
my-lab.iml,.idea/,.vscode/) are not included in the submission.