Replaced concatenation with a better system
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
9c48d932d6
commit
6228fc9248
@ -65,21 +65,22 @@ public final class DBManager {
|
||||
private static void initializeSubtitle(Connection connection) throws SQLException {
|
||||
logger.debug("Creating subtitle table.");
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
String query = "CREATE TABLE IF NOT EXISTS subtitles\n" +
|
||||
"(\n" +
|
||||
" id int GENERATED ALWAYS AS IDENTITY,\n" +
|
||||
" film_id int NOT NULL,\n" +
|
||||
" language_id int NOT NULL,\n" +
|
||||
" importer varchar(37),\n" +
|
||||
" importer_guild_id text,\n" +
|
||||
" imported_date timestamptz NOT NULL DEFAULT now(),\n" +
|
||||
" UNIQUE (film_id, language_id),\n" +
|
||||
" PRIMARY KEY (id),\n" +
|
||||
" FOREIGN KEY (film_id)\n" +
|
||||
" REFERENCES films (id),\n" +
|
||||
" FOREIGN KEY (language_id)\n" +
|
||||
" REFERENCES languages (id)\n" +
|
||||
");";
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS subtitles
|
||||
(
|
||||
id int GENERATED ALWAYS AS IDENTITY,
|
||||
film_id int NOT NULL,
|
||||
language_id int NOT NULL,
|
||||
importer varchar(37),
|
||||
importer_guild_id text,
|
||||
imported_date timestamptz NOT NULL DEFAULT now(),
|
||||
UNIQUE (film_id, language_id),
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (film_id)
|
||||
REFERENCES films (id),
|
||||
FOREIGN KEY (language_id)
|
||||
REFERENCES languages (id)
|
||||
);""";
|
||||
stmt.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
@ -20,19 +20,20 @@ public final class FilmManager {
|
||||
static void initializeFilm(Connection connection) throws SQLException {
|
||||
logger.debug("Creating film table.");
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
String query = "CREATE TABLE IF NOT EXISTS films\n" +
|
||||
"(\n" +
|
||||
" id int GENERATED ALWAYS AS IDENTITY,\n" +
|
||||
" imdb_id varchar(10) NOT NULL,\n" +
|
||||
" title text NOT NULL,\n" +
|
||||
" year int,\n" +
|
||||
" film_type text NOT NULL,\n" +
|
||||
" season int,\n" +
|
||||
" episode int,\n" +
|
||||
" poster_link text,\n" +
|
||||
" PRIMARY KEY (id),\n" +
|
||||
" UNIQUE (imdb_id)\n" +
|
||||
");";
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS films
|
||||
(
|
||||
id int GENERATED ALWAYS AS IDENTITY,
|
||||
imdb_id varchar(10) NOT NULL,
|
||||
title text NOT NULL,
|
||||
year int,
|
||||
film_type text NOT NULL,
|
||||
season int,
|
||||
episode int,
|
||||
poster_link text,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (imdb_id)
|
||||
);""";
|
||||
stmt.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
@ -141,17 +141,18 @@ public final class LanguageManager {
|
||||
static void initializeLanguages(Connection connection) throws SQLException {
|
||||
logger.debug("Creating language table.");
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
String query = "CREATE TABLE IF NOT EXISTS languages\n" +
|
||||
"(\n" +
|
||||
" id int GENERATED ALWAYS AS IDENTITY,\n" +
|
||||
" alpha3_b char(3) NOT NULL,\n" +
|
||||
" alpha3_t char(3),\n" +
|
||||
" alpha2 char(2),\n" +
|
||||
" english text NOT NULL,\n" +
|
||||
" french text NOT NULL,\n" +
|
||||
" PRIMARY KEY (id),\n" +
|
||||
" UNIQUE (alpha3_b)\n" +
|
||||
");";
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS languages
|
||||
(
|
||||
id int GENERATED ALWAYS AS IDENTITY,
|
||||
alpha3_b char(3) NOT NULL,
|
||||
alpha3_t char(3),
|
||||
alpha2 char(2),
|
||||
english text NOT NULL,
|
||||
french text NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (alpha3_b)
|
||||
);""";
|
||||
stmt.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
@ -54,14 +54,15 @@ public final class PropertyManager {
|
||||
static void initializeProperties(Connection connection) throws SQLException {
|
||||
logger.debug("Creating properties table.");
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
String query = "CREATE TABLE IF NOT EXISTS properties\n" +
|
||||
"(\n" +
|
||||
" id int GENERATED ALWAYS AS IDENTITY,\n" +
|
||||
" app_key text NOT NULL,\n" +
|
||||
" app_value text NOT NULL,\n" +
|
||||
" PRIMARY KEY (id),\n" +
|
||||
" UNIQUE (app_key)\n" +
|
||||
");";
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS properties
|
||||
(
|
||||
id int GENERATED ALWAYS AS IDENTITY,
|
||||
app_key text NOT NULL,
|
||||
app_value text NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (app_key)
|
||||
);""";
|
||||
stmt.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
@ -17,16 +17,17 @@ public final class SubtitleLineManager {
|
||||
static void initializeSubtitleLine(Connection connection) throws SQLException {
|
||||
logger.debug("Creating subtitle_line table.");
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
String query = "CREATE TABLE IF NOT EXISTS subtitle_lines\n" +
|
||||
"(\n" +
|
||||
" id int GENERATED ALWAYS AS IDENTITY,\n" +
|
||||
" subtitle_id int NOT NULL,\n" +
|
||||
" dialog_line text NOT NULL,\n" +
|
||||
" time_code text NOT NULL,\n" +
|
||||
" PRIMARY KEY (id),\n" +
|
||||
" FOREIGN KEY (subtitle_id)\n" +
|
||||
" REFERENCES subtitles (id)\n" +
|
||||
");";
|
||||
String query = """
|
||||
CREATE TABLE IF NOT EXISTS subtitle_lines
|
||||
(
|
||||
id int GENERATED ALWAYS AS IDENTITY,
|
||||
subtitle_id int NOT NULL,
|
||||
dialog_line text NOT NULL,
|
||||
time_code text NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (subtitle_id)
|
||||
REFERENCES subtitles (id)
|
||||
);""";
|
||||
stmt.executeUpdate(query);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user