fixed duration and filled missing parameters of StoredJob
This commit is contained in:
parent
77437fa03c
commit
9d79316040
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue