diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/stylesheets/CcmmXslTest.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/stylesheets/CcmmXslTest.java index 9846726f36d..3c753c78b09 100644 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/stylesheets/CcmmXslTest.java +++ b/dspace-oai/src/test/java/org/dspace/xoai/tests/stylesheets/CcmmXslTest.java @@ -354,20 +354,54 @@ public void ccmmAnItemWithNoFilesIsMetadataOnlyNotRestricted() throws Exception public void ccmmContainsPrimaryLanguage() throws Exception { // CCMM: "Use IRI identifier from the register // http://publications.europa.eu/resource/authority/language" - String result = apply("ccmm.xsl").to(resource(MAIN)); + String result = ccmmOf(once(fixture(MAIN), ENG_CODE, "")); assertThat(result, is(ccmm().withXPath( - "//ccmm:dataset/ccmm:primary_language/ccmm:iri", - equalTo("http://publications.europa.eu/resource/authority/language/CES")))); + "//ccmm:dataset/ccmm:primary_language/ccmm:iri", equalTo(LANGUAGE + "CES")))); + assertThat(result, is(ccmm().withXPath("count(//ccmm:dataset/ccmm:other_language)", equalTo("0")))); + } + + @Test + public void ccmmSeveralLanguagesHaveNoPrimaryLanguage() throws Exception { + // dc.language.iso has no order of importance, so with several languages none is the primary one + String result = apply("ccmm.xsl").to(resource(MAIN)); + assertThat(result, is(ccmm().withXPath("count(//ccmm:dataset/ccmm:primary_language)", equalTo("0")))); } @Test public void ccmmOtherLanguageKeepsItsRegisterIri() throws Exception { - // document order is preserved and duplicates removed without reordering, so the second - // distinct code is the first other_language + // with several languages every one is an other_language, in document order String result = apply("ccmm.xsl").to(resource(MAIN)); + assertThat(result, is(ccmm().withXPath("count(//ccmm:dataset/ccmm:other_language)", equalTo("2")))); assertThat(result, is(ccmm().withXPath( - "//ccmm:dataset/ccmm:other_language/ccmm:iri", - equalTo("http://publications.europa.eu/resource/authority/language/ENG")))); + "(//ccmm:dataset/ccmm:other_language/ccmm:iri)[1]", equalTo(LANGUAGE + "CES")))); + assertThat(result, is(ccmm().withXPath( + "(//ccmm:dataset/ccmm:other_language/ccmm:iri)[2]", equalTo(LANGUAGE + "ENG")))); + } + + @Test + public void ccmmTheSameLanguageTwiceIsOnePrimaryLanguage() throws Exception { + // "cs" and "ces" are one language once mapped to ISO 639-3 + String result = ccmmOf(once(fixture(MAIN), ENG_CODE, "cs")); + assertThat(result, is(ccmm().withXPath( + "//ccmm:dataset/ccmm:primary_language/ccmm:iri", equalTo(LANGUAGE + "CES")))); + assertThat(result, is(ccmm().withXPath("count(//ccmm:dataset/ccmm:other_language)", equalTo("0")))); + } + + @Test + public void ccmmAValueWithoutACodeStillMeansSeveralLanguages() throws Exception { + // free text maps to no register code, but it can be another language, so CES is not primary + String result = ccmmOf(once(fixture(MAIN), ENG_CODE, "English; Czech")); + assertThat(result, is(ccmm().withXPath("count(//ccmm:dataset/ccmm:primary_language)", equalTo("0")))); + assertThat(result, is(ccmm().withXPath("count(//ccmm:dataset/ccmm:other_language)", equalTo("1")))); + assertThat(result, is(ccmm().withXPath( + "//ccmm:dataset/ccmm:other_language/ccmm:iri", equalTo(LANGUAGE + "CES")))); + } + + @Test + public void ccmmNoLanguageIsNeitherPrimaryNorOther() throws Exception { + String result = ccmmOf(once(once(fixture(MAIN), "ces", ""), ENG_CODE, "")); + assertThat(result, is(ccmm().withXPath( + "count(//ccmm:dataset/ccmm:primary_language | //ccmm:dataset/ccmm:other_language)", equalTo("0")))); } @Test @@ -1120,13 +1154,13 @@ public void ccmmMandatoryLicenceIsNeverAnEmptyElement() throws Exception { public void ccmmLanguageCarriesTheRegisterIriAndNoInventedLabel() throws Exception { // the scope note asks for the register's label "and/or" its code; DSpace's own string is // not the register's, so only the IRI is published - String result = apply("ccmm.xsl").to(resource(MAIN)); - assertThat(result, is(ccmm().withXPath( - "//ccmm:primary_language/ccmm:iri", - equalTo("http://publications.europa.eu/resource/authority/language/CES")))); - assertThat(result, is(ccmm().withXPath( + String single = ccmmOf(once(fixture(MAIN), ENG_CODE, "")); + assertThat(single, is(ccmm().withXPath("//ccmm:primary_language/ccmm:iri", equalTo(LANGUAGE + "CES")))); + assertThat(single, is(ccmm().withXPath( "count(//ccmm:primary_language/ccmm:label)", equalTo("0")))); - assertThat(result, is(ccmm().withXPath( + String several = apply("ccmm.xsl").to(resource(MAIN)); + assertThat(several, is(ccmm().withXPath("count(//ccmm:other_language/ccmm:iri)", equalTo("2")))); + assertThat(several, is(ccmm().withXPath( "count(//ccmm:other_language/ccmm:label)", equalTo("0")))); } @@ -1717,14 +1751,26 @@ public void ccmmTwoStatedRelationsToOneResourceAreBothPublished() throws Excepti // choosing one would be correcting the record String result = ccmmOf(add(fixture(MAIN), "dc", field("relation.isbasedon", "none", REPLACED))); assertThat(result, is(ccmm().withXPath( - "count(//ccmm:related_resource[ccmm:iri='" + REPLACED + "'])", equalTo("2")))); + "count(//ccmm:related_resource[ccmm:resource_url='" + REPLACED + "'])", equalTo("2")))); for (String type : new String[] {"Obsoletes", "IsDerivedFrom"}) { assertThat(type, result, is(ccmm().withXPath( - "count(//ccmm:related_resource[ccmm:iri='" + REPLACED + "']" + "count(//ccmm:related_resource[ccmm:resource_url='" + REPLACED + "']" + + "[ccmm:identifier/ccmm:value='123456789/1-1111']" + "[ccmm:resource_relation_type/ccmm:iri='" + RELATION + type + "'])", equalTo("1")))); } } + @Test + public void ccmmOnlyTheFirstOfTwoRelationsToOneResourceCarriesItsIri() throws Exception { + // CCMM identifies a related resource by its iri and allows it one relation type (SHACL + // sh:maxCount 1 on ccmm:hasType), so a second relation to the same resource has no iri. + // add() puts isbasedon before MAIN's own dc.relation element, so it is the first one. + String result = ccmmOf(add(fixture(MAIN), "dc", field("relation.isbasedon", "none", REPLACED))); + assertThat(result, is(ccmm().withXPath( + "count(//ccmm:related_resource[ccmm:iri='" + REPLACED + "'])", equalTo("1")))); + assertThat(result, is(ccmm().withXPath(relationTypeOf(REPLACED), equalTo(RELATION + "IsDerivedFrom")))); + } + @Test public void ccmmDemoUriThatIsAFeaturedServiceIsOnlyADistribution() throws Exception { // CCMM: distributions of the dataset SHALL NOT be modeled as related resource @@ -1910,6 +1956,9 @@ private static String relationTypeOf(String iri) { private static final String SOURCE_URI = "https://example.org/czech-nlp-dataset"; /** dc.relation.replaces of MAIN */ private static final String REPLACED = "http://hdl.handle.net/123456789/1-1111"; + /** the second of MAIN's two dc.language.iso codes */ + private static final String ENG_CODE = "eng"; + private static final String LANGUAGE = "http://publications.europa.eu/resource/authority/language/"; /** A fixture as text, to edit with {@link #once} or {@link #add} and transform with {@link #ccmmOf}. */ private String fixture(String name) throws Exception { diff --git a/dspace/config/clarin-dspace.cfg b/dspace/config/clarin-dspace.cfg index f6230a670b0..8e489ff6fa9 100644 --- a/dspace/config/clarin-dspace.cfg +++ b/dspace/config/clarin-dspace.cfg @@ -7,6 +7,8 @@ #------------------------------------------------------------------# dspace.shortname = DSpace dspace.name = CLARIN DSpace +# Prefix of the version string at the REST root (UI ), see dspace.cfg +dspace.version.prefix = CLARIN-DSpace #------------------------------------------------------------------# #---------------------------UPLOAD FILE----------------------------# diff --git a/dspace/config/crosswalks/oai/metadataFormats/ccmm.xsl b/dspace/config/crosswalks/oai/metadataFormats/ccmm.xsl index 2be6551d4a1..51f6abfe169 100644 --- a/dspace/config/crosswalks/oai/metadataFormats/ccmm.xsl +++ b/dspace/config/crosswalks/oai/metadataFormats/ccmm.xsl @@ -160,8 +160,8 @@ abkaframharaasmaze @@ -191,6 +191,12 @@ else ())"/> + + - - + - + @@ -1132,13 +1137,14 @@ - - - - - - - + + + + + + + + @@ -1810,15 +1816,21 @@ distributions (a featured service also given as the demo, a web service also given as the source) is not repeated as a related resource: CCMM says distributions SHALL NOT be modeled as related resources. + CCMM identifies a related resource by its iri and gives it one relation type (SHACL + sh:maxCount 1 on ccmm:hasType), so only the first relation to an IRI, in the record's + order, carries it; a further one is still identified by its resource_url. --> + - + + + diff --git a/dspace/config/crosswalks/oai/xoai.xml b/dspace/config/crosswalks/oai/xoai.xml index 033905d32d7..882881cf46a 100644 --- a/dspace/config/crosswalks/oai/xoai.xml +++ b/dspace/config/crosswalks/oai/xoai.xml @@ -103,7 +103,6 @@ - This context exports items following the openaire data archive rules. diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index e78ba5a041f..fd451d8650b 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -43,10 +43,9 @@ dspace.name = DSpace at My University dspace.shortname = DSpace # Prefix for the version string exposed at the REST root (/server/api), rendered by the UI as -# the HTML value. Falls back to "DSpace" when unset or blank. -# This branch is the UFAL/CLARIN base, so it ships the CLARIN identity by default. -# Non-CLARIN deployments must set this to "DSpace". -dspace.version.prefix = CLARIN-DSpace +# the HTML value. Falls back to "CLARIN-DSpace" when unset or blank. +# Set in clarin-dspace.cfg, which overrides this file; non-CLARIN deployments set +# dspace.version.prefix = DSpace in local.cfg. # Assetstore configurations have moved to config/modules/assetstore.cfg # and config/spring/api/bitstore.xml.