Skip to content

Commit

Permalink
Merge pull request #94 from statisticsnorway/serialization-bugfix
Browse files Browse the repository at this point in the history
more serialization changes to sid types
  • Loading branch information
skykanin authored Feb 29, 2024
2 parents e3d2421 + f76f11b commit c410af7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.ssb.dlp.pseudo.service.sid;

import io.micronaut.core.annotation.Introspected;
import io.micronaut.serde.annotation.Serdeable;
import lombok.Builder;
import lombok.extern.jackson.Jacksonized;
Expand All @@ -8,5 +9,6 @@

@Builder
@Jacksonized
@Introspected
@Serdeable
public record MultiSidLookupResponse (List<String> missing, String datasetExtractionSnapshotTime) {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MultiSidResponse {
@Builder
@Jacksonized
@Introspected
@Serdeable
public record Mapping (List<String> fnrList, List<String> snr, List<String> fnr) { }

public Map<String, SidInfo> toMap() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/no/ssb/dlp/pseudo/service/sid/SidInfo.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package no.ssb.dlp.pseudo.service.sid;

import io.micronaut.core.annotation.Introspected;
import io.micronaut.serde.annotation.Serdeable;
import lombok.Builder;
import lombok.extern.jackson.Jacksonized;

@Builder
@Jacksonized
@Introspected
@Serdeable
public record SidInfo (String fnr, String snr, String datasetExtractionSnapshotTime) {}
6 changes: 3 additions & 3 deletions src/main/java/no/ssb/dlp/pseudo/service/sid/SidMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public void setConfig(Map<String, Object> config) {
parse(config.get(MapFuncConfig.Param.SNAPSHOT_DATE).toString()));
} catch (DateTimeParseException e) {
throw new InvalidSidSnapshotDateException(String.format("Invalid snapshot date format. Valid dates are: %s",
String.join(", ", availableSnapshots.getItems())));
String.join(", ", availableSnapshots.items())));
}
List<LocalDate> availableSnapshotDates = availableSnapshots.getItems().stream()
List<LocalDate> availableSnapshotDates = availableSnapshots.items().stream()
.map(snapshot -> {
try {
return LocalDate.from(formatter.parse(snapshot));
Expand All @@ -144,7 +144,7 @@ public void setConfig(Map<String, Object> config) {
}).toList();
if(availableSnapshotDates.stream().allMatch(requestedSnapshotDate::isBefore)){
throw new InvalidSidSnapshotDateException(String.format("Requested date is of an earlier date than all available SID dates. Valid dates are: %s",
String.join(", ", availableSnapshots.getItems())));
String.join(", ", availableSnapshots.items())));
}
}
this.config = config;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/no/ssb/dlp/pseudo/service/sid/SnapshotInfo.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package no.ssb.dlp.pseudo.service.sid;

import io.micronaut.core.annotation.Introspected;
import io.micronaut.serde.annotation.Serdeable;
import lombok.Builder;
import lombok.Data;
import lombok.extern.jackson.Jacksonized;

import java.util.List;

@Data
@Builder
@Jacksonized
public class SnapshotInfo {
private final List<String> items;
}
@Introspected
@Serdeable
public record SnapshotInfo(List<String> items) {}

0 comments on commit c410af7

Please sign in to comment.