minor refactoring

This commit is contained in:
Konstantinos Spyrou 2024-09-06 16:51:06 +03:00
parent 9d79316040
commit 6a4c939df2
1 changed files with 9 additions and 5 deletions

View File

@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Optional;
@Service("monitorService")
public class MonitorServiceImpl implements MonitorService {
@ -171,16 +171,20 @@ public class MonitorServiceImpl implements MonitorService {
try {
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
} catch (Exception e) {
logger.warn("Job with id '{}' not found in Validator. Trying CRIS...", jobId, e);
if (e.getMessage() == null) {
logger.warn("Job with id '{}' not found in Validator. Trying CRIS...", jobId);
} else {
logger.error(e.getMessage(), e);
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
/////////////////////////////////////////////////////////////////////////////////////////
if (job == null) {
// not a good way to do it but Job id field is string
List<Job> cJobs = crisJobs.getAll().stream().filter(j -> j.getId().hashCode() == Integer.parseInt(jobId)).collect(Collectors.toList());
if (!cJobs.isEmpty()) {
job = CrisValidatorUtils.convertJobToStoredJob(cJobs.get(0));
Optional<Job> cJob = crisJobs.get(jobId);
if (cJob.isPresent()) {
job = CrisValidatorUtils.convertJobToStoredJob(cJob.get());
}
}
/////////////////////////////////////////////////////////////////////////////////////////