1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.controllers;
|
2 |
49236
|
panagiotis
|
|
3 |
|
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
4 |
|
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
5 |
56961
|
ioannis.di
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
6 |
|
|
import eu.dnetlib.repo.manager.service.EmailUtils;
|
7 |
54690
|
panagiotis
|
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
|
8 |
57741
|
ioannis.di
|
import eu.dnetlib.repo.manager.domain.InterfaceInformation;
|
9 |
|
|
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
|
10 |
49236
|
panagiotis
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
11 |
|
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
12 |
|
|
|
13 |
|
|
import java.util.*;
|
14 |
54690
|
panagiotis
|
|
15 |
54525
|
panagiotis
|
import io.swagger.annotations.Api;
|
16 |
50631
|
panagiotis
|
import io.swagger.annotations.ApiParam;
|
17 |
49362
|
panagiotis
|
import org.json.JSONException;
|
18 |
49236
|
panagiotis
|
import org.springframework.beans.factory.annotation.Autowired;
|
19 |
54525
|
panagiotis
|
import org.springframework.http.MediaType;
|
20 |
52781
|
panagiotis
|
import org.springframework.http.ResponseEntity;
|
21 |
51656
|
panagiotis
|
import org.springframework.security.access.prepost.PreAuthorize;
|
22 |
54525
|
panagiotis
|
import org.springframework.web.bind.annotation.*;
|
23 |
49236
|
panagiotis
|
|
24 |
|
|
|
25 |
54525
|
panagiotis
|
@RestController
|
26 |
|
|
@RequestMapping(value = "/validator")
|
27 |
|
|
@Api(description = "Validator API", tags = {"validator"})
|
28 |
|
|
public class ValidatorController {
|
29 |
49236
|
panagiotis
|
|
30 |
|
|
@Autowired
|
31 |
56661
|
ioannis.di
|
private ValidatorServiceImpl validatorService;
|
32 |
49236
|
panagiotis
|
|
33 |
56961
|
ioannis.di
|
@Autowired
|
34 |
|
|
private EmailUtils emailUtils;
|
35 |
|
|
|
36 |
54525
|
panagiotis
|
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
|
37 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
38 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
39 |
|
|
@ResponseBody
|
40 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
41 |
|
|
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
42 |
54690
|
panagiotis
|
return validatorService.submitJobForValidation(jobForValidation);
|
43 |
49236
|
panagiotis
|
}
|
44 |
|
|
|
45 |
54525
|
panagiotis
|
@RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST,
|
46 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
47 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
48 |
|
|
@ResponseBody
|
49 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
50 |
|
|
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
|
51 |
|
|
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
52 |
54690
|
panagiotis
|
return validatorService.reSubmitJobForValidation(email, jobId);
|
53 |
49236
|
panagiotis
|
}
|
54 |
|
|
|
55 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
56 |
|
|
@ResponseBody
|
57 |
49410
|
panagiotis
|
public List<RuleSet> getRuleSets(@PathVariable("mode") String mode) {
|
58 |
54690
|
panagiotis
|
return validatorService.getRuleSets(mode);
|
59 |
49236
|
panagiotis
|
}
|
60 |
|
|
|
61 |
54525
|
panagiotis
|
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
62 |
|
|
@ResponseBody
|
63 |
50845
|
panagiotis
|
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
64 |
54690
|
panagiotis
|
return validatorService.getSetsOfRepository(url);
|
65 |
49236
|
panagiotis
|
}
|
66 |
|
|
|
67 |
54525
|
panagiotis
|
@RequestMapping(value = "/identifyRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
68 |
|
|
@ResponseBody
|
69 |
50845
|
panagiotis
|
public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) {
|
70 |
54690
|
panagiotis
|
return validatorService.identifyRepo(url);
|
71 |
49813
|
panagiotis
|
}
|
72 |
|
|
|
73 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRuleSet/{acronym}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
74 |
|
|
@ResponseBody
|
75 |
50570
|
panagiotis
|
public RuleSet getRuleSet(@PathVariable("acronym") String acronym) {
|
76 |
54690
|
panagiotis
|
return validatorService.getRuleSet(acronym);
|
77 |
49813
|
panagiotis
|
}
|
78 |
|
|
|
79 |
54525
|
panagiotis
|
@RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
80 |
|
|
@ResponseBody
|
81 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
82 |
50631
|
panagiotis
|
public List<StoredJob> getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
83 |
50686
|
panagiotis
|
@RequestParam(value = "jobType", required = false)
|
84 |
|
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
85 |
|
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
86 |
|
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
87 |
|
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
88 |
|
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
89 |
|
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus
|
90 |
|
|
) throws ValidatorServiceException {
|
91 |
54690
|
panagiotis
|
return validatorService.getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus);
|
92 |
50304
|
panagiotis
|
}
|
93 |
|
|
|
94 |
54525
|
panagiotis
|
@RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
95 |
|
|
@ResponseBody
|
96 |
50304
|
panagiotis
|
public int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
97 |
54690
|
panagiotis
|
return validatorService.getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
98 |
50304
|
panagiotis
|
}
|
99 |
|
|
|
100 |
54525
|
panagiotis
|
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
101 |
|
|
@ResponseBody
|
102 |
56961
|
ioannis.di
|
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
|
103 |
54690
|
panagiotis
|
return validatorService.getInterfaceInformation(baseUrl);
|
104 |
50570
|
panagiotis
|
}
|
105 |
|
|
|
106 |
57217
|
ioannis.di
|
@RequestMapping(value = "/validationSummary/{repoId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
107 |
|
|
@ResponseBody
|
108 |
|
|
public List<StoredJob> getInterfaceInformation(@PathVariable(value = "repoId") String repoId, @RequestParam(name = "size", defaultValue = "20") int size ) throws ValidatorServiceException, ResourceNotFoundException, JSONException {
|
109 |
|
|
return validatorService.getJobsSummary(repoId,size);
|
110 |
|
|
}
|
111 |
50570
|
panagiotis
|
|
112 |
57217
|
ioannis.di
|
|
113 |
56961
|
ioannis.di
|
@RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
114 |
|
|
@ResponseBody
|
115 |
|
|
public void validationCompleted(
|
116 |
|
|
@RequestParam(value = "interfaceId") String interfaceId,
|
117 |
|
|
@RequestParam(value = "repoId") String repoId,
|
118 |
|
|
@RequestParam(value = "jobId") String jobId,
|
119 |
|
|
@RequestParam(value = "issuerEmail") String issuerEmail,
|
120 |
|
|
@RequestParam(value = "isUpdate") boolean isUpdate,
|
121 |
|
|
@RequestParam(value = "isSuccess") boolean isSuccess,
|
122 |
|
|
@RequestParam(value = "scoreUsage") int scoreUsage,
|
123 |
|
|
@RequestParam(value = "scoreContent") int scoreContent) throws Exception {
|
124 |
|
|
|
125 |
|
|
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
|
129 |
49236
|
panagiotis
|
}
|