Starter code for the Studio Project. This is a simple layout connected to a GitHub Classroom that serves as the basis for implementing the studio project.
This example program provides:
- A Java class for the Index page (index.html).
- 6x Java classes for 6 pages. Additional pages can be added by adding additional classes.
- JDBCConnection Java class, that uses the CTG Database. This class contains one method to return all LGAs contained in the Database.
- Examples CSS (
common.css
) file in the resources directory. - Example image (
logo.png
) file in the resources directory with where to locate any images you want on your website - Starting database:
vtp.db
- contains a starting database for you based on the example VtP ER Model.
- Optional helper program (
VTPProcessCSV.java
) that shows an example of how to load the SQLite database by using Java to read the CSV files and JDBC insert statements to update the VtP SQLite database. - Optional helper SQL files (
vtp_create_tables.sql
) that creates two tables (LGA
andPopulationStatistics
) based on the example CTG ER Model.
Classes backing Web pages:
├── PageIndex.java - Homepage page for Level 1 Sub-task A
├── PageMission.java - Mission Statement page for Level 1 Sub-task B
├── PageST2/3.java - Sets of 4 Java files backing the 4 pages for 4 Level2/3 sub-tasks.
Other Classes:
├── java/app - Package location for all Java files for the webserver
│ ├── App.java - Main Application entrypoint for Javalin
│ └── JDBCConnection.java - Example JDBC Connection class based on Studio Project Workshop content
├── java/helper - Location of the helper file for loading SQLite with JDBC
│ └── VTPProcessCSV.java - Helper Java program to load SQLite database from the provided CSVs
Folders:
├── /src/main - Location of all files as required by build configuration
│ ├── java - Java Source location
│ │ ├── app - Package location for all Java files for the webserver
│ │ └── helper - Location of the helper file for loading SQLite with JDBC
│ └── resources - Web resources (html templates / style sheets)
│ ├── css - CSS Style-sheets. Base example style sheet (common.css) provided
│ └── images - Image files. Base example image (RMIT Logo) provided
│
├── /target - build directory (DO NOT MODIFY)
├── /database - The folder to store sqlite database files (*.db files), SQL script (*.sql), and other files related to the database
├── pom.xml - Configure Build (DO NOT MODIFY)
└── README.md - This file ;)
Current Libraries:
- org.xerial.sqlite-jdbc (SQLite JDBC library)
- javalin (lightweight Java Webserver)
- thymeleaf (HTML template) - https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html
Libraries required as dependencies:
- By javalin
- slf4j-simple (lightweight logging)
- By xerial/jdbc
- sqlite-jdbc
There are two places code can be run from
- The main web server program
- the optional helper program to use JDBC to load your SQLite database from the CSVs using Java
You can run the main webserver program similar to the project workshop activities
- Open this project within VSCode
- Allow VSCode to read the pom.xml file
- Allow the popups to run and "say yes" to VSCode configuring the build
- Allow VSCode to download the required Java libraries
- To Build & Run
- Open the
src/main/java/app/App.java
source file, and select "Run" from the pop-up above the main function
- Go to: http://localhost:7001
The helper program in src/main/java/helper/VTPProcessCSV.java
can be run separetly from the main webserver. This gives a demonstration of how you can use Java to read the provided CSV files and store the information in an SQLite database. This example transforms the data in the database/lga_indigenous_status_by_age_by_sex_census_2016.csv
file to match the format of the PopulationStatistics
entity as given in the example ER Model for Milestone 1 for the Voice to Parliament social challenge. That is, the code converts the columns of the CSV into rows that can be loaded into the SQLite database using INSERT
statements.
You can run the optional helper program by
- Open this
src/main/java/helper/VTPProcessCSV.java
source file - Select "Debug" from the pop-up above the main function (or "Debug Java" from the top-right dropdown)
- Allow the program to run
You can modify this file as you wish, for other tables and CSVs. When modifying you may need to pay attention to:
DATABASE
field to change the database locationCSV_FILE
to change which CSV file is bring readcategoty
,status
, andsex
arrays which should match the setup of the CSV file being readINSERT
statement construction to:- Change the table being used
- Column data being stored
The .devcontainer
folder contains configuration files for GitHub Codespaces.
This ensures that when the GitHub classroom is cloned, the workspace is correctly configured for Java (V16) and with the required VSCode extensions.
This folder will not affect a local VSCode setup on a computer.
🚨 DO NOT MODIFY THE CONTENTS OF THIS FOLDER. 🚨
- COSC3056 teaching team, School of Science and Technologies, RMIT Vietnam.
- Dr. Timothy Wiley, School of Computing Technologies, STEM College, RMIT University.
- Prof. Santha Sumanasekara, School of Computing Technologies, STEM College, RMIT University.
Copyright RMIT University (c) 2023