diff --git a/src/main/java/eu/dnetlib/repo/manager/utils/CrisValidatorUtils.java b/src/main/java/eu/dnetlib/repo/manager/utils/CrisValidatorUtils.java index 3674cd0..9cd0d5f 100644 --- a/src/main/java/eu/dnetlib/repo/manager/utils/CrisValidatorUtils.java +++ b/src/main/java/eu/dnetlib/repo/manager/utils/CrisValidatorUtils.java @@ -8,9 +8,8 @@ import org.eurocris.openaire.cris.validator.model.RuleResults; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; public class CrisValidatorUtils { @@ -18,18 +17,19 @@ public class CrisValidatorUtils { private static final DateFormat DURATION_FORMATTER = new SimpleDateFormat("HH 'hours' mm 'min' ss 'sec'"); public static StoredJob convertJobToStoredJob(Job job) { + DURATION_FORMATTER.setTimeZone(TimeZone.getTimeZone("UTC")); StoredJob sj = new StoredJob(); - sj.setId(job.getId().hashCode()); + sj.setId(job.getId()); sj.setValidationStatus(job.getStatus()); Date dateFinished = job.getDateFinished(); Date dateStarted = job.getDateStarted(); - if ( dateFinished != null ) { + if (dateFinished != null) { sj.setEnded(DATE_FORMATTER.format(dateFinished)); sj.setDuration(DURATION_FORMATTER.format(new Date(dateFinished.getTime() - dateStarted.getTime()))); } else { sj.setEnded("-"); - sj.setDuration("-"); + sj.setDuration(DURATION_FORMATTER.format(new Date(new Date().getTime() - dateStarted.getTime()))); } sj.setStarted(DATE_FORMATTER.format(dateStarted)); @@ -47,10 +47,11 @@ public class CrisValidatorUtils { sj.setContentJobStatus(job.getContentJobStatus()); // Set scores -// sj.setFilteredScores(); // TODO what is this? + sj.setFilteredScores(Map.of("all", job.getContentScore())); // TODO what is this? sj.setContentJobScore(job.getContentScore()); sj.setUsageJobScore(job.getUsageScore()); + sj.setRules(job.getRuleResults().stream().map(r -> r.getRule().getId()).collect(Collectors.toSet())); sj.setResultEntries(CrisValidatorUtils.crisResultsToJobEntries(job)); sj.setRecordsTested(job.getRecordsTested());