Compare commits
No commits in common. "f031a79718df5235f21618c16597a205642136f9" and "40b3ff6b7cd2804a9f1e162d22b42d70d47876b8" have entirely different histories.
f031a79718
...
40b3ff6b7c
|
@ -6,7 +6,6 @@ import eu.dnetlib.validator2.validation.guideline.openaire.*;
|
|||
import eu.dnetlib.validatorapi.entities.RuleInfo;
|
||||
import eu.dnetlib.validatorapi.entities.ValidationJob;
|
||||
import eu.dnetlib.validatorapi.entities.ValidationRuleResult;
|
||||
import eu.dnetlib.validatorapi.exceptions.ValidationException;
|
||||
import eu.dnetlib.validatorapi.repositories.ValidationIssueRepository;
|
||||
import eu.dnetlib.validatorapi.repositories.ValidationJobRepository;
|
||||
import eu.dnetlib.validatorapi.repositories.ValidationResultRepository;
|
||||
|
@ -15,12 +14,10 @@ import eu.dnetlib.validatorapi.routes.SimpleOaiPmhRoute;
|
|||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -134,11 +131,9 @@ public class ValidationController {
|
|||
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Validation job stopped unexpectedly. " + e.getMessage());
|
||||
log.error("Validation job stopped unexpectedly." + e.getMessage());
|
||||
System.out.println("ERROR " + e.getMessage());
|
||||
validationJob.progress = "STOPPED";
|
||||
validationJob.exceptionClass = e.getClass().getCanonicalName();
|
||||
validationJob.exceptionMessage = e.getMessage();
|
||||
|
||||
|
||||
} finally {
|
||||
validationJob.endDate = new Date();
|
||||
|
@ -184,10 +179,10 @@ public class ValidationController {
|
|||
}
|
||||
|
||||
@RequestMapping(value = {"/realValidator"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
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
|
||||
public 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
|
||||
) {
|
||||
|
||||
AbstractOpenAireProfile profile = initializeOpenAireProfile(guidelinesProfileName);
|
||||
|
@ -196,8 +191,7 @@ public class ValidationController {
|
|||
|
||||
if (profile == null && fairProfile == null) {
|
||||
log.error("Exception: No valid guidelines " + guidelinesProfileName + ".");
|
||||
|
||||
throw new ValidationException("Validation Job stopped unexpectedly. No valid guidelines " +
|
||||
new Exception("Validation Job stopped unexpectedly. No valid guidelines " +
|
||||
guidelinesProfileName + " were provided.");
|
||||
}
|
||||
|
||||
|
@ -234,19 +228,18 @@ public class ValidationController {
|
|||
|
||||
camelContext.addRoutes(oaiPmhRouteBuilder);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Validation job stopped unexpectedly. " + e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Validation job stopped unexpectedly." + e.getMessage());
|
||||
System.out.println("ERROR " + e.getMessage());
|
||||
validationJob.progress = "STOPPED";
|
||||
validationJob.endDate = new Date();
|
||||
validationJob.score = resultSum / validationJob.recordsTested;
|
||||
validationJob.status = validationResultRepository.getStatus(validationJob.id);
|
||||
validationJob.exceptionClass = e.getClass().getCanonicalName();
|
||||
validationJob.exceptionMessage = e.getMessage();
|
||||
validationJobRepository.save(validationJob);
|
||||
return ResponseEntity.status(HttpStatus.SC_UNPROCESSABLE_ENTITY).body(validationJob);
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(validationJob);
|
||||
return validationJob;
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/getSets"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
@ -499,10 +492,8 @@ public class ValidationController {
|
|||
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Validation job stopped unexpectedly. " + e.getMessage());
|
||||
log.error("Validation job stopped unexpectedly." + e.getMessage());
|
||||
validationJob.progress = "STOPPED";
|
||||
validationJob.exceptionClass = e.getClass().getCanonicalName();
|
||||
validationJob.exceptionMessage = e.getMessage();
|
||||
|
||||
} finally {
|
||||
validationJob.endDate = new Date();
|
||||
|
@ -561,6 +552,7 @@ public class ValidationController {
|
|||
|
||||
//String response = camelContext.createProducerTemplate().requestBody("direct:oaipmhRequest", endpoint, String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,10 +9,6 @@ public class SummaryResult {
|
|||
@Id
|
||||
String rule_name;
|
||||
int rule_weight;
|
||||
String requirement_level;
|
||||
String description;
|
||||
String fair_principles;
|
||||
String link;
|
||||
String guidelines;
|
||||
String internal_error;
|
||||
String rule_status;
|
||||
|
@ -34,16 +30,10 @@ public class SummaryResult {
|
|||
this.failed_records = failed_records;
|
||||
}
|
||||
|
||||
|
||||
public SummaryResult(String rule_name, int rule_weight, String requirement_level, String description, String fair_principles,
|
||||
String link, String guidelines, String internal_error, long passed_records, long failed_records,
|
||||
String rule_status, boolean has_errors, boolean has_warnings) {
|
||||
public SummaryResult(String rule_name, int rule_weight, String guidelines, String internal_error, long passed_records,
|
||||
long failed_records, String rule_status, boolean has_errors, boolean has_warnings) {
|
||||
this.rule_name = rule_name;
|
||||
this.rule_weight = rule_weight;
|
||||
this.requirement_level = requirement_level;
|
||||
this.description = description;
|
||||
this.fair_principles = fair_principles;
|
||||
this.link = link;
|
||||
this.guidelines = guidelines;
|
||||
this.internal_error = internal_error;
|
||||
this.rule_status = rule_status;
|
||||
|
@ -53,8 +43,6 @@ public class SummaryResult {
|
|||
this.has_warnings = has_warnings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getRule_name() {
|
||||
return rule_name;
|
||||
}
|
||||
|
@ -71,38 +59,6 @@ public class SummaryResult {
|
|||
this.rule_weight = rule_weight;
|
||||
}
|
||||
|
||||
public String getRequirement_level() {
|
||||
return requirement_level;
|
||||
}
|
||||
|
||||
public void setRequirement_level(String requirement_level) {
|
||||
this.requirement_level = requirement_level;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFair_principles() {
|
||||
return fair_principles;
|
||||
}
|
||||
|
||||
public void setFair_principles(String fair_principles) {
|
||||
this.fair_principles = fair_principles;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public String getGuidelines() {
|
||||
return guidelines;
|
||||
}
|
||||
|
|
|
@ -37,13 +37,6 @@ public class ValidationJob {
|
|||
@Column(name="score")
|
||||
public double score;
|
||||
|
||||
@Column(name="exception_class")
|
||||
public String exceptionClass;
|
||||
|
||||
@Column(name="exception_message")
|
||||
public String exceptionMessage;
|
||||
|
||||
|
||||
public ValidationJob(){
|
||||
startDate = new Date();
|
||||
}
|
||||
|
@ -68,8 +61,6 @@ public class ValidationJob {
|
|||
", progress='" + progress + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", score=" + score +
|
||||
", exceptionClass='" + exceptionClass + '\'' +
|
||||
", exceptionMessage='" + exceptionMessage + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,6 @@ public class ValidationRuleResult implements Serializable {
|
|||
@Column(name = "record_url")
|
||||
public String recordUrl;
|
||||
|
||||
@Column(name="requirement_level")
|
||||
public String requirement_level;
|
||||
|
||||
@Column(name="description")
|
||||
public String description;
|
||||
|
||||
@Column(name="fair_principles")
|
||||
public String fair_principles;
|
||||
|
||||
@Column(name="link")
|
||||
public String link;
|
||||
|
||||
@Column(name = "internal_error")
|
||||
public String internalError;
|
||||
|
||||
|
@ -56,6 +44,7 @@ public class ValidationRuleResult implements Serializable {
|
|||
|
||||
public ValidationRuleResult() {}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValidationRuleResult{" +
|
||||
|
@ -64,10 +53,6 @@ public class ValidationRuleResult implements Serializable {
|
|||
", ruleName='" + ruleName + '\'' +
|
||||
", ruleWeight=" + ruleWeight +
|
||||
", recordUrl='" + recordUrl + '\'' +
|
||||
", requirement_level='" + requirement_level + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", fairPrinciples='" + fair_principles + '\'' +
|
||||
", link='" + link + '\'' +
|
||||
", internalError='" + internalError + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", score=" + score +
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package eu.dnetlib.validatorapi.exceptions;
|
||||
|
||||
public class ErrorMessage {
|
||||
private String message;
|
||||
|
||||
ErrorMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package eu.dnetlib.validatorapi.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
public class ExceptionHandler extends ResponseEntityExceptionHandler {
|
||||
|
||||
@ResponseBody
|
||||
@org.springframework.web.bind.annotation.ExceptionHandler(value = {ValidationException.class})
|
||||
protected ResponseEntity<ErrorMessage> handleValidationError(RuntimeException exception, WebRequest request) {
|
||||
return new ResponseEntity(new ErrorMessage(exception.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package eu.dnetlib.validatorapi.exceptions;
|
||||
|
||||
public class ValidationException extends RuntimeException {
|
||||
public ValidationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ValidationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -129,14 +129,6 @@ public class XmlProcessor implements Processor {
|
|||
validationRuleResult.guidelines = guidelines;
|
||||
validationRuleResult.ruleName = ruleName;
|
||||
validationRuleResult.ruleWeight = profile.guideline(ruleName).getWeight();
|
||||
validationRuleResult.requirement_level = profile.guideline(ruleName).getRequirementLevel().name();
|
||||
System.out.println(validationRuleResult.requirement_level);
|
||||
validationRuleResult.description = profile.guideline(ruleName).getDescription();
|
||||
System.out.println(validationRuleResult.description);
|
||||
validationRuleResult.fair_principles = profile.guideline(ruleName).getFairPrinciples();
|
||||
System.out.println(validationRuleResult.fair_principles);
|
||||
validationRuleResult.link = profile.guideline(ruleName).getLink();
|
||||
System.out.println(validationRuleResult.link);
|
||||
validationRuleResult.recordUrl = recordUrl;
|
||||
validationRuleResult.score = engineResult.score();
|
||||
validationRuleResult.status = engineResult.status().toString();
|
||||
|
|
|
@ -25,8 +25,7 @@ public interface ValidationResultRepository extends JpaRepository<ValidationRule
|
|||
"WHERE vr.validationJobId = :id AND vr.status = 'FAILURE' OR vr.internalError != null")
|
||||
public String getStatus(@Param("id") int validationJobId);
|
||||
|
||||
@Query(value = "SELECT NEW eu.dnetlib.validatorapi.entities.SummaryResult(sr.ruleName, sr.ruleWeight, sr.requirement_level, " +
|
||||
"sr.description, sr.fair_principles, sr.link, sr.guidelines, sr.internalError," +
|
||||
@Query(value = "SELECT NEW eu.dnetlib.validatorapi.entities.SummaryResult(sr.ruleName, sr.ruleWeight, sr.guidelines, sr.internalError," +
|
||||
"COUNT(CASE WHEN sr.status = 'SUCCESS' THEN 1 END) AS passedRecords," +
|
||||
"COUNT(CASE WHEN sr.status = 'FAILURE' OR sr.status = 'ERROR' THEN 1 END) AS failedRecords," +
|
||||
"(SELECT CASE" +
|
||||
|
@ -39,7 +38,7 @@ public interface ValidationResultRepository extends JpaRepository<ValidationRule
|
|||
"CASE WHEN COUNT(CASE WHEN has_warnings IS TRUE THEN 1 END) > 0 THEN TRUE ELSE FALSE END AS hasWarnings)" +
|
||||
"FROM eu.dnetlib.validatorapi.entities.ValidationRuleResult sr " +
|
||||
"WHERE sr.validationJobId = :id " +
|
||||
"GROUP BY sr.ruleName, sr.ruleWeight, sr.description, sr.fair_principles, sr.link, sr.requirement_level, sr.guidelines, sr.internalError, sr.validationJobId")
|
||||
"GROUP BY sr.ruleName, sr.ruleWeight, sr.guidelines, sr.internalError, sr.validationJobId")
|
||||
List<SummaryResult> getFullSummaryResult(@Param("id") int validationJobId);
|
||||
|
||||
@Query(value =
|
||||
|
@ -55,8 +54,7 @@ public interface ValidationResultRepository extends JpaRepository<ValidationRule
|
|||
"WHERE vr.validationJobId = :id AND vr.guidelines = :guidelines AND vr.status = 'FAILURE' OR vr.internalError != null")
|
||||
public String getStatus(@Param("id") int validationJobId, @Param("guidelines") String guidelines);
|
||||
|
||||
@Query(value = "SELECT NEW eu.dnetlib.validatorapi.entities.SummaryResult(sr.ruleName, sr.ruleWeight, sr.requirement_level, " +
|
||||
"sr.description, sr.fair_principles, sr.link, sr.guidelines, sr.internalError," +
|
||||
@Query(value = "SELECT NEW eu.dnetlib.validatorapi.entities.SummaryResult(sr.ruleName, sr.ruleWeight, sr.guidelines, sr.internalError," +
|
||||
"COUNT(CASE WHEN sr.status = 'SUCCESS' THEN 1 END) AS passedRecords," +
|
||||
"COUNT(CASE WHEN sr.status = 'FAILURE' OR sr.status = 'ERROR' THEN 1 END) AS failedRecords," +
|
||||
"(SELECT CASE" +
|
||||
|
@ -69,7 +67,7 @@ public interface ValidationResultRepository extends JpaRepository<ValidationRule
|
|||
"CASE WHEN COUNT(CASE WHEN has_warnings IS TRUE THEN 1 END) > 0 THEN TRUE ELSE FALSE END AS hasWarnings)" +
|
||||
"FROM eu.dnetlib.validatorapi.entities.ValidationRuleResult sr " +
|
||||
"WHERE sr.validationJobId = :id AND sr.guidelines = :guidelines " +
|
||||
"GROUP BY sr.ruleName, sr.ruleWeight, sr.requirement_level, sr.description, sr.fair_principles, sr.link, sr.description, sr.internalError, sr.validationJobId")
|
||||
"GROUP BY sr.ruleName, sr.ruleWeight, sr.guidelines, sr.internalError, sr.validationJobId")
|
||||
List<SummaryResult> getFullSummaryResult(@Param("id") int validationJobId, @Param("guidelines") String guidelines);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue