Package com.studentgui.apphelpers
Class Helpers
java.lang.Object
com.studentgui.apphelpers.Helpers
Miscellaneous filesystem and small utility helpers used by the UI pages.
Responsibilities include selecting and creating the application home
directory, creating per-student folder hierarchies, and providing a
small roster fallback when no students.json exists.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PathApplication home used for storing app-specific files (defaults to .static final PathRoot directory for persisted application data (alias of APP_HOME).static final PathCanonical database file path used by SQLite operations.static final PathDirectory that holds the database file.static final PathThe project working directory (where the process was started). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCreate a basic folder hierarchy under DATA_ROOT for each student.static StringReturn the default student to use when none is provided by the caller.Attempt to return a simple list of students from PROJECT_ROOT/json_Files/students.json.static PathlatestPlotPath(String studentName, String prefix) Find the latest PNG plot file for a named student with the given prefix.static StringPublic safe name helper for filesystem paths.static voidAttempt to set the JVM working directory to APP_HOME.static PathstudentCollectedDataDir(String studentName) Return the per-student collected data directory path (APP_HOME/StudentDataFiles/{safeName}/collected_data).static PathstudentPlotsDir(String studentName) Return the per-student plots directory path (APP_HOME/StudentDataFiles/{safeName}/plots).static PathstudentReportsDir(String studentName) Return the per-student reports directory path (APP_HOME/StudentDataFiles/{safeName}/reports).static voidEnsure the working data directory exists under APP_HOME.
-
Field Details
-
PROJECT_ROOT
The project working directory (where the process was started). -
APP_HOME
Application home used for storing app-specific files (defaults to ./app_home). -
DATA_ROOT
Root directory for persisted application data (alias of APP_HOME). -
DATABASE_ROOT
Directory that holds the database file. -
DATABASE_PATH
Canonical database file path used by SQLite operations.
-
-
Method Details
-
setStartDir
Attempt to set the JVM working directory to APP_HOME. Fails silently if the property cannot be set in the running environment. -
workingDir
Ensure the working data directory exists under APP_HOME. This is idempotent and safe to call on startup. -
createFolderHierarchy
Create a basic folder hierarchy under DATA_ROOT for each student. This will create StudentDataFiles, backups and errorLogs and a per-student folder with subfolders for data sheets and materials. -
safeName
Public safe name helper for filesystem paths. Mirrors the internal sanitize implementation but is callable from other packages.- Parameters:
s- input display name- Returns:
- sanitized filesystem-safe name (never null)
-
latestPlotPath
Find the latest PNG plot file for a named student with the given prefix. Returns null when no matching files exist.- Parameters:
studentName- display name of studentprefix- file prefix such as "iOS" or "ScreenReader"- Returns:
- path to the most recently modified matching PNG, or null
-
studentPlotsDir
Return the per-student plots directory path (APP_HOME/StudentDataFiles/{safeName}/plots).- Parameters:
studentName- display name of the student- Returns:
- path to the student's plots directory (never null)
-
studentReportsDir
Return the per-student reports directory path (APP_HOME/StudentDataFiles/{safeName}/reports).- Parameters:
studentName- display name of the student- Returns:
- path to the student's reports directory (never null)
-
studentCollectedDataDir
Return the per-student collected data directory path (APP_HOME/StudentDataFiles/{safeName}/collected_data).- Parameters:
studentName- display name of the student- Returns:
- path to the student's collected data directory (never null)
-
getStudents
Attempt to return a simple list of students from PROJECT_ROOT/json_Files/students.json. Falls back to a single 'Test Student' entry when the file is missing or cannot be read.- Returns:
- list of student display names (never null)
-
defaultStudent
Return the default student to use when none is provided by the caller. This is the first entry from getStudents() or a sensible fallback when the roster is empty.- Returns:
- display name of the default student (never null)
-