diff --git a/pom.xml b/pom.xml
index bbb7ef2..b28c19e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,20 +38,38 @@
org.springframework.boot
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-data-jdbc
+
org.mariadb.jdbc
mariadb-java-client
- 1.5.7
org.springframework.boot
spring-boot-starter-test
test
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
org.thymeleaf
thymeleaf-spring6
+
+ org.apache.poi
+ poi
+ 5.0.0
+
+
+ org.apache.poi
+ poi-ooxml
+ 5.0.0
+
diff --git a/src/main/java/de/avatic/taricdb/TaricConfiguration.java b/src/main/java/de/avatic/taricdb/TaricConfiguration.java
new file mode 100644
index 0000000..5ef2f37
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/TaricConfiguration.java
@@ -0,0 +1,11 @@
+package de.avatic.taricdb;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+@Configuration
+@EnableAsync
+public class TaricConfiguration {
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/file/InMemFile.java b/src/main/java/de/avatic/taricdb/helper/file/InMemFile.java
new file mode 100644
index 0000000..30020a3
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/file/InMemFile.java
@@ -0,0 +1,25 @@
+package de.avatic.taricdb.helper.file;
+
+public class InMemFile {
+ private String name;
+ private byte[] blob;
+
+
+ public InMemFile(String name, byte[] blob) {
+ this.name = name;
+ this.blob = blob;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getFileSize() {
+ return blob.length;
+ }
+
+ public byte[] getBlob() {
+ return blob;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/stats/HeapStat.java b/src/main/java/de/avatic/taricdb/helper/stats/HeapStat.java
new file mode 100644
index 0000000..b1fd12e
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/stats/HeapStat.java
@@ -0,0 +1,14 @@
+package de.avatic.taricdb.helper.stats;
+
+public class HeapStat {
+
+ public static String getHeapUtilization() {
+
+ long maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;
+ long allocatedMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
+ long freeMemory = Runtime.getRuntime().freeMemory() / 1024 / 1024;
+
+ return "[ Memory used: " + (allocatedMemory - freeMemory) + " MB | total utilization: " + ((((allocatedMemory - freeMemory))*100)/maxMemory) + "%]";
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/UploadFileType.java b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelFileType.java
similarity index 59%
rename from src/main/java/de/avatic/taricdb/model/UploadFileType.java
rename to src/main/java/de/avatic/taricdb/helper/workbook/ExcelFileType.java
index d185ffd..ccf56f8 100644
--- a/src/main/java/de/avatic/taricdb/model/UploadFileType.java
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelFileType.java
@@ -1,7 +1,6 @@
-package de.avatic.taricdb.model;
+package de.avatic.taricdb.helper.workbook;
-public enum UploadFileType {
- ZIP("null"),
+public enum ExcelFileType {
DUTIES("Duties Import 01-99.xlsx"),
BUSINESS_CODE("TARIC Business codes.xlsx"),
GEO_COMPOSITION("Geographical areas composition.xlsx"),
@@ -14,13 +13,29 @@ public enum UploadFileType {
NOMENCLATURE_FR("Nomenclature FR.xlsx"),
NOMENCLATURE_EN("Nomenclature EN.xlsx"),
DECLARABLE_CODES("Declarable codes.xlsx"),
- ADDITIONAL_CODES("Additional codes descriptions.xlsx"),
+ ADDITIONAL_CODES("Additional codes descriptions.xlsx"), //OK
BOX_44("Box 44 codes of the SAD.xlsx"),
FOOTNOTES("Footnotes descriptions.xlsx"),
NOMENCLATURE_FOOTNOTES("Nomenclature footnotes.xlsx");
- UploadFileType(String fileName) {
-
+ private String fileName;
+
+
+ ExcelFileType(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public static ExcelFileType fromFileName(String fileName) {
+ for (ExcelFileType type : values()) {
+ if (type.fileName.equals(fileName)) {
+ return type;
+ }
+ }
+ return null;
}
}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/ExcelHeader.java b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelHeader.java
new file mode 100644
index 0000000..f067fad
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelHeader.java
@@ -0,0 +1,27 @@
+package de.avatic.taricdb.helper.workbook;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.xssf.usermodel.XSSFRow;
+
+public class ExcelHeader {
+
+ private List header = new ArrayList();
+
+ public ExcelHeader(XSSFRow row) {
+ row.cellIterator().forEachRemaining(cell -> {
+ header.add(cell.getStringCellValue().trim());
+ });
+ }
+
+ public int getIndex(String string) {
+ return header.indexOf(string);
+ }
+
+ public String toString() {
+ return header.toString();
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/ExcelRow.java b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelRow.java
new file mode 100644
index 0000000..28eb4d4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelRow.java
@@ -0,0 +1,138 @@
+package de.avatic.taricdb.helper.workbook;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Row;
+
+public class ExcelRow {
+
+ private static final String DATE_FORMAT = "dd-MM-yyyy";
+ private static final String DATE_FORMAT2 = "dd.MM.yyyy";
+ private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
+ private static final DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern(DATE_FORMAT2);
+
+
+ private List values = new ArrayList<>();
+
+ private ExcelHeader header;
+
+ private int index;
+
+ private Row row;
+
+ private List date;
+
+ public ExcelRow(Row row, ExcelHeader header) {
+ this.date = new ArrayList<>();
+ this.row = row;
+
+ row.cellIterator().forEachRemaining(cell -> {
+ LocalDate cellDate = null;
+
+ switch(cell.getCellType())
+ {
+ case NUMERIC:
+ double value = cell.getNumericCellValue();
+
+ if(DateUtil.isCellDateFormatted(cell))
+ {
+ cellDate = cell.getLocalDateTimeCellValue().toLocalDate();
+ }
+ if(isInteger(value)) {
+ values.add(String.valueOf((int)value));
+ } else {
+ values.add(String.valueOf(value));
+ }
+
+ break;
+ case BLANK:
+ case STRING:
+ values.add(cell.getStringCellValue());
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported cell type: " + cell.getCellType());
+ }
+
+ date.add(cellDate);
+ });
+
+ this.header = header;
+ this.index = row.getRowNum();
+
+ }
+
+ public boolean isInteger(double number){
+ return Math.ceil(number) == Math.floor(number);
+ }
+
+
+
+ @SuppressWarnings("unchecked")
+ public T getAs(String string, Class clazz) {
+ int columnIdx = getColumnIdx(string.trim());
+
+
+ if (columnIdx == -1) {
+ throw new IllegalArgumentException("Column " + string + " not found, available columns are: " + header);
+ }
+
+ if ( clazz == String.class) {
+ return (T) values.get(columnIdx);
+ }
+
+ if (clazz == Integer.class) {
+ if (values.get(columnIdx).isEmpty()) {
+ return null;
+ }
+
+ return (T) Integer.valueOf(values.get(columnIdx));
+ }
+
+ if (clazz == Boolean.class) {
+ if (values.get(columnIdx).isEmpty()) {
+ return null;
+ }
+
+ return (T) Boolean.valueOf(Integer.valueOf(values.get(columnIdx)) == 1);
+ }
+
+ if (clazz == LocalDate.class) {
+
+
+ if (this.date.get(columnIdx) != null) {
+ return (T) this.date.get(columnIdx);
+ }
+
+ if (values.get(header.getIndex(string)).isEmpty()) {
+ return null;
+ }
+
+ try {
+ return (T) LocalDate.parse(values.get(columnIdx), formatter2);
+ } catch (Exception e) {
+ return (T) LocalDate.parse(values.get(columnIdx), formatter);
+ }
+ }
+
+ return null;
+ }
+
+ private int getColumnIdx(String string) {
+ int idx = header.getIndex(string);
+
+
+
+ return idx;
+ }
+
+
+
+ public int index() {
+ return index;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/ExcelTable.java b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelTable.java
new file mode 100644
index 0000000..5d9e41f
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelTable.java
@@ -0,0 +1,80 @@
+package de.avatic.taricdb.helper.workbook;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import de.avatic.taricdb.helper.file.InMemFile;
+
+public class ExcelTable {
+
+ private ExcelTableType type;
+
+ private InMemFile file;
+
+ private XSSFWorkbook workbook;
+
+ private XSSFSheet sheet;
+
+ private int recordCount;
+
+ private ExcelHeader header;
+
+ public ExcelTable(ExcelTableType type, InMemFile file) throws IOException {
+ this.file = file;
+ this.type = type;
+
+ this.workbook = new XSSFWorkbook(new ByteArrayInputStream(file.getBlob()));
+ this.sheet = getSheet();
+ this.recordCount = countRecords();
+
+ this.header = new ExcelHeader(sheet.getRow(0));
+
+ }
+
+ private XSSFSheet getSheet() {
+ if (type.getSheetIndex() == -1) {
+ return workbook.getSheet(type.getSheetName());
+ }
+
+ return workbook.getSheetAt(type.getSheetIndex());
+ }
+
+ private int countRecords() {
+ if (sheet == null) {
+ return -1;
+ }
+ return sheet.getPhysicalNumberOfRows();
+ }
+
+
+
+ public ExcelFileType getFileType() {
+ return type.getFileType();
+ }
+
+ public ExcelTableType getType() {
+ return type;
+ }
+
+ public List getRows() {
+ ArrayList rows = new ArrayList<>();
+
+ sheet.iterator().forEachRemaining(row -> {
+ if (row.getRowNum() != 0) {
+ rows.add(new ExcelRow(row , header));
+ }
+ });
+
+ return rows;
+ }
+
+ public int size() {
+ return recordCount;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/ExcelTableType.java b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelTableType.java
new file mode 100644
index 0000000..116f430
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/ExcelTableType.java
@@ -0,0 +1,69 @@
+
+package de.avatic.taricdb.helper.workbook;
+
+public enum ExcelTableType {
+ ADDITIONAL_CODE(ExcelFileType.ADDITIONAL_CODES, "Sheet1", 0),
+ APPLIED_MEASURES(ExcelFileType.DUTIES, "Sheet 1", 0),
+ APPLIED_MEASURE_CONDITION(ExcelFileType.MEASURE_CONDITIONS, "Sheet 1", 0),
+ CERTIFICATE_TYPE(ExcelFileType.BUSINESS_CODE, "Certificate types", -1),
+ CERTIFICATE(ExcelFileType.BOX_44, "Sheet 1 ", 0),
+ CONDITION_TYPE(ExcelFileType.BUSINESS_CODE, "Condition types", -1),
+ FOOTNOTES(ExcelFileType.FOOTNOTES, "Sheet1", 0),
+ GEO_GROUP(ExcelFileType.GEO, "Sheet 1", 0),
+ GEO_MEMBERSHIP(ExcelFileType.GEO_COMPOSITION, "Sheet 1", 0),
+ LEGAL_BASE(ExcelFileType.LEGAL_BASES, "Sheet1 1", 0),
+ MEASURE(ExcelFileType.BUSINESS_CODE, "Measure types", -1),
+ MEASURE_FOOTNOTES(ExcelFileType.MEASURE_FOOTNOTES, "Sheet 1", 0),
+ MEASURE_SERIES(ExcelFileType.BUSINESS_CODE, "Measure type series", -1),
+ MEASURE_ACTION(ExcelFileType.BUSINESS_CODE, "Measure actions", -1),
+ MEASURE_EXCLUSION(ExcelFileType.MEASURE_EXCLUSIONS, "Sheet 1", 0),
+ MONETARY_UNIT(ExcelFileType.BUSINESS_CODE, "Monetary Units", -1),
+ NOMENCLATURE_DE(ExcelFileType.NOMENCLATURE_DE, "Sheet1", 0),
+ NOMENCLATURE_EN(ExcelFileType.NOMENCLATURE_EN, "Sheet1", 0),
+ NOMENCLATURE_FR(ExcelFileType.NOMENCLATURE_FR, "Sheet1", 0),
+ NOMENCLATURE_DECLAREABLE(ExcelFileType.DECLARABLE_CODES, "Sheet 1", 0),
+ NOMENCLATURE_FOOTNOTE(ExcelFileType.NOMENCLATURE_FOOTNOTES, "Sheet 1", 0),
+ UNIT(ExcelFileType.BUSINESS_CODE, "Measurement Units & Qualifiers", -1);
+
+
+ private String sheetName;
+ private int sheetIndex;
+ private ExcelFileType fileType;
+
+ ExcelTableType(ExcelFileType fileType, String sheetName, int sheetIndex) {
+ this.sheetName = sheetName;
+ this.sheetIndex = sheetIndex;
+ this.fileType = fileType;
+ }
+
+ static ExcelTableType fromFileName(String name) {
+ ExcelFileType fileType = ExcelFileType.fromFileName(name);
+
+ if (fileType == null) {
+ return null;
+ }
+
+ for (ExcelTableType tableType : values()) {
+ if (fileType.equals(tableType.getFileType())) {
+ return tableType;
+ }
+ }
+
+ return null;
+ }
+
+ int getSheetIndex() {
+ return sheetIndex;
+ }
+
+ String getSheetName() {
+ return sheetName;
+ }
+
+ public ExcelFileType getFileType() {
+ return fileType;
+ }
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/AdditionalCodeConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/AdditionalCodeConverter.java
new file mode 100644
index 0000000..6ed6fac
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/AdditionalCodeConverter.java
@@ -0,0 +1,46 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.AdditionalCode;
+import de.avatic.taricdb.model.AdditionalCodeDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class AdditionalCodeConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public AdditionalCodeConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection codes = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ if (row.index() == 0) {
+ return;
+ }
+
+ String code = row.getAs("Add code", String.class);
+
+ AdditionalCode addCode = codes.stream().filter(c -> c.getAdditionalCode().equals(code)).findAny().orElse(null);
+
+ if (addCode == null) {
+ addCode = new AdditionalCode(code, row.getAs("Start date", LocalDate.class), row.getAs("End date", LocalDate.class));
+ codes.add(addCode);
+ }
+
+ addCode.addDesc(new AdditionalCodeDesc(row.getAs("Language", String.class), row.getAs("Description", String.class), row.getAs("Descr. start date", LocalDate.class)));
+
+
+ });
+
+ return codes;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/AppliedMeasureConditionConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/AppliedMeasureConditionConverter.java
new file mode 100644
index 0000000..6c2194d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/AppliedMeasureConditionConverter.java
@@ -0,0 +1,102 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.AppliedMeasureConditionWrapper;
+import de.avatic.taricdb.model.AppliedMeasureCondition;
+import de.avatic.taricdb.model.Certificate;
+import de.avatic.taricdb.model.ConditionType;
+import de.avatic.taricdb.model.MeasureAction;
+import de.avatic.taricdb.model.MonetaryUnit;
+import de.avatic.taricdb.model.Unit;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class AppliedMeasureConditionConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public AppliedMeasureConditionConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection conditions = new ArrayList<>();
+ Collection conditionTypes = referenceStorage.getEntites(ConditionType.class);
+ Collection certificates = referenceStorage.getEntites(Certificate.class);
+ Collection monetaryUnits = referenceStorage.getEntites(MonetaryUnit.class);
+ Collection units = referenceStorage.getEntites(Unit.class);
+ Collection actions = referenceStorage.getEntites(MeasureAction.class);
+
+ table.getRows().forEach((row) -> {
+ if (row.index() == 0) {
+ return;
+ }
+
+ String hsCode = row.getAs("Goods code", String.class);
+ String originCode = row.getAs("Origin code", String.class);
+ String additionalCode = row.getAs("Add code", String.class);
+ String orderNumber = row.getAs("Order No.", String.class);
+
+ String monetaryUnitCode = row.getAs("Mon. unit", String.class);
+ String unitCode = row.getAs("Meas. unit", String.class);
+ String amount = row.getAs("Cond. amount", String.class);
+ Integer sequenceNumber = row.getAs("Sequence", Integer.class);
+
+ Integer measureCode = row.getAs("Meas. type code", Integer.class);
+
+ Certificate certificate = certificates.stream()
+ .filter(c -> c.getCertificateCode().equals(row.getAs("Certificate", String.class))).findAny()
+ .orElse(null);
+ MeasureAction action = actions.stream()
+ .filter(c -> c.getMeasureActionCode().equals(row.getAs("Meas. action", String.class))).findAny()
+ .orElse(null);
+ ConditionType conditionType = conditionTypes.stream()
+ .filter(c -> c.getConditionTypeCode().equals(row.getAs("Meas. cond", String.class))).findAny()
+ .orElse(null);
+
+ Unit unit = null;
+ if (unitCode != null) {
+ unit = units.stream().filter(c -> c.getUnitCode().equals(unitCode)).findAny().orElse(null);
+ }
+
+ MonetaryUnit monetaryUnit = null;
+ if (monetaryUnitCode != null) {
+ monetaryUnit = monetaryUnits.stream().filter(c -> c.getMonetaryUnitCode().equals(monetaryUnitCode))
+ .findAny().orElse(null);
+ }
+
+ AppliedMeasureConditionWrapper condition = conditions.stream()
+ .filter(c -> c.getHsCode().equals(hsCode)
+ && c.getOriginCode().equals(originCode)
+ && c.getAdditionalCode().equals(additionalCode)
+ && c.getOrderNumber().equals(orderNumber)
+ && c.getAppliedMeasureCondition().getSequenceNo().equals(sequenceNumber)
+ && c.getAppliedMeasureCondition().getConditionType().getId().equals(conditionType.getId())
+ && c.getMeasureCode().equals(measureCode))
+ .findAny().orElse(null);
+
+ if (condition == null) {
+ condition = new AppliedMeasureConditionWrapper(
+ new AppliedMeasureCondition(AggregateReference.to(action.getId()),
+ monetaryUnit == null ? null : AggregateReference.to(monetaryUnit.getId()),
+ unit == null ? null : AggregateReference.to(unit.getId()),
+ certificate == null ? null : AggregateReference.to(certificate.getId()),
+ AggregateReference.to(conditionType.getId()), amount, sequenceNumber),
+ hsCode, originCode, additionalCode, orderNumber, measureCode);
+ conditions.add(condition);
+ } else {
+ throw new IllegalArgumentException("Duplicate applied measure condtion found: " + hsCode + " "
+ + originCode + " " + additionalCode + " " + orderNumber);
+ }
+
+ });
+
+ return conditions;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/AppliedMeasureConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/AppliedMeasureConverter.java
new file mode 100644
index 0000000..dab1f08
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/AppliedMeasureConverter.java
@@ -0,0 +1,137 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.stats.HeapStat;
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.AppliedMeasureConditionWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.AppliedMeasureWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.MeasureExclusionWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.MeasureFootnoteWrapper;
+import de.avatic.taricdb.model.AppliedMeasure;
+import de.avatic.taricdb.model.AppliedMeasureCondition;
+import de.avatic.taricdb.model.LegalBase;
+import de.avatic.taricdb.model.Measure;
+import de.avatic.taricdb.model.MeasureExclusion;
+import de.avatic.taricdb.model.MeasureFootnote;
+import de.avatic.taricdb.service.ReferenceStorageService;
+import de.avatic.taricdb.service.SetupStatusService;
+
+public class AppliedMeasureConverter implements ExcelTableConverter {
+
+ Logger log = LoggerFactory.getLogger(AppliedMeasureConverter.class);
+
+ private ReferenceStorageService referenceStorage;
+ private SetupStatusService statusService;
+ private int recordOffset;
+ private int count = 0;
+
+ public AppliedMeasureConverter(ReferenceStorageService referenceStorage, SetupStatusService statusService, int recordCurrentCount) {
+ this.referenceStorage = referenceStorage;
+ this.statusService = statusService;
+ this.recordOffset = recordCurrentCount;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection appliedMeasures = new ArrayList<>();
+
+ Collection measureFootnoteWrappers = referenceStorage
+ .getEntites(MeasureFootnoteWrapper.class);
+ Collection measures = referenceStorage.getEntites(Measure.class);
+ Collection measureExclusions = referenceStorage
+ .getEntites(MeasureExclusionWrapper.class);
+ Collection appliedMeasureConditions = referenceStorage
+ .getEntites(AppliedMeasureConditionWrapper.class);
+
+ Collection legalBases = referenceStorage.getEntites(LegalBase.class);
+
+ table.getRows().forEach((row) -> {
+ count++;
+ if (row.index() == 0) {
+ return;
+ }
+
+
+ if (count % 10000 == 0) {
+ int percentage = Math.round((count*100)/table.getRows().size());
+ log.info("applied measures processed: "+percentage+"% - " + count + " of " + table.getRows().size() + " " + HeapStat.getHeapUtilization(), true, null);
+ statusService.setStatus(recordOffset, "Convert applied measures ... " + percentage + "% ", true , null);
+ }
+
+ String hsCode = row.getAs("Goods code", String.class);
+ String origin = row.getAs("Origin code", String.class);
+ String addCode = row.getAs("Add code", String.class);
+ Integer measureCode = row.getAs("Meas. type code", Integer.class);
+ String measureCodeStr = row.getAs("Meas. type code", String.class);
+ String legalBase = row.getAs("Legal base", String.class);
+ String orderNumber = row.getAs("Order No.", String.class);
+ Integer orderNumberInt = row.getAs("Order No.", Integer.class);
+
+ LocalDate startDate = row.getAs("Start date", LocalDate.class);
+ LocalDate endDate = row.getAs("End date", LocalDate.class);
+ String amount = row.getAs("Duty", String.class);
+
+ Measure measure = measures.stream().filter(c -> c.getMeasureCode().equals(measureCodeStr)).findAny()
+ .orElse(null);
+
+ if (null == measure) {
+ throw new RuntimeException("Measure not found: " + row.getAs("Meas. type code", String.class));
+ }
+
+ Set foundMeasureFootnotes = measureFootnoteWrappers.stream()
+ .filter(s -> s.getMeasureCode().equals(measureCode) && s.getHsCode().equals(hsCode)
+ && s.getOrigin().equals(origin) && s.getAddCode().equals(addCode) && s.getOrderNumber().equals(orderNumber))
+ .map(MeasureFootnoteWrapper::getMeasureFootnote).collect(Collectors.toSet());
+
+ Set foundMeasureExclusions = null;
+
+ if(isNumeric(origin)) {
+ Integer originCode = Integer.parseInt(origin);
+ foundMeasureExclusions = measureExclusions.stream()
+ .filter(s -> s.getMeasureCode().equals(measureCode) && s.getHsCode().equals(hsCode)
+ && s.getOriginCode().equals(originCode) && s.getAddCode().equals(addCode) && s.getOrderNumber().equals(orderNumber))
+ .map(MeasureExclusionWrapper::getMeasureExclusion).collect(Collectors.toSet());
+ }
+
+
+ Set foundMeasureConditions = appliedMeasureConditions.stream()
+ .filter(s -> s.getHsCode().equals(hsCode) && s.getOriginCode().equals(origin)
+ && s.getAdditionalCode().equals(addCode) && s.getOrderNumber().equals(orderNumber) && s.getMeasureCode().equals(measureCode))
+ .map(AppliedMeasureConditionWrapper::getAppliedMeasureCondition).collect(Collectors.toSet());
+
+ LegalBase foundLegalBase = legalBases.stream().filter(s -> s.getLegalBase().equals(legalBase)).findAny()
+ .orElse(null);
+
+ if (legalBase == null) {
+ throw new RuntimeException("Legal base not found: " + legalBase);
+ }
+
+ AppliedMeasureWrapper appliedMeasure = new AppliedMeasureWrapper(
+ new AppliedMeasure(AggregateReference.to(measure.getId()), foundMeasureFootnotes,
+ foundLegalBase == null ? null : AggregateReference.to(foundLegalBase.getId()), foundLegalBase == null ? legalBase : null, foundMeasureExclusions,
+ foundMeasureConditions, startDate, endDate, amount, orderNumberInt),
+ hsCode, addCode, origin);
+
+ appliedMeasures.add(appliedMeasure);
+
+ });
+
+ return appliedMeasures;
+ }
+
+
+ private boolean isNumeric(String str) {
+ return str.matches("-?\\d+(\\.\\d+)?"); // match a number with optional '-' and decimal.
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/CertificateConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/CertificateConverter.java
new file mode 100644
index 0000000..013d5b1
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/CertificateConverter.java
@@ -0,0 +1,57 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.Certificate;
+import de.avatic.taricdb.model.CertificateDesc;
+import de.avatic.taricdb.model.CertificateType;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class CertificateConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+
+ public CertificateConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection certs = new ArrayList<>();
+ Collection certTypes = referenceStorage.getEntites(CertificateType.class);
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("Certificate code", String.class);
+
+
+ if (row.index() == 0) {
+ return;
+ }
+
+
+ Certificate cert = certs.stream().filter(s -> s.getCertificateCode().equals(code)).findAny().orElse(null);
+
+ if (cert == null) {
+ String certTypeCode = String.valueOf(code.charAt(0));
+ CertificateType foundCertType = referenceStorage.getEntites(CertificateType.class).stream().filter(s -> s.getCertificateTypeCode().equals(certTypeCode)).findAny().orElse(null);
+
+ cert = new Certificate(code, row.getAs("Start date", LocalDate.class), row.getAs("End date", LocalDate.class), AggregateReference.to(foundCertType.getId()));
+ certs.add(cert);
+ }
+
+ cert.addCertificateDesc(new CertificateDesc(row.getAs("Language", String.class), row.getAs("Description", String.class), row.getAs("Description start date", LocalDate.class)));
+
+ });
+
+
+ return certs;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/CertificateTypeConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/CertificateTypeConverter.java
new file mode 100644
index 0000000..770c1e5
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/CertificateTypeConverter.java
@@ -0,0 +1,42 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.CertificateType;
+import de.avatic.taricdb.model.CertificateTypeDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class CertificateTypeConverter implements ExcelTableConverter {
+
+ public CertificateTypeConverter(ReferenceStorageService referenceStorage) {
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection certTypes = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("CERT_TYP_COD", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ CertificateType certType = certTypes.stream().filter(s -> s.getCertificateTypeCode().equals(code)).findAny().orElse(null);
+
+ if (certType == null) {
+ certType = new CertificateType(code);
+ certTypes.add(certType);
+ }
+
+ certType.addCertificateTypeDesc(new CertificateTypeDesc(row.getAs("LANG_COD", String.class), row.getAs("DESCR", String.class), null));
+
+ });
+
+
+ return certTypes;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/ConditionTypeConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/ConditionTypeConverter.java
new file mode 100644
index 0000000..9d096a0
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/ConditionTypeConverter.java
@@ -0,0 +1,45 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.ConditionType;
+import de.avatic.taricdb.model.ConditionTypeDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class ConditionTypeConverter implements ExcelTableConverter {
+
+
+
+ public ConditionTypeConverter(ReferenceStorageService referenceStorage) {
+
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection conditionTypes = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("MEAS_COND_COD", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ ConditionType conditionType = conditionTypes.stream().filter(s -> s.getConditionTypeCode().equals(code)).findAny().orElse(null);
+
+ if (conditionType == null) {
+ conditionType = new ConditionType(code);
+ conditionTypes.add(conditionType);
+ }
+
+ conditionType.addConditionTypeDesc(new ConditionTypeDesc(row.getAs("LANG_COD", String.class), row.getAs("DESCR", String.class), null));
+
+ });
+
+
+ return conditionTypes;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/DeclarableCodesConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/DeclarableCodesConverter.java
new file mode 100644
index 0000000..93a7fcc
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/DeclarableCodesConverter.java
@@ -0,0 +1,35 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.DeclarableCodesWrapper;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class DeclarableCodesConverter implements ExcelTableConverter {
+
+ public DeclarableCodesConverter(ReferenceStorageService referenceStorageService) {
+
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection declarableGoods = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String goodsCode = row.getAs("Goods code", String.class);
+ String hsCode = goodsCode.substring(0, 10);
+ String suffix = goodsCode.substring(11, 13);
+ Boolean isLeaf = row.getAs("IS_LEAF", Boolean.class);
+ LocalDate declStartDate = row.getAs("Decl. start date", LocalDate.class);
+
+ declarableGoods.add(new DeclarableCodesWrapper(hsCode, suffix, declStartDate, isLeaf));
+
+ });
+
+ return declarableGoods;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/ExcelTableConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/ExcelTableConverter.java
new file mode 100644
index 0000000..0861760
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/ExcelTableConverter.java
@@ -0,0 +1,11 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+
+public interface ExcelTableConverter {
+
+ public Collection convert(ExcelTable table);
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/FootnoteConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/FootnoteConverter.java
new file mode 100644
index 0000000..c464d3d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/FootnoteConverter.java
@@ -0,0 +1,45 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.Footnote;
+import de.avatic.taricdb.model.FootnotesDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class FootnoteConverter implements ExcelTableConverter {
+
+ public FootnoteConverter(ReferenceStorageService referenceStorage) {
+ }
+
+ public Collection convert(ExcelTable table) {
+ List footnotes = new ArrayList<>();
+
+
+ table.getRows().forEach((row) -> {
+ String txt = row.getAs("Footnote", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ Footnote footnote = footnotes.stream().filter(f -> f.getFootnote().equals(txt)).findAny().orElse(null);
+
+ if (footnote == null) {
+ footnote = new Footnote(txt, row.getAs("Description", String.class),
+ row.getAs("Start date", LocalDate.class), row.getAs("End date", LocalDate.class));
+ footnotes.add(footnote);
+ }
+
+ footnote.addFootnotesDesc(new FootnotesDesc(row.getAs("Description", String.class),
+ row.getAs("Language", String.class), row.getAs("Descr. start date", LocalDate.class)));
+ });
+
+
+ return footnotes;
+
+ }
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoConverter.java
new file mode 100644
index 0000000..28e8b26
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoConverter.java
@@ -0,0 +1,54 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.Geo;
+import de.avatic.taricdb.model.GeoDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class GeoConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public GeoConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection geos = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String origin = row.getAs("Or./Dest.", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ if(!isNumeric(origin)) {
+ Geo geo = geos.stream().filter(s -> s.getIso3166Code().equals(origin)).findAny().orElse(null);
+
+ if (geo == null) {
+ geo = new Geo(origin);
+ geos.add(geo);
+ }
+
+ geo.addGeoDescription(new GeoDesc(row.getAs("Language", String.class), row.getAs("Description", String.class), row.getAs("Descr. start date", LocalDate.class)));
+
+ }
+
+
+ });
+
+
+ return geos;
+ }
+
+ private boolean isNumeric(String str) {
+ return str.matches("-?\\d+(\\.\\d+)?"); // match a number with optional '-' and decimal.
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoGroupConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoGroupConverter.java
new file mode 100644
index 0000000..e263aee
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoGroupConverter.java
@@ -0,0 +1,67 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.GeoGroupMembershipWrapper;
+import de.avatic.taricdb.model.GeoGroup;
+import de.avatic.taricdb.model.GeoGroupDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class GeoGroupConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public GeoGroupConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection groups = new ArrayList<>();
+ Collection memberships = referenceStorage.getEntites(GeoGroupMembershipWrapper.class);
+
+ table.getRows().forEach((row) -> {
+ String origin = row.getAs("Or./Dest.", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ if (isNumeric(origin)) {
+ Integer groupId = Integer.parseInt(origin);
+
+ GeoGroup geoGroup = groups.stream().filter(s -> s.getGeoGroupCode().equals(origin)).findAny()
+ .orElse(null);
+
+ if (geoGroup == null) {
+ Set foundMemberships = memberships.stream()
+ .filter(s -> s.getGeoGroupId().equals(groupId)).collect(Collectors.toSet());
+
+ geoGroup = new GeoGroup(origin, row.getAs("Abbrev.", String.class),
+ row.getAs("Start date", LocalDate.class), row.getAs("End date", LocalDate.class),
+ foundMemberships.stream().map(GeoGroupMembershipWrapper::getGeoGroupMembership)
+ .collect(Collectors.toSet()));
+
+ groups.add(geoGroup);
+ }
+
+ geoGroup.addGeoGroupDesc(new GeoGroupDesc(row.getAs("Language", String.class),
+ row.getAs("Description", String.class), row.getAs("Descr. start date", LocalDate.class)));
+
+ }
+
+ });
+
+ return groups;
+ }
+
+ private boolean isNumeric(String str) {
+ return str.matches("-?\\d+(\\.\\d+)?"); // match a number with optional '-' and decimal.
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoGroupMembershipConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoGroupMembershipConverter.java
new file mode 100644
index 0000000..63b50dc
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/GeoGroupMembershipConverter.java
@@ -0,0 +1,51 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.GeoGroupMembershipWrapper;
+import de.avatic.taricdb.model.Geo;
+import de.avatic.taricdb.model.GeoGroupMembership;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class GeoGroupMembershipConverter implements ExcelTableConverter {
+
+
+ private ReferenceStorageService referenceStorage;
+
+ public GeoGroupMembershipConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection memberships = new ArrayList<>();
+ Collection geos = referenceStorage.getEntites(Geo.class);
+
+ table.getRows().forEach((row) -> {
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ Integer group = row.getAs("Country group", Integer.class);
+ String member = row.getAs("Member country", String.class);
+ Geo geo = geos.stream().filter(s -> s.getIso3166Code().equals(member)).findAny().orElse(null);
+ Integer memberId = geo.getId();
+
+ GeoGroupMembershipWrapper membership = memberships.stream().filter(s -> s.getGeoGroupId().equals(group) && s.getGeoGroupMembership().getGeo().getId().equals(memberId)).findAny().orElse(null);
+
+ if (membership == null) {
+ membership = new GeoGroupMembershipWrapper(group, new GeoGroupMembership(row.getAs("Mbship start date", LocalDate.class), row.getAs("Mbship end date", LocalDate.class), AggregateReference.to(memberId)));
+ memberships.add(membership);
+ }
+ });
+
+ return memberships;
+ }
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/ImportConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/ImportConverter.java
new file mode 100644
index 0000000..db1f9e2
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/ImportConverter.java
@@ -0,0 +1,92 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.stats.HeapStat;
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.AppliedMeasureWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.ImportWrapper;
+import de.avatic.taricdb.model.AdditionalCode;
+import de.avatic.taricdb.model.AppliedMeasure;
+import de.avatic.taricdb.model.Geo;
+import de.avatic.taricdb.model.GeoGroup;
+import de.avatic.taricdb.model.Import;
+import de.avatic.taricdb.model.Nomenclature;
+import de.avatic.taricdb.service.ReferenceStorageService;
+import de.avatic.taricdb.service.SetupStatusService;
+
+public class ImportConverter implements ExcelTableConverter {
+
+ Logger log = LoggerFactory.getLogger(ImportConverter.class);
+
+ int count = 0;
+ private ReferenceStorageService referenceStorage;
+
+ private SetupStatusService statusService;
+
+ private int recordOffset;
+
+ public ImportConverter(ReferenceStorageService referenceStorage, SetupStatusService statusService, int recordOffset) {
+ this.referenceStorage = referenceStorage;
+ this.statusService = statusService;
+ this.recordOffset = recordOffset;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+
+
+
+// Collection imports = new ArrayList<>();
+//
+// Collection geos = referenceStorage.getEntites(Geo.class);
+// Collection geoGroups = referenceStorage.getEntites(GeoGroup.class);
+// Collection appliedMeasures = referenceStorage.getEntites(AppliedMeasureWrapper.class);
+// Collection additionalCodes = referenceStorage.getEntites(AdditionalCode.class);
+// Collection nomenclatures = referenceStorage.getEntites(Nomenclature.class);
+//
+// table.getRows().forEach((row) -> {
+// count++;
+// if (row.index() == 0) {
+// return;
+// }
+//
+//
+// if (count % 10000 == 0) {
+// int percentage = Math.round((count*100)/table.getRows().size());
+// log.info("import duties processed: "+percentage+"% - " + count + " of " + table.getRows().size() + " " + HeapStat.getHeapUtilization(), true, null);
+// statusService.setStatus(recordOffset, "Convert import duties measures ... " + percentage + "%", true , null);
+// }
+//
+// String hsCode = row.getAs("Goods code", String.class);
+// String origin = row.getAs("Origin code", String.class);
+// String addCode = row.getAs("Add code", String.class);
+//
+// ImportWrapper im = imports.stream().filter(i -> i.getHsCode().equals(hsCode) && i.getOrigin().equals(origin) && i.getAddCode().equals(addCode)).findFirst().orElse(null);
+//
+// if(im == null) {
+// Nomenclature nomenclature = nomenclatures.stream().filter(n -> n.getHscode().equals(hsCode)).findFirst().orElse(null);
+// AdditionalCode additionalCode = additionalCodes.stream().filter(a -> a.getAdditionalCode().equals(addCode)).findFirst().orElse(null);
+// Set foundAppliedMeasures = appliedMeasures.stream().filter(a -> a.getHsCode().equals(hsCode) && a.getOrigin().equals(origin) && a.getAdditionalCode().equals(addCode)).map(AppliedMeasureWrapper::getAppliedMeasure).collect(Collectors.toSet());
+//
+// Geo geo = geos.parallelStream().filter(g -> g.getIso3166Code().equals(origin)).findFirst().orElse(null);
+// GeoGroup geoGroup = geoGroups.parallelStream().filter(g -> g.getGeoGroupCode().equals(origin)).findFirst().orElse(null);
+//
+// ImportWrapper imw = new ImportWrapper(new Import(AggregateReference.to(nomenclature.getId()), additionalCode == null ? null : AggregateReference.to(additionalCode.getId()), foundAppliedMeasures, geo == null ? null : AggregateReference.to(geo.getId()), geoGroup == null ? null : AggregateReference.to(geoGroup.getId())), hsCode, origin, addCode);
+// imports.add(imw);
+// }
+// });
+
+// return imports.stream().map(ImportWrapper::getImport).collect(Collectors.toSet());
+
+ return null;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/LegalBaseConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/LegalBaseConverter.java
new file mode 100644
index 0000000..dc9d341
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/LegalBaseConverter.java
@@ -0,0 +1,36 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.LegalBase;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class LegalBaseConverter implements ExcelTableConverter {
+
+ public LegalBaseConverter(ReferenceStorageService referenceStorage) {
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection legalBases = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ LegalBase legalBase = new LegalBase(row.getAs("Legal base", String.class),
+ row.getAs("Off. Journal", String.class), row.getAs("Page", Integer.class),
+ row.getAs("Publ. date", LocalDate.class));
+ legalBases.add(legalBase);
+
+ });
+
+ return legalBases;
+
+ }
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureActionConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureActionConverter.java
new file mode 100644
index 0000000..02fd950
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureActionConverter.java
@@ -0,0 +1,44 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.MeasureAction;
+import de.avatic.taricdb.model.MeasureActionDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class MeasureActionConverter implements ExcelTableConverter {
+
+
+ public MeasureActionConverter(ReferenceStorageService referenceStorage) {
+ }
+
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection actions = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("MEAS_ACT_COD", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ MeasureAction measureAction = actions.stream().filter(s -> s.getMeasureActionCode().equals(code)).findAny().orElse(null);
+
+ if (measureAction == null) {
+ measureAction = new MeasureAction(code);
+ actions.add(measureAction);
+ }
+
+ measureAction.addMeasureActionDesc(new MeasureActionDesc(row.getAs("LANG_COD", String.class), row.getAs("DESCR", String.class), null));
+
+ });
+
+
+ return actions;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureConverter.java
new file mode 100644
index 0000000..9e0349d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureConverter.java
@@ -0,0 +1,56 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.Measure;
+import de.avatic.taricdb.model.MeasureDesc;
+import de.avatic.taricdb.model.MeasureSeries;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class MeasureConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public MeasureConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection measures = new ArrayList<>();
+ Collection series = referenceStorage.getEntites(MeasureSeries.class);
+
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("Meas. type", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ Measure measure = measures.stream().filter(s -> s.getMeasureCode().equals(code)).findAny().orElse(null);
+
+
+ if (measure == null) {
+ String seriesCode = row.getAs("Meas. Series", String.class);
+ MeasureSeries foundSeries = series.stream().filter(s -> s.getMeasureSeriesCode().equals(seriesCode)).findAny().orElse(null);
+
+ measure = new Measure(code, row.getAs("Short descr.", String.class),
+ row.getAs("TM code", Integer.class), row.getAs("Start date", LocalDate.class), AggregateReference.to(foundSeries.getId()));
+ measures.add(measure);
+ }
+
+ measure.addMeasureDesc(new MeasureDesc(row.getAs("Language", String.class),
+ row.getAs("Description", String.class)));
+
+ });
+
+ return measures;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureExclusionConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureExclusionConverter.java
new file mode 100644
index 0000000..f1b76ae
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureExclusionConverter.java
@@ -0,0 +1,61 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.MeasureExclusionWrapper;
+import de.avatic.taricdb.model.Geo;
+import de.avatic.taricdb.model.MeasureExclusion;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class MeasureExclusionConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public MeasureExclusionConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+
+ Collection exclusions = new ArrayList<>();
+ Collection geos = referenceStorage.getEntites(Geo.class);
+
+ table.getRows().forEach((row) -> {
+ if (row.index() == 0) {
+ return;
+ }
+
+ String hsCode = row.getAs("Goods code", String.class);
+ String iso3166Code = row.getAs("Excluded country", String.class);
+ Integer measureCode = row.getAs("Meas. type code", Integer.class);
+ Integer originCode = row.getAs("Origin code", Integer.class);
+ String addCode = row.getAs("Add code", String.class);
+ String orderNumber = row.getAs("Order No.", String.class);
+
+ Geo geo = geos.stream().filter(c -> c.getIso3166Code().equals(iso3166Code)).findAny().orElse(null);
+
+ MeasureExclusionWrapper exclusion = exclusions.stream()
+ .filter(c -> c.getHsCode().equals(hsCode) && c.getMeasureCode().equals(measureCode)
+ && c.getOriginCode().equals(originCode) && c.getIso3166Code().equals(iso3166Code) && c.getAddCode().equals(addCode) && c.getOrderNumber().equals(orderNumber))
+ .findAny().orElse(null);
+
+ if (exclusion == null) {
+ exclusion = new MeasureExclusionWrapper(new MeasureExclusion(AggregateReference.to(geo.getId())),
+ hsCode, originCode, measureCode, iso3166Code, addCode, orderNumber);
+ exclusions.add(exclusion);
+ } else {
+ throw new IllegalArgumentException("Duplicate measure exclusion found: measure: " + measureCode + " - origin: " + originCode + " - iso: " + iso3166Code + " - add code: " + addCode + " goods code: " + hsCode + " order number: " + orderNumber);
+ }
+
+ });
+
+ return exclusions;
+
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureFootnoteConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureFootnoteConverter.java
new file mode 100644
index 0000000..5283c06
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureFootnoteConverter.java
@@ -0,0 +1,63 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.MeasureFootnoteWrapper;
+import de.avatic.taricdb.model.Footnote;
+import de.avatic.taricdb.model.MeasureFootnote;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class MeasureFootnoteConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public MeasureFootnoteConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection measureFootnoteWrappers = new ArrayList<>();
+ Collection footnotes = referenceStorage.getEntites(Footnote.class);
+
+ table.getRows().forEach((row) -> {
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ String footnote = row.getAs("Footnote", String.class);
+ Integer measureCode = row.getAs("Meas. type code", Integer.class);
+ String hsCode = row.getAs("Goods code", String.class);
+ String origin = row.getAs("Origin code", String.class);
+ String addCode = row.getAs("Add code", String.class);
+ Integer orderNumber = row.getAs("Order No.", Integer.class);
+
+ Footnote foundFootnote = footnotes.stream().filter(s -> s.getFootnote().equals(footnote)).findAny()
+ .orElse(null);
+
+ MeasureFootnoteWrapper wrapper = measureFootnoteWrappers.stream()
+ .filter(s -> s.getMeasureFootnote().getFootnote().getId().equals(foundFootnote.getId())
+ && s.getMeasureCode().equals(measureCode) && s.getHsCode().equals(hsCode)
+ && s.getOrigin().equals(origin) && s.getAddCode().equals(addCode)
+ && s.getOrderNumber().equals(orderNumber))
+ .findAny().orElse(null);
+
+ if (wrapper == null) {
+ wrapper = new MeasureFootnoteWrapper(new MeasureFootnote(AggregateReference.to(foundFootnote.getId())),
+ measureCode, hsCode, addCode, origin, orderNumber);
+ } else {
+ throw new RuntimeException("MeasureFootnoteWrapper already exists: " + measureCode + " " + hsCode + " "
+ + origin + " " + addCode + " " + orderNumber);
+ }
+
+ });
+
+ return measureFootnoteWrappers;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureSeriesConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureSeriesConverter.java
new file mode 100644
index 0000000..ee26027
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MeasureSeriesConverter.java
@@ -0,0 +1,43 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.MeasureSeries;
+import de.avatic.taricdb.model.MeasureSeriesDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class MeasureSeriesConverter implements ExcelTableConverter {
+
+
+ public MeasureSeriesConverter(ReferenceStorageService referenceStorage) {
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+
+ Collection series = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("MEAS_TYP_SER_ID", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ MeasureSeries measureSeries = series.stream().filter(s -> s.getMeasureSeriesCode().equals(code)).findAny().orElse(null);
+
+ if (measureSeries == null) {
+ measureSeries = new MeasureSeries(code);
+ series.add(measureSeries);
+ }
+
+ measureSeries.addMeasureSeriesDesc(new MeasureSeriesDesc(row.getAs("LANG_COD", String.class),
+ row.getAs("DESCR", String.class)));
+ });
+
+ return series;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/MonetaryUnitConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MonetaryUnitConverter.java
new file mode 100644
index 0000000..c1cb001
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/MonetaryUnitConverter.java
@@ -0,0 +1,47 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.MonetaryUnit;
+import de.avatic.taricdb.model.MonetaryUnitDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class MonetaryUnitConverter implements ExcelTableConverter {
+
+
+ public MonetaryUnitConverter(ReferenceStorageService referenceStorage) {
+
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection units = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("MON_UNIT_COD", String.class);
+
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ MonetaryUnit monetaryUnit = units.stream().filter(
+ s -> s.getMonetaryUnitCode().equals(code))
+ .findAny().orElse(null);
+
+ if (monetaryUnit == null) {
+
+ monetaryUnit = new MonetaryUnit(code);
+ units.add(monetaryUnit);
+ }
+
+ monetaryUnit.addMonetaryUnitDesc(
+ new MonetaryUnitDesc(row.getAs("LANG_COD", String.class), row.getAs("DESCR", String.class), null));
+ });
+
+ return units;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureDeConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureDeConverter.java
new file mode 100644
index 0000000..885235c
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureDeConverter.java
@@ -0,0 +1,73 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.DeclarableCodesWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.NomenclatureDescEnWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.NomenclatureDescFrWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.NomenclatureFootnoteWrapper;
+import de.avatic.taricdb.model.Nomenclature;
+import de.avatic.taricdb.model.NomenclatureDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class NomenclatureDeConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorageService;
+
+ public NomenclatureDeConverter(ReferenceStorageService referenceStorageService) {
+ this.referenceStorageService = referenceStorageService;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection nomenclatures = new ArrayList<>();
+ Collection declarableCodes = referenceStorageService.getEntites(DeclarableCodesWrapper.class);
+ Collection nomenclatureFootnoteWrappers = referenceStorageService.getEntites(NomenclatureFootnoteWrapper.class);
+ Collection nomenclatureDescEn = referenceStorageService.getEntites(NomenclatureDescEnWrapper.class);
+ Collection nomenclatureDescFr = referenceStorageService.getEntites(NomenclatureDescFrWrapper.class);
+
+ table.getRows().forEach((row) -> {
+ if (row.index() == 0) {
+ return;
+ }
+
+ String goodsCode = row.getAs("Goods code", String.class);
+ String hsCode = goodsCode.substring(0, 10);
+ String suffix = goodsCode.substring(11, 13);
+
+ Nomenclature nomenclature = nomenclatures.stream().filter(n -> n.getHscode().equals(hsCode)).findAny().orElse(null);
+ NomenclatureFootnoteWrapper footnoteWrapper = nomenclatureFootnoteWrappers.stream().filter(n -> n.getHsCode().equals(hsCode) && n.getSuffix().equals(suffix)).findFirst().orElse(null);
+ NomenclatureDesc descEn = nomenclatureDescEn.stream().filter(n -> n.getHscode().equals(hsCode) && n.getSuffix().equals(suffix)).map(n -> n.getDesc()).findFirst().orElse(null);
+ NomenclatureDesc descFr = nomenclatureDescFr.stream().filter(n -> n.getHscode().equals(hsCode) && n.getSuffix().equals(suffix)).map(n -> n.getDesc()).findFirst().orElse(null);
+
+
+
+ if (nomenclature == null) {
+ String line = row.getAs("Indent", String.class).trim();
+ int indent = line.length() - line.replace("-", "").length();
+
+ DeclarableCodesWrapper declarableCode = declarableCodes.stream()
+ .filter(d -> d.getHsCode().equals(hsCode)).findAny().orElse(null);
+
+ nomenclature = new Nomenclature(hsCode, suffix, row.getAs("Hier. Pos.", Integer.class), indent,
+ row.getAs("Start date", LocalDate.class), row.getAs("End date", LocalDate.class),
+ declarableCode == null ? false : declarableCode.getIsLeaf(),
+ declarableCode == null ? null : declarableCode.getDeclStartDate(),
+ null, null == footnoteWrapper ? null : footnoteWrapper.getNomenclatureFootnote());
+
+ nomenclatures.add(nomenclature);
+ }
+
+ nomenclature.addNomenclatureDesc(new NomenclatureDesc(row.getAs("Language", String.class), row.getAs("Description", String.class), row.getAs("Descr. start date", LocalDate.class)));
+ nomenclature.addNomenclatureDesc(descEn);
+ nomenclature.addNomenclatureDesc(descFr);
+
+ });
+
+ return nomenclatures;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureEnConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureEnConverter.java
new file mode 100644
index 0000000..b5a761c
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureEnConverter.java
@@ -0,0 +1,53 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.NomenclatureDescEnWrapper;
+import de.avatic.taricdb.model.NomenclatureDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class NomenclatureEnConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorageService;
+
+
+ public NomenclatureEnConverter(ReferenceStorageService referenceStorageService) {
+ this.referenceStorageService = referenceStorageService;
+
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection nomenclatures = new ArrayList<>();
+
+
+ table.getRows().forEach((row) -> {
+ if (row.index() == 0) {
+ return;
+ }
+
+ String goodsCode = row.getAs("Goods code", String.class);
+ String hsCode = goodsCode.substring(0, 10);
+ String suffix = goodsCode.substring(11, 13);
+
+ NomenclatureDescEnWrapper nomenclature = nomenclatures.stream().filter(n -> n.getHscode().equals(hsCode) && n.getSuffix().equals(suffix)).findAny().orElse(null);
+
+
+ if (nomenclature == null) {
+ nomenclature = new NomenclatureDescEnWrapper(new NomenclatureDesc(row.getAs("Language", String.class), row.getAs("Description", String.class), row.getAs("Descr. start date", LocalDate.class)), hsCode, suffix);
+ nomenclatures.add(nomenclature);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Duplicate hscode found: " + hsCode + " " + suffix);
+ }
+
+ });
+
+ return nomenclatures;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureFootnoteConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureFootnoteConverter.java
new file mode 100644
index 0000000..75e1f58
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureFootnoteConverter.java
@@ -0,0 +1,49 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.NomenclatureFootnoteWrapper;
+import de.avatic.taricdb.model.Footnote;
+import de.avatic.taricdb.model.NomenclatureFootnote;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class NomenclatureFootnoteConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorage;
+
+ public NomenclatureFootnoteConverter(ReferenceStorageService referenceStorage) {
+ this.referenceStorage = referenceStorage;
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection nomenclatureFootnoteWrappers = new ArrayList<>();
+ Collection footnotes = referenceStorage.getEntites(Footnote.class);
+
+
+ table.getRows().forEach((row) -> {
+ String goodsCode = row.getAs("Goods code", String.class);
+ String hsCode = goodsCode.substring(0, 10);
+ String suffix = goodsCode.substring(11, 13);
+
+ Footnote footnote = footnotes.stream().filter(f -> f.getFootnote().equals(row.getAs("Footnote code", String.class))).findFirst().orElse(null);
+
+ NomenclatureFootnoteWrapper foundWrapper = nomenclatureFootnoteWrappers.stream().filter(w -> w.getHsCode().equals(hsCode)).findAny().orElse(null);
+
+ if (foundWrapper == null) {
+ foundWrapper = new NomenclatureFootnoteWrapper(hsCode, suffix);
+ nomenclatureFootnoteWrappers.add(foundWrapper);
+ }
+
+ foundWrapper.addNomenclatureFootnote(new NomenclatureFootnote(AggregateReference.to(footnote.getId())));
+
+ });
+
+ return nomenclatureFootnoteWrappers;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureFrConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureFrConverter.java
new file mode 100644
index 0000000..6fdb8e2
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/NomenclatureFrConverter.java
@@ -0,0 +1,54 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.helper.workbook.wrapper.NomenclatureDescFrWrapper;
+import de.avatic.taricdb.model.NomenclatureDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class NomenclatureFrConverter implements ExcelTableConverter {
+
+ private ReferenceStorageService referenceStorageService;
+
+
+ public NomenclatureFrConverter(ReferenceStorageService referenceStorageService) {
+ this.referenceStorageService = referenceStorageService;
+
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+
+ Collection nomenclatures = new ArrayList<>();
+
+
+ table.getRows().forEach((row) -> {
+ if (row.index() == 0) {
+ return;
+ }
+
+ String goodsCode = row.getAs("Goods code", String.class);
+ String hsCode = goodsCode.substring(0, 10);
+ String suffix = goodsCode.substring(11, 13);
+
+ NomenclatureDescFrWrapper nomenclature = nomenclatures.stream().filter(n -> n.getHscode().equals(hsCode) && n.getSuffix().equals(suffix)).findAny().orElse(null);
+
+
+ if (nomenclature == null) {
+ nomenclature = new NomenclatureDescFrWrapper(new NomenclatureDesc(row.getAs("Language", String.class), row.getAs("Description", String.class), row.getAs("Descr. start date", LocalDate.class)), hsCode, suffix);
+ nomenclatures.add(nomenclature);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Duplicate hscode found: " + hsCode + " " + suffix);
+ }
+
+ });
+
+ return nomenclatures;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/converters/UnitConverter.java b/src/main/java/de/avatic/taricdb/helper/workbook/converters/UnitConverter.java
new file mode 100644
index 0000000..02e08fa
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/converters/UnitConverter.java
@@ -0,0 +1,49 @@
+package de.avatic.taricdb.helper.workbook.converters;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import de.avatic.taricdb.helper.workbook.ExcelTable;
+import de.avatic.taricdb.model.Unit;
+import de.avatic.taricdb.model.UnitDesc;
+import de.avatic.taricdb.service.ReferenceStorageService;
+
+public class UnitConverter implements ExcelTableConverter {
+
+ public UnitConverter(ReferenceStorageService referenceStorage) {
+
+ }
+
+ @Override
+ public Collection convert(ExcelTable table) {
+ Collection units = new ArrayList<>();
+
+ table.getRows().forEach((row) -> {
+ String code = row.getAs("Measuremt Unit", String.class);
+ String qualifier = row.getAs("Measuremt. unit qualifier", String.class);
+
+ if (row.index() == 0) {
+ return;
+ }
+
+ Unit unit = units.stream().filter(
+ s -> s.getUnitCode().equals(code) && (((qualifier == null) && (s.getUnitQualifier() == null))
+ || ((s.getUnitQualifier() != null && qualifier != null)
+ && (s.getUnitQualifier().equals(qualifier)))))
+ .findAny().orElse(null);
+
+ if (unit == null) {
+
+
+ unit = new Unit(code, qualifier, row.getAs("Label", String.class));
+ units.add(unit);
+ }
+
+ unit.addUnitDesc(
+ new UnitDesc(row.getAs("Lg", String.class), row.getAs("Concatenated descriptions", String.class), null));
+ });
+
+ return units;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/AppliedMeasureConditionWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/AppliedMeasureConditionWrapper.java
new file mode 100644
index 0000000..bb0ac36
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/AppliedMeasureConditionWrapper.java
@@ -0,0 +1,49 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.AppliedMeasureCondition;
+
+public class AppliedMeasureConditionWrapper {
+
+ private AppliedMeasureCondition appliedMeasureCondition;
+ private String hsCode;
+ private String originCode;
+ private String additionalCode;
+ private String orderNumber;
+ private Integer measureCode;
+
+
+
+ public AppliedMeasureConditionWrapper(AppliedMeasureCondition appliedMeasureCondition, String hsCode, String originCode, String additionalCode, String orderNumber, Integer measureCode) {
+ this.appliedMeasureCondition = appliedMeasureCondition;
+ this.hsCode = hsCode;
+ this.originCode = originCode;
+ this.additionalCode = additionalCode;
+ this.orderNumber = orderNumber;
+ this.measureCode = measureCode;
+ }
+
+ public AppliedMeasureCondition getAppliedMeasureCondition() {
+ return appliedMeasureCondition;
+ }
+
+ public String getOrderNumber() {
+ return orderNumber;
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public String getOriginCode() {
+ return originCode;
+ }
+
+ public String getAdditionalCode() {
+ return additionalCode;
+ }
+
+ public Integer getMeasureCode() {
+ return measureCode;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/AppliedMeasureWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/AppliedMeasureWrapper.java
new file mode 100644
index 0000000..86a9d6c
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/AppliedMeasureWrapper.java
@@ -0,0 +1,40 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.AppliedMeasure;
+
+public class AppliedMeasureWrapper {
+
+ private AppliedMeasure appliedMeasure;
+
+ private String hsCode;
+ private String additionalCode;
+
+
+
+ private String origin;
+
+ public AppliedMeasureWrapper(AppliedMeasure appliedMeasure, String hsCode, String additionalCode, String origin) {
+ this.appliedMeasure = appliedMeasure;
+ this.hsCode = hsCode;
+ this.additionalCode = additionalCode;
+ this.origin = origin;
+ }
+
+ public AppliedMeasure getAppliedMeasure() {
+ return appliedMeasure;
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public String getAdditionalCode() {
+ return additionalCode;
+ }
+
+ public String getOrigin() {
+ return origin;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/DeclarableCodesWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/DeclarableCodesWrapper.java
new file mode 100644
index 0000000..1b4de92
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/DeclarableCodesWrapper.java
@@ -0,0 +1,53 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import java.time.LocalDate;
+
+public class DeclarableCodesWrapper {
+
+ private String hsCode;
+ private String suffix;
+ private Boolean isLeaf;
+ private LocalDate declStartDate;
+
+ public DeclarableCodesWrapper(String hsCode, String suffix, LocalDate declStartDate, Boolean isLeaf) {
+ this.hsCode = hsCode;
+ this.suffix = suffix;
+ this.declStartDate = declStartDate;
+ this.isLeaf = isLeaf;
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public void setHsCode(String hsCode) {
+ this.hsCode = hsCode;
+ }
+
+ public String getSuffix() {
+ return suffix;
+ }
+
+ public void setSuffix(String suffix) {
+ this.suffix = suffix;
+ }
+
+ public Boolean getIsLeaf() {
+ return isLeaf;
+ }
+
+ public void setIsLeaf(Boolean isLeaf) {
+ this.isLeaf = isLeaf;
+ }
+
+ public LocalDate getDeclStartDate() {
+ return declStartDate;
+ }
+
+ public void setDeclStartDate(LocalDate declStartDate) {
+ this.declStartDate = declStartDate;
+ }
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/GeoGroupMembershipWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/GeoGroupMembershipWrapper.java
new file mode 100644
index 0000000..ac0a947
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/GeoGroupMembershipWrapper.java
@@ -0,0 +1,31 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.GeoGroupMembership;
+
+public class GeoGroupMembershipWrapper {
+
+ private Integer geoGroupId;
+ private GeoGroupMembership geoGroupMembership;
+
+ public GeoGroupMembershipWrapper(Integer geoGroupId, GeoGroupMembership geoGroupMembership) {
+ this.setGeoGroupId(geoGroupId);
+ this.setGeoGroupMembership(geoGroupMembership);
+ }
+
+ public GeoGroupMembership getGeoGroupMembership() {
+ return geoGroupMembership;
+ }
+
+ public void setGeoGroupMembership(GeoGroupMembership geoGroupMembership) {
+ this.geoGroupMembership = geoGroupMembership;
+ }
+
+ public Integer getGeoGroupId() {
+ return geoGroupId;
+ }
+
+ public void setGeoGroupId(Integer geoGroupId) {
+ this.geoGroupId = geoGroupId;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/ImportWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/ImportWrapper.java
new file mode 100644
index 0000000..6d7ae42
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/ImportWrapper.java
@@ -0,0 +1,50 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+
+import de.avatic.taricdb.model.Import;
+
+public class ImportWrapper {
+
+ private CompletableFuture im;
+
+ private String hsCode;
+ private String origin;
+ private String addCode;
+
+
+
+ public ImportWrapper(String hsCode, String origin, String addCode) {
+ this.hsCode = hsCode;
+ this.origin = origin;
+ this.addCode = addCode;
+ this.im = new CompletableFuture();
+ }
+
+ public Import getImport() {
+
+ try {
+ return im.get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public String getOrigin() {
+ return origin;
+ }
+
+ public String getAddCode() {
+ return addCode;
+ }
+
+ public void completeImport(Import im) {
+ this.im.complete(im);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/MeasureExclusionWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/MeasureExclusionWrapper.java
new file mode 100644
index 0000000..30140b6
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/MeasureExclusionWrapper.java
@@ -0,0 +1,64 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.MeasureExclusion;
+
+public class MeasureExclusionWrapper {
+
+ private MeasureExclusion exclusion;
+
+ private String hsCode;
+
+ private Integer originCode;
+
+ private Integer measureCode;
+
+ private String iso3166Code;
+
+ private String addCode;
+
+ private String orderNumber;
+
+ public MeasureExclusionWrapper(MeasureExclusion exclusion, String hsCode, Integer originCode, Integer measureCode, String iso3166Code, String addCode, String orderNumber) {
+ this.exclusion = exclusion;
+ this.hsCode = hsCode;
+ this.originCode = originCode;
+ this.measureCode = measureCode;
+ this.iso3166Code = iso3166Code;
+ this.addCode = addCode;
+ this.orderNumber = orderNumber;
+ }
+
+ public MeasureExclusion getExclusion() {
+ return exclusion;
+ }
+
+ public String getOrderNumber() {
+ return orderNumber;
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public Integer getMeasureCode() {
+ return measureCode;
+ }
+
+ public Integer getOriginCode() {
+ return originCode;
+ }
+
+ public MeasureExclusion getMeasureExclusion() {
+ return exclusion;
+ }
+
+ public String getIso3166Code() {
+ return iso3166Code;
+ }
+
+ public Object getAddCode() {
+ return addCode;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/MeasureFootnoteWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/MeasureFootnoteWrapper.java
new file mode 100644
index 0000000..d72cc5b
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/MeasureFootnoteWrapper.java
@@ -0,0 +1,60 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.MeasureFootnote;
+
+public class MeasureFootnoteWrapper {
+
+ private MeasureFootnote measureFootnote;
+
+ private String hsCode;
+
+ private String origin;
+
+ private Integer measureCode;
+
+ private String addCode;
+
+ private Integer orderNumber;
+
+ public MeasureFootnoteWrapper(MeasureFootnote measureFootnote, Integer measureCode, String hsCode, String addCode, String origin, Integer orderNumber) {
+ this.measureFootnote = measureFootnote;
+ this.measureCode = measureCode;
+ this.hsCode = hsCode;
+ this.origin = origin;
+ this.addCode = addCode;
+ this.orderNumber = orderNumber;
+ }
+
+ public Integer getMeasureCode() {
+ return measureCode;
+ }
+
+ public void setMeasureCode(Integer measureCode) {
+ this.measureCode = measureCode;
+ }
+
+ public MeasureFootnote getMeasureFootnote() {
+ return measureFootnote;
+ }
+
+ public void setMeasureFootnote(MeasureFootnote measureFootnote) {
+ this.measureFootnote = measureFootnote;
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public String getOrigin() {
+ return origin;
+ }
+
+ public String getAddCode() {
+ return addCode;
+ }
+
+ public Object getOrderNumber() {
+ return orderNumber;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureDescEnWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureDescEnWrapper.java
new file mode 100644
index 0000000..75555c4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureDescEnWrapper.java
@@ -0,0 +1,29 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.NomenclatureDesc;
+
+public class NomenclatureDescEnWrapper {
+
+ private NomenclatureDesc desc;
+ private String hsCode;
+ private String suffix;
+
+ public NomenclatureDescEnWrapper(NomenclatureDesc desc, String hsCode, String suffix) {
+ this.desc = desc;
+ this.hsCode = hsCode;
+ this.suffix = suffix;
+ }
+
+ public NomenclatureDesc getDesc() {
+ return this.desc;
+ }
+
+ public String getHscode() {
+ return this.hsCode;
+ }
+
+ public String getSuffix() {
+ return this.suffix;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureDescFrWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureDescFrWrapper.java
new file mode 100644
index 0000000..0af7362
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureDescFrWrapper.java
@@ -0,0 +1,29 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import de.avatic.taricdb.model.NomenclatureDesc;
+
+public class NomenclatureDescFrWrapper {
+
+ private NomenclatureDesc desc;
+ private String hsCode;
+ private String suffix;
+
+ public NomenclatureDescFrWrapper(NomenclatureDesc desc, String hsCode, String suffix) {
+ this.desc = desc;
+ this.hsCode = hsCode;
+ this.suffix = suffix;
+ }
+
+ public NomenclatureDesc getDesc() {
+ return this.desc;
+ }
+
+ public String getHscode() {
+ return this.hsCode;
+ }
+
+ public String getSuffix() {
+ return this.suffix;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureFootnoteWrapper.java b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureFootnoteWrapper.java
new file mode 100644
index 0000000..e1261a4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/workbook/wrapper/NomenclatureFootnoteWrapper.java
@@ -0,0 +1,37 @@
+package de.avatic.taricdb.helper.workbook.wrapper;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import de.avatic.taricdb.model.NomenclatureFootnote;
+
+public class NomenclatureFootnoteWrapper {
+
+ private Set nomenclatureFootnotes;
+
+ private String hsCode;
+
+ private String suffix;
+
+ public NomenclatureFootnoteWrapper(String hsCode, String suffix) {
+ this.nomenclatureFootnotes = new HashSet<>();
+ this.hsCode = hsCode;
+ this.suffix = suffix;
+ }
+
+ public Set getNomenclatureFootnote() {
+ return nomenclatureFootnotes;
+ }
+
+ public String getHsCode() {
+ return hsCode;
+ }
+
+ public void addNomenclatureFootnote(NomenclatureFootnote nomenclatureFootnote) {
+ this.nomenclatureFootnotes.add(nomenclatureFootnote);
+ }
+
+ public String getSuffix() {
+ return suffix;
+ }
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/zip/ByteArrayWrapper.java b/src/main/java/de/avatic/taricdb/helper/zip/ByteArrayWrapper.java
new file mode 100644
index 0000000..c587ccf
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/zip/ByteArrayWrapper.java
@@ -0,0 +1,22 @@
+package de.avatic.taricdb.helper.zip;
+
+public class ByteArrayWrapper {
+
+ private byte[] bytes;
+
+ public ByteArrayWrapper(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ public ByteArrayWrapper combine(ByteArrayWrapper other) {
+ byte[] combined = new byte[bytes.length + other.getBytes().length];
+ System.arraycopy(bytes, 0, combined, 0, bytes.length);
+ System.arraycopy(other.getBytes(), 0, combined, bytes.length, other.getBytes().length);
+ return new ByteArrayWrapper(combined);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/zip/UnzipStatusListener.java b/src/main/java/de/avatic/taricdb/helper/zip/UnzipStatusListener.java
new file mode 100644
index 0000000..c1eada4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/zip/UnzipStatusListener.java
@@ -0,0 +1,10 @@
+package de.avatic.taricdb.helper.zip;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public interface UnzipStatusListener {
+
+ void notifyUnzipProgress(String message);
+
+}
diff --git a/src/main/java/de/avatic/taricdb/helper/zip/Unzipper.java b/src/main/java/de/avatic/taricdb/helper/zip/Unzipper.java
new file mode 100644
index 0000000..b53c2c4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/helper/zip/Unzipper.java
@@ -0,0 +1,67 @@
+package de.avatic.taricdb.helper.zip;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import de.avatic.taricdb.helper.file.InMemFile;
+import de.avatic.taricdb.service.SetupStatusService;
+
+
+@Component
+public class Unzipper {
+
+ @Autowired
+ private SetupStatusService statusService;
+
+ Logger log = LoggerFactory.getLogger(Unzipper.class);
+
+ public List unzip(byte[] zipFile) throws IOException {
+ List files = new ArrayList<>();
+ ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(zipFile));
+ ZipEntry entry;
+
+ while ((entry = zipStream.getNextEntry()) != null) {
+ if (!entry.isDirectory()) {
+ files.add(new InMemFile(entry.getName(), readFileContent(zipStream, entry)));
+ }
+ zipStream.closeEntry();
+ log.info("Unzip done: " + entry.getName());
+ statusService.setStatus(0, "unzipping ... " + entry.getName(), true, null);
+ }
+
+ return files;
+ }
+
+ private byte[] readFileContent(InputStream zipStream, ZipEntry entry) throws IOException {
+ int totalRead = 0;
+ List content = new ArrayList<>();
+
+ while (zipStream.available() > 0) {
+ byte[] bytes = new byte[10240];
+ int read = zipStream.read(bytes, 0, bytes.length);
+
+ if (read == -1) {
+ break;
+ }
+
+ content.add(new ByteArrayWrapper(Arrays.copyOf(bytes, read)));
+ totalRead += read;
+ }
+
+ return content.stream().reduce(new ByteArrayWrapper(new byte[0]), ByteArrayWrapper::combine).getBytes();
+
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/AdditionalCode.java b/src/main/java/de/avatic/taricdb/model/AdditionalCode.java
new file mode 100644
index 0000000..56e694b
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/AdditionalCode.java
@@ -0,0 +1,77 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+
+@Table("additional_code")
+public class AdditionalCode {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 4)
+ private String additionalCode;
+
+ private LocalDate startDate;
+
+ private LocalDate endDate;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set desc;
+
+ public AdditionalCode(String additionalCode, LocalDate startDate, LocalDate endDate) {
+ this.desc = new HashSet<>();
+ this.additionalCode = additionalCode;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getAdditionalCode() {
+ return additionalCode;
+ }
+
+ public void setAdditionalCode(final String additionalCode) {
+ this.additionalCode = additionalCode;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public Set getDesc() {
+ return desc;
+ }
+
+ public void addDesc(AdditionalCodeDesc desc) {
+ this.desc.add(desc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/AdditionalCodeDesc.java b/src/main/java/de/avatic/taricdb/model/AdditionalCodeDesc.java
new file mode 100644
index 0000000..1fec852
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/AdditionalCodeDesc.java
@@ -0,0 +1,62 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+@Table("additional_code_desc")
+public class AdditionalCodeDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public AdditionalCodeDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/AppliedMeasure.java b/src/main/java/de/avatic/taricdb/model/AppliedMeasure.java
new file mode 100644
index 0000000..df642b1
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/AppliedMeasure.java
@@ -0,0 +1,126 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.NotNull;
+
+public class AppliedMeasure {
+
+ @Id
+ private Integer id;
+
+ private LocalDate startDate;
+
+ private LocalDate endDate;
+
+ private String amount;
+
+ @Column("order_number")
+ private Integer orderNumber;
+
+ @MappedCollection(idColumn = "applied_measure_id")
+ private Set measureFootnotes;
+
+ @NotNull
+ @Column("measure_id")
+ private AggregateReference measure;
+
+
+ @Column("legal_base_id")
+ private AggregateReference legalBase;
+
+ @Column("legal_base")
+ private String additionalLegalBase;
+
+ @MappedCollection(idColumn = "applied_measure_id")
+ private Set exclusions;
+
+ @MappedCollection(idColumn = "applied_measure_id")
+ private Set conditions;
+
+ public AppliedMeasure(AggregateReference measure, Set measureFootnotes,
+ AggregateReference legalBase, String additionalLegalBase, Set exclusions,
+ Set conditions, LocalDate startDate, LocalDate endDate, String amount, Integer orderNumber) {
+ this.measure = measure;
+ this.measureFootnotes = measureFootnotes;
+ this.legalBase = legalBase;
+ this.exclusions = exclusions;
+ this.conditions = conditions;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.amount = amount;
+ this.orderNumber = orderNumber;
+ this.additionalLegalBase = additionalLegalBase;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public String getAmount() {
+ return amount;
+ }
+
+ public void setAmount(final String amount) {
+ this.amount = amount;
+ }
+
+ public AggregateReference getMeasure() {
+ return measure;
+ }
+
+ public void setMeasure(final AggregateReference measure) {
+ this.measure = measure;
+ }
+
+ public AggregateReference getLegalBase() {
+ return legalBase;
+ }
+
+ public void setLegalBase(final AggregateReference legalBase) {
+ this.legalBase = legalBase;
+ }
+
+ public Integer getOrderNumber() {
+ return orderNumber;
+ }
+
+ public Set getMeasureFootnotes() {
+ return measureFootnotes;
+ }
+
+ public Set getExclusions() {
+ return exclusions;
+ }
+
+ public Set getConditions() {
+ return conditions;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/AppliedMeasureCondition.java b/src/main/java/de/avatic/taricdb/model/AppliedMeasureCondition.java
new file mode 100644
index 0000000..b411c16
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/AppliedMeasureCondition.java
@@ -0,0 +1,118 @@
+package de.avatic.taricdb.model;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.lang.Nullable;
+
+import jakarta.validation.constraints.NotNull;
+
+public class AppliedMeasureCondition {
+
+ @Id
+ private Integer id;
+
+ private Integer sequenceNo;
+
+ private String amount;
+
+ @NotNull
+ @Column("measure_action_id")
+ private AggregateReference measureAction;
+
+ @Column("monetary_unit_id")
+ @Nullable
+ private AggregateReference monetaryUnit;
+
+
+ @Column("unit_id")
+ @Nullable
+ private AggregateReference unit;
+
+ @Column("certificate_id")
+ @Nullable
+ private AggregateReference certificate;
+
+ @NotNull
+ @Column("condition_type_id")
+ private AggregateReference conditionType;
+
+ public AppliedMeasureCondition(AggregateReference measureAction,
+ AggregateReference monetaryUnit,
+ AggregateReference unit,
+ AggregateReference certificate,
+ AggregateReference conditionType, String amount, Integer squenceNo) {
+ this.measureAction = measureAction;
+ this.monetaryUnit = monetaryUnit;
+ this.unit = unit;
+ this.certificate = certificate;
+ this.conditionType = conditionType;
+ this.amount = amount;
+ this.sequenceNo = squenceNo;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public Integer getSequenceNo() {
+ return sequenceNo;
+ }
+
+ public void setSequenceNo(final Integer sequenceNo) {
+ this.sequenceNo = sequenceNo;
+ }
+
+ public String getAmount() {
+ return amount;
+ }
+
+ public void setAmount(final String amount) {
+ this.amount = amount;
+ }
+
+ public AggregateReference getMeasureAction() {
+ return measureAction;
+ }
+
+ public void setMeasureAction(final AggregateReference measureAction) {
+ this.measureAction = measureAction;
+ }
+
+ public AggregateReference getMonetaryUnit() {
+ return monetaryUnit;
+ }
+
+ public void setMonetaryUnit(final AggregateReference monetaryUnit) {
+ this.monetaryUnit = monetaryUnit;
+ }
+
+ public AggregateReference getUnit() {
+ return unit;
+ }
+
+ public void setUnit(final AggregateReference unit) {
+ this.unit = unit;
+ }
+
+ public AggregateReference getCertificate() {
+ return certificate;
+ }
+
+ public void setCertificate(final AggregateReference certificate) {
+ this.certificate = certificate;
+ }
+
+ public AggregateReference getConditionType() {
+ return conditionType;
+ }
+
+ public void setConditionType(final AggregateReference conditionType) {
+ this.conditionType = conditionType;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Certificate.java b/src/main/java/de/avatic/taricdb/model/Certificate.java
new file mode 100644
index 0000000..2dffa26
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Certificate.java
@@ -0,0 +1,88 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+
+
+public class Certificate {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 4)
+ private String certificateCode;
+
+ private LocalDate startDate;
+
+ private LocalDate endDate;
+
+ @NotNull
+ @Column("certificate_type_id")
+ private AggregateReference certificateType;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set certificateDesc;
+
+ public Certificate(String certificateCode, LocalDate startDate, LocalDate endDate, AggregateReference certificateType) {
+ this.certificateCode = certificateCode;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.certificateType = certificateType;
+ this.certificateDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getCertificateCode() {
+ return certificateCode;
+ }
+
+ public void setCertificateCode(final String certificateCode) {
+ this.certificateCode = certificateCode;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public AggregateReference getCertificateType() {
+ return certificateType;
+ }
+
+ public void setCertificateType(final AggregateReference certificateType) {
+ this.certificateType = certificateType;
+ }
+
+ public void addCertificateDesc(CertificateDesc certificateDesc) {
+ this.certificateDesc.add(certificateDesc);
+
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/CertificateDesc.java b/src/main/java/de/avatic/taricdb/model/CertificateDesc.java
new file mode 100644
index 0000000..c535c10
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/CertificateDesc.java
@@ -0,0 +1,63 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class CertificateDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public CertificateDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDescc() {
+ return desc;
+ }
+
+ public void setDescc(final String descc) {
+ this.desc = descc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/CertificateType.java b/src/main/java/de/avatic/taricdb/model/CertificateType.java
new file mode 100644
index 0000000..606f55e
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/CertificateType.java
@@ -0,0 +1,49 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.Size;
+
+public class CertificateType {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 1)
+ private String certificateTypeCode;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set certificateTypeDesc;
+
+ public CertificateType(String certificateTypeCode) {
+ this.certificateTypeCode = certificateTypeCode;
+ this.certificateTypeDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getCertificateTypeCode() {
+ return certificateTypeCode;
+ }
+
+ public void setCertificateTypeCode(final String certificateTypeCode) {
+ this.certificateTypeCode = certificateTypeCode;
+ }
+
+ public void addCertificateTypeDesc(CertificateTypeDesc certificateTypeDesc) {
+ this.certificateTypeDesc.add(certificateTypeDesc);
+ }
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/CertificateTypeDesc.java b/src/main/java/de/avatic/taricdb/model/CertificateTypeDesc.java
new file mode 100644
index 0000000..24752ba
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/CertificateTypeDesc.java
@@ -0,0 +1,62 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class CertificateTypeDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public CertificateTypeDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDescc() {
+ return desc;
+ }
+
+ public void setDescc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/ConditionType.java b/src/main/java/de/avatic/taricdb/model/ConditionType.java
new file mode 100644
index 0000000..02119d3
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/ConditionType.java
@@ -0,0 +1,47 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.Size;
+
+public class ConditionType {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String conditionTypeCode;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set conditionTypeDesc;
+
+ public ConditionType(String conditionTypeCode) {
+ this.conditionTypeCode = conditionTypeCode;
+ this.conditionTypeDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getConditionTypeCode() {
+ return conditionTypeCode;
+ }
+
+ public void setConditionTypeCode(final String conditionTypeCode) {
+ this.conditionTypeCode = conditionTypeCode;
+ }
+
+ public void addConditionTypeDesc(ConditionTypeDesc conditionTypeDesc) {
+ this.conditionTypeDesc.add(conditionTypeDesc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/ConditionTypeDesc.java b/src/main/java/de/avatic/taricdb/model/ConditionTypeDesc.java
new file mode 100644
index 0000000..df67750
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/ConditionTypeDesc.java
@@ -0,0 +1,61 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class ConditionTypeDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public ConditionTypeDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDescc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Footnote.java b/src/main/java/de/avatic/taricdb/model/Footnote.java
new file mode 100644
index 0000000..b972488
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Footnote.java
@@ -0,0 +1,82 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+
+@Table("footnote")
+public class Footnote {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 8)
+ @Column("footnote")
+ private String footnote;
+
+ @Column("start_date")
+ private LocalDate startDate;
+
+
+ @Column("end_date")
+ private LocalDate endDate;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set footnotesDesc;
+
+ public Footnote(String footnote, String descrption, LocalDate startDate, LocalDate endDate) {
+ this.footnote = footnote;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.footnotesDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getFootnote() {
+ return footnote;
+ }
+
+ public void setFootnote(final String footnote) {
+ this.footnote = footnote;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public Set getFootnotesDesc() {
+ return footnotesDesc;
+ }
+
+ public void addFootnotesDesc(FootnotesDesc footnotesDesc) {
+ this.footnotesDesc.add(footnotesDesc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/FootnotesDesc.java b/src/main/java/de/avatic/taricdb/model/FootnotesDesc.java
new file mode 100644
index 0000000..cd5c6de
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/FootnotesDesc.java
@@ -0,0 +1,60 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+
+@Table("footnotes_desc")
+public class FootnotesDesc {
+
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+ public FootnotesDesc(String desc, String lang, LocalDate descStartDate) {
+ this.desc = desc;
+ this.lang = lang;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDescc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Geo.java b/src/main/java/de/avatic/taricdb/model/Geo.java
new file mode 100644
index 0000000..9995911
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Geo.java
@@ -0,0 +1,51 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.Size;
+
+
+public class Geo {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ @Column("iso_3166_code")
+ private String iso3166Code;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set geoDesc;
+
+ public Geo(String iso3166Code) {
+ this.iso3166Code = iso3166Code;
+ this.geoDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getIso3166Code() {
+ return iso3166Code;
+ }
+
+ public void setIso3166Code(final String iso3166Code) {
+ this.iso3166Code = iso3166Code;
+ }
+
+ public void addGeoDescription(GeoDesc geoDesc) {
+ this.geoDesc.add(geoDesc);
+
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/GeoDesc.java b/src/main/java/de/avatic/taricdb/model/GeoDesc.java
new file mode 100644
index 0000000..fbf85f5
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/GeoDesc.java
@@ -0,0 +1,60 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+public class GeoDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public GeoDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/GeoGroup.java b/src/main/java/de/avatic/taricdb/model/GeoGroup.java
new file mode 100644
index 0000000..793ef9a
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/GeoGroup.java
@@ -0,0 +1,89 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.Size;
+
+
+public class GeoGroup {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 4)
+ private String geoGroupCode;
+
+ private String abbr;
+
+ private LocalDate startDate;
+
+ private LocalDate endDate;
+
+ @MappedCollection(idColumn = "geo_group_id")
+ private Set geoGroupMembers;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set geoGroupDescs;
+
+
+ public GeoGroup(String geoGroupCode, String abbr, LocalDate startDate, LocalDate endDate,
+ Set geoGroupMembers) {
+ this.geoGroupCode = geoGroupCode;
+ this.abbr = abbr;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.geoGroupMembers = geoGroupMembers;
+ this.geoGroupDescs = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getGeoGroupCode() {
+ return geoGroupCode;
+ }
+
+ public void setGeoGroupCode(final String geoGroupCode) {
+ this.geoGroupCode = geoGroupCode;
+ }
+
+ public String getAbbr() {
+ return abbr;
+ }
+
+ public void setAbbr(final String abbr) {
+ this.abbr = abbr;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public void addGeoGroupDesc(GeoGroupDesc geoGroupDesc) {
+ this.geoGroupDescs.add(geoGroupDesc);
+
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/GeoGroupDesc.java b/src/main/java/de/avatic/taricdb/model/GeoGroupDesc.java
new file mode 100644
index 0000000..d400061
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/GeoGroupDesc.java
@@ -0,0 +1,61 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class GeoGroupDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public GeoGroupDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDescc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/GeoGroupMembership.java b/src/main/java/de/avatic/taricdb/model/GeoGroupMembership.java
new file mode 100644
index 0000000..e374097
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/GeoGroupMembership.java
@@ -0,0 +1,62 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+
+
+public class GeoGroupMembership {
+
+ @Id
+ private Integer id;
+
+ private LocalDate startDate;
+
+ private LocalDate endDate;
+
+ @Column("geo_id")
+ private AggregateReference geo;
+
+ public GeoGroupMembership(LocalDate startDate, LocalDate endDate,
+ AggregateReference geo) {
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.geo = geo;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public AggregateReference getGeo() {
+ return geo;
+ }
+
+ public void setGeo(final AggregateReference geo) {
+ this.geo = geo;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Import.java b/src/main/java/de/avatic/taricdb/model/Import.java
new file mode 100644
index 0000000..0cee363
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Import.java
@@ -0,0 +1,87 @@
+package de.avatic.taricdb.model;
+
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.NotNull;
+
+@Table("import")
+public class Import {
+
+ @Id
+ private Integer id;
+
+ @NotNull
+ @Column("nomenclature_id")
+ private AggregateReference nomenclature;
+
+ @Column("additional_code_id")
+ private AggregateReference additionalCode;
+
+ @Column("geo_id")
+ private AggregateReference geo;
+
+ @Column("geo_group_id")
+ private AggregateReference geoGroup;
+
+ @MappedCollection(idColumn = "import_id")
+ Set appliedMeasures;
+
+ public Import(AggregateReference nomenclature,
+ AggregateReference additionalCode, Set appliedMeasures, AggregateReference geo,
+ AggregateReference geoGroup) {
+ this.nomenclature = nomenclature;
+ this.additionalCode = additionalCode;
+ this.appliedMeasures = appliedMeasures;
+ this.geo = geo;
+ this.geoGroup = geoGroup;
+ }
+
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public AggregateReference getNomenclature() {
+ return nomenclature;
+ }
+
+ public void setNomenclature(final AggregateReference nomenclature) {
+ this.nomenclature = nomenclature;
+ }
+
+ public AggregateReference getAdditionalCode() {
+ return additionalCode;
+ }
+
+ public void setAdditionalCode(final AggregateReference additionalCode) {
+ this.additionalCode = additionalCode;
+ }
+
+ public AggregateReference getGeo() {
+ return geo;
+ }
+
+ public void setGeo(final AggregateReference geo) {
+ this.geo = geo;
+ }
+
+ public AggregateReference getGeoGroup() {
+ return geoGroup;
+ }
+
+ public void setGeoGroup(final AggregateReference geoGroup) {
+ this.geoGroup = geoGroup;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/LegalBase.java b/src/main/java/de/avatic/taricdb/model/LegalBase.java
new file mode 100644
index 0000000..6da2e05
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/LegalBase.java
@@ -0,0 +1,72 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class LegalBase {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 255)
+ private String legalBase;
+
+ @Size(max = 255)
+ private String journal;
+
+ private Integer page;
+
+ private LocalDate date;
+
+ public LegalBase(String legalBase, String journal, Integer page, LocalDate date) {
+ this.legalBase = legalBase;
+ this.journal = journal;
+ this.page = page;
+ this.date = date;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLegalBase() {
+ return legalBase;
+ }
+
+ public void setLegalBase(final String legalBase) {
+ this.legalBase = legalBase;
+ }
+
+ public String getJournal() {
+ return journal;
+ }
+
+ public void setJournal(final String journal) {
+ this.journal = journal;
+ }
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(final Integer page) {
+ this.page = page;
+ }
+
+ public LocalDate getDate() {
+ return date;
+ }
+
+ public void setDate(final LocalDate date) {
+ this.date = date;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Measure.java b/src/main/java/de/avatic/taricdb/model/Measure.java
new file mode 100644
index 0000000..01ec4bb
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Measure.java
@@ -0,0 +1,96 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+@Table("measure")
+public class Measure {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 3)
+ private String measureCode;
+
+ private String shortDesc;
+
+ private Integer tmCode;
+
+ private LocalDate startDate;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set measureDesc;
+
+
+ @Column("measure_series_id")
+ AggregateReference measureSeries;
+
+ public Measure(String code, String shortDesc, Integer tmCode, LocalDate startDate, AggregateReference measureSeries) {
+ this.measureCode = code;
+ this.shortDesc = shortDesc;
+ this.tmCode = tmCode;
+ this.startDate = startDate;
+ this.measureSeries = measureSeries;
+ this.measureDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getMeasureCode() {
+ return measureCode;
+ }
+
+ public void setMeasureCode(final String measureCode) {
+ this.measureCode = measureCode;
+ }
+
+ public String getShortDesc() {
+ return shortDesc;
+ }
+
+ public void setShortDesc(final String shortDesc) {
+ this.shortDesc = shortDesc;
+ }
+
+ public Integer getTmCode() {
+ return tmCode;
+ }
+
+ public void setTmCode(final Integer tmCode) {
+ this.tmCode = tmCode;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public void addMeasureDesc(MeasureDesc measureDesc) {
+ this.measureDesc.add(measureDesc);
+ }
+
+ public AggregateReference getMeasureSeries() {
+ return measureSeries;
+ }
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureAction.java b/src/main/java/de/avatic/taricdb/model/MeasureAction.java
new file mode 100644
index 0000000..5147956
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureAction.java
@@ -0,0 +1,49 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+@Table("measure_action")
+public class MeasureAction {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String measureActionCode;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set measureActionDesc;
+
+ public MeasureAction(String measureActionCode) {
+ this.measureActionCode = measureActionCode;
+ this.measureActionDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getMeasureActionCode() {
+ return measureActionCode;
+ }
+
+ public void setMeasureActionCode(final String measureActionCode) {
+ this.measureActionCode = measureActionCode;
+ }
+
+ public void addMeasureActionDesc(MeasureActionDesc measureActionDesc) {
+ this.measureActionDesc.add(measureActionDesc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureActionDesc.java b/src/main/java/de/avatic/taricdb/model/MeasureActionDesc.java
new file mode 100644
index 0000000..ae38573
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureActionDesc.java
@@ -0,0 +1,58 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import jakarta.validation.constraints.Size;
+
+
+public class MeasureActionDesc {
+
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+ public MeasureActionDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureDesc.java b/src/main/java/de/avatic/taricdb/model/MeasureDesc.java
new file mode 100644
index 0000000..96b8fb9
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureDesc.java
@@ -0,0 +1,60 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class MeasureDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public MeasureDesc(String lang, String desc) {
+ this.lang = lang;
+ this.desc = desc;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureExclusion.java b/src/main/java/de/avatic/taricdb/model/MeasureExclusion.java
new file mode 100644
index 0000000..5be3660
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureExclusion.java
@@ -0,0 +1,39 @@
+package de.avatic.taricdb.model;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+
+import jakarta.validation.constraints.NotNull;
+
+
+public class MeasureExclusion {
+
+ @Id
+ private Integer id;
+
+ @NotNull
+ @Column("geo_id")
+ private AggregateReference geo;
+
+ public MeasureExclusion(AggregateReference geo) {
+ this.geo = geo;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public AggregateReference getGeo() {
+ return geo;
+ }
+
+ public void setGeo(final AggregateReference geo) {
+ this.geo = geo;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureFootnote.java b/src/main/java/de/avatic/taricdb/model/MeasureFootnote.java
new file mode 100644
index 0000000..229cb27
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureFootnote.java
@@ -0,0 +1,39 @@
+package de.avatic.taricdb.model;
+
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+
+
+public class MeasureFootnote {
+
+ @Id
+ private Integer id;
+
+ @Column("footnote_id")
+ private AggregateReference footnote;
+
+ public MeasureFootnote(AggregateReference footnote) {
+ this.footnote = footnote;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public AggregateReference getFootnote() {
+ return footnote;
+ }
+
+ public void setFootnote(final AggregateReference footnote) {
+ this.footnote = footnote;
+ }
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureSeries.java b/src/main/java/de/avatic/taricdb/model/MeasureSeries.java
new file mode 100644
index 0000000..50b0106
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureSeries.java
@@ -0,0 +1,49 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+@Table("measure_series")
+public class MeasureSeries {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 1)
+ private String measureSeriesCode;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set measureSeriesDesc;
+
+ public MeasureSeries(String measureSeriesCode) {
+ this.measureSeriesCode = measureSeriesCode;
+ this.measureSeriesDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getMeasureSeriesCode() {
+ return measureSeriesCode;
+ }
+
+ public void setMeasureSeriesCode(final String measureSeriesCode) {
+ this.measureSeriesCode = measureSeriesCode;
+ }
+
+ public void addMeasureSeriesDesc(MeasureSeriesDesc measureSeriesDesc) {
+ this.measureSeriesDesc.add(measureSeriesDesc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MeasureSeriesDesc.java b/src/main/java/de/avatic/taricdb/model/MeasureSeriesDesc.java
new file mode 100644
index 0000000..fdeb533
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MeasureSeriesDesc.java
@@ -0,0 +1,61 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+
+@Table("measure_series_desc")
+public class MeasureSeriesDesc {
+
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+
+ public MeasureSeriesDesc(String lang, String desc) {
+ this.lang = lang;
+ this.desc = desc;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDescc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MonetaryUnit.java b/src/main/java/de/avatic/taricdb/model/MonetaryUnit.java
new file mode 100644
index 0000000..098b48b
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MonetaryUnit.java
@@ -0,0 +1,48 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.Size;
+
+
+public class MonetaryUnit {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 3)
+ private String monetaryUnitCode;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set monetaryUnitDesc;
+
+ public MonetaryUnit(String monetaryUnitCode) {
+ this.monetaryUnitCode = monetaryUnitCode;
+ this.monetaryUnitDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getMonetaryUnitCode() {
+ return monetaryUnitCode;
+ }
+
+ public void setMonetaryUnitCode(final String monetaryUnitCode) {
+ this.monetaryUnitCode = monetaryUnitCode;
+ }
+
+ public void addMonetaryUnitDesc(MonetaryUnitDesc monetaryUnitDesc) {
+ this.monetaryUnitDesc.add(monetaryUnitDesc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/MonetaryUnitDesc.java b/src/main/java/de/avatic/taricdb/model/MonetaryUnitDesc.java
new file mode 100644
index 0000000..d2a3007
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/MonetaryUnitDesc.java
@@ -0,0 +1,61 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class MonetaryUnitDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+ public MonetaryUnitDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDescc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Nomenclature.java b/src/main/java/de/avatic/taricdb/model/Nomenclature.java
new file mode 100644
index 0000000..c69446a
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Nomenclature.java
@@ -0,0 +1,146 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import jakarta.validation.constraints.Size;
+
+
+public class Nomenclature {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 10)
+ private String hscode;
+
+ @Size(max = 2)
+ private String suffix;
+
+ private Integer hierachy;
+
+ private Integer indent;
+
+ private LocalDate startDate;
+
+ private LocalDate endDate;
+
+ @JsonProperty("isLeaf")
+ private Boolean isLeaf;
+
+ private LocalDate isLeafStartDate;
+
+ private Integer parentId;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set nomenclatureDescs;
+
+ @MappedCollection(idColumn = "nomenclature_id")
+ private Set footnotes;
+
+ public Nomenclature(String hsCode, String suffix, Integer hierachy, Integer indent, LocalDate startDate,
+ LocalDate endDate, Boolean isLeaf, LocalDate isLeafStartDate, Integer parentId, Set footnotes) {
+ this.hscode = hsCode;
+ this.suffix = suffix;
+ this.hierachy = hierachy;
+ this.indent = indent;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.isLeaf = isLeaf;
+ this.isLeafStartDate = isLeafStartDate;
+ this.parentId = parentId;
+ this.footnotes = footnotes;
+ this.nomenclatureDescs = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getHscode() {
+ return hscode;
+ }
+
+ public void setHscode(final String hscode) {
+ this.hscode = hscode;
+ }
+
+ public String getSuffix() {
+ return suffix;
+ }
+
+ public void setSuffix(final String suffix) {
+ this.suffix = suffix;
+ }
+
+ public Integer getHierachy() {
+ return hierachy;
+ }
+
+ public void setHierachy(final Integer hierachy) {
+ this.hierachy = hierachy;
+ }
+
+ public Integer getIndent() {
+ return indent;
+ }
+
+ public void setIndent(final Integer indent) {
+ this.indent = indent;
+ }
+
+ public LocalDate getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(final LocalDate startDate) {
+ this.startDate = startDate;
+ }
+
+ public LocalDate getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(final LocalDate endDate) {
+ this.endDate = endDate;
+ }
+
+ public Boolean getIsLeaf() {
+ return isLeaf;
+ }
+
+ public void setIsLeaf(final Boolean isLeaf) {
+ this.isLeaf = isLeaf;
+ }
+
+ public LocalDate getIsLeafStartDate() {
+ return isLeafStartDate;
+ }
+
+ public void setIsLeafStartDate(final LocalDate isLeafStartDate) {
+ this.isLeafStartDate = isLeafStartDate;
+ }
+
+ public Integer getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(final Integer parentId) {
+ this.parentId = parentId;
+ }
+
+ public void addNomenclatureDesc(NomenclatureDesc nomenclatureDesc) {
+ this.nomenclatureDescs.add(nomenclatureDesc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/NomenclatureDesc.java b/src/main/java/de/avatic/taricdb/model/NomenclatureDesc.java
new file mode 100644
index 0000000..ae47e09
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/NomenclatureDesc.java
@@ -0,0 +1,61 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class NomenclatureDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+ public NomenclatureDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDescc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/NomenclatureFootnote.java b/src/main/java/de/avatic/taricdb/model/NomenclatureFootnote.java
new file mode 100644
index 0000000..8b6fd06
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/NomenclatureFootnote.java
@@ -0,0 +1,37 @@
+package de.avatic.taricdb.model;
+
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.data.relational.core.mapping.Column;
+
+import jakarta.validation.constraints.NotNull;
+
+
+public class NomenclatureFootnote {
+
+ private Integer id;
+
+ @NotNull
+ @Column("footnote_id")
+ private AggregateReference footnote;
+
+ public NomenclatureFootnote(AggregateReference footnote) {
+ this.footnote = footnote;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public AggregateReference getFootnote() {
+ return footnote;
+ }
+
+ public void setFootnote(final AggregateReference footnote) {
+ this.footnote = footnote;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/SetupStatus.java b/src/main/java/de/avatic/taricdb/model/SetupStatus.java
new file mode 100644
index 0000000..565c04f
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/SetupStatus.java
@@ -0,0 +1,83 @@
+package de.avatic.taricdb.model;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.Table;
+
+import jakarta.validation.constraints.Size;
+
+@Table("setup_status")
+public class SetupStatus {
+
+ @Id
+ private Integer id;
+
+ private Integer currentRecord;
+
+ private Integer maxRecord;
+
+ @Size(max = 255)
+ private String statusText;
+
+ private Boolean running;
+
+ @Size(max = 255)
+ private String exitStatus;
+
+ public SetupStatus(int currentRecord, int maxRecord, String statusText, boolean running, String exitStatus) {
+ this.currentRecord = currentRecord;
+ this.maxRecord = maxRecord;
+ this.statusText = statusText;
+ this.running = running;
+ this.exitStatus = exitStatus;
+ }
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public Integer getCurrentRecord() {
+ return currentRecord;
+ }
+
+ public void setCurrentRecord(final Integer currentRecord) {
+ this.currentRecord = currentRecord;
+ }
+
+ public Integer getMaxRecord() {
+ return maxRecord;
+ }
+
+ public void setMaxRecord(final Integer maxRecord) {
+ this.maxRecord = maxRecord;
+ }
+
+ public String getStatusText() {
+ return statusText;
+ }
+
+ public void setStatusText(final String statusText) {
+ this.statusText = statusText;
+ }
+
+ public Boolean getRunning() {
+ return running;
+ }
+
+ public void setRunning(final Boolean running) {
+ this.running = running;
+ }
+
+ public String getExitStatus() {
+ return exitStatus;
+ }
+
+ public void setExitStatus(final String exitStatus) {
+ this.exitStatus = exitStatus;
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/Unit.java b/src/main/java/de/avatic/taricdb/model/Unit.java
new file mode 100644
index 0000000..12d152c
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/Unit.java
@@ -0,0 +1,71 @@
+package de.avatic.taricdb.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.relational.core.mapping.MappedCollection;
+
+import jakarta.validation.constraints.Size;
+
+
+public class Unit {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 3)
+ private String unitCode;
+
+ @Size(max = 1)
+ private String unitQualifier;
+
+ private String label;
+
+ @MappedCollection(idColumn = "ref_id")
+ private Set unitDesc;
+
+ public Unit(String unitCode, String unitQualifier, String label) {
+ this.unitCode = unitCode;
+ this.unitQualifier = unitQualifier;
+ this.label = label;
+ this.unitDesc = new HashSet<>();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getUnitCode() {
+ return unitCode;
+ }
+
+ public void setUnitCode(final String unitCode) {
+ this.unitCode = unitCode;
+ }
+
+ public String getUnitQualifier() {
+ return unitQualifier;
+ }
+
+ public void setUnitQualifier(final String unitQualifier) {
+ this.unitQualifier = unitQualifier;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(final String label) {
+ this.label = label;
+ }
+
+ public void addUnitDesc(UnitDesc desc) {
+ unitDesc.add(desc);
+ }
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/UnitDesc.java b/src/main/java/de/avatic/taricdb/model/UnitDesc.java
new file mode 100644
index 0000000..b25a298
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/model/UnitDesc.java
@@ -0,0 +1,62 @@
+package de.avatic.taricdb.model;
+
+import java.time.LocalDate;
+
+import org.springframework.data.annotation.Id;
+
+import jakarta.validation.constraints.Size;
+
+
+public class UnitDesc {
+
+ @Id
+ private Integer id;
+
+ @Size(max = 2)
+ private String lang;
+
+ private String desc;
+
+ private LocalDate descStartDate;
+
+
+ public UnitDesc(String lang, String desc, LocalDate descStartDate) {
+ this.lang = lang;
+ this.desc = desc;
+ this.descStartDate = descStartDate;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(final Integer id) {
+ this.id = id;
+ }
+
+ public String getLang() {
+ return lang;
+ }
+
+ public void setLang(final String lang) {
+ this.lang = lang;
+ }
+
+ public String getDescc() {
+ return desc;
+ }
+
+ public void setDesc(final String desc) {
+ this.desc = desc;
+ }
+
+ public LocalDate getDescStartDate() {
+ return descStartDate;
+ }
+
+ public void setDescStartDate(final LocalDate descStartDate) {
+ this.descStartDate = descStartDate;
+ }
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/model/UploadFile.java b/src/main/java/de/avatic/taricdb/model/UploadFile.java
deleted file mode 100644
index 15c8cf6..0000000
--- a/src/main/java/de/avatic/taricdb/model/UploadFile.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package de.avatic.taricdb.model;
-
-
-
-public class UploadFile {
- int id;
- int parentId;
- UploadFileType type;
- byte[] blob;
-}
diff --git a/src/main/java/de/avatic/taricdb/repository/AdditionalCodeRepository.java b/src/main/java/de/avatic/taricdb/repository/AdditionalCodeRepository.java
new file mode 100644
index 0000000..3b6669b
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/AdditionalCodeRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.AdditionalCode;
+
+public interface AdditionalCodeRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/AppliedMeasureConditionRepository.java b/src/main/java/de/avatic/taricdb/repository/AppliedMeasureConditionRepository.java
new file mode 100644
index 0000000..2b405af
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/AppliedMeasureConditionRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.AppliedMeasureCondition;
+
+public interface AppliedMeasureConditionRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/AppliedMeasureRepository.java b/src/main/java/de/avatic/taricdb/repository/AppliedMeasureRepository.java
new file mode 100644
index 0000000..f810070
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/AppliedMeasureRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.AppliedMeasure;
+
+public interface AppliedMeasureRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/CertificateRepository.java b/src/main/java/de/avatic/taricdb/repository/CertificateRepository.java
new file mode 100644
index 0000000..994fd5e
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/CertificateRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.Certificate;
+
+public interface CertificateRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/CertificateTypeRepository.java b/src/main/java/de/avatic/taricdb/repository/CertificateTypeRepository.java
new file mode 100644
index 0000000..f00496a
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/CertificateTypeRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.CertificateType;
+
+public interface CertificateTypeRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/ConditionTypeRepository.java b/src/main/java/de/avatic/taricdb/repository/ConditionTypeRepository.java
new file mode 100644
index 0000000..b522aeb
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/ConditionTypeRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.ConditionType;
+
+public interface ConditionTypeRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/FootnoteRepository.java b/src/main/java/de/avatic/taricdb/repository/FootnoteRepository.java
new file mode 100644
index 0000000..a65a58d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/FootnoteRepository.java
@@ -0,0 +1,11 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.Footnote;
+
+public interface FootnoteRepository extends CrudRepository {
+
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/de/avatic/taricdb/repository/GeoGroupMembershipRepository.java b/src/main/java/de/avatic/taricdb/repository/GeoGroupMembershipRepository.java
new file mode 100644
index 0000000..621fb7d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/GeoGroupMembershipRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.GeoGroupMembership;
+
+public interface GeoGroupMembershipRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/GeoGroupRepository.java b/src/main/java/de/avatic/taricdb/repository/GeoGroupRepository.java
new file mode 100644
index 0000000..5cd8f5c
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/GeoGroupRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.GeoGroup;
+
+public interface GeoGroupRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/GeoRepository.java b/src/main/java/de/avatic/taricdb/repository/GeoRepository.java
new file mode 100644
index 0000000..53fb9b1
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/GeoRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.Geo;
+
+public interface GeoRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/ImportRepository.java b/src/main/java/de/avatic/taricdb/repository/ImportRepository.java
new file mode 100644
index 0000000..039f289
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/ImportRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.Import;
+
+public interface ImportRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/LegalBaseRepository.java b/src/main/java/de/avatic/taricdb/repository/LegalBaseRepository.java
new file mode 100644
index 0000000..187cc8c
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/LegalBaseRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.LegalBase;
+
+public interface LegalBaseRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/MeasureActionRepository.java b/src/main/java/de/avatic/taricdb/repository/MeasureActionRepository.java
new file mode 100644
index 0000000..04dbbd4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/MeasureActionRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.MeasureAction;
+
+public interface MeasureActionRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/MeasureExclusionRepository.java b/src/main/java/de/avatic/taricdb/repository/MeasureExclusionRepository.java
new file mode 100644
index 0000000..edeac69
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/MeasureExclusionRepository.java
@@ -0,0 +1,10 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.MeasureExclusion;
+
+public interface MeasureExclusionRepository extends CrudRepository
+{
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/MeasureFootnoteRepository.java b/src/main/java/de/avatic/taricdb/repository/MeasureFootnoteRepository.java
new file mode 100644
index 0000000..a45be15
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/MeasureFootnoteRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.MeasureFootnote;
+
+public interface MeasureFootnoteRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/MeasureRepository.java b/src/main/java/de/avatic/taricdb/repository/MeasureRepository.java
new file mode 100644
index 0000000..d35fcb4
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/MeasureRepository.java
@@ -0,0 +1,15 @@
+package de.avatic.taricdb.repository;
+
+import java.time.LocalDate;
+
+import org.springframework.data.jdbc.repository.query.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
+
+import de.avatic.taricdb.model.Measure;
+
+public interface MeasureRepository extends CrudRepository {
+
+
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/MeasureSeriesRepository.java b/src/main/java/de/avatic/taricdb/repository/MeasureSeriesRepository.java
new file mode 100644
index 0000000..5f9097d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/MeasureSeriesRepository.java
@@ -0,0 +1,11 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.MeasureSeries;
+
+public interface MeasureSeriesRepository extends CrudRepository {
+
+ public MeasureSeries findByMeasureSeriesCode(String measureSeriesCode);
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/MonetaryUnitRepository.java b/src/main/java/de/avatic/taricdb/repository/MonetaryUnitRepository.java
new file mode 100644
index 0000000..9a8a306
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/MonetaryUnitRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.MonetaryUnit;
+
+public interface MonetaryUnitRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/NomenclatureFootnoteRepository.java b/src/main/java/de/avatic/taricdb/repository/NomenclatureFootnoteRepository.java
new file mode 100644
index 0000000..0abe541
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/NomenclatureFootnoteRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.NomenclatureFootnote;
+
+public interface NomenclatureFootnoteRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/NomenclatureRepository.java b/src/main/java/de/avatic/taricdb/repository/NomenclatureRepository.java
new file mode 100644
index 0000000..e4dc01d
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/NomenclatureRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.Nomenclature;
+
+public interface NomenclatureRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/UnitRepository.java b/src/main/java/de/avatic/taricdb/repository/UnitRepository.java
new file mode 100644
index 0000000..2856369
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/repository/UnitRepository.java
@@ -0,0 +1,9 @@
+package de.avatic.taricdb.repository;
+
+import org.springframework.data.repository.CrudRepository;
+
+import de.avatic.taricdb.model.Unit;
+
+public interface UnitRepository extends CrudRepository {
+
+}
diff --git a/src/main/java/de/avatic/taricdb/repository/UploadFileRepository.java b/src/main/java/de/avatic/taricdb/repository/UploadFileRepository.java
deleted file mode 100644
index caa7238..0000000
--- a/src/main/java/de/avatic/taricdb/repository/UploadFileRepository.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package de.avatic.taricdb.repository;
-
-public class UploadFileRepository {
-
-}
diff --git a/src/main/java/de/avatic/taricdb/service/AsyncSetupDutiesService.java b/src/main/java/de/avatic/taricdb/service/AsyncSetupDutiesService.java
new file mode 100644
index 0000000..b3bb66a
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/service/AsyncSetupDutiesService.java
@@ -0,0 +1,58 @@
+package de.avatic.taricdb.service;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jdbc.core.mapping.AggregateReference;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import de.avatic.taricdb.helper.workbook.wrapper.AppliedMeasureWrapper;
+import de.avatic.taricdb.helper.workbook.wrapper.ImportWrapper;
+import de.avatic.taricdb.model.AdditionalCode;
+import de.avatic.taricdb.model.AppliedMeasure;
+import de.avatic.taricdb.model.Geo;
+import de.avatic.taricdb.model.GeoGroup;
+import de.avatic.taricdb.model.Import;
+import de.avatic.taricdb.model.Nomenclature;
+
+@Service
+public class AsyncSetupDutiesService {
+
+ private static final Logger logger = LoggerFactory.getLogger(AsyncSetupDutiesService.class);
+
+ @Autowired
+ ReferenceStorageService referenceStorage;
+
+
+ @Async
+ public void setupDuties(ImportWrapper im) {
+
+ String hsCode = im.getHsCode();
+ String origin = im.getOrigin();
+ String addCode = im.getAddCode();
+
+ Collection geos = referenceStorage.getEntites(Geo.class);
+ Collection geoGroups = referenceStorage.getEntites(GeoGroup.class);
+ Collection appliedMeasures = referenceStorage.getEntites(AppliedMeasureWrapper.class);
+ Collection additionalCodes = referenceStorage.getEntites(AdditionalCode.class);
+ Collection nomenclatures = referenceStorage.getEntites(Nomenclature.class);
+
+ Nomenclature nomenclature = nomenclatures.stream().filter(n -> n.getHscode().equals(hsCode)).findFirst().orElse(null);
+ AdditionalCode additionalCode = additionalCodes.stream().filter(a -> a.getAdditionalCode().equals(addCode)).findFirst().orElse(null);
+ Set foundAppliedMeasures = appliedMeasures.stream().filter(a -> a.getHsCode().equals(hsCode) && a.getOrigin().equals(origin) && a.getAdditionalCode().equals(addCode)).map(AppliedMeasureWrapper::getAppliedMeasure).collect(Collectors.toSet());
+
+ Geo geo = geos.stream().filter(g -> g.getIso3166Code().equals(origin)).findFirst().orElse(null);
+ GeoGroup geoGroup = geoGroups.stream().filter(g -> g.getGeoGroupCode().equals(origin)).findFirst().orElse(null);
+
+ im.completeImport(new Import(AggregateReference.to(nomenclature.getId()), additionalCode == null ? null : AggregateReference.to(additionalCode.getId()), foundAppliedMeasures, geo == null ? null : AggregateReference.to(geo.getId()), geoGroup == null ? null : AggregateReference.to(geoGroup.getId())));
+
+
+ }
+}
diff --git a/src/main/java/de/avatic/taricdb/service/ReferenceStorageService.java b/src/main/java/de/avatic/taricdb/service/ReferenceStorageService.java
new file mode 100644
index 0000000..5c1aed3
--- /dev/null
+++ b/src/main/java/de/avatic/taricdb/service/ReferenceStorageService.java
@@ -0,0 +1,27 @@
+package de.avatic.taricdb.service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ReferenceStorageService {
+
+ Map, List