process(File item) throws Exception {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/src/main/java/de/avatic/taricdb/batch/processors/FootnoteItemProcessor.java b/src/main/java/de/avatic/taricdb/batch/processors/FootnoteItemProcessor.java
deleted file mode 100644
index 31d0bc8..0000000
--- a/src/main/java/de/avatic/taricdb/batch/processors/FootnoteItemProcessor.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package de.avatic.taricdb.batch.processors;
-
-public class FootnoteItemProcessor {
-
-}
diff --git a/src/main/java/de/avatic/taricdb/model/UploadFile.java b/src/main/java/de/avatic/taricdb/model/UploadFile.java
index a4b5879..15c8cf6 100644
--- a/src/main/java/de/avatic/taricdb/model/UploadFile.java
+++ b/src/main/java/de/avatic/taricdb/model/UploadFile.java
@@ -3,9 +3,8 @@ package de.avatic.taricdb.model;
public class UploadFile {
-
- int id;
-
+ int id;
+ int parentId;
UploadFileType type;
-
+ byte[] blob;
}
diff --git a/src/main/java/de/avatic/taricdb/service/UploadService.java b/src/main/java/de/avatic/taricdb/service/UploadService.java
index af878c0..2e46abb 100644
--- a/src/main/java/de/avatic/taricdb/service/UploadService.java
+++ b/src/main/java/de/avatic/taricdb/service/UploadService.java
@@ -1,8 +1,8 @@
package de.avatic.taricdb.service;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
-@Component
+@Service
public class UploadService {
}
diff --git a/src/main/java/de/avatic/taricdb/batch/ImporterConfiguration.java b/src/main/java/de/avatic/taricdb/tasks/ImporterConfiguration.java
similarity index 77%
rename from src/main/java/de/avatic/taricdb/batch/ImporterConfiguration.java
rename to src/main/java/de/avatic/taricdb/tasks/ImporterConfiguration.java
index 16d7514..4e12cda 100644
--- a/src/main/java/de/avatic/taricdb/batch/ImporterConfiguration.java
+++ b/src/main/java/de/avatic/taricdb/tasks/ImporterConfiguration.java
@@ -1,8 +1,9 @@
-package de.avatic.taricdb.batch;
+package de.avatic.taricdb.tasks;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ImporterConfiguration {
+
}
diff --git a/src/main/java/de/avatic/taricdb/web/NomenclatureController.java b/src/main/java/de/avatic/taricdb/web/NomenclatureController.java
new file mode 100644
index 0000000..6f39876
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/web/NomenclatureController.java
@@ -0,0 +1,8 @@
+package de.avatic.taricdb.web;
+
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class NomenclatureController {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/web/maintenance/MaintenanceController.java b/src/main/java/de/avatic/taricdb/web/maintenance/MaintenanceController.java
new file mode 100644
index 0000000..fab01e1
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/web/maintenance/MaintenanceController.java
@@ -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";
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/web/UploadController.java b/src/main/java/de/avatic/taricdb/web/maintenance/UploadController.java
similarity index 51%
rename from src/main/java/de/avatic/taricdb/web/UploadController.java
rename to src/main/java/de/avatic/taricdb/web/maintenance/UploadController.java
index af22d4d..1b344ab 100644
--- a/src/main/java/de/avatic/taricdb/web/UploadController.java
+++ b/src/main/java/de/avatic/taricdb/web/maintenance/UploadController.java
@@ -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.RestController;
@RestController
+@Profile("maintenance")
public class UploadController {
- @PostMapping
- public void startConversion() {
+ @PostMapping("/upload")
+ public void uploadZip() {
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b8761f1..738b9fa 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,2 +1,6 @@
spring.application.name=taricdb
-spring.batch.job.enabled= false
\ No newline at end of file
+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
\ No newline at end of file
diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql
index a686437..499daac 100644
--- a/src/main/resources/schema.sql
+++ b/src/main/resources/schema.sql
@@ -1,117 +1,134 @@
-- upload tables
-create table if not exists "upload_file"
+create table if not exists `upload_file`
(
- id INT NOT NULL PRIMARY KEY,
- file_name TEXT,
- 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",
- "footnotes", "nomenclature_footnotes")
- blob LONGBLOB
- parent_zip INT
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `file_name` VARCHAR(255),
+ `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',
+ 'footnotes', 'nomenclature_footnotes'),
+ `blob` LONGBLOB,
+ `parent_zip` INT
);
-- 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,
- legal_base TEXT,
- jounal TEXT,
- page INT,
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `legal_base` VARCHAR(255),
+ `journal` VARCHAR(255),
+ `page` INT,
`date` DATE
);
-create table if not exists "monetary_unit"
+
+create table if not exists `monetary_unit`
(
- id INT NOT NULL PRIMARY KEY,
- monetary_unit_code CHAR(3)
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `monetary_unit_code` CHAR(3)
);
-create table if not exists "unit"
+
+create table if not exists `unit`
(
- id INT NOT NULL PRIMARY KEY,
- unit_code CHAR(3),
- unit_qualifier CHAR(1),
- label TEXT
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `unit_code` CHAR(3),
+ `unit_qualifier` CHAR(1),
+ `label` TEXT
);
-create table if not exists "certificate_type"
+
+create table if not exists `certificate_type`
(
- id INT NOT NULL PRIMARY KEY,
- certificate_type_code CHAR(1)
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `certificate_type_code` CHAR(1)
);
-create table if not exists "certificate"
+
+create table if not exists `condition_type`
(
- id INT NOT NULL PRIMARY KEY,
- certificate_code CHAR(4),
- FOREIGN KEY (certificate_type_id) REFERENCES certificate_type(id),
- start_date DATE,
- end_date DATE
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `condition_type_code` CHAR(1)
);
-create table if not exists "condition_type"
+
+create table if not exists `certificate`
(
- id INT NOT NULL PRIMARY KEY,
- condition_type_code CHAR(1)
+ `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ `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
-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),
start_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)
);
-create table if not exists "measure"
+
+create table if not exists `measure`
(
- id INT NOT NULL PRIMARY KEY,
- FOREIGN KEY (measure_series_id) REFERENCES measure_series(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ measure_series_id INT NOT NULL,
measure_code CHAR(3),
short_desc TEXT,
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 (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)
);
-- 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),
`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),
abbr TEXT,
start_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,
- FOREIGN KEY (geo_id) REFERENCES geo(id),
- FOREIGN KEY (geo_group_id) REFERENCES geo_group(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ geo_id INT NOT NULL,
+ geo_group_id INT NOT NULL,
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
-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),
suffix CHAR(2),
hierachy TINYINT,
@@ -120,156 +137,201 @@ create table if not exists "nomenclature"
end_date DATE,
is_leaf BOOLEAN,
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 (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),
start_date DATE,
- end_date DATE,
+ end_date DATE
);
-- 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 (additional_code_id) REFERENCES additional_code(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,
- FOREIGN KEY (import_id) REFERENCES import(id),
- FOREIGN KEY (measure_id) REFERENCES measure(id),
- FOREIGN KEY (legal_base_id) REFERENCES legal_base(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ import_id INT NOT NULL,
+ measure_id INT NOT NULL,
+ legal_base_id INT NOT NULL,
start_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,
+ 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 (unit_id) REFERENCES unit(id),
FOREIGN KEY (certificate_id) REFERENCES certificate(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 (applied_measure_id) REFERENCES applied_measure(id)
);
-- descriptions
-create table if not exists "footnotes_desc"
+create table if not exists `footnotes_desc`
(
- id INT NOT NULL PRIMARY KEY,
- FOREIGN KEY (ref_id) REFERENCES footnotes(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES measure(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES measure_series(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES measure_action(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES geo_group(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES monetary_unit(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES unit(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES certificate(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES certificate_type(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES condition_type(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES additional_code(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`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,
- FOREIGN KEY (ref_id) REFERENCES nomenclature(id),
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ ref_id INT NOT NULL,
lang CHAR(2),
`desc` TEXT,
- desc_start_date DATE
+ desc_start_date DATE,
+ FOREIGN KEY (ref_id) REFERENCES nomenclature(id)
);
diff --git a/src/main/resources/templates/form.html b/src/main/resources/templates/form.html
new file mode 100644
index 0000000..80006fc
--- /dev/null
+++ b/src/main/resources/templates/form.html
@@ -0,0 +1,12 @@
+
+
+
+
+ First Thymeleaf Template
+
+
+This is it!
+
+Your very first Thymleaf template.
+
+
\ No newline at end of file