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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +82,11 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""


# Determine the Java command to use to start the JVM.
Expand All @@ -133,22 +133,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
Loading