added set in ValidationJob db entity and and class
This commit is contained in:
parent
c5de380a11
commit
24427a23ed
|
@ -80,7 +80,7 @@ public class ValidationController {
|
|||
log.error("Exception: No valid guidelines");
|
||||
new Exception("Validation Job stopped unexpectedly. No valid guidelines were provided.");
|
||||
}
|
||||
ValidationJob validationJob = new ValidationJob(baseURL, numberOfRecords);
|
||||
ValidationJob validationJob = new ValidationJob(baseURL, null, numberOfRecords);
|
||||
validationJob.guidelines = profile.name();
|
||||
validationJobRepository.save(validationJob);
|
||||
System.out.println("id " + validationJob.id);
|
||||
|
@ -187,8 +187,7 @@ public class ValidationController {
|
|||
public ResponseEntity<ValidationJob> validateWithApacheCamel(@RequestParam(name = "guidelines") String guidelinesProfileName,
|
||||
@RequestParam(name = "baseUrl", defaultValue = "http://repositorium.sdum.uminho.pt/oai/request") String baseURL, //not in use now
|
||||
@RequestParam(name="numberOfRecords", defaultValue = "10") int numberOfRecords,
|
||||
@RequestParam(name="set", required = false) Optional<String> set
|
||||
) {
|
||||
@RequestParam(name="set", required = false) Optional<String> set) {
|
||||
|
||||
AbstractOpenAireProfile profile = initializeOpenAireProfile(guidelinesProfileName);
|
||||
AbstractOpenAireProfile fairProfile = initializeFairProfile(guidelinesProfileName);
|
||||
|
@ -201,7 +200,7 @@ public class ValidationController {
|
|||
guidelinesProfileName + " were provided.");
|
||||
}
|
||||
|
||||
ValidationJob validationJob = new ValidationJob(baseURL, numberOfRecords);
|
||||
ValidationJob validationJob = new ValidationJob(baseURL, set, numberOfRecords);
|
||||
validationJob.guidelines = profile.name();
|
||||
validationJobRepository.save(validationJob);
|
||||
log.info("Initial validation job id "+ validationJob.id);
|
||||
|
@ -210,24 +209,22 @@ public class ValidationController {
|
|||
double resultSum = 0;
|
||||
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
|
||||
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
||||
RouteBuilder oaiPmhRouteBuilder;
|
||||
|
||||
String oaiEndpoint= "oaipmh://" + baseURL + "?verb=ListRecords&metadataPrefix=" + metadataPrefix;
|
||||
|
||||
if (set.isPresent())
|
||||
oaiEndpoint += "&set="+set.get();
|
||||
|
||||
if (fairProfile == null) {
|
||||
oaiPmhRouteBuilder =
|
||||
new SimpleOaiPmhRoute(oaiEndpoint, profile, validationJob, numberOfRecords, uuid.toString());
|
||||
|
||||
} else {
|
||||
oaiPmhRouteBuilder =
|
||||
new FairOaiPmhRoute2(oaiEndpoint, profile, validationJob, numberOfRecords, uuid.toString());
|
||||
|
||||
}
|
||||
|
||||
camelContext.addRoutes(oaiPmhRouteBuilder);
|
||||
|
@ -247,7 +244,15 @@ public class ValidationController {
|
|||
return ResponseEntity.ok(validationJob);
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/getSets"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
/*@RequestMapping(value = {"/getSets"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public void getSets(@RequestParam(name = "baseUrl", defaultValue = "http://repositorium.sdum.uminho.pt/oai/request") String baseURL) throws Exception {
|
||||
String oaiListEndpoint = "oaipmh://" + baseURL + "?verb=ListSets";
|
||||
|
||||
OaiSetListRoute oaiSetListRoute = new OaiSetListRoute(oaiListEndpoint, UUID.randomUUID().toString());
|
||||
camelContext.addRoutes(oaiSetListRoute);
|
||||
}*/
|
||||
|
||||
@RequestMapping(value = {"/getSets"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getSets(@RequestParam(name = "baseUrl", defaultValue = "http://repositorium.sdum.uminho.pt/oai/request") String baseURL //not in use now
|
||||
) throws Exception {
|
||||
|
||||
|
@ -442,7 +447,7 @@ public class ValidationController {
|
|||
@RequestParam(name="numberOfRecords", defaultValue = "10") int numberOfRecords, //not in use now
|
||||
@RequestBody String OAIPMHResponse) {
|
||||
|
||||
ValidationJob validationJob = new ValidationJob(baseUrl, numberOfRecords);
|
||||
ValidationJob validationJob = new ValidationJob(baseUrl, null, numberOfRecords);
|
||||
|
||||
List<RuleInfo> resultRules = null;
|
||||
List<RuleInfo> fairRules = null;
|
||||
|
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.validatorapi.entities;
|
|||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
@Entity
|
||||
@Table(name = "validation_jobs")
|
||||
|
@ -13,6 +14,9 @@ public class ValidationJob {
|
|||
@Column(name = "base_url")
|
||||
public String baseUrl;
|
||||
|
||||
@Column(name = "set")
|
||||
public String set;
|
||||
|
||||
@Column(name="number_of_records")
|
||||
public int numberOfRecords;
|
||||
|
||||
|
@ -48,9 +52,10 @@ public class ValidationJob {
|
|||
startDate = new Date();
|
||||
}
|
||||
|
||||
public ValidationJob(String baseUrl, int numberOfRecords) {
|
||||
public ValidationJob(String baseUrl, Optional<String> set, int numberOfRecords) {
|
||||
this.startDate = new Date();
|
||||
this.baseUrl = baseUrl;
|
||||
if (set.isPresent()) this.set = set.get();
|
||||
this.numberOfRecords = numberOfRecords;
|
||||
this.progress = "IN_PROGRESS";
|
||||
}
|
||||
|
@ -60,6 +65,7 @@ public class ValidationJob {
|
|||
return "ValidationJob{" +
|
||||
"id=" + id +
|
||||
", baseUrl='" + baseUrl + '\'' +
|
||||
", set='" + set + '\'' +
|
||||
", numberOfRecords=" + numberOfRecords +
|
||||
", guidelines='" + guidelines + '\'' +
|
||||
", startDate=" + startDate +
|
||||
|
|
|
@ -12,7 +12,8 @@ public class DataBaseProcessor implements Processor {
|
|||
public void process(Exchange exchange) throws Exception {
|
||||
ValidationJob validationJob = new ValidationJob();
|
||||
validationJob.id = (Integer)exchange.getIn().getHeader("validationId");
|
||||
validationJob.baseUrl= (String)(exchange.getIn().getHeader("baseUrl"));
|
||||
validationJob.baseUrl = (String)(exchange.getIn().getHeader("baseUrl"));
|
||||
validationJob.set = (String)(exchange.getIn().getHeader("set"));
|
||||
validationJob.startDate = (Date) exchange.getIn().getHeader("startDate");
|
||||
validationJob.guidelines = (String) exchange.getIn().getHeader("guidelines");
|
||||
validationJob.status = (String)exchange.getIn().getHeader("status");
|
||||
|
|
|
@ -102,6 +102,7 @@ public class XmlProcessor implements Processor {
|
|||
exchange.getIn().setHeader("MyHeader", "stop");
|
||||
exchange.getIn().setHeader("validationId", validationJob.id);
|
||||
exchange.getIn().setHeader("baseUrl", validationJob.baseUrl);
|
||||
exchange.getIn().setHeader("set", validationJob.set);
|
||||
exchange.getIn().setHeader("startDate", validationJob.startDate);
|
||||
exchange.getIn().setHeader("guidelines", validationJob.guidelines);
|
||||
exchange.getIn().setHeader("status", status);
|
||||
|
|
Loading…
Reference in New Issue