-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
772f9bb
commit d06cf6e
Showing
17 changed files
with
486 additions
and
75 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
64 changes: 64 additions & 0 deletions
64
src/main/java/io/github/lucasstarsz/fxdex/database/DatabaseSetup.java
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.github.lucasstarsz.fxdex.database; | ||
|
||
public class DatabaseSetup { | ||
|
||
public static final String CreateDexes = """ | ||
CREATE TABLE IF NOT EXISTS `dexes` ( | ||
`apiName` tinytext PRIMARY KEY NOT NULL, | ||
`uiName` tinytext NOT NULL, | ||
`apiUrl` tinytext NOT NULL | ||
);"""; | ||
|
||
public static final String CreateDexPokemon = """ | ||
CREATE TABLE IF NOT EXISTS `dexPokemon` ( | ||
`nationalDexNumber` int PRIMARY KEY NOT NULL, | ||
`apiDexName` tinytext UNIQUE NOT NULL | ||
);"""; | ||
|
||
public static final String CreatePokemonNamesToDex = """ | ||
CREATE TABLE IF NOT EXISTS `pokemonNamesToDex` ( | ||
`apiDexName` tinytext PRIMARY KEY NOT NULL, | ||
`nationalDexNumber` int UNIQUE NOT NULL, | ||
FOREIGN KEY (`apiDexName`) REFERENCES `dexPokemon` (`apiDexName`), | ||
FOREIGN KEY (`nationalDexNumber`) REFERENCES `dexPokemon` (`nationalDexNumber`) | ||
);"""; | ||
|
||
public static final String CreateDexEntries = """ | ||
CREATE TABLE IF NOT EXISTS `dexEntries` ( | ||
`nationalDexNumber` int PRIMARY KEY NOT NULL, | ||
`name` tinytext NOT NULL, | ||
`speciesUrl` tinytext NOT NULL, | ||
`genus` tinytext NOT NULL, | ||
`generation` int NOT NULL, | ||
FOREIGN KEY (`nationalDexNumber`) REFERENCES `dexPokemon` (`nationalDexNumber`), | ||
FOREIGN KEY (`name`) REFERENCES `dexPokemon` (`apiDexName`) | ||
);"""; | ||
|
||
public static final String CreateEggGroups = """ | ||
CREATE TABLE IF NOT EXISTS `eggGroups` ( | ||
`nationalDexNumber` int PRIMARY KEY NOT NULL, | ||
`eggGroupsString` tinytext NOT NULL, | ||
FOREIGN KEY (`nationalDexNumber`) REFERENCES `dexEntries` (`nationalDexNumber`) | ||
);"""; | ||
|
||
public static final String CreateFlavorTexts = """ | ||
CREATE TABLE IF NOT EXISTS `flavorTexts` ( | ||
`nationalDexNumber` int NOT NULL, | ||
`region` tinytext NOT NULL, | ||
`regionText` tinytext NOT NULL, | ||
PRIMARY KEY (`nationalDexNumber`, `region`), | ||
FOREIGN KEY (`nationalDexNumber`) REFERENCES `dexEntries` (`nationalDexNumber`), | ||
FOREIGN KEY (`region`) REFERENCES `dexes` (`apiName`) | ||
);"""; | ||
|
||
public static String[] getStartupStatements() { | ||
return new String[]{ | ||
CreateDexes, | ||
CreateDexPokemon, | ||
CreatePokemonNamesToDex, | ||
CreateDexEntries, | ||
CreateEggGroups, | ||
CreateFlavorTexts | ||
}; | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/main/java/io/github/lucasstarsz/fxdex/misc/FileLinks.java
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.github.lucasstarsz.fxdex.misc; | ||
|
||
public class FileLinks { | ||
public static final String DatabaseLocation = System.getProperty("user.home") + "/database.db"; | ||
public static final String JDBCConnectionUrl = "jdbc:sqlite:" + DatabaseLocation; | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/main/java/io/github/lucasstarsz/fxdex/persistence/DexInfoHandler.java
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.github.lucasstarsz.fxdex.persistence; | ||
|
||
import io.github.lucasstarsz.fxdex.model.JsonDexEntryItem; | ||
import io.github.lucasstarsz.fxdex.model.JsonDexItem; | ||
import io.github.lucasstarsz.fxdex.model.JsonDexListItem; | ||
|
||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
public interface DexInfoHandler { | ||
void saveDexItems(List<JsonDexItem> jsonDexItems); | ||
|
||
void saveDexEntry(JsonDexEntryItem jsonDexEntry, String dexEntryLink); | ||
|
||
JsonDexEntryItem loadDexEntry(int nationalDexNumber) throws SQLException; | ||
|
||
void saveDexPokemon(JsonDexListItem dexEntryFromList); | ||
|
||
int loadPokemonNumber(String apiPokemonName); | ||
} |
Oops, something went wrong.