Skip to content

Commit 3408b64

Browse files
authored
Merge pull request #53 from kin-cunico/development-country-class
Development country class
2 parents ea92fd8 + 1346335 commit 3408b64

16 files changed

Lines changed: 120 additions & 15 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Bug Report
2+
description: File a structured bug report.
3+
title: "[BUG]: "
4+
labels: ["bug"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for helping improve the project!
10+
11+
- type: textarea
12+
id: what-happened
13+
attributes:
14+
label: What happened?
15+
description: Describe the bug clearly
16+
placeholder: The application crashes when...
17+
validations:
18+
required: true
19+
20+
- type: textarea
21+
id: steps
22+
attributes:
23+
label: Steps to reproduce
24+
description: How can we replicate the issue?
25+
placeholder: 1. ...
26+
validations:
27+
required: true
28+
29+
- type: textarea
30+
id: logs
31+
attributes:
32+
label: Logs
33+
render: shell
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Describe the bug
2+
A clear and concise description of the problem.
3+
4+
## To Reproduce
5+
Steps to reproduce the behavior:
6+
1.
7+
2.
8+
9+
## Expected behavior
10+
What you expected to happen.
11+
12+
## Additional context
13+
Add any other context.

.github/workflows/main.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,34 @@ jobs:
9393
echo "- Java version: $(java -version 2>&1 | head -n 1)" >> $GITHUB_STEP_SUMMARY
9494
echo "- Tests passed ✅" >> $GITHUB_STEP_SUMMARY
9595
echo "- Coverage report generated: target/site/jacoco/index.html" >> $GITHUB_STEP_SUMMARY
96+
97+
98+
build-and-deploy:
99+
needs: test
100+
runs-on: ubuntu-22.04
101+
permissions: write-all
102+
steps:
103+
104+
- name: Build Run in Docker and Deploy Release
105+
uses: actions/checkout@v4
106+
with:
107+
submodules: recursive
108+
109+
- name: Set up JDK 17
110+
uses: actions/setup-java@v4
111+
with:
112+
java-version: '17'
113+
distribution: 'temurin'
114+
115+
- name: Package and Run docker compose
116+
run: |
117+
mvn package -DskipTests
118+
docker compose up --abort-on-container-exit
119+
- uses: "marvinpinto/action-automatic-releases@latest"
120+
with:
121+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
122+
prerelease: false
123+
draft: false
124+
automatic_release_tag: "latest"
125+
files: |
126+
./target/*.jar

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
restart: always
2020
ports:
2121
# fallback port for app and database
22-
- "33060:3306"
22+
- "3306:3306"
2323
# shared bridge between app and database
2424
networks:
2525
- semgroup4
@@ -33,7 +33,7 @@ services:
3333
app:
3434
build: .
3535
healthcheck:
36-
test: ["CMD", "ping", "-h", "localhost"]
36+
test: ["CMD", "curl", "-h", "localhost"]
3737
interval: 50s
3838
# added so that the app only starts AFTER the database container is up and running
3939
start_period: 40s

src/main/java/com/napier/semGROUP4/App.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import com.napier.semGROUP4.helper.DatabaseHelper;
44
import com.napier.semGROUP4.menu.Menu;
5+
import com.napier.semGROUP4.services.CityService;
6+
7+
import java.sql.Connection;
58

69
/**
710
* Main entry point for the application.
@@ -20,6 +23,7 @@ public static void main(String[] args) {
2023

2124
System.out.println("Initialising app...");
2225
DatabaseHelper db = new DatabaseHelper();
26+
Connection con = null;
2327

2428
// If command-line args are supplied, use them; otherwise default to local.
2529
if (args.length < 2) {
@@ -32,7 +36,8 @@ public static void main(String[] args) {
3236
// Run menu if connected
3337
if (db.isConnected()) {
3438
Menu menu = new Menu(db.getConnection());
35-
menu.menuStart();
39+
menu.menuSample();
40+
3641
} else {
3742
System.out.println("Database connection failed. Exiting...");
3843
}

src/main/java/com/napier/semGROUP4/menu/Menu.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import java.sql.Connection;
44
import java.util.Scanner;
55

6-
import com.napier.semGROUP4.CapitalCity;
7-
import com.napier.semGROUP4.City;
8-
import com.napier.semGROUP4.queries.Language;
6+
import com.napier.semGROUP4.queriesClasses.City;
7+
import com.napier.semGROUP4.queriesClasses.Language;
98
import com.napier.semGROUP4.services.CapitalCityService;
109
import com.napier.semGROUP4.services.CityService;
1110
import com.napier.semGROUP4.services.LanguageService;
@@ -30,6 +29,23 @@ public Menu(Connection con) {
3029
this.capitalCityService = new CapitalCityService(con);
3130
}
3231

32+
public void menuSample() {
33+
String cityName = "Edinburgh";
34+
String languageName = "Arabic";
35+
String continentName = "Asia";
36+
System.out.println("Printing sample to show app is working...");
37+
System.out.println("---- \n");
38+
City city = cityService.getCity(cityName);
39+
System.out.println(city);
40+
System.out.println("---- \n");
41+
Language language = languageService.getLanguage(languageName);
42+
System.out.println(language);
43+
System.out.println("---- \n");
44+
System.out.println(capitalCityService.getAllCapitalsInContinent(continentName));
45+
System.out.println("---- \n");
46+
System.out.println("Exiting app...");
47+
}
48+
3349
/**
3450
* Starts the main menu loop, routing to city, language,
3551
* or capital city report submenus until the user exits.

src/main/java/com/napier/semGROUP4/CapitalCity.java renamed to src/main/java/com/napier/semGROUP4/queriesClasses/CapitalCity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.napier.semGROUP4;
1+
package com.napier.semGROUP4.queriesClasses;
22

33
// Represents a Capital City
44

src/main/java/com/napier/semGROUP4/City.java renamed to src/main/java/com/napier/semGROUP4/queriesClasses/City.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.napier.semGROUP4;
1+
package com.napier.semGROUP4.queriesClasses;
22

33
/**
44
* Represents a city with its name, country, district, and population.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.napier.semGROUP4.queriesClasses;
2+
3+
public class Country {
4+
}

src/main/java/com/napier/semGROUP4/queries/Language.java renamed to src/main/java/com/napier/semGROUP4/queriesClasses/Language.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.napier.semGROUP4.queries;
1+
package com.napier.semGROUP4.queriesClasses;
22

33
/**
44
* Represents a language with its name, number of speakers,

0 commit comments

Comments
 (0)