Remove deprecated TariffService2, TariffController2, and associated DTOs while enhancing repository interfaces and refactoring tariff services for applied measure retrieval.
This commit is contained in:
parent
b8b8b2b5e9
commit
d06531599f
43 changed files with 633 additions and 984 deletions
|
|
@ -0,0 +1,35 @@
|
|||
package de.avatic.taric.controller;
|
||||
|
||||
import de.avatic.taric.model.Certificate;
|
||||
import de.avatic.taric.repository.CertificateRepository;
|
||||
import de.avatic.taric.repository.CertificateTypeRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/certificates")
|
||||
public class CertificateController {
|
||||
|
||||
private final CertificateRepository certificateRepository;
|
||||
private final CertificateTypeRepository certificateTypeRepository;
|
||||
|
||||
public CertificateController(CertificateRepository certificateRepository, CertificateTypeRepository certificateTypeRepository) {
|
||||
this.certificateRepository = certificateRepository;
|
||||
this.certificateTypeRepository = certificateTypeRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Iterable<Certificate> getCertificates(@RequestParam(required = false) String certificateTypeCode) {
|
||||
|
||||
if (certificateTypeCode != null) {
|
||||
return certificateTypeRepository.findByCertificateTypeCode(certificateTypeCode).map(type -> certificateRepository.findByCertificateType(AggregateReference.to(type.getId()))).orElse(List.of());
|
||||
}
|
||||
|
||||
return certificateRepository.findAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package de.avatic.taric.controller;
|
||||
|
||||
import de.avatic.taric.model.ConditionType;
|
||||
import de.avatic.taric.repository.ConditionTypeRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/conditions")
|
||||
public class ConditionController {
|
||||
|
||||
private final ConditionTypeRepository conditionTypeRepository;
|
||||
|
||||
public ConditionController(ConditionTypeRepository conditionTypeRepository) {
|
||||
this.conditionTypeRepository = conditionTypeRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Iterable<ConditionType> getConditions() {
|
||||
return conditionTypeRepository.findAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package de.avatic.taric.controller;
|
||||
|
||||
import de.avatic.taric.model.Measure;
|
||||
import de.avatic.taric.model.MeasureAction;
|
||||
import de.avatic.taric.model.MeasureSeries;
|
||||
import de.avatic.taric.repository.MeasureActionRepository;
|
||||
import de.avatic.taric.repository.MeasureRepository;
|
||||
import de.avatic.taric.repository.MeasureSeriesRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/measures")
|
||||
public class MeasureController {
|
||||
|
||||
private final MeasureRepository measureRepository;
|
||||
private final MeasureSeriesRepository measureSeriesRepository;
|
||||
private final MeasureActionRepository measureActionRepository;
|
||||
|
||||
public MeasureController(MeasureRepository measureRepository, MeasureSeriesRepository measureSeriesRepository, MeasureActionRepository measureActionRepository) {
|
||||
this.measureRepository = measureRepository;
|
||||
this.measureSeriesRepository = measureSeriesRepository;
|
||||
this.measureActionRepository = measureActionRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Iterable<Measure> getMeasures() {
|
||||
return measureRepository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/series")
|
||||
public Iterable<MeasureSeries> getMeasuresSeries() {
|
||||
return measureSeriesRepository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/action")
|
||||
public Iterable<MeasureAction> getMeasuresAction() {
|
||||
return measureActionRepository.findAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
package de.avatic.taric.controller;
|
||||
|
||||
import de.avatic.taric.model.AppliedMeasure;
|
||||
import de.avatic.taric.service.TariffService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/tariff")
|
||||
public class TariffController {
|
||||
|
|
@ -19,8 +22,8 @@ public class TariffController {
|
|||
}
|
||||
|
||||
@GetMapping("")
|
||||
public ResponseEntity<Double> getTariffRate(@RequestParam String hsCode, @RequestParam String countryCode) {
|
||||
return tariffService.getCustomPref( hsCode, countryCode).map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
|
||||
public Map<String, Map<String, List<AppliedMeasure>>> getTariffRate(@RequestParam String hsCode, @RequestParam String countryCode) {
|
||||
return tariffService.getAppliedMeasures(hsCode, countryCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,131 +0,0 @@
|
|||
package de.avatic.taric.controller;
|
||||
|
||||
import de.avatic.taric.service.TariffService2;
|
||||
//import de.avatic.taric.service.TariffService2.TariffResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//@RestController
|
||||
//@RequestMapping("/api/v1/tariff")
|
||||
|
||||
@Tag(name = "Tariff API", description = "API zur Abfrage von Zolltarifen")
|
||||
public class TariffController2 {
|
||||
|
||||
// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TariffController2.class);
|
||||
//
|
||||
// private final TariffService2 tariffService;
|
||||
//
|
||||
// public TariffController2(TariffService2 tariffService) {
|
||||
// this.tariffService = tariffService;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/rate")
|
||||
// @Operation(summary = "Zolltarif abfragen",
|
||||
// description = "Ermittelt den Zolltarif für einen HS-Code und ein Herkunftsland")
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(responseCode = "200", description = "Tarif erfolgreich gefunden"),
|
||||
// @ApiResponse(responseCode = "404", description = "Kein Tarif gefunden"),
|
||||
// @ApiResponse(responseCode = "400", description = "Ungültige Eingabeparameter")
|
||||
// })
|
||||
// public ResponseEntity<TariffResponse> getTariffRate(
|
||||
// @Parameter(description = "HS-Code (6, 8 oder 10 Stellen)", example = "850410")
|
||||
// @RequestParam
|
||||
// @NotBlank(message = "HS Code ist erforderlich")
|
||||
// @Pattern(regexp = "^[0-9]{4,10}$", message = "HS Code muss 4-10 Ziffern enthalten")
|
||||
// String hsCode,
|
||||
//
|
||||
// @Parameter(description = "ISO-2 Ländercode", example = "CN")
|
||||
// @RequestParam
|
||||
// @NotBlank(message = "Ländercode ist erforderlich")
|
||||
// @Pattern(regexp = "^[A-Z]{2}$", message = "Ländercode muss 2 Großbuchstaben sein")
|
||||
// String countryCode) {
|
||||
//
|
||||
// log.info("Tariff rate request - HS Code: {}, Country: {}", hsCode, countryCode);
|
||||
//
|
||||
// try {
|
||||
// TariffResult result = tariffService.getTariffRate(hsCode, countryCode);
|
||||
//
|
||||
// if (result.isFound()) {
|
||||
// TariffResponse response = TariffResponse.success(
|
||||
// result.getRate(),
|
||||
// result.getHsCode(),
|
||||
// result.getCountryCode()
|
||||
// );
|
||||
// return ResponseEntity.ok(response);
|
||||
// } else {
|
||||
// TariffResponse response = TariffResponse.notFound(result.getMessage());
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// log.error("Error getting tariff rate", e);
|
||||
// TariffResponse response = TariffResponse.error("Internal server error: " + e.getMessage());
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/health")
|
||||
// @Operation(summary = "Health Check", description = "Prüft ob der Service verfügbar ist")
|
||||
// public ResponseEntity<Map<String, String>> health() {
|
||||
// Map<String, String> response = new HashMap<>();
|
||||
// response.put("status", "UP");
|
||||
// response.put("service", "TARIC Tariff Service");
|
||||
// return ResponseEntity.ok(response);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Response-Klasse für Tarif-Abfragen
|
||||
// */
|
||||
// public static class TariffResponse {
|
||||
// private final boolean success;
|
||||
// private final BigDecimal tariffRate;
|
||||
// private final String hsCode;
|
||||
// private final String countryCode;
|
||||
// private final String message;
|
||||
// private final String formattedRate;
|
||||
//
|
||||
// private TariffResponse(boolean success, BigDecimal tariffRate,
|
||||
// String hsCode, String countryCode, String message) {
|
||||
// this.success = success;
|
||||
// this.tariffRate = tariffRate;
|
||||
// this.hsCode = hsCode;
|
||||
// this.countryCode = countryCode;
|
||||
// this.message = message;
|
||||
// this.formattedRate = tariffRate != null ?
|
||||
// tariffRate.toString() + " %" : null;
|
||||
// }
|
||||
//
|
||||
// public static TariffResponse success(BigDecimal rate, String hsCode, String countryCode) {
|
||||
// return new TariffResponse(true, rate, hsCode, countryCode,
|
||||
// "Tariff rate found successfully");
|
||||
// }
|
||||
//
|
||||
// public static TariffResponse notFound(String message) {
|
||||
// return new TariffResponse(false, null, null, null, message);
|
||||
// }
|
||||
//
|
||||
// public static TariffResponse error(String message) {
|
||||
// return new TariffResponse(false, null, null, null, message);
|
||||
// }
|
||||
//
|
||||
// // Getters
|
||||
// public boolean isSuccess() { return success; }
|
||||
// public BigDecimal getTariffRate() { return tariffRate; }
|
||||
// public String getHsCode() { return hsCode; }
|
||||
// public String getCountryCode() { return countryCode; }
|
||||
// public String getMessage() { return message; }
|
||||
// public String getFormattedRate() { return formattedRate; }
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package de.avatic.taric.dto;
|
||||
|
||||
import de.avatic.taric.model.Nomenclature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NomenclatureDTO {
|
||||
|
||||
private List<Nomenclature> cascade;
|
||||
|
||||
private List<Nomenclature> declarables;
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,10 @@ package de.avatic.taric.model;
|
|||
import java.time.LocalDate;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.LegalBaseReferenceSerializer;
|
||||
import de.avatic.taric.serializer.MeasureReferenceSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
|
@ -19,6 +23,7 @@ import org.springframework.data.relational.core.mapping.Table;
|
|||
public class AppliedMeasure {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Column("start_date")
|
||||
|
|
@ -37,13 +42,16 @@ public class AppliedMeasure {
|
|||
|
||||
@NotNull
|
||||
@Column("measure_id")
|
||||
@JsonSerialize(using = MeasureReferenceSerializer.class)
|
||||
private AggregateReference<Measure, Integer> measure;
|
||||
|
||||
|
||||
@Column("legal_base_id")
|
||||
@JsonSerialize(using = LegalBaseReferenceSerializer.class)
|
||||
private AggregateReference<LegalBase, Integer> legalBase;
|
||||
|
||||
@Column("legal_base")
|
||||
@JsonIgnore
|
||||
private String additionalLegalBase;
|
||||
|
||||
@MappedCollection(idColumn = "applied_measure_id")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package de.avatic.taric.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -15,6 +18,7 @@ import org.springframework.lang.Nullable;
|
|||
public class AppliedMeasureCondition {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
private Integer sequenceNo;
|
||||
|
|
@ -23,23 +27,28 @@ public class AppliedMeasureCondition {
|
|||
|
||||
@NotNull
|
||||
@Column("measure_action_id")
|
||||
@JsonSerialize(using = MeasureActionReferenceSerializer.class)
|
||||
private AggregateReference<MeasureAction, Integer> measureAction;
|
||||
|
||||
@Column("monetary_unit_id")
|
||||
@Nullable
|
||||
@JsonSerialize(using = MonetaryUnitReferenceSerializer.class)
|
||||
private AggregateReference<MonetaryUnit, Integer> monetaryUnit;
|
||||
|
||||
|
||||
@Column("unit_id")
|
||||
@Nullable
|
||||
@JsonSerialize(using = UnitReferenceSerializer.class)
|
||||
private AggregateReference<Unit, Integer> unit;
|
||||
|
||||
@Column("certificate_id")
|
||||
@Nullable
|
||||
@JsonSerialize(using = CertificateReferenceSerializer.class)
|
||||
private AggregateReference<Certificate, Integer> certificate;
|
||||
|
||||
@NotNull
|
||||
@Column("condition_type_id")
|
||||
@JsonSerialize(using = ConditionTypeReferenceSerializer.class)
|
||||
private AggregateReference<ConditionType, Integer> conditionType;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ import java.time.LocalDate;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.CertificateTypeReferenceSerializer;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.data.relational.core.mapping.Column;
|
||||
|
|
@ -12,10 +18,12 @@ import org.springframework.data.relational.core.mapping.MappedCollection;
|
|||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Certificate {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 4)
|
||||
|
|
@ -27,62 +35,13 @@ public class Certificate {
|
|||
|
||||
@NotNull
|
||||
@Column("certificate_type_id")
|
||||
@JsonSerialize(using = CertificateTypeReferenceSerializer.class)
|
||||
private AggregateReference<CertificateType, Integer> certificateType;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<CertificateDesc> certificateDesc;
|
||||
|
||||
public Certificate(String certificateCode, LocalDate startDate, LocalDate endDate, AggregateReference<CertificateType, Integer> 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<CertificateType, Integer> getCertificateType() {
|
||||
return certificateType;
|
||||
}
|
||||
|
||||
public void setCertificateType(final AggregateReference<CertificateType, Integer> certificateType) {
|
||||
this.certificateType = certificateType;
|
||||
}
|
||||
|
||||
public void addCertificateDesc(CertificateDesc certificateDesc) {
|
||||
this.certificateDesc.add(certificateDesc);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@ package de.avatic.taric.model;
|
|||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
public class CertificateDesc {
|
||||
@Getter
|
||||
@Setter
|
||||
public class CertificateDesc implements Description {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 2)
|
||||
|
|
@ -20,44 +25,5 @@ public class CertificateDesc {
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,47 +3,32 @@ package de.avatic.taric.model;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CertificateType {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 1)
|
||||
private String certificateTypeCode;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<CertificateTypeDesc> 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package de.avatic.taric.model;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
public class CertificateTypeDesc {
|
||||
@Getter
|
||||
@Setter
|
||||
public class CertificateTypeDesc implements Description {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
|
|
@ -20,43 +23,5 @@ public class CertificateTypeDesc {
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,45 +3,31 @@ package de.avatic.taric.model;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConditionType {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 2)
|
||||
private String conditionTypeCode;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<ConditionTypeDesc> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@ package de.avatic.taric.model;
|
|||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
public class ConditionTypeDesc {
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConditionTypeDesc implements Description{
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 2)
|
||||
|
|
@ -20,42 +25,5 @@ public class ConditionTypeDesc {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package de.avatic.taric.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -13,6 +14,7 @@ import java.time.LocalDate;
|
|||
public class LegalBase {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 255)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package de.avatic.taric.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import de.avatic.taric.serializer.MeasureSeriesReferenceSerializer;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -19,6 +23,7 @@ import java.util.Set;
|
|||
public class Measure {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 3)
|
||||
|
|
@ -32,9 +37,11 @@ public class Measure {
|
|||
private LocalDate startDate;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<MeasureDesc> measureDesc;
|
||||
|
||||
@Column("measure_series_id")
|
||||
@JsonSerialize(using = MeasureSeriesReferenceSerializer.class)
|
||||
AggregateReference<MeasureSeries, Integer> measureSeries;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,47 +3,33 @@ package de.avatic.taric.model;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
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;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Table("measure_action")
|
||||
public class MeasureAction {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 2)
|
||||
private String measureActionCode;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<MeasureActionDesc> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@ package de.avatic.taric.model;
|
|||
import java.time.LocalDate;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
public class MeasureActionDesc {
|
||||
@Setter
|
||||
@Getter
|
||||
public class MeasureActionDesc implements Description {
|
||||
|
||||
private Integer id;
|
||||
|
||||
|
|
@ -16,43 +20,5 @@ public class MeasureActionDesc {
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,19 @@ package de.avatic.taric.model;
|
|||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
public class MeasureDesc {
|
||||
@Getter
|
||||
@Setter
|
||||
public class MeasureDesc implements Description {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 2)
|
||||
|
|
@ -20,41 +25,4 @@ public class MeasureDesc {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package de.avatic.taric.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.GeoReferenceSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
|
@ -18,6 +21,7 @@ import java.time.LocalDate;
|
|||
public class MeasureExclusion {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Column("start_date")
|
||||
|
|
@ -28,6 +32,7 @@ public class MeasureExclusion {
|
|||
|
||||
@NotNull
|
||||
@Column("geo_id")
|
||||
@JsonSerialize(using = GeoReferenceSerializer.class)
|
||||
private AggregateReference<Geo, Integer> geo;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package de.avatic.taric.model;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.FootnoteReferenceSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
|
@ -16,6 +19,7 @@ import java.time.LocalDate;
|
|||
public class MeasureFootnote {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Column("start_date")
|
||||
|
|
@ -25,7 +29,8 @@ public class MeasureFootnote {
|
|||
private LocalDate endDate;
|
||||
|
||||
@Column("footnote_id")
|
||||
private Integer footnote;
|
||||
@JsonSerialize(using = FootnoteReferenceSerializer.class)
|
||||
private AggregateReference<Footnote, Integer> footnote;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,47 +3,33 @@ package de.avatic.taric.model;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
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;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Table("measure_series")
|
||||
public class MeasureSeries {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 1)
|
||||
private String measureSeriesCode;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<MeasureSeriesDesc> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@ package de.avatic.taric.model;
|
|||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Table("measure_series_desc")
|
||||
public class MeasureSeriesDesc {
|
||||
public class MeasureSeriesDesc implements Description {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 2)
|
||||
|
|
@ -21,41 +28,4 @@ public class MeasureSeriesDesc {
|
|||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,20 @@ package de.avatic.taric.model;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class MonetaryUnit {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 3)
|
||||
|
|
@ -20,29 +25,4 @@ public class MonetaryUnit {
|
|||
@MappedCollection(idColumn = "ref_id")
|
||||
private Set<MonetaryUnitDesc> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,23 @@ package de.avatic.taric.model;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import de.avatic.taric.serializer.DescSetSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Unit {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 3)
|
||||
|
|
@ -23,49 +31,9 @@ public class Unit {
|
|||
private String label;
|
||||
|
||||
@MappedCollection(idColumn = "ref_id")
|
||||
@JsonSerialize(using = DescSetSerializer.class)
|
||||
private Set<UnitDesc> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ package de.avatic.taric.model;
|
|||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
|
||||
public class UnitDesc {
|
||||
@Getter
|
||||
@Setter
|
||||
public class UnitDesc implements Description{
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
|
|
@ -20,43 +23,6 @@ public class UnitDesc {
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
package de.avatic.taric.repository;
|
||||
|
||||
import de.avatic.taric.model.CertificateType;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import de.avatic.taric.model.Certificate;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CertificateRepository extends CrudRepository<Certificate, Integer> {
|
||||
|
||||
Iterable<Certificate> findByCertificateType(@NotNull AggregateReference<CertificateType, Integer> certificateType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import org.springframework.data.repository.CrudRepository;
|
|||
|
||||
import de.avatic.taric.model.CertificateType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface CertificateTypeRepository extends CrudRepository<CertificateType, Integer> {
|
||||
|
||||
Optional<CertificateType> findByCertificateTypeCode(String certificateTypeCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import de.avatic.taric.model.Import;
|
|||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ImportRepository extends CrudRepository<Import, Integer> {
|
||||
|
|
@ -12,4 +13,6 @@ public interface ImportRepository extends CrudRepository<Import, Integer> {
|
|||
|
||||
List<Import> findByNomenclatureAndGeoGroupIn(Integer nomenclatureId, List<Integer> geoGroupIds);
|
||||
|
||||
List<Import> findByNomenclatureAndGeoGroup(Integer nomenclatureId, Integer geoGroupId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,6 @@ import de.avatic.taric.model.MeasureAction;
|
|||
|
||||
public interface MeasureActionRepository extends CrudRepository<MeasureAction, Integer> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,10 @@
|
|||
package de.avatic.taric.repository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jdbc.repository.query.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import de.avatic.taric.model.Measure;
|
||||
|
||||
public interface MeasureRepository extends CrudRepository<Measure, Integer> {
|
||||
|
||||
|
||||
Optional<Measure> getMeasureByShortDesc(String pref);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ import de.avatic.taric.model.MeasureSeries;
|
|||
|
||||
public interface MeasureSeriesRepository extends CrudRepository<MeasureSeries, Integer> {
|
||||
|
||||
public MeasureSeries findByMeasureSeriesCode(String measureSeriesCode);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Certificate;
|
||||
import de.avatic.taric.model.Unit;
|
||||
import de.avatic.taric.repository.CertificateRepository;
|
||||
import de.avatic.taric.repository.UnitRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class CertificateReferenceSerializer extends JsonSerializer<AggregateReference<Certificate, Integer>> {
|
||||
|
||||
private final CertificateRepository certificateRepository;
|
||||
|
||||
public CertificateReferenceSerializer(CertificateRepository certificateRepository) {
|
||||
|
||||
this.certificateRepository = certificateRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<Certificate, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
Certificate cert = certificateRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(cert);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.CertificateType;
|
||||
import de.avatic.taric.repository.CertificateTypeRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class CertificateTypeReferenceSerializer extends JsonSerializer<AggregateReference<CertificateType, Integer>> {
|
||||
|
||||
private final CertificateTypeRepository certificateTypeRepository;
|
||||
|
||||
public CertificateTypeReferenceSerializer(CertificateTypeRepository certificateTypeRepository) {
|
||||
this.certificateTypeRepository = certificateTypeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<CertificateType, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
CertificateType type = certificateTypeRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(type);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Certificate;
|
||||
import de.avatic.taric.model.ConditionType;
|
||||
import de.avatic.taric.repository.CertificateRepository;
|
||||
import de.avatic.taric.repository.ConditionTypeRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class ConditionTypeReferenceSerializer extends JsonSerializer<AggregateReference<ConditionType, Integer>> {
|
||||
|
||||
|
||||
private final ConditionTypeRepository conditionTypeRepository;
|
||||
|
||||
public ConditionTypeReferenceSerializer(ConditionTypeRepository conditionTypeRepository) {
|
||||
this.conditionTypeRepository = conditionTypeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<ConditionType, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
ConditionType type = conditionTypeRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(type);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Footnote;
|
||||
import de.avatic.taric.model.LegalBase;
|
||||
import de.avatic.taric.repository.FootnoteRepository;
|
||||
import de.avatic.taric.repository.LegalBaseRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class LegalBaseReferenceSerializer extends JsonSerializer<AggregateReference<Footnote, Integer>> {
|
||||
|
||||
|
||||
private final LegalBaseRepository legalBaseRepository;
|
||||
|
||||
public LegalBaseReferenceSerializer(LegalBaseRepository legalBaseRepository) {
|
||||
this.legalBaseRepository = legalBaseRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<Footnote, Integer> value, JsonGenerator gen,
|
||||
SerializerProvider serializers) throws IOException {
|
||||
if (value != null) {
|
||||
LegalBase legalBase = legalBaseRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(legalBase);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Certificate;
|
||||
import de.avatic.taric.model.MeasureAction;
|
||||
import de.avatic.taric.repository.CertificateRepository;
|
||||
import de.avatic.taric.repository.MeasureActionRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class MeasureActionReferenceSerializer extends JsonSerializer<AggregateReference<MeasureAction, Integer>> {
|
||||
|
||||
|
||||
private final MeasureActionRepository measureActionRepository;
|
||||
|
||||
public MeasureActionReferenceSerializer(MeasureActionRepository measureActionRepository) {
|
||||
|
||||
|
||||
this.measureActionRepository = measureActionRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<MeasureAction, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
MeasureAction action = measureActionRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(action);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Footnote;
|
||||
import de.avatic.taric.model.LegalBase;
|
||||
import de.avatic.taric.model.Measure;
|
||||
import de.avatic.taric.repository.MeasureRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class MeasureReferenceSerializer extends JsonSerializer<AggregateReference<Measure, Integer>> {
|
||||
|
||||
|
||||
private final MeasureRepository measureRepository;
|
||||
|
||||
public MeasureReferenceSerializer(MeasureRepository measureRepository) {
|
||||
this.measureRepository = measureRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<Measure, Integer> value, JsonGenerator gen,
|
||||
SerializerProvider serializers) throws IOException {
|
||||
if (value != null) {
|
||||
Measure measure = measureRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(measure);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Certificate;
|
||||
import de.avatic.taric.model.MeasureSeries;
|
||||
import de.avatic.taric.repository.CertificateRepository;
|
||||
import de.avatic.taric.repository.MeasureSeriesRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class MeasureSeriesReferenceSerializer extends JsonSerializer<AggregateReference<MeasureSeries, Integer>> {
|
||||
|
||||
|
||||
private final MeasureSeriesRepository measureSeriesRepository;
|
||||
|
||||
public MeasureSeriesReferenceSerializer(MeasureSeriesRepository measureSeriesRepository) {
|
||||
|
||||
this.measureSeriesRepository = measureSeriesRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<MeasureSeries, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
MeasureSeries series = measureSeriesRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(series);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.MonetaryUnit;
|
||||
import de.avatic.taric.repository.MonetaryUnitRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class MonetaryUnitReferenceSerializer extends JsonSerializer<AggregateReference<MonetaryUnit, Integer>> {
|
||||
private final MonetaryUnitRepository monetaryUnitRepository;
|
||||
|
||||
public MonetaryUnitReferenceSerializer(MonetaryUnitRepository monetaryUnitRepository) {
|
||||
this.monetaryUnitRepository = monetaryUnitRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<MonetaryUnit, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
MonetaryUnit unit = monetaryUnitRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(unit);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package de.avatic.taric.serializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import de.avatic.taric.model.Unit;
|
||||
import de.avatic.taric.repository.UnitRepository;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class UnitReferenceSerializer extends JsonSerializer<AggregateReference<Unit, Integer>> {
|
||||
private final UnitRepository unitRepository;
|
||||
|
||||
public UnitReferenceSerializer(UnitRepository unitRepository) {
|
||||
this.unitRepository = unitRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(AggregateReference<Unit, Integer> value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
|
||||
if (value != null) {
|
||||
Unit unit = unitRepository.findById(value.getId())
|
||||
.orElse(null);
|
||||
|
||||
gen.writeObject(unit);
|
||||
} else {
|
||||
gen.writeNull();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,10 +4,10 @@ package de.avatic.taric.service;
|
|||
import de.avatic.taric.error.ArgumentException;
|
||||
import de.avatic.taric.model.*;
|
||||
import de.avatic.taric.repository.ImportRepository;
|
||||
import de.avatic.taric.repository.MeasureRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
|
|
@ -17,56 +17,49 @@ public class TariffService {
|
|||
private final GeoService geoService;
|
||||
private final NomenclatureService nomenclatureService;
|
||||
private final ImportRepository importRepository;
|
||||
private final MeasureRepository measureRepository;
|
||||
|
||||
public TariffService(GeoService geoService, NomenclatureService nomenclatureService, ImportRepository importRepository, MeasureRepository measureRepository) {
|
||||
public TariffService(GeoService geoService, NomenclatureService nomenclatureService, ImportRepository importRepository) {
|
||||
this.geoService = geoService;
|
||||
this.nomenclatureService = nomenclatureService;
|
||||
this.importRepository = importRepository;
|
||||
this.measureRepository = measureRepository;
|
||||
}
|
||||
|
||||
public Optional<Double> getCustomPref(String hsCode, String countryCode) {
|
||||
public Map<String, Map<String, List<AppliedMeasure>>> getAppliedMeasures(String hsCode, String countryCode) {
|
||||
|
||||
Map<String, Map<String, List<AppliedMeasure>>> collectedMeasures = new HashMap<>();
|
||||
|
||||
var geoGroups = geoService.getGeoGroupByCountryCode(countryCode);
|
||||
var geo = geoService.getGeo(countryCode);
|
||||
var optGeo = geoService.getGeo(countryCode);
|
||||
|
||||
var nomenclature = nomenclatureService.getNomenclature(hsCode);
|
||||
var cascade = nomenclatureService.getNomenclatureCascade(hsCode);
|
||||
|
||||
var customAppl = measureRepository.getMeasureByShortDesc("APPL");
|
||||
|
||||
if (nomenclature.isEmpty() || !nomenclature.get().getIsLeaf()) throw new ArgumentException("hsCode");
|
||||
if (geo.isEmpty()) throw new ArgumentException("countryCode");
|
||||
|
||||
if (customAppl.isEmpty()) throw new InternalError("APPL not found");
|
||||
if (optGeo.isEmpty()) throw new ArgumentException("countryCode");
|
||||
|
||||
var geo = optGeo.get();
|
||||
|
||||
for (Nomenclature n : cascade) {
|
||||
var applMeasures = findAppliedMeasureByGeo(n, geo.get());
|
||||
var nomenclatureMeasures = new HashMap<String, List<AppliedMeasure>>();
|
||||
|
||||
if (!applMeasures.isEmpty()) {
|
||||
var tariff = findTariff(applMeasures, customAppl.get());
|
||||
var measuresByOrigin = findAppliedMeasureByGeo(n, geo);
|
||||
|
||||
if (tariff.isPresent())
|
||||
return tariff;
|
||||
if (!measuresByOrigin.isEmpty())
|
||||
nomenclatureMeasures.put(geo.getIso3166Code(), measuresByOrigin);
|
||||
|
||||
for (var geoGroup : geoGroups) {
|
||||
var measuresByGeoGroup = findAppliedMeasureByGeoGroup(n, geo, geoGroup);
|
||||
if (!measuresByGeoGroup.isEmpty())
|
||||
nomenclatureMeasures.put(geoGroup.getAbbr(), measuresByGeoGroup);
|
||||
}
|
||||
|
||||
if (!nomenclatureMeasures.isEmpty())
|
||||
collectedMeasures.put(n.getHscode(), nomenclatureMeasures);
|
||||
}
|
||||
|
||||
for (Nomenclature n : cascade) {
|
||||
var applMeasures = findAppliedMeasureByGeoGroup(n, geo.get(), geoGroups);
|
||||
|
||||
if (!applMeasures.isEmpty()) {
|
||||
var tariff = findTariff(applMeasures, customAppl.get());
|
||||
|
||||
if (tariff.isPresent())
|
||||
return tariff;
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
return collectedMeasures;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +67,7 @@ public class TariffService {
|
|||
|
||||
var code = appl.getMeasureCode();
|
||||
|
||||
//TODO return all measures...
|
||||
|
||||
List<AppliedMeasure> filteredMeasures = measures.stream()
|
||||
.filter(meas -> meas.getAmount() != null && meas.getAmount().trim().matches("\\d+\\.\\d+\\s*%"))
|
||||
|
|
@ -81,11 +75,12 @@ public class TariffService {
|
|||
|
||||
AppliedMeasure customTariff = filteredMeasures.stream().filter(meas -> meas.getMeasure().getId().equals(appl.getId())).findAny().orElse(filteredMeasures.isEmpty() ? null : filteredMeasures.getFirst());
|
||||
|
||||
if (!filteredMeasures.isEmpty()) return Optional.of(customTariff).map(meas -> Double.parseDouble(meas.getAmount().trim().replace("%", "").trim())/100);
|
||||
if (!filteredMeasures.isEmpty())
|
||||
return Optional.of(customTariff).map(meas -> Double.parseDouble(meas.getAmount().trim().replace("%", "").trim()) / 100);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public Collection<AppliedMeasure> findAppliedMeasureByGeo(Nomenclature nomenclature, Geo geo) {
|
||||
public List<AppliedMeasure> findAppliedMeasureByGeo(Nomenclature nomenclature, Geo geo) {
|
||||
|
||||
var foundImport = importRepository.findByNomenclatureAndGeo(nomenclature.getId(), geo.getId());
|
||||
var applMeasures = new ArrayList<AppliedMeasure>();
|
||||
|
|
@ -94,7 +89,7 @@ public class TariffService {
|
|||
|
||||
for (var imp : foundImport) {
|
||||
for (var applMeasure : imp.getAppliedMeasures()) {
|
||||
if (applMeasure.getExclusions().stream().noneMatch(ex -> ex.getGeo().getId().equals(geo.getId()))) {
|
||||
if (isCurrentlyValid(applMeasure) && applMeasure.getExclusions().stream().noneMatch(ex -> ex.getGeo().getId().equals(geo.getId()))) {
|
||||
applMeasures.add(applMeasure);
|
||||
}
|
||||
}
|
||||
|
|
@ -104,15 +99,16 @@ public class TariffService {
|
|||
|
||||
}
|
||||
|
||||
public Collection<AppliedMeasure> findAppliedMeasureByGeoGroup(Nomenclature nomenclature, Geo geo, List<GeoGroup> geoGroups) {
|
||||
var foundImport = importRepository.findByNomenclatureAndGeoGroupIn(nomenclature.getId(), geoGroups.stream().map(GeoGroup::getId).toList());
|
||||
|
||||
public List<AppliedMeasure> findAppliedMeasureByGeoGroup(Nomenclature nomenclature, Geo geo, GeoGroup geoGroup) {
|
||||
var foundImport = importRepository.findByNomenclatureAndGeoGroup(nomenclature.getId(), geoGroup.getId());
|
||||
var applMeasures = new ArrayList<AppliedMeasure>();
|
||||
|
||||
if (foundImport.isEmpty()) return Collections.emptyList();
|
||||
|
||||
for (var imp : foundImport) {
|
||||
for (var applMeasure : imp.getAppliedMeasures()) {
|
||||
if (applMeasure.getExclusions().stream().noneMatch(ex -> ex.getGeo().getId().equals(geo.getId()))) {
|
||||
if (isCurrentlyValid(applMeasure) && applMeasure.getExclusions().stream().noneMatch(ex -> ex.getGeo().getId().equals(geo.getId()))) {
|
||||
applMeasures.add(applMeasure);
|
||||
}
|
||||
}
|
||||
|
|
@ -121,5 +117,13 @@ public class TariffService {
|
|||
return applMeasures;
|
||||
}
|
||||
|
||||
private boolean isCurrentlyValid(AppliedMeasure applMeasure) {
|
||||
var start = applMeasure.getStartDate();
|
||||
var end = applMeasure.getEndDate();
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
return (start == null || start.isBefore(now)) && (end == null || end.isAfter(now));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,303 +0,0 @@
|
|||
package de.avatic.taric.service;
|
||||
|
||||
import de.avatic.taric.model.*;
|
||||
import de.avatic.taric.repository.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
public class TariffService2 {
|
||||
|
||||
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TariffService2.class);
|
||||
|
||||
private final ImportRepository importRepository;
|
||||
private final AppliedMeasureRepository appliedMeasureRepository;
|
||||
private final NomenclatureRepository nomenclatureRepository;
|
||||
private final GeoRepository geoRepository;
|
||||
private final GeoGroupRepository geoGroupRepository;
|
||||
private final GeoGroupMembershipRepository geoGroupMembershipRepository;
|
||||
private final MeasureRepository measureRepository;
|
||||
private final MeasureExclusionRepository measureExclusionRepository;
|
||||
|
||||
public TariffService2(ImportRepository importRepository, AppliedMeasureRepository appliedMeasureRepository, NomenclatureRepository nomenclatureRepository, GeoRepository geoRepository, GeoGroupRepository geoGroupRepository, GeoGroupMembershipRepository geoGroupMembershipRepository, MeasureRepository measureRepository, MeasureExclusionRepository measureExclusionRepository) {
|
||||
this.importRepository = importRepository;
|
||||
this.appliedMeasureRepository = appliedMeasureRepository;
|
||||
this.nomenclatureRepository = nomenclatureRepository;
|
||||
this.geoRepository = geoRepository;
|
||||
this.geoGroupRepository = geoGroupRepository;
|
||||
this.geoGroupMembershipRepository = geoGroupMembershipRepository;
|
||||
this.measureRepository = measureRepository;
|
||||
this.measureExclusionRepository = measureExclusionRepository;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Ermittelt den Zolltarif für einen HS-Code und ein Herkunftsland
|
||||
// *
|
||||
// * @param hsCode HS-Code (kann 6, 8 oder 10 Stellen haben)
|
||||
// * @param countryCode ISO-2 Ländercode (z.B. "CN" für China)
|
||||
// * @return Zolltarif in Prozent
|
||||
// */
|
||||
// @Transactional(readOnly = true)
|
||||
// public TariffResult getTariffRate(String hsCode, String countryCode) {
|
||||
// log.info("Getting tariff rate for HS Code: {} from country: {}", hsCode, countryCode);
|
||||
//
|
||||
// // Normalisiere HS-Code auf 10 Stellen
|
||||
// String normalizedHsCode = normalizeHsCode(hsCode);
|
||||
//
|
||||
// // Finde alle relevanten Nomenclature-Codes (inkl. Parent-Codes durch Cascade-Prinzip)
|
||||
// List<String> relevantCodes = findRelevantNomenclatureCodes(normalizedHsCode);
|
||||
// log.debug("Found relevant codes: {}", relevantCodes);
|
||||
//
|
||||
// // Hole das Land
|
||||
// Optional<Geo> countryOpt = geoRepository.findByIso3166Code(countryCode);
|
||||
// if (countryOpt.isEmpty()) {
|
||||
// log.warn("Country not found: {}", countryCode);
|
||||
// return TariffResult.notFound("Country code not found: " + countryCode);
|
||||
// }
|
||||
//
|
||||
// Geo country = countryOpt.get();
|
||||
//
|
||||
// // Finde alle Imports für die relevanten Codes
|
||||
// List<Import> imports = findRelevantImports(relevantCodes, country);
|
||||
//
|
||||
// if (imports.isEmpty()) {
|
||||
// log.info("No imports found for codes: {} and country: {}", relevantCodes, countryCode);
|
||||
// // Versuche Erga Omnes (alle Länder)
|
||||
// imports = findErgaOmnesImports(relevantCodes);
|
||||
// }
|
||||
//
|
||||
// if (imports.isEmpty()) {
|
||||
// return TariffResult.notFound("No tariff data found for HS code: " + hsCode);
|
||||
// }
|
||||
//
|
||||
// // Finde die anwendbaren Maßnahmen
|
||||
// BigDecimal tariffRate = calculateTariffRate(imports, country);
|
||||
//
|
||||
// return TariffResult.success(tariffRate, normalizedHsCode, countryCode);
|
||||
// }
|
||||
//
|
||||
// private String normalizeHsCode(String hsCode) {
|
||||
// // Entferne alle nicht-numerischen Zeichen
|
||||
// String cleaned = hsCode.replaceAll("[^0-9]", "");
|
||||
//
|
||||
// // Fülle auf 10 Stellen mit Nullen auf
|
||||
// while (cleaned.length() < 10) {
|
||||
// cleaned += "0";
|
||||
// }
|
||||
//
|
||||
// // Begrenze auf 10 Stellen
|
||||
// if (cleaned.length() > 10) {
|
||||
// cleaned = cleaned.substring(0, 10);
|
||||
// }
|
||||
//
|
||||
// return cleaned;
|
||||
// }
|
||||
//
|
||||
// private List<String> findRelevantNomenclatureCodes(String hsCode) {
|
||||
// List<String> codes = new ArrayList<>();
|
||||
// codes.add(hsCode);
|
||||
//
|
||||
// // Füge Parent-Codes hinzu (Cascade-Prinzip)
|
||||
// // Beispiel: 8504101010 -> auch 85041010, 850410, 8504, 85
|
||||
// String code = hsCode;
|
||||
// while (code.length() > 2) {
|
||||
// // Entferne die letzten 2 Nullen
|
||||
// if (code.endsWith("00")) {
|
||||
// code = code.substring(0, code.length() - 2);
|
||||
// codes.add(code + "0".repeat(10 - code.length()));
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return codes;
|
||||
// }
|
||||
//
|
||||
// private List<Import> findRelevantImports(List<String> nomenclatureCodes, Geo country) {
|
||||
// List<Import> imports = new ArrayList<>();
|
||||
//
|
||||
// for (String code : nomenclatureCodes) {
|
||||
// // Suche direkte Länder-Zuordnungen
|
||||
// Optional<Nomenclature> nomenclatureOpt = nomenclatureRepository.findByHscode(code);
|
||||
// if (nomenclatureOpt.isPresent()) {
|
||||
// Nomenclature nomenclature = nomenclatureOpt.get();
|
||||
//
|
||||
// // Suche Imports mit direkter Geo-Zuordnung
|
||||
// imports.addAll(importRepository.findByNomenclatureIdAndGeoId(
|
||||
// nomenclature.getId(), country.getId()));
|
||||
//
|
||||
// // Suche auch nach Ländergruppen-Mitgliedschaften
|
||||
// List<GeoGroupMembership> memberships =
|
||||
// geoGroupMembershipRepository.findByGeoId(country.getId());
|
||||
//
|
||||
// for (GeoGroupMembership membership : memberships) {
|
||||
// // Hole die geo_group_id aus der membership
|
||||
// Integer geoGroupId = geoGroupMembershipRepository
|
||||
// .findGeoGroupIdByMembershipId(membership.getId());
|
||||
// if (geoGroupId != null) {
|
||||
// imports.addAll(importRepository.findByNomenclatureIdAndGeoGroupId(
|
||||
// nomenclature.getId(), geoGroupId));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return imports;
|
||||
// }
|
||||
//
|
||||
// private List<Import> findErgaOmnesImports(List<String> nomenclatureCodes) {
|
||||
// List<Import> imports = new ArrayList<>();
|
||||
//
|
||||
// // Erga Omnes hat normalerweise den Code "1011"
|
||||
// Optional<GeoGroup> ergaOmnes = geoGroupRepository.findByGeoGroupCode("1011");
|
||||
// if (ergaOmnes.isEmpty()) {
|
||||
// return imports;
|
||||
// }
|
||||
//
|
||||
// for (String code : nomenclatureCodes) {
|
||||
// Optional<Nomenclature> nomenclatureOpt = nomenclatureRepository.findByHscode(code);
|
||||
// if (nomenclatureOpt.isPresent()) {
|
||||
// imports.addAll(importRepository.findByNomenclatureIdAndGeoGroupId(
|
||||
// nomenclatureOpt.get().getId(), ergaOmnes.get().getId()));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return imports;
|
||||
// }
|
||||
//
|
||||
// private BigDecimal calculateTariffRate(List<Import> imports, Geo country) {
|
||||
// BigDecimal lowestRate = null;
|
||||
// LocalDate today = LocalDate.now();
|
||||
//
|
||||
// for (Import imp : imports) {
|
||||
// // Nutze die korrekte Repository-Methode mit Import-Reference
|
||||
// List<AppliedMeasure> measures = appliedMeasureRepository
|
||||
// .findByImport(AggregateReference.to(imp.getId()));
|
||||
//
|
||||
// for (AppliedMeasure appliedMeasure : measures) {
|
||||
// // Prüfe ob Maßnahme gültig ist
|
||||
// if (!isMeasureValid(appliedMeasure, today)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // Prüfe ob das Land ausgeschlossen ist
|
||||
// if (isCountryExcluded(appliedMeasure, country)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // Hole die Maßnahme über die AggregateReference
|
||||
// if (appliedMeasure.getMeasure() == null) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// Optional<Measure> measureOpt = measureRepository.findById(
|
||||
// appliedMeasure.getMeasure().getId());
|
||||
// if (measureOpt.isEmpty()) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// Measure measure = measureOpt.get();
|
||||
//
|
||||
// // Wir interessieren uns hauptsächlich für Third Country Duty (103)
|
||||
// // und Preferential Tariff (142, 143)
|
||||
// if (!"103".equals(measure.getMeasureCode()) &&
|
||||
// !"142".equals(measure.getMeasureCode()) &&
|
||||
// !"143".equals(measure.getMeasureCode())) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // Parse den Zollsatz aus dem amount String
|
||||
// BigDecimal rate = parseTariffRate(appliedMeasure.getAmount());
|
||||
// if (rate != null && (lowestRate == null || rate.compareTo(lowestRate) < 0)) {
|
||||
// lowestRate = rate;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return lowestRate != null ? lowestRate : BigDecimal.ZERO;
|
||||
// }
|
||||
//
|
||||
// private boolean isMeasureValid(AppliedMeasure measure, LocalDate date) {
|
||||
// if (measure.getStartDate() != null && measure.getStartDate().isAfter(date)) {
|
||||
// return false;
|
||||
// }
|
||||
// if (measure.getEndDate() != null && measure.getEndDate().isBefore(date)) {
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private boolean isCountryExcluded(AppliedMeasure measure, Geo country) {
|
||||
// // Finde Exclusions für diese AppliedMeasure
|
||||
// List<MeasureExclusion> exclusions =
|
||||
// measureExclusionRepository.findByAppliedMeasure(
|
||||
// AggregateReference.to(measure.getId()));
|
||||
//
|
||||
// return exclusions.stream()
|
||||
// .anyMatch(exc -> exc.getGeo() != null &&
|
||||
// exc.getGeo().getId().equals(country.getId()));
|
||||
// }
|
||||
//
|
||||
// private BigDecimal parseTariffRate(String amount) {
|
||||
// if (amount == null || amount.isEmpty()) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// // Einfacher Parser für Prozentsätze
|
||||
// // Format: "12.5 %" oder "12.5% + ..." oder "12.5 % MAX ..."
|
||||
// Pattern pattern = Pattern.compile("^([0-9]+\\.?[0-9]*)\\s*%");
|
||||
// Matcher matcher = pattern.matcher(amount);
|
||||
//
|
||||
// if (matcher.find()) {
|
||||
// try {
|
||||
// return new BigDecimal(matcher.group(1));
|
||||
// } catch (NumberFormatException e) {
|
||||
// log.warn("Could not parse tariff rate from: {}", amount);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Result-Klasse für Tarif-Abfragen
|
||||
// */
|
||||
// public static class TariffResult {
|
||||
// private final boolean found;
|
||||
// private final BigDecimal rate;
|
||||
// private final String hsCode;
|
||||
// private final String countryCode;
|
||||
// private final String message;
|
||||
//
|
||||
// private TariffResult(boolean found, BigDecimal rate, String hsCode,
|
||||
// String countryCode, String message) {
|
||||
// this.found = found;
|
||||
// this.rate = rate;
|
||||
// this.hsCode = hsCode;
|
||||
// this.countryCode = countryCode;
|
||||
// this.message = message;
|
||||
// }
|
||||
//
|
||||
// public static TariffResult success(BigDecimal rate, String hsCode, String countryCode) {
|
||||
// return new TariffResult(true, rate, hsCode, countryCode, null);
|
||||
// }
|
||||
//
|
||||
// public static TariffResult notFound(String message) {
|
||||
// return new TariffResult(false, null, null, null, message);
|
||||
// }
|
||||
//
|
||||
// // Getters
|
||||
// public boolean isFound() { return found; }
|
||||
// public BigDecimal getRate() { return rate; }
|
||||
// public String getHsCode() { return hsCode; }
|
||||
// public String getCountryCode() { return countryCode; }
|
||||
// public String getMessage() { return message; }
|
||||
// }
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue