generated from kappsegla/javafx-classrom
-
Notifications
You must be signed in to change notification settings - Fork 59
Moon #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
met4lk1tty
wants to merge
61
commits into
ithsjava25:main
Choose a base branch
from
ithsjava25:moon
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Moon #12
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
478a8f2
add deadline
github-classroom[bot] eca520c
test first commit
met4lk1tty 2760978
Moved test file to correct structure
met4lk1tty 4c2fa50
Enable dev mode and add test logging in Main
met4lk1tty 1815cd2
Implement login loop in Main using System.in for input
met4lk1tty 66cca47
Add menu options to run method
met4lk1tty d0e7c92
add listMoonMissions method
met4lk1tty 008acb8
add getMoonMissionById method
met4lk1tty ce95e82
add countMissionsByYear method
met4lk1tty 687784b
Implement more method cases in switch
met4lk1tty 7493b37
Implement visible id to method listMoonMissions when printing menu op…
met4lk1tty 08cc1b8
Implement createAccount method, passes integration test
met4lk1tty 97ff845
implement createAccount, updateAccountPassword, and listAccounts help…
met4lk1tty c376082
add deleteAccount method with user ID input and confirmation - passe…
met4lk1tty 3b4145a
Create class SimpleDriverManagerDataSource
met4lk1tty aa41e0d
Create interface AccountRepository
met4lk1tty 98a30f1
Create interface MoonMissionRepository
met4lk1tty f40b9f2
Create record Accont and MoonMission
met4lk1tty be0f8b5
Implemented immutable data (records) for Account and MoonMission to r…
met4lk1tty fc8ac6e
Impl AccountRepositoryJdbcImpl class
met4lk1tty 63a1f71
Impl MoonMissionJdbcImpl class
met4lk1tty 46735bd
Impl AppFlow class
met4lk1tty ccf957d
Impl AccountRepository interface
met4lk1tty ebb3209
Impl MoonMissionRepository interface
met4lk1tty 4929580
Impl AccountImpl class
met4lk1tty 27fe08d
Move MoonMission and Account records to model package, update code
met4lk1tty 15310fb
Move AccountRepository and MoonMissionRepository to repository packag…
met4lk1tty 4dbc5b0
update class name CLIFlow to BaseRepository, move to repository package
met4lk1tty b3e3ced
update class name AccountImpl to AccountRepositoryJdbc, move to repos…
met4lk1tty d761c6d
update clas name MoonMissionImpl to MoonMissionRepositoryJdbc, move t…
met4lk1tty 87184b4
move methods from main: isDevMode and resolveConfig to new class Conf…
met4lk1tty 05866a6
move menu loop from main: to package cli and new class menuCLI
met4lk1tty 7687e25
move login from main: to package cli and new class LoginManager
met4lk1tty fab16bf
create class InputReader in package cli
met4lk1tty c72e434
create class AccountCLI in package cli
met4lk1tty aaa0145
create class MoonMissionCLI in package cli
met4lk1tty 75105b4
move method readline from main: to input reader class
met4lk1tty bfbe2cd
move methods listmoonmissions, getmoonmissionbyid, countmissionsbyyea…
met4lk1tty b04d846
update main
met4lk1tty 966a100
update repository classes
met4lk1tty a3b8b13
update MoonMissionCLI
met4lk1tty 1e2d5fc
update MenyCLI
met4lk1tty bd45ee4
update LoginManager
met4lk1tty 50c4fbc
update InputReader
met4lk1tty 645fca3
add interface handleExitOrMenu to CLI package
met4lk1tty cb4e370
update AccountCLI
met4lk1tty 6ddbfe3
add class RepositoryException to repository package
met4lk1tty 089411e
add AccountService and MoonMissionService class to service package
met4lk1tty 9d26027
update main and SimpleDriverManagerDataSource class
met4lk1tty ce8c5ac
update test deleteaccount with yes confirmation of deleting account
met4lk1tty 311755d
Refactor AccountCLI to display accounts using toString() in updatePas…
met4lk1tty 81ccb5f
random commit
met4lk1tty 7efbfd3
Refactor repositories and services to use unchecked RepositoryException
met4lk1tty b32a557
remove comment from record
met4lk1tty d5653e8
Refactor: replace manual year filtering with service.countMissionsByY…
met4lk1tty ba15350
add javadoc comments to cli package
met4lk1tty 1893076
add jacadoc comments to model package
met4lk1tty fb2a25b
add javadoc comments to repository package
met4lk1tty c10196b
add javadoc comments to service package
met4lk1tty 9a9f51b
add javdoc comments to main example package
met4lk1tty c2ed679
add more javadocs because coderabbit said so
met4lk1tty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>com.example</groupId> | ||
| <artifactId>jdbc</artifactId> | ||
| <version>1.0-SNAPSHOT</version> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.13.0</version> | ||
| <configuration> | ||
| <release>${maven.compiler.release}</release> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>3.2.5</version> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-failsafe-plugin</artifactId> | ||
| <version>3.5.4</version> | ||
| <executions> | ||
| <execution> | ||
| <id>integration-test</id> | ||
| <goals> | ||
| <goal>integration-test</goal> | ||
| <goal>verify</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-shade-plugin</artifactId> | ||
| <version>3.5.0</version> | ||
| <executions> | ||
| <execution> | ||
| <phase>package</phase> | ||
| <goals> | ||
| <goal>shade</goal> | ||
| </goals> | ||
| <configuration> | ||
| <transformers> | ||
| <transformer> | ||
| <mainClass>com.example.Main</mainClass> | ||
| </transformer> | ||
| </transformers> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>6.0.1</version> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <artifactId>junit-jupiter-params</artifactId> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <version>3.27.6</version> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <artifactId>byte-buddy</artifactId> | ||
| <groupId>net.bytebuddy</groupId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-junit-jupiter</artifactId> | ||
| <version>5.20.0</version> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <artifactId>mockito-core</artifactId> | ||
| <groupId>org.mockito</groupId> | ||
| </exclusion> | ||
| <exclusion> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>1.21.3</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| <properties> | ||
| <maven.compiler.release>25</maven.compiler.release> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <mockito.version>5.20.0</mockito.version> | ||
| <junit.jupiter.version>6.0.1</junit.jupiter.version> | ||
| <assertj.core.version>3.27.6</assertj.core.version> | ||
| </properties> | ||
| </project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.example; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * Utility class for reading configuration and environment variables. | ||
| */ | ||
| public class ConfigUtils { | ||
|
|
||
| /** | ||
| * Determines if the application should run in development mode. | ||
| * Checks system property "devMode", environment variable "DEV_MODE", | ||
| * and command-line argument "--dev". | ||
| * | ||
| * @param args command-line arguments | ||
| * @return true if dev mode is enabled, false otherwise | ||
| */ | ||
| public static boolean isDevMode(String[] args) { | ||
| if (Boolean.getBoolean("devMode")) return true; | ||
| if ("true".equalsIgnoreCase(System.getenv("DEV_MODE"))) return true; | ||
| return Arrays.asList(args).contains("--dev"); | ||
| } | ||
|
|
||
| /** | ||
| * Resolves a configuration value from system properties or environment variables. | ||
| * Returns null if neither is set. | ||
| * | ||
| * @param propertyKey system property key | ||
| * @param envKey environment variable key | ||
| * @return trimmed configuration value or null if not set | ||
| */ | ||
| public static String resolveConfig(String propertyKey, String envKey) { | ||
| String v = System.getProperty(propertyKey); | ||
| if (v == null || v.trim().isEmpty()) v = System.getenv(envKey); | ||
| return (v == null || v.trim().isEmpty()) ? null : v.trim(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,62 +1,56 @@ | ||
| package com.example; | ||
|
|
||
| import java.sql.Connection; | ||
| import java.sql.DriverManager; | ||
| import java.sql.SQLException; | ||
| import java.util.Arrays; | ||
|
|
||
| import com.example.cli.*; | ||
| import com.example.repository.*; | ||
| import com.example.service.*; | ||
|
|
||
| /** | ||
| * Entry point for the Moon Mission application. | ||
| * | ||
| * <p> | ||
| * Initializes the development database if dev mode is enabled, sets up repositories, | ||
| * services, and CLI components, handles user login, and shows the main menu. | ||
| * </p> | ||
| */ | ||
| public class Main { | ||
|
|
||
| static void main(String[] args) { | ||
| if (isDevMode(args)) { | ||
| /** | ||
| * Starts the application. | ||
| * | ||
| * @param args Command-line arguments. Supports "--dev" to enable dev mode. | ||
| */ | ||
| public static void main(String[] args) { | ||
| if (ConfigUtils.isDevMode(args)) { | ||
| DevDatabaseInitializer.start(); | ||
| } | ||
| new Main().run(); | ||
| } | ||
|
|
||
| public void run() { | ||
| // Resolve DB settings with precedence: System properties -> Environment variables | ||
| String jdbcUrl = resolveConfig("APP_JDBC_URL", "APP_JDBC_URL"); | ||
| String dbUser = resolveConfig("APP_DB_USER", "APP_DB_USER"); | ||
| String dbPass = resolveConfig("APP_DB_PASS", "APP_DB_PASS"); | ||
| String jdbcUrl = ConfigUtils.resolveConfig("APP_JDBC_URL", "APP_JDBC_URL"); | ||
| String dbUser = ConfigUtils.resolveConfig("APP_DB_USER", "APP_DB_USER"); | ||
| String dbPass = ConfigUtils.resolveConfig("APP_DB_PASS", "APP_DB_PASS"); | ||
|
|
||
| if (jdbcUrl == null || dbUser == null || dbPass == null) { | ||
| throw new IllegalStateException( | ||
| "Missing DB configuration. Provide APP_JDBC_URL, APP_DB_USER, APP_DB_PASS " + | ||
| "as system properties (-Dkey=value) or environment variables."); | ||
| throw new IllegalStateException("Missing DB configuration."); | ||
| } | ||
|
|
||
| try (Connection connection = DriverManager.getConnection(jdbcUrl, dbUser, dbPass)) { | ||
| } catch (SQLException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| //Todo: Starting point for your code | ||
| } | ||
| SimpleDriverManagerDataSource dataSource = new SimpleDriverManagerDataSource(jdbcUrl, dbUser, dbPass); | ||
| boolean devMode = ConfigUtils.isDevMode(args); | ||
|
|
||
| /** | ||
| * Determines if the application is running in development mode based on system properties, | ||
| * environment variables, or command-line arguments. | ||
| * | ||
| * @param args an array of command-line arguments | ||
| * @return {@code true} if the application is in development mode; {@code false} otherwise | ||
| */ | ||
| private static boolean isDevMode(String[] args) { | ||
| if (Boolean.getBoolean("devMode")) //Add VM option -DdevMode=true | ||
| return true; | ||
| if ("true".equalsIgnoreCase(System.getenv("DEV_MODE"))) //Environment variable DEV_MODE=true | ||
| return true; | ||
| return Arrays.asList(args).contains("--dev"); //Argument --dev | ||
| } | ||
| AccountRepositoryJdbc accountRepo = new AccountRepositoryJdbc(dataSource, devMode); | ||
| MoonMissionRepositoryJdbc missionRepo = new MoonMissionRepositoryJdbc(dataSource, devMode); | ||
|
|
||
| /** | ||
| * Reads configuration with precedence: Java system property first, then environment variable. | ||
| * Returns trimmed value or null if neither source provides a non-empty value. | ||
| */ | ||
| private static String resolveConfig(String propertyKey, String envKey) { | ||
| String v = System.getProperty(propertyKey); | ||
| if (v == null || v.trim().isEmpty()) { | ||
| v = System.getenv(envKey); | ||
| AccountService accountService = new AccountService(accountRepo); | ||
| MoonMissionService missionService = new MoonMissionService(missionRepo); | ||
|
|
||
| InputReader input = new InputReader(); | ||
|
|
||
| AccountCLI accountCLI = new AccountCLI(accountService, input); | ||
| MoonMissionCLI missionCLI = new MoonMissionCLI(missionService, input); | ||
| MenuCLI menu = new MenuCLI(accountCLI, missionCLI, input); | ||
|
|
||
| LoginManager loginManager = new LoginManager(accountService, input); | ||
|
|
||
| if (loginManager.login()) { | ||
| menu.showMainMenu(); | ||
| } | ||
| return (v == null || v.trim().isEmpty()) ? null : v.trim(); | ||
| } | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/example/SimpleDriverManagerDataSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package com.example; | ||
|
|
||
| import javax.sql.DataSource; | ||
| import java.sql.Connection; | ||
| import java.sql.DriverManager; | ||
| import java.sql.SQLException; | ||
|
|
||
| /** | ||
| * Simple DataSource implementation using DriverManager. | ||
| * | ||
| * <p> | ||
| * Provides basic JDBC connections using a URL, username, and password. | ||
| * Only getConnection methods are supported; other DataSource features throw | ||
| * UnsupportedOperationException. | ||
| * </p> | ||
| */ | ||
| public class SimpleDriverManagerDataSource implements DataSource { | ||
| private final String url; | ||
| private final String username; | ||
| private final String password; | ||
|
|
||
| /** | ||
| * Creates a new DataSource with the given JDBC parameters. | ||
| * | ||
| * @param url the JDBC URL | ||
| * @param username the database username | ||
| * @param password the database password | ||
| */ | ||
| public SimpleDriverManagerDataSource(String url, String username, String password) { | ||
| this.url = url; | ||
| this.username = username; | ||
| this.password = password; | ||
| } | ||
|
|
||
| @Override | ||
| public Connection getConnection() throws SQLException { return DriverManager.getConnection(url, username, password); } | ||
|
|
||
| @Override | ||
| public Connection getConnection(String username, String password) throws SQLException { return DriverManager.getConnection(url, username, password); } | ||
|
|
||
| @Override public <T> T unwrap(Class<T> iface) { throw new UnsupportedOperationException(); } | ||
| @Override public boolean isWrapperFor(Class<?> iface) { return false; } | ||
| @Override public java.io.PrintWriter getLogWriter() { throw new UnsupportedOperationException(); } | ||
| @Override public void setLogWriter(java.io.PrintWriter out) { throw new UnsupportedOperationException(); } | ||
| @Override public void setLoginTimeout(int seconds) { throw new UnsupportedOperationException(); } | ||
| @Override public int getLoginTimeout() { return 0; } | ||
| @Override public java.util.logging.Logger getParentLogger() { throw new UnsupportedOperationException(); } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ithsjava25/ithsjava25-java-databas-jdbc-javafx-classrom
Length of output: 2977
🌐 Web query:
Java 25 release date stable version 2025💡 Result:
The stable (General Availability) release date for Java (JDK) 25 was September 16, 2025. [1][2]
Sources:
Add
dependency-reduced-pom.xmlto.gitignore.The file
dependency-reduced-pom.xmlis automatically generated bymaven-shade-pluginduring the build process and should be excluded from version control (add to.gitignore) to avoid merge conflicts and repository bloat. Add the following line to.gitignore:Note: Java 25 is now stable (released September 2025) and intentionally configured for this classroom project; no action needed on that front.
🤖 Prompt for AI Agents