Skip to content

Commit

Permalink
Added offset config parameter to allow delayed import
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhofmann committed Sep 25, 2024
1 parent d3ed9e9 commit 9b88eef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class SRUConfiguration implements Configuration {

private LocalDate newestDate;

private Integer dayOffset = 1;

private String recordFilterService;

@Override
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/de/vzg/oai_importer/foreign/sru/SRUHarvester.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ public String buildLink(SRUConfiguration source, LocalDate day, int startRecord,
"&recordSchema=picaxml&startRecord=" + startRecord;
}

public List<LocalDate> getDaysSince(LocalDate since, LocalDate until) {
LocalDate now = until == null ? LocalDate.now().plusDays(1) : until.plusDays(1);
return since.datesUntil(now).toList();
public List<LocalDate> getDaysSince(LocalDate from, LocalDate until) {
if(from.isAfter(until)) {
return List.of();
}
return from.datesUntil(until).toList();
}

public SRUResponse harvest(String link) throws IOException {
Expand Down Expand Up @@ -134,7 +136,8 @@ public List<ForeignEntity> update(String configID, SRUConfiguration source, bool

List<ForeignEntity> result = new ArrayList<>();

List<LocalDate> days = getDaysSince(oldestDate, source.getNewestDate());
List<LocalDate> days = getDaysSince(oldestDate, source.getNewestDate() == null ?
LocalDate.now().plusDays(source.getDayOffset()) : source.getNewestDate());
for (LocalDate day : days) {
SRUResponse resp = null;
String link = null;
Expand Down

0 comments on commit 9b88eef

Please sign in to comment.