Built synthetic FAIR guidelines that needed to get through rules of the data archives guidelines.

This commit is contained in:
pispis 2022-12-08 15:53:29 +02:00
parent 101421094b
commit 674a8ca833
9 changed files with 212 additions and 199 deletions

View File

@ -16,7 +16,7 @@ public final class StandardResult implements Guideline.Result {
private final Status status; private final Status status;
private final int score; private final int score;
private StandardResult(int score, Status status, List<String> warnings, List<String> errors, String internalError) { public StandardResult(int score, Status status, List<String> warnings, List<String> errors, String internalError) {
this.status = status; this.status = status;
this.score = score; this.score = score;
this.warnings = warnings; this.warnings = warnings;

View File

@ -88,7 +88,7 @@ public final class F2_01M extends AbstractOpenAireProfile {
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum); private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
public F2_01M() { public F2_01M() {
super("F2_01M Guideline for the OpenAIRE FAIR Guidelines for Data Repositories Profile v4"); super("Rich metadata is provided to allow discovery");
} }
@Override @Override

View File

@ -53,7 +53,7 @@ public final class F3_01M extends AbstractOpenAireProfile {
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum); private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
public F3_01M() { public F3_01M() {
super("F3_01M Guideline for the OpenAIRE FAIR Guidelines for Data Repositories Profile v4"); super("Metadata includes the identifier for the data");
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package eu.dnetlib.validator2.validation.guideline.openaire; package eu.dnetlib.validator2.validation.guideline.openaire;
//import com.google.gson.Gson;
import eu.dnetlib.validator2.engine.Status; import eu.dnetlib.validator2.engine.Status;
import eu.dnetlib.validator2.validation.XMLApplicationProfile; import eu.dnetlib.validator2.validation.XMLApplicationProfile;
import eu.dnetlib.validator2.validation.guideline.*; import eu.dnetlib.validator2.validation.guideline.*;
@ -9,8 +10,7 @@ import org.w3c.dom.Document;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE; import static eu.dnetlib.validator2.validation.guideline.Cardinality.*;
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
public final class FAIR_Data_GuidelinesProfile extends AbstractOpenAireProfile { public final class FAIR_Data_GuidelinesProfile extends AbstractOpenAireProfile {
@ -289,80 +289,80 @@ public final class FAIR_Data_GuidelinesProfile extends AbstractOpenAireProfile {
} }
// TODO this goes to FAIRProfile //// TODO this goes to FAIRProfile
class MetadataCompleteness extends AbstractGuideline<Document> { //class MetadataCompleteness extends AbstractGuideline<Document> {
//
public MetadataCompleteness() { // public MetadataCompleteness() {
super("MetadataCompleteness", 40); // super("MetadataCompleteness", 40);
}
@Override
public Result validate(String id, Document t) {
DataArchiveGuidelinesV2Profile profile = new DataArchiveGuidelinesV2Profile();
// <></>ODO: iterate over results and build one Guideline.Result
try {
// System.out.println("Processing MetadataCompleteness...");
XMLApplicationProfile.ValidationResult res = profile.validate(id, t);
Map<String, Result> results = res.results();
int MaxScoreMetadataCompleteness = (int) ((res.score()*getWeight())/100);
// System.out.println("Max score DataValidator(%): " + res.score());
// System.out.println("Weight FAIRG: " + getWeight());
// System.out.println("Max score MetadataCompleteness: " + MaxScoreMetadataCompleteness);
// System.out.println("\n\n\n\n");
// for (Map.Entry entry : results.entrySet()) {
// System.out.println(entry.getKey() + " = " + entry.getValue());
// } // }
// System.out.println(score); //
return getResult(MaxScoreMetadataCompleteness); // @Override
// public Result validate(String id, Document t) {
// System.out.println(tempp.status() + " - " + tempp.score()); // DataArchiveGuidelinesV2Profile profile = new DataArchiveGuidelinesV2Profile();
// String printout = results.entrySet().stream(). //
// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); // // <></>ODO: iterate over results and build one Guideline.Result
// System.out.println(printout); // try {
//// System.out.println("Processing MetadataCompleteness...");
// System.out.println("\n\n\n\n"); // XMLApplicationProfile.ValidationResult res = profile.validate(id, t);
} catch (Exception e) { // Map<String, Result> results = res.results();
System.out.println(e.getMessage()); // int MaxScoreMetadataCompleteness = (int) ((res.score()*getWeight())/100);
System.out.println(e); //
e.printStackTrace(); //// System.out.println("Max score DataValidator(%): " + res.score());
} //// System.out.println("Weight FAIRG: " + getWeight());
//// System.out.println("Max score MetadataCompleteness: " + MaxScoreMetadataCompleteness);
return null; //// System.out.println("\n\n\n\n");
} //
//// for (Map.Entry entry : results.entrySet()) {
private static Result getResult(int score) { //// System.out.println(entry.getKey() + " = " + entry.getValue());
String aa; //// }
aa = (score > 0) ? "SUCCESS" : "FAILURE"; //// System.out.println(score);
return new Result() { // return getResult(MaxScoreMetadataCompleteness);
@Override //
public int score() { //// System.out.println(tempp.status() + " - " + tempp.score());
return score; //// String printout = results.entrySet().stream().
} //// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
//// System.out.println(printout);
@Override //
public Status status() { //// System.out.println("\n\n\n\n");
// } catch (Exception e) {
// System.out.println(e.getMessage());
// System.out.println(e);
// e.printStackTrace();
// }
//
// return null; // return null;
return Status.valueOf(aa); // }
} //
// private static Result getResult(int score) {
@Override // String aa;
public Iterable<String> warnings() { return null; } // aa = (score > 0) ? "SUCCESS" : "FAILURE";
// return new Result() {
@Override // @Override
public Iterable<String> errors() { // public int score() {
return null; // return score;
} // }
//
@Override // @Override
public String internalError() { // public Status status() {
return null; //// return null;
} // return Status.valueOf(aa);
}; // }
} //
} // @Override
// public Iterable<String> warnings() { return null; }
//
// @Override
// public Iterable<String> errors() {
// return null;
// }
//
// @Override
// public String internalError() {
// return null;
// }
// };
// }
//}
class F2_01M_SPEC extends AbstractGuideline<Document> { class F2_01M_SPEC extends AbstractGuideline<Document> {
@ -374,39 +374,47 @@ class F2_01M_SPEC extends AbstractGuideline<Document> {
public Result validate(String id, Document t) { public Result validate(String id, Document t) {
F2_01M profile = new F2_01M(); F2_01M profile = new F2_01M();
// <></>ODO: iterate over results and build one Guideline.Result // TODO: iterate over results and build one Guideline.Result
try { try {
System.out.println("\nRich metadata is provided to allow discovery");
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t); XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
Map<String, Result> results = res_F.results();
int MaxScoreF2_01M_SPEC = (int) ((res_F.score()*getWeight())/100); // Get actual score and not (%) to incorporate to FAIR score
final int MaxScoreF2_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
// System.out.println("Max score DataValidator(%): " + res_F.score()); // System.out.println("Max score DataValidator(%): " + res_F.score());
// System.out.println("Weight FAIRG: " + getWeight()); // System.out.println("Weight FAIRG: " + getWeight());
// System.out.println("Max score F2_01M_SPEC: " + MaxScoreF2_01M_SPEC); // System.out.println("Max score F2_01M_SPEC: " + MaxScoreF2_01M_SPEC);
// System.out.println("\n\n\n\n"); ArrayList<String> warnings2 = new ArrayList<>();
for (Map.Entry entry : results.entrySet()) { ArrayList<String> errors2 = new ArrayList<>();
System.out.println(entry.getKey() + " = " + entry.getValue()); int score = 0;
for (Map.Entry entry : res_F.results().entrySet()) {
if (res_F.results().get(entry.getKey()).warnings().toString().length() > 2) {
warnings2.add(res_F.results().get(entry.getKey()).warnings().toString());
}
if (res_F.results().get(entry.getKey()).errors().toString().length() > 2) {
errors2.add(res_F.results().get(entry.getKey()).errors().toString());
}
if (entry.getValue().toString().contains("SUCCESS")) {
score += 2;
}
} }
return getResult(MaxScoreF2_01M_SPEC);
// System.out.println(tempp.status() + " - " + tempp.score()); final Result ress = getResult(warnings2, errors2, score);
// String printout = results.entrySet().stream().
// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
// System.out.println(printout);
// System.out.println("\n\n\n\n");
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e); System.out.println(e);
e.printStackTrace();} e.printStackTrace();
return null; return null;
} }
}
private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
private static Result getResult(int score) {
String aa;
aa = (score > 0) ? "SUCCESS" : "FAILURE";
return new Result() { return new Result() {
@Override @Override
public int score() { public int score() {
@ -415,18 +423,17 @@ class F2_01M_SPEC extends AbstractGuideline<Document> {
@Override @Override
public Status status() { public Status status() {
// return null; return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
return Status.valueOf(aa);
} }
@Override @Override
public Iterable<String> warnings() { public Iterable<String> warnings() {
return null; return warnings2;
} }
@Override @Override
public Iterable<String> errors() { public Iterable<String> errors() {
return null; return errors2;
} }
@Override @Override
@ -445,9 +452,9 @@ class F3_01M_SPEC extends AbstractGuideline<Document> {
public Result validate(String id, Document t) { public Result validate(String id, Document t) {
F3_01M profile = new F3_01M(); F3_01M profile = new F3_01M();
// <></>ODO: iterate over results and build one Guideline.Result // TODO: iterate over results and build one Guideline.Result
try { try {
System.out.println("\nMetadata includes the identifier for the data"); // System.out.println("\nMetadata includes the identifier for the data");
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t); XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
Map<String, Result> results = res_F.results(); Map<String, Result> results = res_F.results();
// int MaxScoreF3_01M_SPEC = (int) ((res_F.score()*getWeight())/100); // int MaxScoreF3_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
@ -460,32 +467,30 @@ class F3_01M_SPEC extends AbstractGuideline<Document> {
MaxScoreF3_01M_SPEC = (int) ((res_F.score()*getWeight())/100); MaxScoreF3_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
} }
// System.out.println("% score DataValidator: " + res_F.score()); ArrayList<String> warnings2 = new ArrayList<>();
// System.out.println("Weight FAIRG: " + getWeight()); ArrayList<String> errors2 = new ArrayList<>();
// System.out.println("Max score F3_01M_SPEC: " + MaxScoreF3_01M_SPEC); for (Map.Entry entry : res_F.results().entrySet()) {
if (res_F.results().get(entry.getKey()).warnings().toString().length() > 2) {
// System.out.println("\n\n\n\n"); warnings2.add(res_F.results().get(entry.getKey()).warnings().toString());
for (Map.Entry entry : results.entrySet()) { }
System.out.println(entry.getKey() + " = " + entry.getValue()); if (res_F.results().get(entry.getKey()).errors().toString().length() > 2) {
errors2.add(res_F.results().get(entry.getKey()).errors().toString());
}
} }
return getResult(MaxScoreF3_01M_SPEC);
// System.out.println(tempp.status() + " - " + tempp.score()); final Result ress = getResult(warnings2, errors2, MaxScoreF3_01M_SPEC);
// String printout = results.entrySet().stream().
// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
// System.out.println(printout);
// System.out.println("\n\n\n\n");
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e); System.out.println(e);
e.printStackTrace(); e.printStackTrace();
}
return null; return null;
} }
}
private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
private static Result getResult(int score) {
String aa;
aa = (score > 0) ? "SUCCESS" : "FAILURE";
return new Result() { return new Result() {
@Override @Override
public int score() { public int score() {
@ -494,18 +499,17 @@ class F3_01M_SPEC extends AbstractGuideline<Document> {
@Override @Override
public Status status() { public Status status() {
// return null; return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
return Status.valueOf(aa);
} }
@Override @Override
public Iterable<String> warnings() { public Iterable<String> warnings() {
return null; return warnings2;
} }
@Override @Override
public Iterable<String> errors() { public Iterable<String> errors() {
return null; return errors2;
} }
@Override @Override
@ -524,9 +528,9 @@ class I2_01M_SPEC extends AbstractGuideline<Document> {
public Result validate(String id, Document t) { public Result validate(String id, Document t) {
I2_01M profile = new I2_01M(); I2_01M profile = new I2_01M();
// <></>ODO: iterate over results and build one Guideline.Result // TODO: iterate over results and build one Guideline.Result
try { try {
System.out.println("\nMetadata uses FAIR-compliant vocabularies"); // System.out.println("\nMetadata uses FAIR-compliant vocabularies");
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t); XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
Map<String, Result> results = res_F.results(); Map<String, Result> results = res_F.results();
// int MaxScoreI2_01M_SPEC = (int) ((res_F.score()*getWeight())/100); // int MaxScoreI2_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
@ -539,21 +543,21 @@ class I2_01M_SPEC extends AbstractGuideline<Document> {
MaxScoreI2_01M_SPEC = (int) ((res_F.score()*getWeight())/100); MaxScoreI2_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
} }
// System.out.println("% score DataValidator: " + res_F.score()); ArrayList<String> warnings2 = new ArrayList<>();
// System.out.println("Weight FAIRG: " + getWeight()); ArrayList<String> errors2 = new ArrayList<>();
// System.out.println("Max score I2_01M_SPEC: " + MaxScoreI2_01M_SPEC); for (Map.Entry entry : res_F.results().entrySet()) {
if (res_F.results().get(entry.getKey()).warnings().toString().length() > 2) {
// System.out.println("\n\n\n\n"); warnings2.add(res_F.results().get(entry.getKey()).warnings().toString());
for (Map.Entry entry : results.entrySet()) { }
System.out.println(entry.getKey() + " = " + entry.getValue()); if (res_F.results().get(entry.getKey()).errors().toString().length() > 2) {
errors2.add(res_F.results().get(entry.getKey()).errors().toString());
}
} }
return getResult(MaxScoreI2_01M_SPEC);
// System.out.println(tempp.status() + " - " + tempp.score()); final Result ress = getResult(warnings2, errors2, MaxScoreI2_01M_SPEC);
// String printout = results.entrySet().stream().
// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
// System.out.println(printout);
// System.out.println("\n\n\n\n");
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e); System.out.println(e);
@ -562,9 +566,8 @@ class I2_01M_SPEC extends AbstractGuideline<Document> {
return null; return null;
} }
private static Result getResult(int score) { private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
String aa;
aa = (score > 0) ? "SUCCESS" : "FAILURE";
return new Result() { return new Result() {
@Override @Override
public int score() { public int score() {
@ -573,18 +576,17 @@ class I2_01M_SPEC extends AbstractGuideline<Document> {
@Override @Override
public Status status() { public Status status() {
return null; return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
// return Status.valueOf(aa);
} }
@Override @Override
public Iterable<String> warnings() { public Iterable<String> warnings() {
return null; return warnings2;
} }
@Override @Override
public Iterable<String> errors() { public Iterable<String> errors() {
return null; return errors2;
} }
@Override @Override
@ -603,28 +605,32 @@ class R1_01M_SPEC extends AbstractGuideline<Document> {
public Result validate(String id, Document t) { public Result validate(String id, Document t) {
R1_01M profile = new R1_01M(); R1_01M profile = new R1_01M();
// <></>ODO: iterate over results and build one Guideline.Result // TODO: iterate over results and build one Guideline.Result
try { try {
System.out.println("\nPlurality of accurate and relevant attributes are provided to allow reuse"); // System.out.println("\nPlurality of accurate and relevant attributes are provided to allow reuse");
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t); XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
Map<String, Result> results = res_F.results(); Map<String, Result> results = res_F.results();
int MaxScoreR1_01M_SPEC = (int) ((res_F.score()*getWeight())/100); int MaxScoreR1_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
// System.out.println("% score DataValidator: " + res_F.score()); ArrayList<String> warnings2 = new ArrayList<>();
// System.out.println("Weight FAIRG: " + getWeight()); ArrayList<String> errors2 = new ArrayList<>();
// System.out.println("Max score R1_01M_SPEC: " + MaxScoreR1_01M_SPEC); int score = 0;
for (Map.Entry entry : res_F.results().entrySet()) {
// System.out.println("\n\n\n\n"); if (res_F.results().get(entry.getKey()).warnings().toString().length() > 2) {
for (Map.Entry entry : results.entrySet()) { warnings2.add(res_F.results().get(entry.getKey()).warnings().toString());
System.out.println(entry.getKey() + " = " + entry.getValue()); }
if (res_F.results().get(entry.getKey()).errors().toString().length() > 2) {
errors2.add(res_F.results().get(entry.getKey()).errors().toString());
}
if (entry.getValue().toString().contains("SUCCESS")) {
score += 3;
}
} }
return getResult(MaxScoreR1_01M_SPEC);
// System.out.println(tempp.status() + " - " + tempp.score()); final Result ress = getResult(warnings2, errors2, score);
// String printout = results.entrySet().stream().
// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
// System.out.println(printout);
// System.out.println("\n\n\n\n");
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e); System.out.println(e);
@ -633,8 +639,8 @@ class R1_01M_SPEC extends AbstractGuideline<Document> {
return null; return null;
} }
private static Result getResult(int score) { private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
String aa = (score > 0) ? "SUCCESS" : "FAILURE";
return new Result() { return new Result() {
@Override @Override
public int score() { public int score() {
@ -643,18 +649,17 @@ class R1_01M_SPEC extends AbstractGuideline<Document> {
@Override @Override
public Status status() { public Status status() {
return null; return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
// return Status.valueOf(aa);
} }
@Override @Override
public Iterable<String> warnings() { public Iterable<String> warnings() {
return null; return warnings2;
} }
@Override @Override
public Iterable<String> errors() { public Iterable<String> errors() {
return null; return errors2;
} }
@Override @Override
@ -673,28 +678,33 @@ class R1_2_01M_SPEC extends AbstractGuideline<Document> {
public Result validate(String id, Document t) { public Result validate(String id, Document t) {
R1_2_01M profile = new R1_2_01M(); R1_2_01M profile = new R1_2_01M();
// <></>ODO: iterate over results and build one Guideline.Result // TODO: iterate over results and build one Guideline.Result
try { try {
System.out.println("\nMetadata includes provenance information according to a cross-community language"); // System.out.println("\nMetadata includes provenance information according to a cross-community language");
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t); XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
Map<String, Result> results = res_F.results(); Map<String, Result> results = res_F.results();
int MaxScoreR1_2_01M_SPEC = (int) ((res_F.score()*getWeight())/100); int MaxScoreR1_2_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
// System.out.println("% score DataValidator: " + res_F.score());
// System.out.println("Weight FAIRG: " + getWeight());
// System.out.println("Max score R1_2_01M_SPEC: " + MaxScoreR1_2_01M_SPEC);
// System.out.println("\n\n\n\n"); ArrayList<String> warnings2 = new ArrayList<>();
for (Map.Entry entry : results.entrySet()) { ArrayList<String> errors2 = new ArrayList<>();
System.out.println(entry.getKey() + " = " + entry.getValue()); int score = 0;
for (Map.Entry entry : res_F.results().entrySet()) {
if (res_F.results().get(entry.getKey()).warnings().toString().length() > 2) {
warnings2.add(res_F.results().get(entry.getKey()).warnings().toString());
}
if (res_F.results().get(entry.getKey()).errors().toString().length() > 2) {
errors2.add(res_F.results().get(entry.getKey()).errors().toString());
}
if (entry.getValue().toString().contains("SUCCESS")) {
score += 3;
}
} }
return getResult(MaxScoreR1_2_01M_SPEC);
// System.out.println(tempp.status() + " - " + tempp.score()); final Result ress = getResult(warnings2, errors2, score);
// String printout = results.entrySet().stream().
// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
// System.out.println(printout);
// System.out.println("\n\n\n\n");
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e); System.out.println(e);
@ -703,9 +713,8 @@ class R1_2_01M_SPEC extends AbstractGuideline<Document> {
return null; return null;
} }
private static Result getResult(int score) { private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
String aa;
aa = (score > 0) ? "SUCCESS" : "FAILURE";
return new Result() { return new Result() {
@Override @Override
public int score() { public int score() {
@ -714,18 +723,17 @@ class R1_2_01M_SPEC extends AbstractGuideline<Document> {
@Override @Override
public Status status() { public Status status() {
// return null; return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
return Status.valueOf(aa);
} }
@Override @Override
public Iterable<String> warnings() { public Iterable<String> warnings() {
return null; return warnings2;
} }
@Override @Override
public Iterable<String> errors() { public Iterable<String> errors() {
return null; return errors2;
} }
@Override @Override

View File

@ -43,7 +43,7 @@ public final class I2_01M extends AbstractOpenAireProfile {
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum); private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
public I2_01M() { public I2_01M() {
super("I2_01M Guideline for the OpenAIRE FAIR Guidelines for Data Repositories Profile v4"); super("Metadata uses FAIR-compliant vocabularies");
} }
@Override @Override

View File

@ -59,7 +59,7 @@ public final class R1_01M extends AbstractOpenAireProfile {
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum); private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
public R1_01M() { public R1_01M() {
super("F2_01M Guideline for the OpenAIRE FAIR Guidelines for Data Repositories Profile v4"); super("Plurality of accurate and relevant attributes are provided to allow reuse");
} }
@Override @Override

View File

@ -102,7 +102,7 @@ public final class R1_2_01M extends AbstractOpenAireProfile {
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum); private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
public R1_2_01M() { public R1_2_01M() {
super("R1_2_01M Guideline for the OpenAIRE FAIR Guidelines for Data Repositories Profile v4"); super("Metadata includes provenance information according to a cross-community language");
} }
@Override @Override

View File

@ -14,9 +14,9 @@ import java.util.stream.Collectors;
public class Test { public class Test {
private static final String[] FILES = new String[] { private static final String[] FILES = new String[] {
"src/test/resources/openaireguidelinesV3/dia.library.tuc.gr/Record_21811.xml", // "src/test/resources/openaireguidelinesV3/dia.library.tuc.gr/Record_21811.xml",
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/01.xml", // "src/test/resources/openaireguidelinesV3/cris.vtt.fi/01.xml",
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/02.xml", // "src/test/resources/openaireguidelinesV3/cris.vtt.fi/02.xml",
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml" "src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml"
}; };

View File

@ -1,7 +1,9 @@
package eu.dnetlib.validator2.engine; package eu.dnetlib.validator2.engine;
//import com.google.gson.Gson;
import eu.dnetlib.validator2.validation.XMLApplicationProfile; import eu.dnetlib.validator2.validation.XMLApplicationProfile;
import eu.dnetlib.validator2.validation.guideline.Guideline; import eu.dnetlib.validator2.validation.guideline.Guideline;
import eu.dnetlib.validator2.validation.guideline.StandardResult;
import eu.dnetlib.validator2.validation.guideline.openaire.FAIR_Data_GuidelinesProfile; import eu.dnetlib.validator2.validation.guideline.openaire.FAIR_Data_GuidelinesProfile;
import groovy.xml.DOMBuilder; import groovy.xml.DOMBuilder;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -30,24 +32,27 @@ public class Test_FAIR {
for (String file : FILES) { for (String file : FILES) {
try { try {
System.out.println("Processing " + file); System.out.println("Processing " + file);
// Document doc = DOMBuilder.parse(new FileReader(file), false, true, true);
Document doc = DOMBuilder.parse(new FileReader(file), false, true, true); Document doc = DOMBuilder.parse(new FileReader(file), false, true, true);
XMLApplicationProfile.ValidationResult result = profile.validate(file, doc); XMLApplicationProfile.ValidationResult result = profile.validate(file, doc);
scorePerDoc.put(file, result.score()); scorePerDoc.put(file, result.score());
Map<String, Guideline.Result> results = result.results(); Map<String, Guideline.Result> results = result.results();
for (Map.Entry entry : results.entrySet()) { for (Map.Entry entry : results.entrySet()) {
if (!entry.getValue().toString().contains("eu.dnetlib.validator2")) { // System.out.println(result.results().get(entry.getKey().toString()));
// System.out.println(entry.getValue().getClass() + ": ");
//// if (!entry.getValue().toString().contains("eu.dnetlib.validator2")) {
System.out.println(entry.getKey() + " = " + entry.getValue()); System.out.println(entry.getKey() + " = " + entry.getValue());
//// }
} }
}
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
System.out.println(e); System.out.println(e);
e.printStackTrace(); e.printStackTrace();
} }
System.out.println("\n\n\n\n"); // System.out.println("\n\n\n\n");
} }
System.out.println("\n\n\n\n"); // System.out.println("\n\n\n\n");
String printout = scorePerDoc.entrySet().stream(). String printout = scorePerDoc.entrySet().stream().
map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n")); map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
System.out.println(printout); System.out.println(printout);