Compare commits

..

No commits in common. "d2baa7ccf288b98eb317354032f2999ec766feb7" and "c5de380a11c4f3e33b590e3af66c8bf6dd4c6550" have entirely different histories.

6 changed files with 18 additions and 74 deletions

View File

@ -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, null, numberOfRecords);
ValidationJob validationJob = new ValidationJob(baseURL, numberOfRecords);
validationJob.guidelines = profile.name();
validationJobRepository.save(validationJob);
System.out.println("id " + validationJob.id);
@ -187,7 +187,8 @@ 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);
@ -200,7 +201,7 @@ public class ValidationController {
guidelinesProfileName + " were provided.");
}
ValidationJob validationJob = new ValidationJob(baseURL, set, numberOfRecords);
ValidationJob validationJob = new ValidationJob(baseURL, numberOfRecords);
validationJob.guidelines = profile.name();
validationJobRepository.save(validationJob);
log.info("Initial validation job id "+ validationJob.id);
@ -209,22 +210,24 @@ 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);
@ -244,15 +247,7 @@ public class ValidationController {
return ResponseEntity.ok(validationJob);
}
/*@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)
@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 {
@ -415,9 +410,6 @@ 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;
@ -450,7 +442,7 @@ public class ValidationController {
@RequestParam(name="numberOfRecords", defaultValue = "10") int numberOfRecords, //not in use now
@RequestBody String OAIPMHResponse) {
ValidationJob validationJob = new ValidationJob(baseUrl, null, numberOfRecords);
ValidationJob validationJob = new ValidationJob(baseUrl, numberOfRecords);
List<RuleInfo> resultRules = null;
List<RuleInfo> fairRules = null;
@ -568,4 +560,6 @@ public class ValidationController {
//String response = camelContext.createProducerTemplate().requestBody("direct:oaipmhRequest", endpoint, String.class);
}
}
}

View File

@ -1,56 +1,24 @@
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
@IdClass(SummaryResult.class)
public class SummaryResult implements Serializable {
public class SummaryResult {
@Id
@Column(name="rule_name")
String rule_name;
@Id
@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) {

View File

@ -2,7 +2,6 @@ package eu.dnetlib.validatorapi.entities;
import javax.persistence.*;
import java.util.Date;
import java.util.Optional;
@Entity
@Table(name = "validation_jobs")
@ -14,9 +13,6 @@ public class ValidationJob {
@Column(name = "base_url")
public String baseUrl;
@Column(name = "set")
public String set;
@Column(name="number_of_records")
public int numberOfRecords;
@ -52,10 +48,9 @@ public class ValidationJob {
startDate = new Date();
}
public ValidationJob(String baseUrl, Optional<String> set, int numberOfRecords) {
public ValidationJob(String baseUrl, int numberOfRecords) {
this.startDate = new Date();
this.baseUrl = baseUrl;
if (set.isPresent()) this.set = set.get();
this.numberOfRecords = numberOfRecords;
this.progress = "IN_PROGRESS";
}
@ -65,7 +60,6 @@ public class ValidationJob {
return "ValidationJob{" +
"id=" + id +
", baseUrl='" + baseUrl + '\'' +
", set='" + set + '\'' +
", numberOfRecords=" + numberOfRecords +
", guidelines='" + guidelines + '\'' +
", startDate=" + startDate +

View File

@ -12,8 +12,7 @@ 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.set = (String)(exchange.getIn().getHeader("set"));
validationJob.baseUrl= (String)(exchange.getIn().getHeader("baseUrl"));
validationJob.startDate = (Date) exchange.getIn().getHeader("startDate");
validationJob.guidelines = (String) exchange.getIn().getHeader("guidelines");
validationJob.status = (String)exchange.getIn().getHeader("status");

View File

@ -102,7 +102,6 @@ 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);

View File

@ -1,10 +0,0 @@
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> {
}