-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Song Database Implementation: songLibrary, songDsData, bits and pieces.
Pull includes the implementation of everything relating to Song's database: mainly songLibrary and songDsData. Brief summary; - **Uploaded the standard library of songs.** Currently located in the new folder songLib under src. Any test cases or other pieces of code that currently create new instances of Songs should likely be re-reviewed with this in mind. I already fixed a few, but I might've missed some. - Updated build.gradle to include jaudiotagger - Updated Song entity to include username of uploading user. - Reading/saving from songs.csv, formatted as `ID, uploader, filepath` - Changed artistList from List<String> to String[] - Removed 'length' as Jaudiotagger cannot retrieve it. If we want to show it, it would be on the Jlayer side. Better suited this way, anyway. - Removed isExplicit. Too much of a pain for too little gain. - changed saveSong to return a boolean for a successful song addition. - Created Test file for SongLibrary. KNOWN ISSUES - createFile() assumes the existence of a user admin, as it assigns all songs currently in songLib /to/ admin. (This was only important for creating songs.csv from scratch. It won't do this now that it exists.) - Many files don't have album covers. I'll be creating default covers to put in the BufferedImage parameter later. I don't think anyone is at that stage (which is why I'm putting it off for a later PR), but please don't try accessing the BufferedImage parameter until I do. - When parsing ID names, the 0s at the beginning of the names are omitted. Theoretically, this shouldn't create duplicate IDs anyway, as 1) what's being checked is the parsed ID, and 2) randInt will not create more IDs that start with 0. I'll go back and rename the files to omit the 0s (not that difficult), but I figure its lower priority due to the reasons I stated. - Need to implement safeguard against improperly formatted mp3s (ex. missing genre). There currently aren't any, so it should be temporarily OK, but I have some code smells because of this. Making this a PR despite this so you guys have a better SONG_LIBRARY to work with for now.
- Loading branch information
clin1967
committed
Nov 13, 2022
1 parent
b67bac5
commit d2cd089
Showing
271 changed files
with
471 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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 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,40 +1,33 @@ | ||
package Database; | ||
|
||
import Entities.Song; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
|
||
/** | ||
* Data storage class between database class and entities. | ||
*/ | ||
public class songDsData { | ||
private final Song song; | ||
|
||
public songDsData(int id) { | ||
// TODO: remove once class is complete | ||
this.song = new Song(id, null, null, 0, null, null, false, null); | ||
} | ||
|
||
public songDsData(Song song){ | ||
this.song = song; | ||
} | ||
|
||
public songDsData(String[] data){ | ||
//TODO: Implementation for use when reading in from csv. | ||
// temporary constructor to avoid null exception in other tests | ||
this.song = new Song(0, null, null, 0, null, null, | ||
false, null); | ||
} | ||
|
||
public Song buildFromWrite(){ | ||
//TODO: Helper for String[] data constructor. | ||
return null; | ||
public songDsData(int id, String name, String[] artistList, String genre, | ||
File file, BufferedImage cover, String uploader){ | ||
this.song = new Song(id, name, artistList, genre, file, cover, uploader); | ||
} | ||
|
||
public String buildToWrite(){ | ||
//TODO: Helper to turn into csv formatted line. | ||
return null; | ||
return this.song.getID() + "," + this.song.getUploader() + "," + this.song.getFile().getPath() + "\n"; | ||
} | ||
|
||
public Song getSong() { | ||
return this.song; | ||
} | ||
|
||
public int getID(){ | ||
return this.song.getID(); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.