Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
430 changes: 237 additions & 193 deletions README.md

Large diffs are not rendered by default.

60 changes: 31 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
plugins {
id 'java'
id 'application'
id 'org.javamodularity.moduleplugin' version '1.8.12'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
id 'application' // For easily running the application
id 'org.openjfx.javafxplugin' version '0.1.0' // Or 0.0.13 if 0.1.0 causes issues
}

group 'AP.Restaurant'
group 'ap.restaurant'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

ext {
junitVersion = '5.10.2'
java {
// Set to Java 24 as requested
sourceCompatibility = JavaVersion.VERSION_24
targetCompatibility = JavaVersion.VERSION_24
}

sourceCompatibility = '23'
targetCompatibility = '23'
javafx {
version = "24"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
}

dependencies {
implementation 'org.postgresql:postgresql:42.7.3'

testImplementation platform('org.junit:junit-bom:5.10.2')
testImplementation 'org.junit.jupiter:junit-jupiter'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

application {
mainModule = 'ap.restaurant.restaurant'
mainClass = 'ap.restaurant.restaurant.HelloApplication'
}

javafx {
version = '17.0.6'
modules = ['javafx.controls', 'javafx.fxml']
applicationDefaultJvmArgs = ['--enable-native-access=javafx.graphics']
}

dependencies {

testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
run {

jvmArgs += [
'--module-path', classpath.asPath,
'--add-modules', application.mainModule.get() + "," + javafx.modules.join(',')
]

}

test {
useJUnitPlatform()}

jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
tasks.withType(JavaCompile) {
options.compilerArgs += "-Xlint:unchecked"
options.encoding = 'UTF-8'
}

jlinkZip {
group = 'distribution'
}
test {
useJUnitPlatform()
}
84 changes: 84 additions & 0 deletions db_setup/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
-- Drop tables if they exist to start fresh (optional, use with caution)
DROP TABLE IF EXISTS OrderDetail CASCADE;
DROP TABLE IF EXISTS "Order" CASCADE; -- "Order" is a keyword, so use quotes
DROP TABLE IF EXISTS MenuItem CASCADE;
DROP TABLE IF EXISTS "User" CASCADE; -- "User" is a keyword, so use quotes

-- User Table
CREATE TABLE "User" (
id SERIAL PRIMARY KEY,
username VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL, -- Store hashed passwords
email VARCHAR(255), -- Optional
is_admin BOOLEAN DEFAULT FALSE -- For bonus admin feature
);

-- MenuItem Table
CREATE TABLE MenuItem (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT, -- Optional
price DECIMAL(10, 2) NOT NULL,
category VARCHAR(100), -- Optional, for bonus
image_url VARCHAR(512) -- Optional, for bonus image feature
);

-- Order Table
CREATE TABLE "Order" (
id SERIAL PRIMARY KEY,
user_id INT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
total_price DECIMAL(10, 2) NOT NULL,
CONSTRAINT fk_user
FOREIGN KEY(user_id)
REFERENCES "User"(id)
ON DELETE CASCADE -- If a user is deleted, their orders are also deleted
);

-- OrderDetail Table
CREATE TABLE OrderDetail (
id SERIAL PRIMARY KEY,
order_id INT NOT NULL,
menu_item_id INT NOT NULL,
quantity INT NOT NULL,
price_per_unit DECIMAL(10, 2) NOT NULL, -- Price at the time of order
CONSTRAINT fk_order
FOREIGN KEY(order_id)
REFERENCES "Order"(id)
ON DELETE CASCADE, -- If an order is deleted, its details are also deleted
CONSTRAINT fk_menu_item
FOREIGN KEY(menu_item_id)
REFERENCES MenuItem(id)
ON DELETE RESTRICT -- Prevent deleting a menu item if it's part of an order detail
);

-- Indexes for better performance on foreign keys
CREATE INDEX idx_order_user_id ON "Order"(user_id);
CREATE INDEX idx_orderdetail_order_id ON OrderDetail(order_id);
CREATE INDEX idx_orderdetail_menu_item_id ON OrderDetail(menu_item_id);

-- Sample Menu Items (added category and a placeholder for image_url)
INSERT INTO MenuItem (name, description, price, category, image_url) VALUES
('Margherita Pizza', 'Classic cheese and tomato pizza', 12.99, 'Pizza', 'images/margherita.png'),
('Pepperoni Pizza', 'Pizza with pepperoni topping', 14.99, 'Pizza', 'images/pepperoni.png'),
('Cheeseburger', 'Beef patty with cheese, lettuce, and tomato', 9.50, 'Burgers', 'images/cheeseburger.png'),
('Veggie Burger', 'Plant-based patty with lettuce and tomato', 8.75, 'Burgers', 'images/veggie_burger.png'),
('Caesar Salad', 'Romaine lettuce, croutons, Parmesan cheese, and Caesar dressing', 7.25, 'Salads', 'images/caesar_salad.png'),
('Spaghetti Carbonara', 'Pasta with eggs, cheese, pancetta, and pepper', 15.50, 'Pasta', 'images/carbonara.png'),
('Coca-Cola', 'Classic cola drink', 2.00, 'Drinks', 'images/coke.png'),
('Orange Juice', 'Freshly squeezed orange juice', 3.50, 'Drinks', 'images/orange_juice.png'),
('Chicken Alfredo', 'Creamy Alfredo pasta with grilled chicken', 16.00, 'Pasta', 'images/chicken_alfredo.png'),
('French Fries', 'Crispy golden french fries', 4.50, 'Sides', 'images/fries.png');

-- Sample User (for testing - password is 'password123')
-- The actual hashing will be done by PasswordUtil in Java.
-- INSERT INTO "User" (username, password_hash, email, is_admin) VALUES
-- ('testuser', 'hashed_password_for_password123', 'test@example.com', FALSE),
-- ('admin', 'hashed_password_for_adminpass', 'admin@example.com', TRUE);

COMMENT ON TABLE "User" IS 'Represents a person using the system (e.g., a customer or admin).';
COMMENT ON COLUMN "User".is_admin IS 'Flag to identify administrator users.';
COMMENT ON TABLE MenuItem IS 'Represents a single item on the restaurant''s menu.';
COMMENT ON COLUMN MenuItem.image_url IS 'URL or path to an image for the menu item.';
COMMENT ON TABLE "Order" IS 'Represents a single order placed by a user.';
COMMENT ON TABLE OrderDetail IS 'Represents a line item in an order.';
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
47 changes: 32 additions & 15 deletions gradlew
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading