Skip to content

Repository files navigation

Schedule Management Web API

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.

Features

  • 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:
    1. List all assignments.
    2. List assignments for a specific teacher.
    3. List assignments for a specific date.
    4. List assignments for a specific teacher on a specific date.

Requirements

  • Java Development Kit (JDK): Version 11 or higher.
  • SQLite: The database file (vikarie.db) is included in the project.

Project Structure

.
├── 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

How to Run

1. Clone the Repository

git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

2. Compile and Start the Server

Run the following script to compile the code and start the Winstone server:

./compile_servlet_and_start_winstone.sh

The server will start on port 9090 (HTTP) and 9009 (AJP13).

3. Test the API

You can test the API using curl or a web browser.

Example Requests:

  • 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"

4. Verify Against the Database

To verify the API responses, you can query the SQLite database directly:

sqlite3 www/WEB-INF/resources/vikarie.db

Example 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';

Included Files

  • 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/.
  • Database:

    • vikarie.db: SQLite database file.
  • Configuration:

    • web.xml: Web application configuration file.

Excluded Files

  • IDE-specific files (e.g., my-lab.iml, .idea/, .vscode/) are not included in the submission.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages