Compare commits
4 Commits
c5de380a11
...
d2baa7ccf2
Author | SHA1 | Date |
---|---|---|
Katerina | d2baa7ccf2 | |
Katerina | f5fef8fd5c | |
Katerina | 16a258b263 | |
Katerina | 24427a23ed |
|
@ -80,7 +80,7 @@ public class ValidationController {
|
||||||
log.error("Exception: No valid guidelines");
|
log.error("Exception: No valid guidelines");
|
||||||
new Exception("Validation Job stopped unexpectedly. No valid guidelines were provided.");
|
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();
|
validationJob.guidelines = profile.name();
|
||||||
validationJobRepository.save(validationJob);
|
validationJobRepository.save(validationJob);
|
||||||
System.out.println("id " + validationJob.id);
|
System.out.println("id " + validationJob.id);
|
||||||
|
@ -187,8 +187,7 @@ public class ValidationController {
|
||||||
public ResponseEntity<ValidationJob> validateWithApacheCamel(@RequestParam(name = "guidelines") String guidelinesProfileName,
|
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 = "baseUrl", defaultValue = "http://repositorium.sdum.uminho.pt/oai/request") String baseURL, //not in use now
|
||||||
@RequestParam(name="numberOfRecords", defaultValue = "10") int numberOfRecords,
|
@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 profile = initializeOpenAireProfile(guidelinesProfileName);
|
||||||
AbstractOpenAireProfile fairProfile = initializeFairProfile(guidelinesProfileName);
|
AbstractOpenAireProfile fairProfile = initializeFairProfile(guidelinesProfileName);
|
||||||
|
@ -201,7 +200,7 @@ public class ValidationController {
|
||||||
guidelinesProfileName + " were provided.");
|
guidelinesProfileName + " were provided.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationJob validationJob = new ValidationJob(baseURL, numberOfRecords);
|
ValidationJob validationJob = new ValidationJob(baseURL, set, numberOfRecords);
|
||||||
validationJob.guidelines = profile.name();
|
validationJob.guidelines = profile.name();
|
||||||
validationJobRepository.save(validationJob);
|
validationJobRepository.save(validationJob);
|
||||||
log.info("Initial validation job id "+ validationJob.id);
|
log.info("Initial validation job id "+ validationJob.id);
|
||||||
|
@ -210,24 +209,22 @@ public class ValidationController {
|
||||||
double resultSum = 0;
|
double resultSum = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
|
||||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
|
||||||
|
|
||||||
|
|
||||||
UUID uuid = UUID.randomUUID();
|
UUID uuid = UUID.randomUUID();
|
||||||
|
|
||||||
RouteBuilder oaiPmhRouteBuilder;
|
RouteBuilder oaiPmhRouteBuilder;
|
||||||
|
|
||||||
String oaiEndpoint= "oaipmh://" + baseURL + "?verb=ListRecords&metadataPrefix=" + metadataPrefix;
|
String oaiEndpoint= "oaipmh://" + baseURL + "?verb=ListRecords&metadataPrefix=" + metadataPrefix;
|
||||||
|
|
||||||
if (set.isPresent())
|
if (set.isPresent())
|
||||||
oaiEndpoint += "&set="+set.get();
|
oaiEndpoint += "&set="+set.get();
|
||||||
|
|
||||||
if (fairProfile == null) {
|
if (fairProfile == null) {
|
||||||
oaiPmhRouteBuilder =
|
oaiPmhRouteBuilder =
|
||||||
new SimpleOaiPmhRoute(oaiEndpoint, profile, validationJob, numberOfRecords, uuid.toString());
|
new SimpleOaiPmhRoute(oaiEndpoint, profile, validationJob, numberOfRecords, uuid.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
oaiPmhRouteBuilder =
|
oaiPmhRouteBuilder =
|
||||||
new FairOaiPmhRoute2(oaiEndpoint, profile, validationJob, numberOfRecords, uuid.toString());
|
new FairOaiPmhRoute2(oaiEndpoint, profile, validationJob, numberOfRecords, uuid.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
camelContext.addRoutes(oaiPmhRouteBuilder);
|
camelContext.addRoutes(oaiPmhRouteBuilder);
|
||||||
|
@ -247,7 +244,15 @@ public class ValidationController {
|
||||||
return ResponseEntity.ok(validationJob);
|
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
|
public String getSets(@RequestParam(name = "baseUrl", defaultValue = "http://repositorium.sdum.uminho.pt/oai/request") String baseURL //not in use now
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
|
@ -410,6 +415,9 @@ public class ValidationController {
|
||||||
private AbstractOpenAireProfile initializeFairProfile(String guidelinesProfileName) {
|
private AbstractOpenAireProfile initializeFairProfile(String guidelinesProfileName) {
|
||||||
if (guidelinesProfileName.equals("OpenAIRE Guidelines for Data Archives Profile v2")) {
|
if (guidelinesProfileName.equals("OpenAIRE Guidelines for Data Archives Profile v2")) {
|
||||||
return new FAIR_Data_GuidelinesProfile();
|
return new FAIR_Data_GuidelinesProfile();
|
||||||
|
|
||||||
|
} else if (guidelinesProfileName.equals("OpenAIRE Guidelines for Literature Repositories Profile v4")) {
|
||||||
|
return new FAIR_Literature_GuidelinesV4Profile();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -442,7 +450,7 @@ public class ValidationController {
|
||||||
@RequestParam(name="numberOfRecords", defaultValue = "10") int numberOfRecords, //not in use now
|
@RequestParam(name="numberOfRecords", defaultValue = "10") int numberOfRecords, //not in use now
|
||||||
@RequestBody String OAIPMHResponse) {
|
@RequestBody String OAIPMHResponse) {
|
||||||
|
|
||||||
ValidationJob validationJob = new ValidationJob(baseUrl, numberOfRecords);
|
ValidationJob validationJob = new ValidationJob(baseUrl, null, numberOfRecords);
|
||||||
|
|
||||||
List<RuleInfo> resultRules = null;
|
List<RuleInfo> resultRules = null;
|
||||||
List<RuleInfo> fairRules = null;
|
List<RuleInfo> fairRules = null;
|
||||||
|
@ -560,6 +568,4 @@ public class ValidationController {
|
||||||
|
|
||||||
//String response = camelContext.createProducerTemplate().requestBody("direct:oaipmhRequest", endpoint, String.class);
|
//String response = camelContext.createProducerTemplate().requestBody("direct:oaipmhRequest", endpoint, String.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,56 @@
|
||||||
package eu.dnetlib.validatorapi.entities;
|
package eu.dnetlib.validatorapi.entities;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.IdClass;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class SummaryResult {
|
@IdClass(SummaryResult.class)
|
||||||
|
public class SummaryResult implements Serializable {
|
||||||
|
@Id
|
||||||
|
@Column(name="rule_name")
|
||||||
|
String rule_name;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
String rule_name;
|
@Column(name="validation_job_id")
|
||||||
|
int validationJobId;
|
||||||
|
|
||||||
|
@Column(name="rule_weight")
|
||||||
int rule_weight;
|
int rule_weight;
|
||||||
|
|
||||||
|
@Column(name="requirement_level")
|
||||||
String requirement_level;
|
String requirement_level;
|
||||||
|
|
||||||
|
@Column(name="description")
|
||||||
String description;
|
String description;
|
||||||
|
|
||||||
|
@Column(name="fair_principles")
|
||||||
String fair_principles;
|
String fair_principles;
|
||||||
|
|
||||||
|
@Column(name="link")
|
||||||
String link;
|
String link;
|
||||||
|
|
||||||
|
@Column(name="guidelines")
|
||||||
String guidelines;
|
String guidelines;
|
||||||
|
|
||||||
|
@Column(name = "internal_error")
|
||||||
String internal_error;
|
String internal_error;
|
||||||
|
|
||||||
|
@Column(name="rule_status")
|
||||||
String rule_status;
|
String rule_status;
|
||||||
|
|
||||||
|
@Column(name = "passed_records")
|
||||||
long passed_records;
|
long passed_records;
|
||||||
|
|
||||||
|
@Column(name="failed_records")
|
||||||
long failed_records;
|
long failed_records;
|
||||||
|
|
||||||
|
@Column(name="has_errors")
|
||||||
boolean has_errors;
|
boolean has_errors;
|
||||||
|
|
||||||
|
@Column(name="has_warnings")
|
||||||
boolean has_warnings;
|
boolean has_warnings;
|
||||||
|
|
||||||
public SummaryResult(String rule_name, long passed_records, long failed_records) {
|
public SummaryResult(String rule_name, long passed_records, long failed_records) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.dnetlib.validatorapi.entities;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "validation_jobs")
|
@Table(name = "validation_jobs")
|
||||||
|
@ -13,6 +14,9 @@ public class ValidationJob {
|
||||||
@Column(name = "base_url")
|
@Column(name = "base_url")
|
||||||
public String baseUrl;
|
public String baseUrl;
|
||||||
|
|
||||||
|
@Column(name = "set")
|
||||||
|
public String set;
|
||||||
|
|
||||||
@Column(name="number_of_records")
|
@Column(name="number_of_records")
|
||||||
public int numberOfRecords;
|
public int numberOfRecords;
|
||||||
|
|
||||||
|
@ -48,9 +52,10 @@ public class ValidationJob {
|
||||||
startDate = new Date();
|
startDate = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationJob(String baseUrl, int numberOfRecords) {
|
public ValidationJob(String baseUrl, Optional<String> set, int numberOfRecords) {
|
||||||
this.startDate = new Date();
|
this.startDate = new Date();
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
|
if (set.isPresent()) this.set = set.get();
|
||||||
this.numberOfRecords = numberOfRecords;
|
this.numberOfRecords = numberOfRecords;
|
||||||
this.progress = "IN_PROGRESS";
|
this.progress = "IN_PROGRESS";
|
||||||
}
|
}
|
||||||
|
@ -60,6 +65,7 @@ public class ValidationJob {
|
||||||
return "ValidationJob{" +
|
return "ValidationJob{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", baseUrl='" + baseUrl + '\'' +
|
", baseUrl='" + baseUrl + '\'' +
|
||||||
|
", set='" + set + '\'' +
|
||||||
", numberOfRecords=" + numberOfRecords +
|
", numberOfRecords=" + numberOfRecords +
|
||||||
", guidelines='" + guidelines + '\'' +
|
", guidelines='" + guidelines + '\'' +
|
||||||
", startDate=" + startDate +
|
", startDate=" + startDate +
|
||||||
|
|
|
@ -12,7 +12,8 @@ public class DataBaseProcessor implements Processor {
|
||||||
public void process(Exchange exchange) throws Exception {
|
public void process(Exchange exchange) throws Exception {
|
||||||
ValidationJob validationJob = new ValidationJob();
|
ValidationJob validationJob = new ValidationJob();
|
||||||
validationJob.id = (Integer)exchange.getIn().getHeader("validationId");
|
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.startDate = (Date) exchange.getIn().getHeader("startDate");
|
||||||
validationJob.guidelines = (String) exchange.getIn().getHeader("guidelines");
|
validationJob.guidelines = (String) exchange.getIn().getHeader("guidelines");
|
||||||
validationJob.status = (String)exchange.getIn().getHeader("status");
|
validationJob.status = (String)exchange.getIn().getHeader("status");
|
||||||
|
|
|
@ -102,6 +102,7 @@ public class XmlProcessor implements Processor {
|
||||||
exchange.getIn().setHeader("MyHeader", "stop");
|
exchange.getIn().setHeader("MyHeader", "stop");
|
||||||
exchange.getIn().setHeader("validationId", validationJob.id);
|
exchange.getIn().setHeader("validationId", validationJob.id);
|
||||||
exchange.getIn().setHeader("baseUrl", validationJob.baseUrl);
|
exchange.getIn().setHeader("baseUrl", validationJob.baseUrl);
|
||||||
|
exchange.getIn().setHeader("set", validationJob.set);
|
||||||
exchange.getIn().setHeader("startDate", validationJob.startDate);
|
exchange.getIn().setHeader("startDate", validationJob.startDate);
|
||||||
exchange.getIn().setHeader("guidelines", validationJob.guidelines);
|
exchange.getIn().setHeader("guidelines", validationJob.guidelines);
|
||||||
exchange.getIn().setHeader("status", status);
|
exchange.getIn().setHeader("status", status);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package eu.dnetlib.validatorapi.repositories;
|
||||||
|
|
||||||
|
import eu.dnetlib.validatorapi.entities.SummaryResult;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface SummaryValidationJobRepository extends JpaRepository<SummaryResult, Long> {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue