update schema.sql, works now

This commit is contained in:
Jan 2025-01-06 17:34:48 +01:00
parent 010efaa917
commit f71fe83a10
12 changed files with 251 additions and 169 deletions

17
pom.xml
View file

@ -38,20 +38,19 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<dependency> <groupId>org.mariadb.jdbc</groupId>
<groupId>com.h2database</groupId> <!----> <artifactId>mariadb-java-client</artifactId>
<artifactId>h2</artifactId> <version>1.5.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.example</groupId> <groupId>org.thymeleaf</groupId>
<artifactId>batchprocessing</artifactId> <artifactId>thymeleaf-spring6</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -1,16 +0,0 @@
package de.avatic.taricdb.batch.processors;
import java.io.File;
import java.util.List;
import org.springframework.batch.item.ItemProcessor;
public class ExtractZipItemProcessor implements ItemProcessor<File,List<File>> {
@Override
public List<File> process(File item) throws Exception {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -1,5 +0,0 @@
package de.avatic.taricdb.batch.processors;
public class FootnoteItemProcessor {
}

View file

@ -3,9 +3,8 @@ package de.avatic.taricdb.model;
public class UploadFile { public class UploadFile {
int id;
int id; int parentId;
UploadFileType type; UploadFileType type;
byte[] blob;
} }

View file

@ -1,8 +1,8 @@
package de.avatic.taricdb.service; package de.avatic.taricdb.service;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Service;
@Component @Service
public class UploadService { public class UploadService {
} }

View file

@ -1,8 +1,9 @@
package de.avatic.taricdb.batch; package de.avatic.taricdb.tasks;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class ImporterConfiguration { public class ImporterConfiguration {
} }

View file

@ -0,0 +1,8 @@
package de.avatic.taricdb.web;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class NomenclatureController {
}

View file

@ -0,0 +1,16 @@
package de.avatic.taricdb.web.maintenance;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
@Profile("maintenance")
public class MaintenanceController {
@GetMapping("/maintenance")
public String uploadForm() {
return "form.html";
}
}

View file

@ -1,14 +1,16 @@
package de.avatic.taricdb.web; package de.avatic.taricdb.web.maintenance;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@Profile("maintenance")
public class UploadController { public class UploadController {
@PostMapping @PostMapping("/upload")
public void startConversion() { public void uploadZip() {
} }

View file

@ -1,2 +1,6 @@
spring.application.name=taricdb spring.application.name=taricdb
spring.batch.job.enabled= false spring.datasource.url=jdbc:mariadb://localhost:3306/taric
spring.datasource.username=spring
spring.datasource.password=z8gc!w6L$Z5J32$n2Tbw#!Sjj5usxRTxNg67
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.sql.init.mode=always

View file

@ -1,117 +1,134 @@
-- upload tables -- upload tables
create table if not exists "upload_file" create table if not exists `upload_file`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
file_name TEXT, `file_name` VARCHAR(255),
file_type ENUM("zip", "duties", "business_codes", "geo_composition", "geo", "legal_bases", "measure_conditions", "measure_exclusions", `file_type` ENUM('zip', 'duties', 'business_codes', 'geo_composition', 'geo', 'legal_bases', 'measure_conditions', 'measure_exclusions',
"measure_footnotes", "nomenclature_de", "nomenclature_en", , "nomenclature_fr", "declarable_codes", "additional_codes", "box44", 'measure_footnotes', 'nomenclature_de', 'nomenclature_en', 'nomenclature_fr', 'declarable_codes', 'additional_codes', 'box44',
"footnotes", "nomenclature_footnotes") 'footnotes', 'nomenclature_footnotes'),
blob LONGBLOB `blob` LONGBLOB,
parent_zip INT `parent_zip` INT
); );
-- meta tables, like units and certificates -- meta tables, like units and certificates
create table if not exists "legal_base" create table if not exists `legal_base`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
legal_base TEXT, `legal_base` VARCHAR(255),
jounal TEXT, `journal` VARCHAR(255),
page INT, `page` INT,
`date` DATE `date` DATE
); );
create table if not exists "monetary_unit"
create table if not exists `monetary_unit`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
monetary_unit_code CHAR(3) `monetary_unit_code` CHAR(3)
); );
create table if not exists "unit"
create table if not exists `unit`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
unit_code CHAR(3), `unit_code` CHAR(3),
unit_qualifier CHAR(1), `unit_qualifier` CHAR(1),
label TEXT `label` TEXT
); );
create table if not exists "certificate_type"
create table if not exists `certificate_type`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
certificate_type_code CHAR(1) `certificate_type_code` CHAR(1)
); );
create table if not exists "certificate"
create table if not exists `condition_type`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
certificate_code CHAR(4), `condition_type_code` CHAR(1)
FOREIGN KEY (certificate_type_id) REFERENCES certificate_type(id),
start_date DATE,
end_date DATE
); );
create table if not exists "condition_type"
create table if not exists `certificate`
( (
id INT NOT NULL PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
condition_type_code CHAR(1) `certificate_code` CHAR(4),
`certificate_type_id` INT NOT NULL,
`start_date` DATE,
`end_date` DATE,
FOREIGN KEY (certificate_type_id) REFERENCES certificate_type(id)
); );
-- measure meta infos -- measure meta infos
create table if not exists "footnotes" create table if not exists `footnote`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
footnote CHAR(5), footnote CHAR(5),
start_date DATE, start_date DATE,
end_date DATE end_date DATE
); );
create table if not exists "measure_series"
create table if not exists `measure_series`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
measure_series_code CHAR(1) measure_series_code CHAR(1)
); );
create table if not exists "measure"
create table if not exists `measure`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (measure_series_id) REFERENCES measure_series(id), measure_series_id INT NOT NULL,
measure_code CHAR(3), measure_code CHAR(3),
short_desc TEXT, short_desc TEXT,
tm_code TINYINT, tm_code TINYINT,
start_date DATE start_date DATE,
FOREIGN KEY (measure_series_id) REFERENCES measure_series(id)
); );
create table if not exists "measure_footnote"
create table if not exists `measure_footnote`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
footnote_id INT NOT NULL,
measure_id INT NOT NULL,
FOREIGN KEY (footnote_id) REFERENCES footnote(id), FOREIGN KEY (footnote_id) REFERENCES footnote(id),
FOREIGN KEY (measure_id) REFERENCES measure(id) FOREIGN KEY (measure_id) REFERENCES measure(id)
); );
create table if not exists "measure_action"
create table if not exists `measure_action`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
measure_action_code CHAR(1) measure_action_code CHAR(1)
); );
-- geo -- geo
create table if not exists "geo" create table if not exists `geo`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
iso_3166_code CHAR(2), iso_3166_code CHAR(2),
`desc` TEXT `desc` TEXT
); );
create table if not exists "geo_group"
create table if not exists `geo_group`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
geo_group_code CHAR(4), geo_group_code CHAR(4),
abbr TEXT, abbr TEXT,
start_date DATE, start_date DATE,
end_date DATE end_date DATE
); );
create table if not exists "geo_group_membership"
create table if not exists `geo_group_membership`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (geo_id) REFERENCES geo(id), geo_id INT NOT NULL,
FOREIGN KEY (geo_group_id) REFERENCES geo_group(id), geo_group_id INT NOT NULL,
start_date DATE, start_date DATE,
end_date DATE end_date DATE,
FOREIGN KEY (geo_id) REFERENCES geo(id),
FOREIGN KEY (geo_group_id) REFERENCES geo_group(id)
); );
-- nomenclature -- nomenclature
create table if not exists "nomenclature" create table if not exists `nomenclature`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
hscode CHAR(10), hscode CHAR(10),
suffix CHAR(2), suffix CHAR(2),
hierachy TINYINT, hierachy TINYINT,
@ -120,156 +137,201 @@ create table if not exists "nomenclature"
end_date DATE, end_date DATE,
is_leaf BOOLEAN, is_leaf BOOLEAN,
is_leaf_start_date DATE, is_leaf_start_date DATE,
parent_id INT -- TODO: for each child do: alter table nomenclature add constraint parent_nomenclature foreign key (parent_id) references nomenclature(id) on delete set null; parent_id INT NULL -- TODO: for each child do: alter table nomenclature add constraint parent_nomenclature foreign key (parent_id) references nomenclature(id) on delete set null;
); );
create table if not exists "nomenclature_footnote"
create table if not exists `nomenclature_footnote`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
footnote_id INT NOT NULL,
nomenclature_id INT NOT NULL,
FOREIGN KEY (footnote_id) REFERENCES footnote(id), FOREIGN KEY (footnote_id) REFERENCES footnote(id),
FOREIGN KEY (nomenclature_id) REFERENCES nomenclature(id) FOREIGN KEY (nomenclature_id) REFERENCES nomenclature(id)
); );
create table if not exists "additional_code"
create table if not exists `additional_code`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
additional_code CHAR(4), additional_code CHAR(4),
start_date DATE, start_date DATE,
end_date DATE, end_date DATE
); );
-- import, applied_measures -- import, applied_measures
create table if not exists "import" create table if not exists `import`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
nomenclature_id INT NOT NULL,
additional_code_id INT NOT NULL,
geo_id INT NOT NULL,
geo_group_id INT NOT NULL,
FOREIGN KEY (nomenclature_id) REFERENCES nomenclature(id), FOREIGN KEY (nomenclature_id) REFERENCES nomenclature(id),
FOREIGN KEY (additional_code_id) REFERENCES additional_code(id), FOREIGN KEY (additional_code_id) REFERENCES additional_code(id),
FOREIGN KEY (geo_id) REFERENCES geo(id), FOREIGN KEY (geo_id) REFERENCES geo(id),
FOREIGN KEY (geo_group_id) REFERENCES geo_group(id), FOREIGN KEY (geo_group_id) REFERENCES geo_group(id)
); );
create table if not exists "applied_measure"
create table if not exists `applied_measure`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (import_id) REFERENCES import(id), import_id INT NOT NULL,
FOREIGN KEY (measure_id) REFERENCES measure(id), measure_id INT NOT NULL,
FOREIGN KEY (legal_base_id) REFERENCES legal_base(id), legal_base_id INT NOT NULL,
start_date DATE, start_date DATE,
end_date DATE, end_date DATE,
amount TEXT
);
create table if not exists "applied_measure_condition"
(
id INT NOT NULL PRIMARY KEY,
FOREIGN KEY (applied_measure_id) REFERENCES applied_measure(id),
sequence_no INT,
FOREIGN KEY (measure_action_id) REFERENCES measure_action(id),
amount TEXT, amount TEXT,
FOREIGN KEY (import_id) REFERENCES import(id),
FOREIGN KEY (measure_id) REFERENCES measure(id),
FOREIGN KEY (legal_base_id) REFERENCES legal_base(id)
);
create table if not exists `applied_measure_condition`
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
sequence_no INT,
applied_measure_id INT NOT NULL,
measure_action_id INT NOT NULL,
monetary_unit_id INT NOT NULL,
unit_id INT NOT NULL,
certificate_id INT NOT NULL,
condition_type_id INT NOT NULL,
amount TEXT,
FOREIGN KEY (applied_measure_id) REFERENCES applied_measure(id),
FOREIGN KEY (measure_action_id) REFERENCES measure_action(id),
FOREIGN KEY (monetary_unit_id) REFERENCES monetary_unit(id), FOREIGN KEY (monetary_unit_id) REFERENCES monetary_unit(id),
FOREIGN KEY (unit_id) REFERENCES unit(id), FOREIGN KEY (unit_id) REFERENCES unit(id),
FOREIGN KEY (certificate_id) REFERENCES certificate(id), FOREIGN KEY (certificate_id) REFERENCES certificate(id),
FOREIGN KEY (condition_type_id) REFERENCES condition_type(id) FOREIGN KEY (condition_type_id) REFERENCES condition_type(id)
); );
create table if not exists "measure_exclusion"
create table if not exists `measure_exclusion`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
geo_id INT NOT NULL,
applied_measure_id INT NOT NULL,
FOREIGN KEY (geo_id) REFERENCES geo(id), FOREIGN KEY (geo_id) REFERENCES geo(id),
FOREIGN KEY (applied_measure_id) REFERENCES applied_measure(id) FOREIGN KEY (applied_measure_id) REFERENCES applied_measure(id)
); );
-- descriptions -- descriptions
create table if not exists "footnotes_desc" create table if not exists `footnotes_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES footnotes(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES footnote(id)
); );
create table if not exists "measure_desc"
create table if not exists `measure_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES measure(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES measure(id)
); );
create table if not exists "measure_series_desc"
create table if not exists `measure_series_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES measure_series(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES measure_series(id)
); );
create table if not exists "measure_action_desc"
create table if not exists `measure_action_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES measure_action(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES measure_action(id)
); );
create table if not exists "geo_group_desc"
create table if not exists `geo_group_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES geo_group(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES geo_group(id)
); );
create table if not exists "monetary_unit_desc"
create table if not exists `monetary_unit_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES monetary_unit(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES monetary_unit(id)
); );
create table if not exists "unit_desc"
create table if not exists `unit_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES unit(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES unit(id)
); );
create table if not exists "certificate_desc"
create table if not exists `certificate_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES certificate(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES certificate(id)
); );
create table if not exists "certificate_type_desc"
create table if not exists `certificate_type_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES certificate_type(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES certificate_type(id)
); );
create table if not exists "condition_type_desc"
create table if not exists `condition_type_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES condition_type(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES condition_type(id)
); );
create table if not exists "additional_code_desc"
create table if not exists `additional_code_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES additional_code(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES additional_code(id)
); );
create table if not exists "nomenclature_desc"
create table if not exists `nomenclature_desc`
( (
id INT NOT NULL PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
FOREIGN KEY (ref_id) REFERENCES nomenclature(id), ref_id INT NOT NULL,
lang CHAR(2), lang CHAR(2),
`desc` TEXT, `desc` TEXT,
desc_start_date DATE desc_start_date DATE,
FOREIGN KEY (ref_id) REFERENCES nomenclature(id)
); );

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>First Thymeleaf Template</title>
</head>
<body>
<h1>This is it!</h1>
<p>Your very first Thymleaf template.</p>
</body>
</html>