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");
|
||||
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 {
|
||||
|
||||
|
@ -410,6 +415,9 @@ public class ValidationController {
|
|||
private AbstractOpenAireProfile initializeFairProfile(String guidelinesProfileName) {
|
||||
if (guidelinesProfileName.equals("OpenAIRE Guidelines for Data Archives Profile v2")) {
|
||||
return new FAIR_Data_GuidelinesProfile();
|
||||
|
||||
} else if (guidelinesProfileName.equals("OpenAIRE Guidelines for Literature Repositories Profile v4")) {
|
||||
return new FAIR_Literature_GuidelinesV4Profile();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -442,7 +450,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;
|
||||
|
@ -560,6 +568,4 @@ public class ValidationController {
|
|||
|
||||
//String response = camelContext.createProducerTemplate().requestBody("direct:oaipmhRequest", endpoint, String.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,24 +1,56 @@
|
|||
package eu.dnetlib.validatorapi.entities;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
public class SummaryResult {
|
||||
@IdClass(SummaryResult.class)
|
||||
public class SummaryResult implements Serializable {
|
||||
@Id
|
||||
@Column(name="rule_name")
|
||||
String rule_name;
|
||||
|
||||
@Id
|
||||
String rule_name;
|
||||
@Column(name="validation_job_id")
|
||||
int validationJobId;
|
||||
|
||||
@Column(name="rule_weight")
|
||||
int rule_weight;
|
||||
|
||||
@Column(name="requirement_level")
|
||||
String requirement_level;
|
||||
|
||||
@Column(name="description")
|
||||
String description;
|
||||
|
||||
@Column(name="fair_principles")
|
||||
String fair_principles;
|
||||
|
||||
@Column(name="link")
|
||||
String link;
|
||||
|
||||
@Column(name="guidelines")
|
||||
String guidelines;
|
||||
|
||||
@Column(name = "internal_error")
|
||||
String internal_error;
|
||||
|
||||
@Column(name="rule_status")
|
||||
String rule_status;
|
||||
|
||||
@Column(name = "passed_records")
|
||||
long passed_records;
|
||||
|
||||
@Column(name="failed_records")
|
||||
long failed_records;
|
||||
|
||||
@Column(name="has_errors")
|
||||
boolean has_errors;
|
||||
|
||||
@Column(name="has_warnings")
|
||||
boolean has_warnings;
|
||||
|
||||
public SummaryResult(String rule_name, long passed_records, long failed_records) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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