added requirement_level, link, description and fair_principles in SummaryResult and ValidationRuleResults

This commit is contained in:
Katerina 2023-09-13 13:22:21 +03:00
parent 40b3ff6b7c
commit e324211595
7 changed files with 82 additions and 7 deletions

View File

@ -9,6 +9,10 @@ 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;
@ -30,10 +34,16 @@ public class SummaryResult {
this.failed_records = failed_records;
}
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) {
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) {
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;
@ -43,6 +53,8 @@ public class SummaryResult {
this.has_warnings = has_warnings;
}
public String getRule_name() {
return rule_name;
}
@ -59,6 +71,38 @@ 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;
}

View File

@ -27,6 +27,18 @@ 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;
@ -44,7 +56,6 @@ public class ValidationRuleResult implements Serializable {
public ValidationRuleResult() {}
@Override
public String toString() {
return "ValidationRuleResult{" +
@ -53,6 +64,10 @@ 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 +

View File

@ -0,0 +1,2 @@
package eu.dnetlib.validatorapi.exceptions;public class ErrorMessage {
}

View File

@ -0,0 +1,2 @@
package eu.dnetlib.validatorapi.exceptions;public class ExceptionHandler {
}

View File

@ -0,0 +1,2 @@
package eu.dnetlib.validatorapi.exceptions;public class ValidationException {
}

View File

@ -129,6 +129,14 @@ 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();

View File

@ -25,7 +25,8 @@ 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.guidelines, sr.internalError," +
@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," +
"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" +
@ -38,7 +39,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.guidelines, sr.internalError, sr.validationJobId")
"GROUP BY sr.ruleName, sr.ruleWeight, sr.description, sr.fair_principles, sr.link, sr.requirement_level, sr.guidelines, sr.internalError, sr.validationJobId")
List<SummaryResult> getFullSummaryResult(@Param("id") int validationJobId);
@Query(value =
@ -54,7 +55,8 @@ 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.guidelines, sr.internalError," +
@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," +
"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" +
@ -67,7 +69,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.guidelines, sr.internalError, sr.validationJobId")
"GROUP BY sr.ruleName, sr.ruleWeight, sr.requirement_level, sr.description, sr.fair_principles, sr.link, sr.description, sr.internalError, sr.validationJobId")
List<SummaryResult> getFullSummaryResult(@Param("id") int validationJobId, @Param("guidelines") String guidelines);