53 lines
1.3 KiB
Java
53 lines
1.3 KiB
Java
package eu.dnetlib.manager.wf.nodes.aggregation;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import eu.dnetlib.dsm.DsmService;
|
|
import eu.dnetlib.manager.wf.annotations.WfInputParam;
|
|
import eu.dnetlib.manager.wf.annotations.WfNode;
|
|
import eu.dnetlib.manager.wf.annotations.WfOutputParam;
|
|
import eu.dnetlib.manager.wf.nodes.AbstractJobNode;
|
|
|
|
@WfNode("findDateRangeForIncrementalHarvesting")
|
|
public class FindDateRangeForIncrementalHarvestingNode extends AbstractJobNode {
|
|
|
|
@WfInputParam
|
|
private String dsId;
|
|
|
|
@WfInputParam
|
|
private String apiId;
|
|
|
|
@WfInputParam
|
|
private LocalDateTime overrideFromDate;
|
|
|
|
@WfInputParam
|
|
private LocalDateTime overrideUntilDate;
|
|
|
|
@WfOutputParam
|
|
private LocalDateTime fromDate;
|
|
|
|
@WfOutputParam
|
|
private LocalDateTime untilDate;
|
|
|
|
@Autowired
|
|
private DsmService dsmService;
|
|
|
|
@Override
|
|
protected void execute() {
|
|
fromDate = overrideFromDate != null ? overrideFromDate : findLastCollDate();
|
|
untilDate = overrideUntilDate != null ? overrideUntilDate : null;
|
|
}
|
|
|
|
private LocalDateTime findLastCollDate() {
|
|
return dsmService.getApis(dsId)
|
|
.stream()
|
|
.filter(a -> apiId.equals(a.getId()))
|
|
.findFirst()
|
|
.map(a -> a.getLastCollectionDate().toLocalDateTime())
|
|
.orElse(null);
|
|
}
|
|
|
|
}
|