fixed duration and filled missing parameters of StoredJob

This commit is contained in:
Konstantinos Spyrou 2024-09-06 16:50:20 +03:00
parent 77437fa03c
commit 9d79316040
1 changed files with 8 additions and 7 deletions

View File

@ -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,8 +17,9 @@ 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();
@ -29,7 +29,7 @@ public class CrisValidatorUtils {
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());