Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
31af7ea
add deadline
github-classroom[bot] Dec 15, 2025
149c2cf
Adds docker-compose.yml
mattknatt Dec 16, 2025
53f3bad
Merge pull request #1 from ithsjava25/feature/dbsetup
mattknatt Dec 16, 2025
31e5caa
Adds PersistenceManager class
mattknatt Dec 16, 2025
2b06218
Adds entities
mattknatt Dec 16, 2025
f10da7c
Corrects mapping in Album and Artist classes.
mattknatt Dec 16, 2025
99a0dd4
Merge pull request #2 from ithsjava25/feature/persistenceconfig
mattknatt Dec 16, 2025
2072f52
Implements ItunesApiClient
mattknatt Dec 17, 2025
7bbf493
Imports entitymanagerfactory
mattknatt Dec 17, 2025
4c53813
Fixes according to CodeRabbit feedback. Corrects duplicate handling w…
mattknatt Dec 17, 2025
e26c8ca
Merge pull request #3 from ithsjava25/feature/itunesapiconnection
mattknatt Dec 17, 2025
5733aee
repo split
jesperlarsson1910 Dec 18, 2025
da32a4a
repo split
jesperlarsson1910 Dec 18, 2025
157b3a1
Merge pull request #5 from ithsjava25/reposplit
jesperlarsson1910 Dec 18, 2025
583d9c9
Add implementation for AlbumRepositoryl, add implementation for Artis…
simonforsberg Dec 18, 2025
a822044
Merge pull request #6 from ithsjava25/artist_album_repoimpl
simonforsberg Dec 18, 2025
b1fc312
Implements methods from SongRepository
mattknatt Dec 18, 2025
b965860
Merge pull request #7 from ithsjava25/feature/songrepo
mattknatt Dec 18, 2025
d1a4ba8
Updated pom.xml-file with
johanbriger Dec 18, 2025
054eadf
Added Stylesheet
johanbriger Dec 18, 2025
bc75e64
Added MyPod.java for UI
johanbriger Dec 18, 2025
0a1b05a
Added MyPod.java for UI
johanbriger Dec 18, 2025
e032fdf
Added MyPod.java for UI
johanbriger Dec 18, 2025
db5bbb0
Added MyPod.java for UI
johanbriger Dec 18, 2025
1c4943f
Move initialization to a background thread(CodeRabbit)
johanbriger Dec 18, 2025
348ab56
Handle nullpointerexception
johanbriger Dec 18, 2025
012dddb
Added RuntimeException
johanbriger Dec 18, 2025
ce1335a
Initialize UI components before starting the Task:
johanbriger Dec 18, 2025
51bc759
New window to edit playlists(Itunes)
johanbriger Dec 19, 2025
58f9e6a
New window to edit playlists(Itunes)
johanbriger Dec 19, 2025
e2ba577
New Icons för ScrollWheel
johanbriger Dec 19, 2025
1dee24d
Moved all styling to ipod_style.css
johanbriger Dec 19, 2025
4759e22
Added comments
johanbriger Jan 5, 2026
8114044
Added comments
johanbriger Jan 5, 2026
9cdff2a
Added comments
johanbriger Jan 5, 2026
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/_uV8Mn8f)
# 📘 Projektarbete: JPA + Hibernate med GitHub-flöde

Projektet genomförs som antingen en Java CLI-applikation eller med hjälp av JavaFX om ni vill ha ett grafiskt gränssnitt.
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
myPod:
image: mysql:9.5.0
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: myPodDB
MYSQL_USER: user
MYSQL_PASSWORD: pass
ports:
- "3306:3306"
volumes:
- mypod_data:/var/lib/mysql
volumes:
mypod_data:
54 changes: 54 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,64 @@
<version>9.5.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.184</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>25</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>25</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>25</source>
<target>25</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>org.example.MyPod</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
7 changes: 6 additions & 1 deletion src/main/java/org/example/App.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.example;

import javafx.application.Application;


public class App {
public static void main(String[] args) {
System.out.println("Hello There!");

Application.launch(MyPod.class, args);

}
}
67 changes: 67 additions & 0 deletions src/main/java/org/example/DatabaseInitializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.example;

import org.example.entity.Album;
import org.example.entity.Artist;
import org.example.entity.Song;
import org.example.repo.AlbumRepository;
import org.example.repo.ArtistRepository;
import org.example.repo.SongRepository;

import java.util.List;

public class DatabaseInitializer {

private final ItunesApiClient apiClient;

private final SongRepository songRepo;
private final AlbumRepository albumRepo;
private final ArtistRepository artistRepo;

public DatabaseInitializer(ItunesApiClient apiClient, SongRepository songRepo , AlbumRepository albumRepo, ArtistRepository artistRepo) {
this.apiClient = apiClient;
this.songRepo = songRepo;
this.albumRepo = albumRepo;
this.artistRepo = artistRepo;
}

public void init() {
if (songRepo.count() > 0) { //check if there is data already
return;
}

List<String> searches = List.of("the+war+on+drugs",
"refused",
"thrice",
"16+horsepower",
"viagra+boys",
"geese",
"ghost",
"run+the+jewels",
"rammstein",
"salvatore+ganacci",
"baroness"
);
for (String term : searches) {
try {
apiClient.searchSongs(term).forEach(dto -> {
Artist ar = Artist.fromDTO(dto);
if (!artistRepo.existsByUniqueId(ar)) {
artistRepo.save(ar);
}

Album al = Album.fromDTO(dto, ar);
if (!albumRepo.existsByUniqueId(al)) {
albumRepo.save(al);
}

Song s = Song.fromDTO(dto, al);
if (!songRepo.existsByUniqueId(s)) {
songRepo.save(s);
}
});
} catch (Exception e) {
throw new RuntimeException("Failed to fetch or persist data for search term: " + term, e);
}
}
}
}
63 changes: 63 additions & 0 deletions src/main/java/org/example/ItunesApiClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.example;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

public class ItunesApiClient {

private final HttpClient client;
private final ObjectMapper mapper;

public ItunesApiClient() {
this.client = HttpClient.newHttpClient();
this.mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
}

public List<ItunesDTO> searchSongs(String term) throws Exception {

String encodedTerm = URLEncoder.encode(term, StandardCharsets.UTF_8);
String url = "https://itunes.apple.com/search?term=" + encodedTerm + "&entity=song&attribute=artistTerm&limit=8";

HttpRequest request = HttpRequest.newBuilder()
.GET()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(10))
.build();

HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());

// Kontrollera status
if (response.statusCode() != 200) {
throw new RuntimeException("API-fel: " + response.statusCode());
Comment on lines +42 to +44
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove Swedish comments and error messages for consistency.

The codebase uses English for code and comments elsewhere, but this file contains Swedish comments ("Kontrollera status", "Parse JSON") and error messages ("API-fel: "). This creates inconsistency and may confuse international contributors.

🔎 Proposed fix
-        // Kontrollera status
         if (response.statusCode() != 200) {
-            throw new RuntimeException("API-fel: " + response.statusCode());
+            throw new RuntimeException("iTunes API error: " + response.statusCode());
         }
 
-        // Parse JSON
         JsonNode root = mapper.readTree(response.body());

Also applies to: 47-47

🤖 Prompt for AI Agents
In @src/main/java/org/example/ItunesApiClient.java around lines 42-44, Replace
Swedish comments and error text in ItunesApiClient with English for consistency:
change the comment preceding the response.statusCode() check ("Kontrollera
status") to an English comment like "Check response status" and update the
RuntimeException message ("API-fel: ") to an English message such as "API error:
" plus the status code; likewise convert the nearby JSON parse comment ("Parse
JSON") to "Parse JSON". Locate these within the method that performs the HTTP
request/response handling in class ItunesApiClient and update the comment
strings and exception message accordingly.

}

// Parse JSON
JsonNode root = mapper.readTree(response.body());
JsonNode results = root.get("results");
if (results == null || !results.isArray()) {
return List.of();
}

List<ItunesDTO> songs = new ArrayList<>();
for (JsonNode node : results) {
ItunesDTO song = mapper.treeToValue(node, ItunesDTO.class);
songs.add(song);
}

return songs;
}
}

23 changes: 23 additions & 0 deletions src/main/java/org/example/ItunesDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.example;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.time.LocalDate;

@JsonIgnoreProperties(ignoreUnknown = true)
public record ItunesDTO(Long artistId,
Long collectionId,
Long trackId,
String trackName,
String artistName,
String collectionName,
String country,
String primaryGenreName,
LocalDate releaseDate,
Long trackCount,
Long trackTimeMillis) {

public int releaseYear() {
return releaseDate != null ? releaseDate.getYear() : 0;
}
}
Loading