Revision 57648
Added by Antonis Lempesis over 4 years ago
ValidatorServiceImpl.java | ||
---|---|---|
3 | 3 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
4 | 4 |
import eu.dnetlib.domain.data.Repository; |
5 | 5 |
import eu.dnetlib.domain.data.RepositoryInterface; |
6 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
7 |
import eu.dnetlib.domain.functionality.validator.JobResultEntry; |
|
8 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
9 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
6 |
import eu.dnetlib.domain.functionality.validator.*; |
|
10 | 7 |
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; |
11 | 8 |
import eu.dnetlib.repo.manager.shared.Constants; |
12 | 9 |
import eu.dnetlib.repo.manager.shared.InterfaceInformation; |
... | ... | |
14 | 11 |
import eu.dnetlib.repo.manager.utils.OaiTools; |
15 | 12 |
import gr.uoa.di.driver.util.ServiceLocator; |
16 | 13 |
import org.apache.log4j.Logger; |
14 |
import org.eurocris.openaire.cris.validator.model.Job; |
|
15 |
import org.eurocris.openaire.cris.validator.service.JobExecutor; |
|
16 |
import org.eurocris.openaire.cris.validator.service.MapJobDao; |
|
17 | 17 |
import org.json.JSONException; |
18 | 18 |
import org.springframework.beans.factory.annotation.Autowired; |
19 | 19 |
import org.springframework.http.HttpStatus; |
... | ... | |
61 | 61 |
@Autowired |
62 | 62 |
private EmailUtils emailUtils; |
63 | 63 |
|
64 |
@Autowired |
|
65 |
private JobExecutor crisValidatorExecutor; |
|
66 |
|
|
67 |
@Autowired |
|
68 |
private MapJobDao crisJobs; |
|
69 |
|
|
64 | 70 |
@PostConstruct |
65 | 71 |
private void loadRules(){ |
66 | 72 |
LOGGER.debug("PostConstruct method! Load rules!"); |
... | ... | |
84 | 90 |
} |
85 | 91 |
} |
86 | 92 |
} |
93 |
|
|
94 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
95 |
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly // |
|
96 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
97 |
int ruleId = -1000; |
|
98 |
Rule rule = new Rule(); |
|
99 |
rule.setType("cris"); |
|
100 |
rule.setName("CRIS Rules"); |
|
101 |
rule.setId(ruleId); |
|
102 |
rule.setMandatory(true); |
|
103 |
RuleSet crisRuleSet = new RuleSet(); |
|
104 |
crisRuleSet.setContentRulesIds(Collections.singleton(ruleId)); |
|
105 |
crisRuleSet.setContentRules(Collections.singletonList(rule)); |
|
106 |
crisRuleSet.setUsageRulesIds(Collections.singleton(ruleId)); |
|
107 |
crisRuleSet.setUsageRules(Collections.singletonList(rule)); |
|
108 |
crisRuleSet.setId(-1); |
|
109 |
crisRuleSet.setDescription("Validates using the CRIS Validator implementation"); |
|
110 |
crisRuleSet.setName("CRIS Validation"); |
|
111 |
|
|
112 |
String crisKey = Constants.VALIDATION_MODE_CRIS; |
|
113 |
if (rulesetMap.containsKey(crisKey)) |
|
114 |
rulesetMap.get(crisKey).add(crisRuleSet); |
|
115 |
else { |
|
116 |
List<RuleSet> ruleSets = new ArrayList<RuleSet>(); |
|
117 |
ruleSets.add(crisRuleSet); |
|
118 |
rulesetMap.put(crisKey, ruleSets); |
|
119 |
} |
|
120 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
121 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
87 | 122 |
} catch (ValidatorServiceException e) { |
88 | 123 |
LOGGER.error(e); |
89 | 124 |
} |
... | ... | |
96 | 131 |
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId()); |
97 | 132 |
try { |
98 | 133 |
emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(),jobForValidation); |
99 |
this.getValidationService().submitValidationJob(jobForValidation); |
|
134 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
135 |
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly // |
|
136 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
137 |
if (jobForValidation.getSelectedContentRules().size() == 1 && |
|
138 |
jobForValidation.getSelectedContentRules().contains(-1000)) { |
|
139 |
crisValidatorExecutor.submit(jobForValidation.getBaseUrl(), jobForValidation.getUserEmail()); |
|
140 |
} else { |
|
141 |
this.getValidationService().submitValidationJob(jobForValidation); |
|
142 |
} |
|
143 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
144 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
145 |
// this.getValidationService().submitValidationJob(jobForValidation); |
|
100 | 146 |
} catch (ValidatorServiceException e) { |
101 | 147 |
LOGGER.debug("Exception on submitJobForValidation" , e); |
102 | 148 |
emailUtils.reportException(e); |
... | ... | |
199 | 245 |
String dateFrom, |
200 | 246 |
String dateTo, |
201 | 247 |
String validationStatus ) throws ValidatorServiceException { |
202 |
return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus); |
|
248 |
// return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus); |
|
249 |
List<StoredJob> jobs = getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus); |
|
250 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly // |
|
252 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
253 |
if (jobs == null) { |
|
254 |
jobs = new ArrayList<>(); |
|
255 |
} |
|
256 |
List<Job> cj = crisJobs.getJobs(user); |
|
257 |
for (Job job : cj) { |
|
258 |
StoredJob sj = new StoredJob(); |
|
259 |
|
|
260 |
if (job.getDateFinished() != null) { |
|
261 |
sj.setEnded(job.getDateFinished().toString()); |
|
262 |
sj.setDuration(Long.toString(job.getDateFinished().getTime() - job.getDateStarted().getTime()) + " seconds"); |
|
263 |
} else { |
|
264 |
sj.setEnded("-"); |
|
265 |
sj.setDuration("-"); |
|
266 |
} |
|
267 |
sj.setStarted(job.getDateStarted().toString()); |
|
268 |
|
|
269 |
sj.setUserEmail(job.getUser()); |
|
270 |
sj.setCris(true); |
|
271 |
sj.setBaseUrl(job.getUrl()); |
|
272 |
sj.setJobType("CRIS Validation"); |
|
273 |
|
|
274 |
// TODO: status |
|
275 |
sj.setValidationStatus(job.getStatus()); |
|
276 |
sj.setUsageJobStatus(job.getStatus()); |
|
277 |
sj.setContentJobStatus(job.getStatus()); |
|
278 |
|
|
279 |
// TODO: scores |
|
280 |
// sj.setFilteredScores(); |
|
281 |
sj.setContentJobScore(job.getScore()); |
|
282 |
sj.setUsageJobScore(job.getScore()); |
|
283 |
|
|
284 |
jobs.add(sj); |
|
285 |
} |
|
286 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
287 |
///////////////////////////////////////////////////////////////////////////////////////// |
|
288 |
return jobs; |
|
203 | 289 |
} |
204 | 290 |
|
205 | 291 |
@Override |
Also available in: Unified diff
merged branch cris r57561-HEAD