Added FAIR Guidelines for literature v4.
media Types file updated Minor updates to the FAIR Guidelines
This commit is contained in:
parent
29f049802b
commit
5a69b9eb6e
|
@ -42,7 +42,7 @@ public final class F2_01M extends AbstractOpenAireProfile {
|
|||
.build();
|
||||
|
||||
private static final ElementSpec F2_01M_SPEC_3 = Builders.
|
||||
forMandatoryElement("publisher", ONE).
|
||||
forMandatoryElement("publisher", ONE_TO_N).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F2_01M_SPEC_4 = Builders.
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
import eu.dnetlib.validator2.validation.guideline.Builders;
|
||||
import eu.dnetlib.validator2.validation.guideline.ElementSpec;
|
||||
import eu.dnetlib.validator2.validation.guideline.Guideline;
|
||||
import eu.dnetlib.validator2.validation.guideline.SyntheticGuideline;
|
||||
import eu.dnetlib.validator2.validation.utils.RegexValuePredicate;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE;
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
import static eu.dnetlib.validator2.validation.utils.SupportedRegExs.*;
|
||||
|
||||
public final class F2_01M_LIT extends AbstractOpenAireProfile {
|
||||
|
||||
private static final String[] TITLE_TYPES = {
|
||||
"AlternativeTitle", "Subtitle", "TranslatedTitle", "Other"
|
||||
};
|
||||
|
||||
private static final String[] NAME_TYPES = {
|
||||
"Organizational", "Personal"
|
||||
};
|
||||
|
||||
private static final ElementSpec F2_01M_LIT_SPEC_1 = Builders.
|
||||
forMandatoryElement("datacite:creator", ONE_TO_N).
|
||||
withSubElement(Builders.
|
||||
forMandatoryElement("datacite:creatorName", ONE).
|
||||
withRecommendedAttribute("nameType", NAME_TYPES)).
|
||||
withSubElement(Builders.
|
||||
forRecommendedElement("datacite:givenName")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedElement("datacite:familyName")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedRepeatableElement("datacite:nameIdentifier").
|
||||
withMandatoryAttribute("nameIdentifierScheme").
|
||||
withRecommendedAttribute("schemeURI")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedRepeatableElement("datacite:affiliation")).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F2_01M_LIT_SPEC_2 = Builders.
|
||||
forMandatoryElement("datacite:title", ONE_TO_N).
|
||||
withOptionalAttribute("xml:lang", new RegexValuePredicate(COMPILED_BCP47_LANG_TAGS_REG_EX)).
|
||||
withOptionalAttribute("titleType", TITLE_TYPES).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F2_01M_LIT_SPEC_3 = Builders.
|
||||
forMandatoryElement("dc:publisher", ONE_TO_N).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F2_01M_LIT_SPEC_4 = Builders.
|
||||
forMandatoryElement("datacite:date", ONE).
|
||||
withMandatoryAttribute("dateType", "Issued").
|
||||
allowedValues(new RegexValuePredicate(COMPILED_PUBLICATION_DATE_REG_EX).or(new RegexValuePredicate(COMPILED_YYYY_MM_DD_RANGE_REGEX).or(new RegexValuePredicate(COMPILED_YEAR_YYYY_REG_EX)))).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F2_01M_LIT_SPEC_5 = Builders.
|
||||
forMandatoryElement("dc:description", ONE_TO_N).
|
||||
withMandatoryAttribute("descriptionType", "Abstract").
|
||||
withOptionalAttribute("xml:lang", new RegexValuePredicate(COMPILED_BCP47_LANG_TAGS_REG_EX)).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F2_01M_LIT_SPEC_6 = Builders.
|
||||
forMandatoryElement("datacite:subject", ONE_TO_N).
|
||||
withOptionalAttribute("subjectScheme").
|
||||
withOptionalAttribute("schemeURI").
|
||||
withOptionalAttribute("valueURI").
|
||||
build();
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 1.
|
||||
public static SyntheticGuideline F2_01M_LIT_1 = SyntheticGuideline.of("Creator", 2, F2_01M_LIT_SPEC_1);
|
||||
public static SyntheticGuideline F2_01M_LIT_2 = SyntheticGuideline.of("Title", 2, F2_01M_LIT_SPEC_2);
|
||||
public static SyntheticGuideline F2_01M_LIT_3 = SyntheticGuideline.of("Publisher", 2, F2_01M_LIT_SPEC_3);
|
||||
public static SyntheticGuideline F2_01M_LIT_4 = SyntheticGuideline.of("Date", 2, F2_01M_LIT_SPEC_4);
|
||||
public static SyntheticGuideline F2_01M_LIT_5 = SyntheticGuideline.of("Summary (Description with descriptionType)", 2, F2_01M_LIT_SPEC_5);
|
||||
public static SyntheticGuideline F2_01M_LIT_6 = SyntheticGuideline.of("Keywords (Subjects)", 2, F2_01M_LIT_SPEC_6);
|
||||
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
F2_01M_LIT_1,
|
||||
F2_01M_LIT_2,
|
||||
F2_01M_LIT_3,
|
||||
F2_01M_LIT_4,
|
||||
F2_01M_LIT_5,
|
||||
F2_01M_LIT_6
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public F2_01M_LIT() {
|
||||
super("Rich metadata is provided to allow discovery");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() {
|
||||
return MAX_SCORE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
import eu.dnetlib.validator2.validation.guideline.Builders;
|
||||
import eu.dnetlib.validator2.validation.guideline.ElementSpec;
|
||||
import eu.dnetlib.validator2.validation.guideline.Guideline;
|
||||
import eu.dnetlib.validator2.validation.guideline.SyntheticGuideline;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE;
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
|
||||
public final class F3_01M_LIT extends AbstractOpenAireProfile {
|
||||
|
||||
private static final String[] RESOURCE_IDENTIFIER_TYPES = {
|
||||
"ARK", "DOI", "Handle", "IGSN", "arXiv", "PURL", "URL", "URN", "PMID"
|
||||
};
|
||||
|
||||
private static final String[] PERSISTENT_IDENTIFIER_TYPES = {
|
||||
"IGSN", "QID", "ARK", "IVOA", "CAS RN", "RRID", "URL", "RInChi", "ERM", "ISO 27729:2012 ISNI",
|
||||
"EC Number", "PURL", "LSID", "TFClass Schema", "InChI", "w3id", "Handle", "DOI", "ORCID iD", "arXiv"
|
||||
};
|
||||
|
||||
private static final ElementSpec F3_01M_LIT_SPEC_1 = Builders.
|
||||
forMandatoryElement("datacite:identifier", ONE).
|
||||
// withMandatoryAttribute("identifierType", new PIDCheckValuePredicate()).
|
||||
withMandatoryAttribute("identifierType", RESOURCE_IDENTIFIER_TYPES).
|
||||
build();
|
||||
|
||||
private static final ElementSpec F3_01M_LIT_SPEC_2 = Builders.
|
||||
forMandatoryElement("datacite:alternateIdentifier", ONE_TO_N).
|
||||
// withMandatoryAttribute("identifierType", new PIDCheckValuePredicate()).
|
||||
withMandatoryAttribute("alternateIdentifierType", PERSISTENT_IDENTIFIER_TYPES).
|
||||
build();
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 1.
|
||||
public static SyntheticGuideline F3_01M_LIT_1 = SyntheticGuideline.of("Identifier", 2, F3_01M_LIT_SPEC_1);
|
||||
public static SyntheticGuideline F3_01M_LIT_2 = SyntheticGuideline.of("AlternateIdentifier", 2, F3_01M_LIT_SPEC_2);
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
F3_01M_LIT_1,
|
||||
F3_01M_LIT_2
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public F3_01M_LIT() {
|
||||
super("Metadata includes the identifier for the data");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() { return MAX_SCORE; }
|
||||
}
|
|
@ -1,364 +0,0 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
//import com.google.gson.Gson;
|
||||
|
||||
import eu.dnetlib.validator2.validation.guideline.*;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE;
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
|
||||
public final class FAIR_Literature_GuidelinesProfile extends AbstractOpenAireProfile {
|
||||
|
||||
private static final String[] TITLE_TYPES = {
|
||||
"AlternativeTitle", "Subtitle", "TranslatedTitle", "Other"
|
||||
};
|
||||
|
||||
private static final String[] NAME_TYPES = {
|
||||
"Organizational", "Personal"
|
||||
};
|
||||
|
||||
private static final String[] CONTRIBUTOR_TYPES = {
|
||||
"ContactPerson", "DataCollector", "DataCurator", "DataManager", "Distributor",
|
||||
"Editor", "HostingInstitution", "Producer", "ProjectLeader", "ProjectManager", "ProjectMember",
|
||||
"RegistrationAgency", "RegistrationAuthority", "RelatedPerson", "Researcher", "ResearchGroup",
|
||||
"RightsHolder", "Sponsor", "Supervisor", "WorkPackageLeader", "Other"
|
||||
};
|
||||
|
||||
private static final String[] FUNDER_IDENTIFIER_TYPES = {
|
||||
"ISNI", "GRID", "Crossref Funder"
|
||||
};
|
||||
|
||||
private static final String[] CONTRIBUTOR_NAME_IDENTIFIER_TYPES = {
|
||||
"Funder", "FundingProgramme", "ProjectID", "Jurisdiction", "ProjectName", "ProjectAcronym"
|
||||
};
|
||||
|
||||
private static final String[] rightsURIList = {
|
||||
"info:eu-repo/semantics/closedAccess",
|
||||
"info:eu-repo/semantics/embargoedAccess",
|
||||
"info:eu-repo/semantics/restrictedAccess",
|
||||
"info:eu-repo/semantics/openAccess"
|
||||
};
|
||||
|
||||
private static final String[] IDENTIFIER_TYPES = {
|
||||
"ARK", "arXiv", "bibcode", "DOI", "EAN13", "EISSN", "Handle", "IGSN", "ISBN",
|
||||
"ISSN", "ISTC", "LISSN", "LSID", "PISSN", "PMID", "PURL", "UPC", "URL", "URN", "WOS",
|
||||
};
|
||||
|
||||
private static final String[] PERSISTENT_IDENTIFIER_TYPES = {
|
||||
"IGSN", "QID", "ARK", "IVOA", "CAS RN", "RRID", "URL", "RInChi", "ERM", "ISO 27729:2012 ISNI",
|
||||
"EC Number", "PURL", "LSID", "TFClass Schema", "InChI", "w3id", "Handle", "DOI", "ORCID iD", "arXiv"
|
||||
};
|
||||
|
||||
private static final String[] RELATION_TYPES = {
|
||||
"IsCitedBy", "Cites", "IsSupplementTo", "IsSupplementedBy", "IsContinuedBy",
|
||||
"Continues", "IsDescribedBy", "Describes", "HasMetadata", "IsMetadataFor", "HasVersion",
|
||||
"IsVersionOf", "IsNewVersionOf", "IsPreviousVersionOf", "IsPartOf", "HasPart", "IsReferencedBy",
|
||||
"References", "IsDocumentedBy", "Documents", "IsCompiledBy", "Compiles", "IsVariantFormOf",
|
||||
"IsOriginalFormOf", "IsIdenticalTo", "IsReviewedBy", "Reviews", "IsDerivedFrom", "IsSourceOf",
|
||||
"IsRequiredBy", "Requires"
|
||||
};
|
||||
|
||||
private static final String[] RELATION_TYPES_LIMITED = {
|
||||
"IsSupplementTo", "Describes", "IsMetadataFor", "IsPartOf"
|
||||
};
|
||||
|
||||
private static final String[] RELATED_RESOURCE_GENERAL_TYPES = {
|
||||
"Audiovisual", "Collection", "DataPaper", "Dataset", "Event", "Image", "InteractiveResource",
|
||||
"Model", "PhysicalObject", "Service", "Software", "Sound", "Text", "Workflow", "Other"
|
||||
};
|
||||
|
||||
private static final String[] EMBARGO_DATE_TYPES = {
|
||||
"Created", "Collected"
|
||||
};
|
||||
|
||||
private static final String[] NAME_IDENTIFIER_SCHEMES = {
|
||||
"ORCID", "ISNI", "ROR", "GRID"
|
||||
};
|
||||
|
||||
private static final String[] NAME_IDENTIFIER_SCHEMES_URIS = {
|
||||
"https://orcid.org/", "http://www.isni.org/", "https://ror.org/", "https://www.grid.ac/"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_GENERAL_TYPES = {
|
||||
"literature", "dataset", "software", "other research product"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_CONCEPT_URIS = {
|
||||
"http://purl.org/coar/resource_type/c_1162", "http://purl.org/coar/resource_type/c_6501",
|
||||
"http://purl.org/coar/resource_type/c_545b", "http://purl.org/coar/resource_type/c_b239",
|
||||
"http://purl.org/coar/resource_type/c_2df8fbb1", "http://purl.org/coar/resource_type/c_dcae04bc",
|
||||
"http://purl.org/coar/resource_type/c_beb9", "http://purl.org/coar/resource_type/c_3e5a",
|
||||
"http://purl.org/coar/resource_type/c_ba08", "http://purl.org/coar/resource_type/c_3248",
|
||||
"http://purl.org/coar/resource_type/c_2f33", "http://purl.org/coar/resource_type/c_86bc",
|
||||
"http://purl.org/coar/resource_type/c_816b", "http://purl.org/coar/resource_type/c_8042",
|
||||
"http://purl.org/coar/resource_type/c_71bd", "http://purl.org/coar/resource_type/c_18gh",
|
||||
"http://purl.org/coar/resource_type/c_18ws", "http://purl.org/coar/resource_type/c_18hj",
|
||||
"http://purl.org/coar/resource_type/c_18op", "http://purl.org/coar/resource_type/c_186u",
|
||||
"http://purl.org/coar/resource_type/c_18wq", "http://purl.org/coar/resource_type/c_18wz",
|
||||
"http://purl.org/coar/resource_type/c_18ww", "http://purl.org/coar/resource_type/c_efa0",
|
||||
"http://purl.org/coar/resource_type/c_baaf", "http://purl.org/coar/resource_type/c_ba1f",
|
||||
"http://purl.org/coar/resource_type/c_93fc", "http://purl.org/coar/resource_type/c_15cd",
|
||||
"http://purl.org/coar/resource_type/c_18co", "http://purl.org/coar/resource_type/c_18cp",
|
||||
"http://purl.org/coar/resource_type/c_6670", "http://purl.org/coar/resource_type/c_5794",
|
||||
"http://purl.org/coar/resource_type/c_c94f", "http://purl.org/coar/resource_type/c_f744",
|
||||
"http://purl.org/coar/resource_type/c_7a1f", "http://purl.org/coar/resource_type/c_bdcc",
|
||||
"http://purl.org/coar/resource_type/c_db06", "http://purl.org/coar/resource_type/c_46ec",
|
||||
"http://purl.org/coar/resource_type/c_0857", "http://purl.org/coar/resource_type/c_8544",
|
||||
"http://purl.org/coar/resource_type/c_18cf", "http://purl.org/coar/resource_type/c_18cw",
|
||||
"http://purl.org/coar/resource_type/c_18cd", "http://purl.org/coar/resource_type/c_18cc",
|
||||
"http://purl.org/coar/resource_type/c_12ce", "http://purl.org/coar/resource_type/c_8a7e",
|
||||
"http://purl.org/coar/resource_type/c_ecc8", "http://purl.org/coar/resource_type/c_c513",
|
||||
"http://purl.org/coar/resource_type/c_12cd", "http://purl.org/coar/resource_type/c_12cc",
|
||||
"http://purl.org/coar/resource_type/c_5ce6", "http://purl.org/coar/resource_type/c_ddb1",
|
||||
"http://purl.org/coar/resource_type/c_e9a0", "http://purl.org/coar/resource_type/c_7ad9",
|
||||
"http://purl.org/coar/resource_type/c_393c", "http://purl.org/coar/resource_type/c_1843"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_IDENTIFIER_TYPES = {
|
||||
"ARK", "DOI", "Handle", "IGSN", "arXiv", "PURL", "URL", "URN", "PMID"
|
||||
};
|
||||
|
||||
private static final String[] ACCESS_RIGHTS_URIS = {
|
||||
"http://purl.org/coar/access_right/c_abf2", "http://purl.org/coar/access_right/c_abf2",
|
||||
"http://purl.org/coar/access_right/c_16ec", "http://purl.org/coar/access_right/c_f1cf",
|
||||
"http://purl.org/coar/access_right/c_16ec", "http://purl.org/coar/access_right/c_16ec",
|
||||
"http://purl.org/coar/access_right/c_16ec", "http://purl.org/coar/access_right/c_14cb"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_VERSION_URIS = {
|
||||
"http://purl.org/coar/version/c_b1a7d7d4d402bcce", "http://purl.org/coar/version/c_71e4c1898caa6e32",
|
||||
"http://purl.org/coar/version/c_ab4af688f83e57aa", "http://purl.org/coar/version/c_fa2ee174bc00049f",
|
||||
"http://purl.org/coar/version/c_970fb48d4fbd8a85", "http://purl.org/coar/version/c_e19f295774971610",
|
||||
"http://purl.org/coar/version/c_dc82b40f9837b551", "http://purl.org/coar/version/c_be7fb7dd8ff6fe43"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_VERSION_LABELS = {
|
||||
"AO", "SMUR", "AM", "P", "VoR", "CVoR", "EVoR", "NA"
|
||||
};
|
||||
|
||||
private static final String[] DATE_TYPES = {
|
||||
"Accepted", "Available", "Copyrighted", "Collected", "Created", "Issued", "Submitted", "Updated", "Valid"
|
||||
};
|
||||
|
||||
private static final String[] FILE_OBJECT_TYPES = {
|
||||
"fulltext", "dataset", "software", "other"
|
||||
};
|
||||
|
||||
private static final String[] AUDIENCE_VOCABULARY = {
|
||||
"Administrators", "Community Groups", "Counsellors", "Federal Funds Recipients and Applicants",
|
||||
"Librarians", "News Media", "Other", "Parents and Families", "Policymakers", "Researchers",
|
||||
"School Support Staff", "Student Financial Aid Providers", "Students", "Teachers"
|
||||
};
|
||||
|
||||
// globally unique identifier
|
||||
private static final ElementSpec F1_01D_SPEC = Builders.
|
||||
forMandatoryElement("identifier", ONE).
|
||||
// withMandatoryAttribute("identifierType", new PIDCheckValuePredicate()).
|
||||
withMandatoryAttribute("identifierType", PERSISTENT_IDENTIFIER_TYPES).
|
||||
build();
|
||||
|
||||
// persistent identifier
|
||||
private static final ElementSpec F1_02D_SPEC = Builders.
|
||||
forMandatoryElement("identifier", ONE).
|
||||
withMandatoryAttribute("identifierType", IDENTIFIER_TYPES).
|
||||
build();
|
||||
|
||||
// // To be implemented: In the case of OpenAIRE we suppose it succeeds
|
||||
// private static final ElementSpec F4_01M_SPEC = Builders.
|
||||
// forMandatoryElement("identifier", ONE).
|
||||
// withMandatoryAttribute("identifierType", RESOURCE_IDENTIFIER_TYPES).
|
||||
// build();
|
||||
|
||||
private static final ElementSpec A1_01M_SPEC = Builders.
|
||||
forMandatoryElement("rights", ONE_TO_N).
|
||||
withMandatoryAttribute("rightsURI", rightsURIList).
|
||||
build();
|
||||
|
||||
// // To be implemented
|
||||
// private static final ElementSpec A2_01M_SPEC = Builders.
|
||||
// forMandatoryElement("subject", ONE_TO_N).
|
||||
// withMandatoryAttribute("subjectScheme").
|
||||
// withMandatoryAttribute("schemeURI").
|
||||
// build();
|
||||
|
||||
// // To be implemented
|
||||
// private static final ElementSpec I1_01M_SPEC = Builders.
|
||||
// forMandatoryElement("subject", ONE_TO_N).
|
||||
// build();
|
||||
|
||||
// // To be implemented
|
||||
// // I1_02M Metadata uses semantic resources
|
||||
// private static final ElementSpec I1_02M_SPEC = Builders.
|
||||
// forMandatoryElement("subject", ONE).
|
||||
// build();
|
||||
|
||||
private static final ElementSpec I3_01M_SPEC_1 = Builders.
|
||||
forMandatoryElement("relatedIdentifier", ONE_TO_N).
|
||||
withMandatoryAttribute("relatedIdentifierType", IDENTIFIER_TYPES).
|
||||
withMandatoryAttribute("relationType", RELATION_TYPES).
|
||||
build();
|
||||
|
||||
// private static final ElementSpec I3_01M_SPEC_2 = Builders.
|
||||
// forMandatoryElement("creator", ONE_TO_N).
|
||||
// withMandatoryAttribute("creatorName").
|
||||
// withMandatoryAttribute("nameIdentifier", NAME_IDENTIFIER_SCHEMES).
|
||||
// withMandatoryAttribute("nameIdentifierScheme", NAME_IDENTIFIER_SCHEMES).
|
||||
// withMandatoryAttribute("schemeURI", NAME_IDENTIFIER_SCHEMES_URIS).
|
||||
// withMandatoryAttribute("affiliation", NAME_IDENTIFIER_SCHEMES).
|
||||
// build();
|
||||
|
||||
// TO BE IMPLEMENTED
|
||||
|
||||
private static final ElementSpec R1_1_01M_SPEC = Builders.
|
||||
forMandatoryElement("rights", ONE_TO_N)
|
||||
.atPosition(ElementPosition.FIRST)
|
||||
.withMandatoryAttribute("rightsURI") // Not in the rightsURIList HOW TO IMPLEMENT?????
|
||||
// .withMandatoryAttribute("rightsURI", rightsURIList) // Not in the rightsURIList HOW TO IMPLEMENT?????
|
||||
.build();
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 10.
|
||||
public static SyntheticGuideline F1_01D = SyntheticGuideline.of("Data is identified by a persistent identifier", 10, F1_01D_SPEC);
|
||||
public static SyntheticGuideline F1_02D = SyntheticGuideline.of("Data is identified by a globally unique identifier", 10, F1_02D_SPEC);
|
||||
// public static SyntheticGuideline F4_01M = SyntheticGuideline.of("F4_01M", 10, F4_01M_SPEC);
|
||||
public static SyntheticGuideline A1_01M = SyntheticGuideline.of("Metadata contains information to enable the user to get access to the data", 10, A1_01M_SPEC);
|
||||
// public static SyntheticGuideline A2_01M = SyntheticGuideline.of("A2_01M", 10, A2_01M_SPEC);
|
||||
// public static SyntheticGuideline I1_01M = SyntheticGuideline.of("I1_01M", 10, I1_01M_SPEC);
|
||||
// public static SyntheticGuideline I1_02M = SyntheticGuideline.of("I1_02M", 10, I1_02M_SPEC);
|
||||
public static SyntheticGuideline I3_01M_1 = SyntheticGuideline.of("Metadata includes references to other metadata", 10, I3_01M_SPEC_1);
|
||||
// public static SyntheticGuideline I3_01M_2 = SyntheticGuideline.of("I3_01M_2", 5, I3_01M_SPEC_2);
|
||||
// public static SyntheticGuideline R1_01M = SyntheticGuideline.of("R1_01M", 10, R1_01M_SPEC);
|
||||
public static SyntheticGuideline R1_1_01M = SyntheticGuideline.of("Metadata includes information about the licence under which the data can be reused", 10, R1_1_01M_SPEC);
|
||||
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
F1_01D,
|
||||
F1_02D,
|
||||
new F2_01M_SPEC(),
|
||||
new F3_01M_SPEC(),
|
||||
// F4_01M,
|
||||
A1_01M,
|
||||
// A2_01M,
|
||||
// I1_01M,
|
||||
// I1_02M,
|
||||
new I2_01M_SPEC(),
|
||||
I3_01M_1,
|
||||
// I3_01M_2,
|
||||
// R1_01M,
|
||||
new R1_01M_SPEC(),
|
||||
R1_1_01M,
|
||||
new R1_2_01M_SPEC()
|
||||
// new MetadataCompleteness()
|
||||
// new I3_01M()
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public FAIR_Literature_GuidelinesProfile() {
|
||||
super("OpenAIRE FAIR Guidelines for Data Repositories Profile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() {
|
||||
return MAX_SCORE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// TODO this goes to FAIRProfile
|
||||
//class MetadataCompleteness extends AbstractGuideline<Document> {
|
||||
//
|
||||
// public MetadataCompleteness() {
|
||||
// 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);
|
||||
//
|
||||
//// System.out.println(tempp.status() + " - " + tempp.score());
|
||||
//// String printout = results.entrySet().stream().
|
||||
//// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
|
||||
//// System.out.println(printout);
|
||||
//
|
||||
//// System.out.println("\n\n\n\n");
|
||||
// } catch (Exception e) {
|
||||
// System.out.println(e.getMessage());
|
||||
// System.out.println(e);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private static Result getResult(int score) {
|
||||
// String aa;
|
||||
// aa = (score > 0) ? "SUCCESS" : "FAILURE";
|
||||
// return new Result() {
|
||||
// @Override
|
||||
// public int score() {
|
||||
// return score;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Status status() {
|
||||
//// 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;
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,752 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
//import com.google.gson.Gson;
|
||||
|
||||
import eu.dnetlib.validator2.engine.Status;
|
||||
import eu.dnetlib.validator2.validation.XMLApplicationProfile;
|
||||
import eu.dnetlib.validator2.validation.guideline.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE;
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
|
||||
public final class FAIR_Literature_GuidelinesV4Profile extends AbstractOpenAireProfile {
|
||||
|
||||
|
||||
private static final String[] TITLE_TYPES = {
|
||||
"AlternativeTitle", "Subtitle", "TranslatedTitle", "Other"
|
||||
};
|
||||
|
||||
private static final String[] NAME_TYPES = {
|
||||
"Organizational", "Personal"
|
||||
};
|
||||
|
||||
private static final String[] CONTRIBUTOR_TYPES = {
|
||||
"ContactPerson", "DataCollector", "DataCurator", "DataManager", "Distributor",
|
||||
"Editor", "HostingInstitution", "Producer", "ProjectLeader", "ProjectManager", "ProjectMember",
|
||||
"RegistrationAgency", "RegistrationAuthority", "RelatedPerson", "Researcher", "ResearchGroup",
|
||||
"RightsHolder", "Sponsor", "Supervisor", "WorkPackageLeader", "Other"
|
||||
};
|
||||
|
||||
private static final String[] FUNDER_IDENTIFIER_TYPES = {
|
||||
"ISNI", "GRID", "Crossref Funder"
|
||||
};
|
||||
|
||||
private static final String[] IDENTIFIER_TYPES = {
|
||||
"ARK", "arXiv", "bibcode", "DOI", "EAN13", "EISSN", "Handle", "IGSN", "ISBN",
|
||||
"ISSN", "ISTC", "LISSN", "LSID", "PISSN", "PMID", "PURL", "UPC", "URL", "URN", "WOS",
|
||||
};
|
||||
|
||||
private static final String[] RELATION_TYPES = {
|
||||
"IsCitedBy", "Cites", "IsSupplementTo", "IsSupplementedBy", "IsContinuedBy",
|
||||
"Continues", "IsDescribedBy", "Describes", "HasMetadata", "IsMetadataFor", "HasVersion",
|
||||
"IsVersionOf", "IsNewVersionOf", "IsPreviousVersionOf", "IsPartOf", "HasPart", "IsReferencedBy",
|
||||
"References", "IsDocumentedBy", "Documents", "IsCompiledBy", "Compiles", "IsVariantFormOf",
|
||||
"IsOriginalFormOf", "IsIdenticalTo", "IsReviewedBy", "Reviews", "IsDerivedFrom", "IsSourceOf",
|
||||
"IsRequiredBy", "Requires"
|
||||
};
|
||||
|
||||
private static final String[] RELATED_RESOURCE_GENERAL_TYPES = {
|
||||
"Audiovisual", "Collection", "DataPaper", "Dataset", "Event", "Image", "InteractiveResource",
|
||||
"Model", "PhysicalObject", "Service", "Software", "Sound", "Text", "Workflow", "Other"
|
||||
};
|
||||
|
||||
private static final String[] EMBARGO_DATE_TYPES = {
|
||||
"Accepted", "Available"
|
||||
};
|
||||
|
||||
private static final String[] PUBLICATION_DATE_TYPE = {
|
||||
"Issued"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_GENERAL_TYPES = {
|
||||
"literature", "dataset", "software", "other research product"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_CONCEPT_URIS = {
|
||||
"http://purl.org/coar/resource_type/c_1162", "http://purl.org/coar/resource_type/c_6501",
|
||||
"http://purl.org/coar/resource_type/c_545b", "http://purl.org/coar/resource_type/c_b239",
|
||||
"http://purl.org/coar/resource_type/c_2df8fbb1", "http://purl.org/coar/resource_type/c_dcae04bc",
|
||||
"http://purl.org/coar/resource_type/c_beb9", "http://purl.org/coar/resource_type/c_3e5a",
|
||||
"http://purl.org/coar/resource_type/c_ba08", "http://purl.org/coar/resource_type/c_3248",
|
||||
"http://purl.org/coar/resource_type/c_2f33", "http://purl.org/coar/resource_type/c_86bc",
|
||||
"http://purl.org/coar/resource_type/c_816b", "http://purl.org/coar/resource_type/c_8042",
|
||||
"http://purl.org/coar/resource_type/c_71bd", "http://purl.org/coar/resource_type/c_18gh",
|
||||
"http://purl.org/coar/resource_type/c_18ws", "http://purl.org/coar/resource_type/c_18hj",
|
||||
"http://purl.org/coar/resource_type/c_18op", "http://purl.org/coar/resource_type/c_186u",
|
||||
"http://purl.org/coar/resource_type/c_18wq", "http://purl.org/coar/resource_type/c_18wz",
|
||||
"http://purl.org/coar/resource_type/c_18ww", "http://purl.org/coar/resource_type/c_efa0",
|
||||
"http://purl.org/coar/resource_type/c_baaf", "http://purl.org/coar/resource_type/c_ba1f",
|
||||
"http://purl.org/coar/resource_type/c_93fc", "http://purl.org/coar/resource_type/c_15cd",
|
||||
"http://purl.org/coar/resource_type/c_18co", "http://purl.org/coar/resource_type/c_18cp",
|
||||
"http://purl.org/coar/resource_type/c_6670", "http://purl.org/coar/resource_type/c_5794",
|
||||
"http://purl.org/coar/resource_type/c_c94f", "http://purl.org/coar/resource_type/c_f744",
|
||||
"http://purl.org/coar/resource_type/c_7a1f", "http://purl.org/coar/resource_type/c_bdcc",
|
||||
"http://purl.org/coar/resource_type/c_db06", "http://purl.org/coar/resource_type/c_46ec",
|
||||
"http://purl.org/coar/resource_type/c_0857", "http://purl.org/coar/resource_type/c_8544",
|
||||
"http://purl.org/coar/resource_type/c_18cf", "http://purl.org/coar/resource_type/c_18cw",
|
||||
"http://purl.org/coar/resource_type/c_18cd", "http://purl.org/coar/resource_type/c_18cc",
|
||||
"http://purl.org/coar/resource_type/c_12ce", "http://purl.org/coar/resource_type/c_8a7e",
|
||||
"http://purl.org/coar/resource_type/c_ecc8", "http://purl.org/coar/resource_type/c_c513",
|
||||
"http://purl.org/coar/resource_type/c_12cd", "http://purl.org/coar/resource_type/c_12cc",
|
||||
"http://purl.org/coar/resource_type/c_5ce6", "http://purl.org/coar/resource_type/c_ddb1",
|
||||
"http://purl.org/coar/resource_type/c_e9a0", "http://purl.org/coar/resource_type/c_7ad9",
|
||||
"http://purl.org/coar/resource_type/c_393c", "http://purl.org/coar/resource_type/c_1843"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_IDENTIFIER_TYPES = {
|
||||
"ARK", "DOI", "Handle", "PURL", "URL", "URN"
|
||||
};
|
||||
|
||||
private static final String[] ACCESS_RIGHTS_TYPES = {
|
||||
"open access", "embargoed access",
|
||||
"restricted access", "metadata only access"
|
||||
};
|
||||
|
||||
private static final String[] ACCESS_RIGHTS_URIS = {
|
||||
"http://purl.org/coar/access_right/c_abf2", "http://purl.org/coar/access_right/c_f1cf",
|
||||
"http://purl.org/coar/access_right/c_16ec", "http://purl.org/coar/access_right/c_14cb"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_VERSION_URIS = {
|
||||
"http://purl.org/coar/version/c_b1a7d7d4d402bcce", "http://purl.org/coar/version/c_71e4c1898caa6e32",
|
||||
"http://purl.org/coar/version/c_ab4af688f83e57aa", "http://purl.org/coar/version/c_fa2ee174bc00049f",
|
||||
"http://purl.org/coar/version/c_970fb48d4fbd8a85", "http://purl.org/coar/version/c_e19f295774971610",
|
||||
"http://purl.org/coar/version/c_dc82b40f9837b551", "http://purl.org/coar/version/c_be7fb7dd8ff6fe43"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_VERSION_LABELS = {
|
||||
"AO", "SMUR", "AM", "P", "VoR", "CVoR", "EVoR", "NA"
|
||||
};
|
||||
|
||||
private static final String[] FILE_OBJECT_TYPES = {
|
||||
"fulltext", "dataset", "software", "other"
|
||||
};
|
||||
|
||||
private static final String[] AUDIENCE_VOCABULARY = {
|
||||
"Administrators", "Community Groups", "Counsellors", "Federal Funds Recipients and Applicants",
|
||||
"Librarians", "News Media", "Other", "Parents and Families", "Policymakers", "Researchers",
|
||||
"School Support Staff", "Student Financial Aid Providers", "Students", "Teachers"
|
||||
};
|
||||
|
||||
// persistent identifier
|
||||
private static final ElementSpec F1_01D_SPEC = Builders.
|
||||
forMandatoryElement("datacite:identifier", ONE).
|
||||
withMandatoryAttribute("identifierType", RESOURCE_IDENTIFIER_TYPES).
|
||||
build();
|
||||
|
||||
// persistent identifier
|
||||
private static final ElementSpec F1_02D_SPEC = Builders.
|
||||
forMandatoryElement("identifier", ONE).
|
||||
withMandatoryAttribute("identifierType", IDENTIFIER_TYPES).
|
||||
build();
|
||||
|
||||
// // To be implemented: In the case of OpenAIRE we suppose it succeeds
|
||||
// private static final ElementSpec F4_01M_SPEC = Builders.
|
||||
// forMandatoryElement("identifier", ONE).
|
||||
// withMandatoryAttribute("identifierType", RESOURCE_IDENTIFIER_TYPES).
|
||||
// build();
|
||||
|
||||
private static final ElementSpec A1_01M_SPEC = Builders.
|
||||
forMandatoryElement("datacite:rights", ONE_TO_N).
|
||||
withMandatoryAttribute("rightsURI", ACCESS_RIGHTS_URIS).
|
||||
build();
|
||||
|
||||
// // To be implemented
|
||||
// private static final ElementSpec A2_01M_SPEC = Builders.
|
||||
// forMandatoryElement("subject", ONE_TO_N).
|
||||
// withMandatoryAttribute("subjectScheme").
|
||||
// withMandatoryAttribute("schemeURI").
|
||||
// build();
|
||||
|
||||
// // To be implemented
|
||||
// private static final ElementSpec I1_01M_SPEC = Builders.
|
||||
// forMandatoryElement("subject", ONE_TO_N).
|
||||
// build();
|
||||
|
||||
// // To be implemented
|
||||
// // I1_02M Metadata uses semantic resources
|
||||
// private static final ElementSpec I1_02M_SPEC = Builders.
|
||||
// forMandatoryElement("subject", ONE).
|
||||
// build();
|
||||
|
||||
|
||||
private static final ElementSpec I3_01M_SPEC_1 = Builders.
|
||||
forRecommendedRepeatableElement("datacite:relatedIdentifier").
|
||||
withMandatoryAttribute("relatedIdentifierType", IDENTIFIER_TYPES).
|
||||
withMandatoryAttribute("relationType", RELATION_TYPES).
|
||||
//TODO: For following 3 attributes. Need a way to target relationType attribute of current element
|
||||
// - Should be used only with relation type (HasMetadata/IsMetadataFor).
|
||||
withOptionalAttribute("relatedMetadataScheme").
|
||||
withOptionalAttribute("schemeURI").
|
||||
withOptionalAttribute("schemeType").
|
||||
withOptionalAttribute("resourceTypeGeneral", RELATED_RESOURCE_GENERAL_TYPES).
|
||||
build();
|
||||
|
||||
// private static final ElementSpec I3_01M_SPEC_2 = Builders.
|
||||
// forMandatoryElement("creator", ONE_TO_N).
|
||||
// withMandatoryAttribute("creatorName").
|
||||
// withMandatoryAttribute("nameIdentifier", NAME_IDENTIFIER_SCHEMES).
|
||||
// withMandatoryAttribute("nameIdentifierScheme", NAME_IDENTIFIER_SCHEMES).
|
||||
// withMandatoryAttribute("schemeURI", NAME_IDENTIFIER_SCHEMES_URIS).
|
||||
// withMandatoryAttribute("affiliation", NAME_IDENTIFIER_SCHEMES).
|
||||
// build();
|
||||
|
||||
// TO BE IMPLEMENTED
|
||||
|
||||
private static final ElementSpec R1_1_01M_SPEC = Builders.
|
||||
forRecommendedElement("oaire:licenseCondition").
|
||||
withMandatoryIfApplicableAttribute("uri", elementIsPresent("oaire:licenseCondition")).
|
||||
withMandatoryIfApplicableAttribute("startDate", elementIsPresent("oaire:licenseCondition")).
|
||||
build();
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 10.
|
||||
public static SyntheticGuideline F1_01D = SyntheticGuideline.of("Data is identified by a persistent identifier", 10, F1_01D_SPEC);
|
||||
public static SyntheticGuideline F1_02D = SyntheticGuideline.of("Data is identified by a globally unique identifier", 10, F1_02D_SPEC);
|
||||
// public static SyntheticGuideline F4_01M = SyntheticGuideline.of("F4_01M", 10, F4_01M_SPEC);
|
||||
public static SyntheticGuideline A1_01M = SyntheticGuideline.of("Metadata contains information to enable the user to get access to the data", 10, A1_01M_SPEC);
|
||||
// public static SyntheticGuideline A2_01M = SyntheticGuideline.of("A2_01M", 10, A2_01M_SPEC);
|
||||
// public static SyntheticGuideline I1_01M = SyntheticGuideline.of("I1_01M", 10, I1_01M_SPEC);
|
||||
// public static SyntheticGuideline I1_02M = SyntheticGuideline.of("I1_02M", 10, I1_02M_SPEC);
|
||||
public static SyntheticGuideline I3_01M_1 = SyntheticGuideline.of("Metadata includes references to other metadata", 10, I3_01M_SPEC_1);
|
||||
// public static SyntheticGuideline I3_01M_2 = SyntheticGuideline.of("I3_01M_2", 5, I3_01M_SPEC_2);
|
||||
// public static SyntheticGuideline R1_01M = SyntheticGuideline.of("R1_01M", 10, R1_01M_SPEC);
|
||||
public static SyntheticGuideline R1_1_01M = SyntheticGuideline.of("Metadata includes information about the licence under which the data can be reused", 10, R1_1_01M_SPEC);
|
||||
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
F1_01D,
|
||||
F1_02D,
|
||||
new F2_01M_SPEC(),
|
||||
new F3_01M_SPEC(),
|
||||
// F4_01M,
|
||||
A1_01M,
|
||||
// A2_01M,
|
||||
// I1_01M,
|
||||
// I1_02M,
|
||||
new I2_01M_SPEC(),
|
||||
I3_01M_1,
|
||||
// I3_01M_2,
|
||||
// R1_01M,
|
||||
new R1_01M_SPEC(),
|
||||
R1_1_01M,
|
||||
new R1_2_01M_SPEC()
|
||||
// new MetadataCompleteness()
|
||||
// new I3_01M()
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public FAIR_Literature_GuidelinesV4Profile() {
|
||||
super("OpenAIRE FAIR Guidelines for Data Repositories Profile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() {
|
||||
return MAX_SCORE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// TODO this goes to FAIRProfile
|
||||
//class MetadataCompleteness extends AbstractGuideline<Document> {
|
||||
//
|
||||
// public MetadataCompleteness() {
|
||||
// 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);
|
||||
//
|
||||
//// System.out.println(tempp.status() + " - " + tempp.score());
|
||||
//// String printout = results.entrySet().stream().
|
||||
//// map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
|
||||
//// System.out.println(printout);
|
||||
//
|
||||
//// System.out.println("\n\n\n\n");
|
||||
// } catch (Exception e) {
|
||||
// System.out.println(e.getMessage());
|
||||
// System.out.println(e);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private static Result getResult(int score) {
|
||||
// String aa;
|
||||
// aa = (score > 0) ? "SUCCESS" : "FAILURE";
|
||||
// return new Result() {
|
||||
// @Override
|
||||
// public int score() {
|
||||
// return score;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Status status() {
|
||||
//// 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_LIT extends AbstractGuideline<Document> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(F2_01M_SPEC.class);
|
||||
|
||||
public F2_01M_SPEC_LIT() {
|
||||
super("Rich metadata is provided to allow discovery", 2*6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result validate(String id, Document t) {
|
||||
F2_01M_LIT profile = new F2_01M_LIT();
|
||||
|
||||
// TODO: iterate over results and build one Guideline.Result
|
||||
try {
|
||||
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
|
||||
Map<String, Guideline.Result> results = res_F.results();
|
||||
|
||||
// Get actual score and not (%) to incorporate to FAIR score
|
||||
final int MaxScoreF2_01M_LIT_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
|
||||
logger.debug("Max score DataValidator(%): " + res_F.score());
|
||||
logger.debug("Weight FAIRG: " + getWeight());
|
||||
logger.debug("Max score F2_01M_SPEC: " + MaxScoreF2_01M_LIT_SPEC);
|
||||
|
||||
List<String> warnings2 = new ArrayList<>();
|
||||
List<String> errors2 = new ArrayList<>();
|
||||
int score = 0;
|
||||
for (Map.Entry<String, Guideline.Result> entry : results.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String warningsStr = results.get(key).warnings().toString();
|
||||
String errorsStr = results.get(key).errors().toString();
|
||||
if ( warningsStr.length() > 2 ) {
|
||||
warnings2.add(warningsStr);
|
||||
}
|
||||
if ( errorsStr.length() > 2 ) {
|
||||
errors2.add(errorsStr);
|
||||
}
|
||||
if (entry.getValue().toString().contains("SUCCESS")) {
|
||||
score += 2;
|
||||
}
|
||||
if ( logger.isTraceEnabled() ) {
|
||||
logger.trace(String.valueOf(results.get(key).warnings().getClass()));
|
||||
logger.trace(String.valueOf(warnings2.getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final Result ress = getResult(warnings2, errors2, score);
|
||||
|
||||
return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Result getResult(List<String> warnings2, List<String> errors2, int score) {
|
||||
|
||||
return new Result() {
|
||||
@Override
|
||||
public int score() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status status() {
|
||||
return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> warnings() {
|
||||
return warnings2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> errors() {
|
||||
return errors2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String internalError() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class F3_01M_SPEC_LIT extends AbstractGuideline<Document> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(F3_01M_SPEC.class);
|
||||
|
||||
|
||||
public F3_01M_SPEC_LIT() { super("Metadata includes the identifier for the data", 2*2); }
|
||||
|
||||
@Override
|
||||
public Result validate(String id, Document t) {
|
||||
F3_01M_LIT profile = new F3_01M_LIT();
|
||||
|
||||
// TODO: iterate over results and build one Guideline.Result
|
||||
try {
|
||||
// System.out.println("\nMetadata includes the identifier for the data");
|
||||
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
|
||||
Map<String, Guideline.Result> results = res_F.results();
|
||||
// int MaxScoreF3_01M_LIT_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
|
||||
int MaxScoreF3_01M_LIT_SPEC;
|
||||
if ((int) res_F.score() == 50 ) {
|
||||
MaxScoreF3_01M_LIT_SPEC = (int) (((2*res_F.score())*getWeight())/100);
|
||||
}
|
||||
else {
|
||||
MaxScoreF3_01M_LIT_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
}
|
||||
|
||||
ArrayList<String> warnings2 = new ArrayList<>();
|
||||
ArrayList<String> errors2 = new ArrayList<>();
|
||||
for (Map.Entry<String, Guideline.Result> entry : results.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String warningsStr = results.get(key).warnings().toString();
|
||||
String errorsStr = results.get(key).errors().toString();
|
||||
if ( warningsStr.length() > 2 ) {
|
||||
warnings2.add(warningsStr);
|
||||
}
|
||||
if ( errorsStr.length() > 2 ) {
|
||||
errors2.add(errorsStr);
|
||||
}
|
||||
}
|
||||
|
||||
final Result ress = getResult(warnings2, errors2, MaxScoreF3_01M_LIT_SPEC);
|
||||
|
||||
return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
|
||||
|
||||
return new Result() {
|
||||
@Override
|
||||
public int score() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status status() {
|
||||
return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> warnings() {
|
||||
return warnings2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> errors() {
|
||||
return errors2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String internalError() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class I2_01M_SPEC_LIT extends AbstractGuideline<Document> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(I2_01M_SPEC_LIT.class);
|
||||
|
||||
public I2_01M_SPEC_LIT() { super("Metadata uses FAIR-compliant vocabularies", 5*2); }
|
||||
|
||||
@Override
|
||||
public Result validate(String id, Document t) {
|
||||
I2_01M_LIT profile = new I2_01M_LIT();
|
||||
|
||||
// TODO: iterate over results and build one Guideline.Result
|
||||
try {
|
||||
logger.debug("Metadata uses FAIR-compliant vocabularies");
|
||||
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
|
||||
Map<String, Guideline.Result> results = res_F.results();
|
||||
// int MaxScoreI2_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
|
||||
int MaxScoreI2_01M_LIT_SPEC;
|
||||
if ((int) res_F.score() == 50 ) {
|
||||
MaxScoreI2_01M_LIT_SPEC = (int) (((2*res_F.score())*getWeight())/100);
|
||||
}
|
||||
else {
|
||||
MaxScoreI2_01M_LIT_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
}
|
||||
|
||||
ArrayList<String> warnings2 = new ArrayList<>();
|
||||
ArrayList<String> errors2 = new ArrayList<>();
|
||||
for (Map.Entry<String, Guideline.Result> entry : results.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String warningsStr = results.get(key).warnings().toString();
|
||||
String errorsStr = results.get(key).errors().toString();
|
||||
if ( warningsStr.length() > 2 ) {
|
||||
warnings2.add(warningsStr);
|
||||
}
|
||||
if ( errorsStr.length() > 2 ) {
|
||||
errors2.add(errorsStr);
|
||||
}
|
||||
}
|
||||
|
||||
final Result ress = getResult(warnings2, errors2, MaxScoreI2_01M_LIT_SPEC);
|
||||
|
||||
return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
|
||||
|
||||
return new Result() {
|
||||
@Override
|
||||
public int score() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status status() {
|
||||
return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> warnings() {
|
||||
return warnings2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> errors() {
|
||||
return errors2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String internalError() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class R1_01M_SPEC_LIT extends AbstractGuideline<Document> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(R1_01M_SPEC_LIT.class);
|
||||
|
||||
|
||||
public R1_01M_SPEC_LIT() { super("Plurality of accurate and relevant attributes are provided to allow reuse", 3*4); }
|
||||
|
||||
@Override
|
||||
public Result validate(String id, Document t) {
|
||||
R1_01M_LIT profile = new R1_01M_LIT();
|
||||
|
||||
// TODO: iterate over results and build one Guideline.Result
|
||||
try {
|
||||
// System.out.println("\nPlurality of accurate and relevant attributes are provided to allow reuse");
|
||||
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
|
||||
Map<String, Guideline.Result> results = res_F.results();
|
||||
int MaxScoreR1_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
|
||||
ArrayList<String> warnings2 = new ArrayList<>();
|
||||
ArrayList<String> errors2 = new ArrayList<>();
|
||||
int score = 0;
|
||||
for (Map.Entry<String, Guideline.Result> entry : results.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String warningsStr = results.get(key).warnings().toString();
|
||||
String errorsStr = results.get(key).errors().toString();
|
||||
if ( warningsStr.length() > 2 ) {
|
||||
warnings2.add(warningsStr);
|
||||
}
|
||||
if ( errorsStr.length() > 2 ) {
|
||||
errors2.add(errorsStr);
|
||||
}
|
||||
if (entry.getValue().toString().contains("SUCCESS")) {
|
||||
score += 3;
|
||||
}
|
||||
}
|
||||
|
||||
final Result ress = getResult(warnings2, errors2, score);
|
||||
|
||||
return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
|
||||
|
||||
return new Result() {
|
||||
@Override
|
||||
public int score() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status status() {
|
||||
return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> warnings() {
|
||||
return warnings2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> errors() {
|
||||
return errors2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String internalError() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class R1_2_01M_SPEC_LIT extends AbstractGuideline<Document> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(R1_2_01M_SPEC_LIT.class);
|
||||
|
||||
|
||||
public R1_2_01M_SPEC_LIT() { super("Metadata includes provenance information according to a cross-community language", 2*5); }
|
||||
|
||||
@Override
|
||||
public Result validate(String id, Document t) {
|
||||
R1_2_01M_LIT profile = new R1_2_01M_LIT();
|
||||
|
||||
// TODO: iterate over results and build one Guideline.Result
|
||||
try {
|
||||
// System.out.println("\nMetadata includes provenance information according to a cross-community language");
|
||||
XMLApplicationProfile.ValidationResult res_F = profile.validate(id, t);
|
||||
Map<String, Guideline.Result> results = res_F.results();
|
||||
int MaxScoreR1_2_01M_SPEC = (int) ((res_F.score()*getWeight())/100);
|
||||
|
||||
ArrayList<String> warnings2 = new ArrayList<>();
|
||||
ArrayList<String> errors2 = new ArrayList<>();
|
||||
int score = 0;
|
||||
for (Map.Entry<String, Guideline.Result> entry : results.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String warningsStr = results.get(key).warnings().toString();
|
||||
String errorsStr = results.get(key).errors().toString();
|
||||
if ( warningsStr.length() > 2 ) {
|
||||
warnings2.add(warningsStr);
|
||||
}
|
||||
if ( errorsStr.length() > 2 ) {
|
||||
errors2.add(errorsStr);
|
||||
}
|
||||
if (entry.getValue().toString().contains("SUCCESS")) {
|
||||
score += 3;
|
||||
}
|
||||
}
|
||||
|
||||
final Result ress = getResult(warnings2, errors2, score);
|
||||
|
||||
return new StandardResult(ress.score(), ress.status(), (List<String>) ress.warnings(), (List<String>) ress.errors(), ress.internalError());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Result getResult(ArrayList<String> warnings2, ArrayList<String> errors2, int score) {
|
||||
|
||||
return new Result() {
|
||||
@Override
|
||||
public int score() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status status() {
|
||||
return Status.valueOf((score > 0) ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> warnings() {
|
||||
return warnings2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> errors() {
|
||||
return errors2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String internalError() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
import eu.dnetlib.validator2.validation.guideline.*;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
|
||||
public final class I2_01M_LIT extends AbstractOpenAireProfile {
|
||||
|
||||
private static final ElementSpec I2_01M_LIT_SPEC_1 = Builders.
|
||||
forMandatoryElement("datacite:subject", ONE_TO_N).
|
||||
withOptionalAttribute("subjectScheme").
|
||||
withOptionalAttribute("schemeURI").
|
||||
withOptionalAttribute("valueURI").
|
||||
build();
|
||||
|
||||
private static final ElementSpec I2_01M_LIT_SPEC_2 = Builders.
|
||||
// forMandatoryElement("rights", ONE_TO_N).
|
||||
// withMandatoryAttribute("rightsURI").
|
||||
// build();
|
||||
forMandatoryIfApplicableElement("datacite:rights", ONE_TO_N, AbstractOpenAireProfile.elementIsPresent("rights")).
|
||||
atPosition(ElementPosition.FIRST).
|
||||
withMandatoryAttribute("uri").
|
||||
build();
|
||||
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 1.
|
||||
public static SyntheticGuideline I2_01M_LIT_1 = SyntheticGuideline.of("Subject", 5, I2_01M_LIT_SPEC_1);
|
||||
public static SyntheticGuideline I2_01M_LIT_2 = SyntheticGuideline.of("Rights", 5, I2_01M_LIT_SPEC_2);
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
I2_01M_LIT_1,
|
||||
I2_01M_LIT_2
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public I2_01M_LIT() {
|
||||
super("Metadata uses FAIR-compliant vocabularies");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() { return MAX_SCORE; }
|
||||
}
|
|
@ -19,9 +19,44 @@ public final class R1_01M extends AbstractOpenAireProfile {
|
|||
"Model", "PhysicalObject", "Service", "Software", "Sound", "Text", "Workflow", "Other"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_CONCEPT_URIS = {
|
||||
"http://purl.org/coar/resource_type/c_1162", "http://purl.org/coar/resource_type/c_6501",
|
||||
"http://purl.org/coar/resource_type/c_545b", "http://purl.org/coar/resource_type/c_b239",
|
||||
"http://purl.org/coar/resource_type/c_2df8fbb1", "http://purl.org/coar/resource_type/c_dcae04bc",
|
||||
"http://purl.org/coar/resource_type/c_beb9", "http://purl.org/coar/resource_type/c_3e5a",
|
||||
"http://purl.org/coar/resource_type/c_ba08", "http://purl.org/coar/resource_type/c_3248",
|
||||
"http://purl.org/coar/resource_type/c_2f33", "http://purl.org/coar/resource_type/c_86bc",
|
||||
"http://purl.org/coar/resource_type/c_816b", "http://purl.org/coar/resource_type/c_8042",
|
||||
"http://purl.org/coar/resource_type/c_71bd", "http://purl.org/coar/resource_type/c_18gh",
|
||||
"http://purl.org/coar/resource_type/c_18ws", "http://purl.org/coar/resource_type/c_18hj",
|
||||
"http://purl.org/coar/resource_type/c_18op", "http://purl.org/coar/resource_type/c_186u",
|
||||
"http://purl.org/coar/resource_type/c_18wq", "http://purl.org/coar/resource_type/c_18wz",
|
||||
"http://purl.org/coar/resource_type/c_18ww", "http://purl.org/coar/resource_type/c_efa0",
|
||||
"http://purl.org/coar/resource_type/c_baaf", "http://purl.org/coar/resource_type/c_ba1f",
|
||||
"http://purl.org/coar/resource_type/c_93fc", "http://purl.org/coar/resource_type/c_15cd",
|
||||
"http://purl.org/coar/resource_type/c_18co", "http://purl.org/coar/resource_type/c_18cp",
|
||||
"http://purl.org/coar/resource_type/c_6670", "http://purl.org/coar/resource_type/c_5794",
|
||||
"http://purl.org/coar/resource_type/c_c94f", "http://purl.org/coar/resource_type/c_f744",
|
||||
"http://purl.org/coar/resource_type/c_7a1f", "http://purl.org/coar/resource_type/c_bdcc",
|
||||
"http://purl.org/coar/resource_type/c_db06", "http://purl.org/coar/resource_type/c_46ec",
|
||||
"http://purl.org/coar/resource_type/c_0857", "http://purl.org/coar/resource_type/c_8544",
|
||||
"http://purl.org/coar/resource_type/c_18cf", "http://purl.org/coar/resource_type/c_18cw",
|
||||
"http://purl.org/coar/resource_type/c_18cd", "http://purl.org/coar/resource_type/c_18cc",
|
||||
"http://purl.org/coar/resource_type/c_12ce", "http://purl.org/coar/resource_type/c_8a7e",
|
||||
"http://purl.org/coar/resource_type/c_ecc8", "http://purl.org/coar/resource_type/c_c513",
|
||||
"http://purl.org/coar/resource_type/c_12cd", "http://purl.org/coar/resource_type/c_12cc",
|
||||
"http://purl.org/coar/resource_type/c_5ce6", "http://purl.org/coar/resource_type/c_ddb1",
|
||||
"http://purl.org/coar/resource_type/c_e9a0", "http://purl.org/coar/resource_type/c_7ad9",
|
||||
"http://purl.org/coar/resource_type/c_393c", "http://purl.org/coar/resource_type/c_1843"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_GENERAL_TYPES = {
|
||||
"literature", "dataset", "software", "other research product"
|
||||
};
|
||||
private static final ElementSpec R1_01M_SPEC_1 = Builders.
|
||||
forMandatoryElement("resourceType", ONE).
|
||||
withMandatoryAttribute("resourceTypeGeneral", RELATED_RESOURCE_GENERAL_TYPES).
|
||||
withMandatoryAttribute("resourceTypeGeneral", RESOURCE_GENERAL_TYPES).
|
||||
withMandatoryAttribute("uri", RESOURCE_CONCEPT_URIS).
|
||||
build();
|
||||
|
||||
private static final ElementSpec R1_01M_SPEC_2 = Builders.
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
import eu.dnetlib.validator2.validation.guideline.Builders;
|
||||
import eu.dnetlib.validator2.validation.guideline.ElementSpec;
|
||||
import eu.dnetlib.validator2.validation.guideline.Guideline;
|
||||
import eu.dnetlib.validator2.validation.guideline.SyntheticGuideline;
|
||||
import eu.dnetlib.validator2.validation.utils.MediaTypesValuePredicate;
|
||||
import eu.dnetlib.validator2.validation.utils.RegexValuePredicate;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE;
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
import static eu.dnetlib.validator2.validation.utils.SupportedRegExs.COMPILED_BCP47_LANG_TAGS_REG_EX;
|
||||
|
||||
public final class R1_01M_LIT extends AbstractOpenAireProfile {
|
||||
|
||||
private static final String[] RELATED_RESOURCE_GENERAL_TYPES = {
|
||||
"Audiovisual", "Collection", "DataPaper", "Dataset", "Event", "Image", "InteractiveResource",
|
||||
"Model", "PhysicalObject", "Service", "Software", "Sound", "Text", "Workflow", "Other"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_CONCEPT_URIS = {
|
||||
"http://purl.org/coar/resource_type/c_1162", "http://purl.org/coar/resource_type/c_6501",
|
||||
"http://purl.org/coar/resource_type/c_545b", "http://purl.org/coar/resource_type/c_b239",
|
||||
"http://purl.org/coar/resource_type/c_2df8fbb1", "http://purl.org/coar/resource_type/c_dcae04bc",
|
||||
"http://purl.org/coar/resource_type/c_beb9", "http://purl.org/coar/resource_type/c_3e5a",
|
||||
"http://purl.org/coar/resource_type/c_ba08", "http://purl.org/coar/resource_type/c_3248",
|
||||
"http://purl.org/coar/resource_type/c_2f33", "http://purl.org/coar/resource_type/c_86bc",
|
||||
"http://purl.org/coar/resource_type/c_816b", "http://purl.org/coar/resource_type/c_8042",
|
||||
"http://purl.org/coar/resource_type/c_71bd", "http://purl.org/coar/resource_type/c_18gh",
|
||||
"http://purl.org/coar/resource_type/c_18ws", "http://purl.org/coar/resource_type/c_18hj",
|
||||
"http://purl.org/coar/resource_type/c_18op", "http://purl.org/coar/resource_type/c_186u",
|
||||
"http://purl.org/coar/resource_type/c_18wq", "http://purl.org/coar/resource_type/c_18wz",
|
||||
"http://purl.org/coar/resource_type/c_18ww", "http://purl.org/coar/resource_type/c_efa0",
|
||||
"http://purl.org/coar/resource_type/c_baaf", "http://purl.org/coar/resource_type/c_ba1f",
|
||||
"http://purl.org/coar/resource_type/c_93fc", "http://purl.org/coar/resource_type/c_15cd",
|
||||
"http://purl.org/coar/resource_type/c_18co", "http://purl.org/coar/resource_type/c_18cp",
|
||||
"http://purl.org/coar/resource_type/c_6670", "http://purl.org/coar/resource_type/c_5794",
|
||||
"http://purl.org/coar/resource_type/c_c94f", "http://purl.org/coar/resource_type/c_f744",
|
||||
"http://purl.org/coar/resource_type/c_7a1f", "http://purl.org/coar/resource_type/c_bdcc",
|
||||
"http://purl.org/coar/resource_type/c_db06", "http://purl.org/coar/resource_type/c_46ec",
|
||||
"http://purl.org/coar/resource_type/c_0857", "http://purl.org/coar/resource_type/c_8544",
|
||||
"http://purl.org/coar/resource_type/c_18cf", "http://purl.org/coar/resource_type/c_18cw",
|
||||
"http://purl.org/coar/resource_type/c_18cd", "http://purl.org/coar/resource_type/c_18cc",
|
||||
"http://purl.org/coar/resource_type/c_12ce", "http://purl.org/coar/resource_type/c_8a7e",
|
||||
"http://purl.org/coar/resource_type/c_ecc8", "http://purl.org/coar/resource_type/c_c513",
|
||||
"http://purl.org/coar/resource_type/c_12cd", "http://purl.org/coar/resource_type/c_12cc",
|
||||
"http://purl.org/coar/resource_type/c_5ce6", "http://purl.org/coar/resource_type/c_ddb1",
|
||||
"http://purl.org/coar/resource_type/c_e9a0", "http://purl.org/coar/resource_type/c_7ad9",
|
||||
"http://purl.org/coar/resource_type/c_393c", "http://purl.org/coar/resource_type/c_1843"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_GENERAL_TYPES = {
|
||||
"literature", "dataset", "software", "other research product"
|
||||
};
|
||||
|
||||
private static final ElementSpec R1_01M_LIT_SPEC_1 = Builders.
|
||||
forMandatoryElement("oaire:resourceType", ONE).
|
||||
withMandatoryAttribute("resourceTypeGeneral", RESOURCE_GENERAL_TYPES).
|
||||
withMandatoryAttribute("uri", RESOURCE_CONCEPT_URIS).
|
||||
build();
|
||||
|
||||
private static final ElementSpec R1_01M_LIT_SPEC_2 = Builders.
|
||||
forMandatoryElement("format", ONE).
|
||||
allowedValues(new MediaTypesValuePredicate()).
|
||||
build();
|
||||
|
||||
// Method for data Not applicable in Literature
|
||||
// private static final ElementSpec R1_01M_LIT_SPEC_3 = Builders. // With very low weight
|
||||
// forMandatoryElement("dc:description", ONE_TO_N).
|
||||
// withOptionalAttribute("xml:lang", new RegexValuePredicate(COMPILED_BCP47_LANG_TAGS_REG_EX)).
|
||||
// build();
|
||||
|
||||
private static final ElementSpec R1_01M_LIT_SPEC_4 = Builders. // With very low weight
|
||||
forMandatoryElement("size", ONE_TO_N).
|
||||
build();
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 1.
|
||||
public static SyntheticGuideline R1_01M_LIT_1 = SyntheticGuideline.of("ResourceType", 3, R1_01M_LIT_SPEC_1);
|
||||
public static SyntheticGuideline R1_01M_LIT_2 = SyntheticGuideline.of("Format", 3, R1_01M_LIT_SPEC_2);
|
||||
// public static SyntheticGuideline R1_01M_LIT_3 = SyntheticGuideline.of("Description", 3, R1_01M_SPEC_3);
|
||||
public static SyntheticGuideline R1_01M_LIT_4 = SyntheticGuideline.of("Size", 3, R1_01M_LIT_SPEC_4);
|
||||
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
R1_01M_LIT_1,
|
||||
R1_01M_LIT_2,
|
||||
// R1_01M_LIT_3,
|
||||
R1_01M_LIT_4
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public R1_01M_LIT() {
|
||||
super("Plurality of accurate and relevant attributes are provided to allow reuse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() {
|
||||
return MAX_SCORE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package eu.dnetlib.validator2.validation.guideline.openaire;
|
||||
|
||||
import eu.dnetlib.validator2.engine.Rule;
|
||||
import eu.dnetlib.validator2.engine.builtins.XMLVocabularyRule;
|
||||
import eu.dnetlib.validator2.validation.guideline.Builders;
|
||||
import eu.dnetlib.validator2.validation.guideline.ElementSpec;
|
||||
import eu.dnetlib.validator2.validation.guideline.Guideline;
|
||||
import eu.dnetlib.validator2.validation.guideline.SyntheticGuideline;
|
||||
import eu.dnetlib.validator2.validation.utils.RegexValuePredicate;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE;
|
||||
import static eu.dnetlib.validator2.validation.guideline.Cardinality.ONE_TO_N;
|
||||
import static eu.dnetlib.validator2.validation.utils.SupportedRegExs.*;
|
||||
|
||||
public final class R1_2_01M_LIT extends AbstractOpenAireProfile {
|
||||
|
||||
private static final String[] NAME_IDENTIFIER_SCHEMES = {
|
||||
"ORCID", "ISNI", "ROR", "GRID"
|
||||
};
|
||||
|
||||
private static final String[] CONTRIBUTOR_TYPES = {
|
||||
"ContactPerson", "DataCollector", "DataCurator", "DataManager", "Distributor",
|
||||
"Editor", "HostingInstitution", "Producer", "ProjectLeader", "ProjectManager", "ProjectMember",
|
||||
"RegistrationAgency", "RegistrationAuthority", "RelatedPerson", "Researcher", "ResearchGroup",
|
||||
"RightsHolder", "Sponsor", "Supervisor", "WorkPackageLeader", "Other"
|
||||
};
|
||||
|
||||
private static final String[] PUBLICATION_DATE_TYPE = {
|
||||
"Issued"
|
||||
};
|
||||
|
||||
private static final String[] CONTRIBUTOR_NAME_IDENTIFIER_TYPES = {
|
||||
"Funder", "FundingProgramme", "ProjectID", "Jurisdiction", "ProjectName", "ProjectAcronym"
|
||||
};
|
||||
|
||||
private static final String[] IDENTIFIER_TYPES = {
|
||||
"ARK", "arXiv", "bibcode", "DOI", "EAN13", "EISSN", "Handle", "IGSN", "ISBN",
|
||||
"ISSN", "ISTC", "LISSN", "LSID", "PISSN", "PMID", "PURL", "UPC", "URL", "URN", "WOS",
|
||||
};
|
||||
|
||||
private static final String[] RELATION_TYPES_LIMITED = {
|
||||
"IsSupplementTo", "Describes", "IsMetadataFor", "IsPartOf"
|
||||
};
|
||||
|
||||
private static final String[] NAME_TYPES = {
|
||||
"Organizational", "Personal"
|
||||
};
|
||||
|
||||
private static final String[] RESOURCE_VERSION_URIS = {
|
||||
"http://purl.org/coar/version/c_b1a7d7d4d402bcce", "http://purl.org/coar/version/c_71e4c1898caa6e32",
|
||||
"http://purl.org/coar/version/c_ab4af688f83e57aa", "http://purl.org/coar/version/c_fa2ee174bc00049f",
|
||||
"http://purl.org/coar/version/c_970fb48d4fbd8a85", "http://purl.org/coar/version/c_e19f295774971610",
|
||||
"http://purl.org/coar/version/c_dc82b40f9837b551", "http://purl.org/coar/version/c_be7fb7dd8ff6fe43"
|
||||
};
|
||||
private static final String[] RELATION_TYPES = {
|
||||
"IsCitedBy", "Cites", "IsSupplementTo", "IsSupplementedBy", "IsContinuedBy",
|
||||
"Continues", "IsDescribedBy", "Describes", "HasMetadata", "IsMetadataFor", "HasVersion",
|
||||
"IsVersionOf", "IsNewVersionOf", "IsPreviousVersionOf", "IsPartOf", "HasPart", "IsReferencedBy",
|
||||
"References", "IsDocumentedBy", "Documents", "IsCompiledBy", "Compiles", "IsVariantFormOf",
|
||||
"IsOriginalFormOf", "IsIdenticalTo", "IsReviewedBy", "Reviews", "IsDerivedFrom", "IsSourceOf",
|
||||
"IsRequiredBy", "Requires"
|
||||
};
|
||||
private static final String[] RESOURCE_VERSION_LABELS = {
|
||||
"AO", "SMUR", "AM", "P", "VoR", "CVoR", "EVoR", "NA"
|
||||
};
|
||||
private static final String[] RELATED_RESOURCE_GENERAL_TYPES = {
|
||||
"Audiovisual", "Collection", "DataPaper", "Dataset", "Event", "Image", "InteractiveResource",
|
||||
"Model", "PhysicalObject", "Service", "Software", "Sound", "Text", "Workflow", "Other"
|
||||
};
|
||||
|
||||
private static final ElementSpec R1_2_01M_LIT_SPEC_1 = Builders.
|
||||
forMandatoryElement("datacite:creator", ONE_TO_N).
|
||||
withSubElement(Builders.
|
||||
forMandatoryElement("datacite:creatorName", ONE).
|
||||
withRecommendedAttribute("nameType", NAME_TYPES)).
|
||||
withSubElement(Builders.
|
||||
forRecommendedElement("datacite:givenName")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedElement("datacite:familyName")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedRepeatableElement("datacite:nameIdentifier").
|
||||
withMandatoryAttribute("nameIdentifierScheme").
|
||||
withRecommendedAttribute("schemeURI")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedRepeatableElement("datacite:affiliation")).
|
||||
build();
|
||||
|
||||
private static final ElementSpec R1_2_01M_LIT_SPEC_2 = Builders.
|
||||
forMandatoryElement("datacite:contributor", ONE_TO_N).
|
||||
withMandatoryAttribute("contributorType", CONTRIBUTOR_TYPES).
|
||||
withSubElement(Builders.
|
||||
forMandatoryElement("datacite:contributorName", ONE).
|
||||
withRecommendedAttribute("nameType", NAME_TYPES)).
|
||||
withSubElement(Builders.
|
||||
forOptionalElement("datacite:familyName")).
|
||||
withSubElement(Builders.
|
||||
forOptionalElement("datacite:givenName")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedRepeatableElement("datacite:nameIdentifier").
|
||||
withMandatoryAttribute("nameIdentifierScheme").
|
||||
withRecommendedAttribute("schemeURI")).
|
||||
withSubElement(Builders.
|
||||
forRecommendedRepeatableElement("datacite:affiliation")).
|
||||
build();
|
||||
|
||||
|
||||
private static final ElementSpec R1_2_01M_LIT_SPEC_3 = Builders.
|
||||
forMandatoryElement("datacite:date", ONE).
|
||||
withMandatoryAttribute("dateType", PUBLICATION_DATE_TYPE).
|
||||
allowedValues(new RegexValuePredicate(COMPILED_PUBLICATION_DATE_REG_EX).or(new RegexValuePredicate(COMPILED_YYYY_MM_DD_RANGE_REGEX).or(new RegexValuePredicate(COMPILED_YEAR_YYYY_REG_EX)))).
|
||||
build();
|
||||
|
||||
private static final ElementSpec R1_2_01M_LIT_SPEC_4 = Builders.
|
||||
forMandatoryElement("oaire:version", ONE).
|
||||
withMandatoryIfApplicableAttribute("uri", applicabilityRuleForURIAttributeOfResourceVersion(), RESOURCE_VERSION_URIS).
|
||||
build();
|
||||
|
||||
private static final ElementSpec R1_2_01M_LIT_SPEC_5 = Builders.
|
||||
forMandatoryElement("relatedIdentifier", ONE_TO_N).
|
||||
withMandatoryAttribute("relatedIdentifierType", IDENTIFIER_TYPES).
|
||||
withMandatoryAttribute("relationType", RELATION_TYPES).
|
||||
withOptionalAttribute("relatedMetadataScheme").
|
||||
withOptionalAttribute("schemeURI").
|
||||
withOptionalAttribute("schemeType").
|
||||
withOptionalAttribute("resourceTypeGeneral", RELATED_RESOURCE_GENERAL_TYPES).
|
||||
build();
|
||||
|
||||
private static Rule<Document> applicabilityRuleForURIAttributeOfResourceVersion() {
|
||||
return XMLVocabularyRule.builder().
|
||||
setId(ElementSpec.APPLICABILITY_RULE_ID).
|
||||
setXPathExpression("//*[name()='oaire:version']/text()").
|
||||
setNodeListAction("1").
|
||||
setVocabularyTermsAndTermsType(String.join(", ", RESOURCE_VERSION_LABELS), "whitelist").
|
||||
build();
|
||||
}
|
||||
|
||||
//TODO: weights for guidelines haven't been finalized. They've been given an arbitrary value of 1.
|
||||
public static SyntheticGuideline R1_2_01M_LIT_1 = SyntheticGuideline.of("Creator", 2, R1_2_01M_LIT_SPEC_1);
|
||||
public static SyntheticGuideline R1_2_01M_LIT_2 = SyntheticGuideline.of("Contributor", 2, R1_2_01M_LIT_SPEC_2);
|
||||
public static SyntheticGuideline R1_2_01M_LIT_3 = SyntheticGuideline.of("Date", 2, R1_2_01M_LIT_SPEC_3);
|
||||
public static SyntheticGuideline R1_2_01M_LIT_4 = SyntheticGuideline.of("Version", 2, R1_2_01M_LIT_SPEC_4);
|
||||
public static SyntheticGuideline R1_2_01M_LIT_5 = SyntheticGuideline.of("RelatedIdentifier", 2, R1_2_01M_LIT_SPEC_5);
|
||||
|
||||
private static final List<Guideline<Document>> GUIDELINES = Collections.unmodifiableList(
|
||||
Arrays.asList(
|
||||
R1_2_01M_LIT_1,
|
||||
R1_2_01M_LIT_2,
|
||||
R1_2_01M_LIT_3,
|
||||
R1_2_01M_LIT_4,
|
||||
R1_2_01M_LIT_5
|
||||
)
|
||||
);
|
||||
|
||||
private static final Map<String, Guideline> GUIDELINE_MAP = GUIDELINES.
|
||||
stream().
|
||||
collect(Collectors.toMap(Guideline::getName, (guideline) -> guideline));
|
||||
|
||||
private static final int MAX_SCORE = GUIDELINES.stream().map(Guideline::getWeight).reduce(0, Integer::sum);
|
||||
|
||||
public R1_2_01M_LIT() {
|
||||
super("Metadata includes provenance information according to a cross-community language");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends Guideline<Document>> guidelines() {
|
||||
return GUIDELINES;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param guidelineName
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Guideline guideline(String guidelineName) {
|
||||
return GUIDELINE_MAP.get(guidelineName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxScore() {
|
||||
return MAX_SCORE;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@ package eu.dnetlib.validator2.engine;
|
|||
|
||||
import eu.dnetlib.validator2.validation.XMLApplicationProfile;
|
||||
import eu.dnetlib.validator2.validation.guideline.Guideline;
|
||||
import eu.dnetlib.validator2.validation.guideline.openaire.FAIR_Literature_GuidelinesProfile;
|
||||
import eu.dnetlib.validator2.validation.guideline.openaire.FAIR_Literature_GuidelinesV4Profile;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
|
@ -19,18 +19,19 @@ public class Test_FAIR_LIT {
|
|||
|
||||
|
||||
private static final String[] FILES = new String[]{
|
||||
"src/test/resources/openaireguidelinesV3/dia.library.tuc.gr/Record_21811.xml",
|
||||
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml",
|
||||
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/01_data.xml",
|
||||
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/02_data.xml",
|
||||
"src/test/resources/openaireguidelinesV3/cris.vtt.fi/04_data.xml",
|
||||
// "src/test/resources/openaireguidelinesV3/dia.library.tuc.gr/Record_21811.xml",
|
||||
// "src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml",
|
||||
// "src/test/resources/openaireguidelinesV3/cris.vtt.fi/01_data.xml",
|
||||
// "src/test/resources/openaireguidelinesV3/cris.vtt.fi/02_data.xml",
|
||||
// "src/test/resources/openaireguidelinesV3/cris.vtt.fi/04_data.xml",
|
||||
// "src/test/resources/openaireguidelinesV3/cris.vtt.fi/03_data.xml",
|
||||
// "src/test/resources/openaireguidelinesV4/01_gv4.xml"
|
||||
// "src/test/resources/openaireguidelinesV4/01_gv4.xml",
|
||||
"src/test/resources/openaireguidelinesV4/v4_literature_all_guidelines_record.xml"
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String xmlFile = args[0];
|
||||
FAIR_Literature_GuidelinesProfile profile = new FAIR_Literature_GuidelinesProfile();
|
||||
FAIR_Literature_GuidelinesV4Profile profile = new FAIR_Literature_GuidelinesV4Profile();
|
||||
logger.info("Max score: " + profile.maxScore());
|
||||
Map<String, Double> scorePerDoc = new LinkedHashMap<>();
|
||||
DocumentBuilder builder = TestUtils.getDocumentBuilder();
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package eu.dnetlib.validator2.engine;
|
||||
|
||||
import eu.dnetlib.validator2.validation.XMLApplicationProfile;
|
||||
import eu.dnetlib.validator2.validation.guideline.Guideline;
|
||||
import eu.dnetlib.validator2.validation.guideline.openaire.AbstractOpenAireProfile;
|
||||
import eu.dnetlib.validator2.validation.guideline.openaire.DataArchiveGuidelinesV2Profile;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test_v2_data {
|
||||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Test_v2_data.class);
|
||||
|
||||
|
||||
private static final String[] FILES = new String[] {
|
||||
// "src/test/resources/openaireguidelinesV4/v4_literature_all_invalid_guidelines_record.xml",
|
||||
"src/test/resources/openaireguidelinesV4/v4_literature_all_guidelines_record.xml",
|
||||
// "src/test/resources/openaireguidelinesV4/oai_mediarep_org_doc_2534.xml",
|
||||
// "src/test/resources/openaireguidelinesV4/01_gv4.xml"
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String xmlFile = args[0];
|
||||
AbstractOpenAireProfile profile = new DataArchiveGuidelinesV2Profile();
|
||||
logger.info("Max score: " + profile.maxScore());
|
||||
Map<String, Double> scorePerDoc = new LinkedHashMap<>();
|
||||
DocumentBuilder builder = TestUtils.getDocumentBuilder();
|
||||
if ( builder == null )
|
||||
return;
|
||||
for ( String fileName : FILES ) {
|
||||
try {
|
||||
logger.info("Processing \"" + fileName + "\"");
|
||||
Document doc = builder.parse(new File(fileName));
|
||||
XMLApplicationProfile.ValidationResult result = profile.validate(fileName, doc);
|
||||
scorePerDoc.put(fileName, result.score());
|
||||
Map<String, Guideline.Result> results = result.results();
|
||||
for ( Map.Entry<String, Guideline.Result> entry : results.entrySet() ) {
|
||||
String key = entry.getKey();
|
||||
Guideline.Result value = entry.getValue();
|
||||
logger.debug(key + " = " + value);
|
||||
if ( key.contains("Date")) {
|
||||
logger.info("Warnings: " + results.get(key).warnings().toString());
|
||||
logger.info("Errors: " + results.get(key).errors().toString());
|
||||
logger.info("Result: " + key + " = " + value + "\n");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Individual scores
|
||||
String printout = scorePerDoc.entrySet().stream().
|
||||
map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
|
||||
|
||||
logger.info(printout);
|
||||
|
||||
// Average Score
|
||||
OptionalDouble optionalFinalScore = scorePerDoc.values().stream().mapToDouble(aDouble -> aDouble).average();
|
||||
double finalScore = (optionalFinalScore.isPresent() ? optionalFinalScore.getAsDouble() : -1 );
|
||||
|
||||
logger.info("Validation Score: " + finalScore);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue