Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,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, "<field name=\"value\">cs</field>"));
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, "<field name=\"value\">English; Czech</field>"));
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), "<field name=\"value\">ces</field>", ""), ENG_CODE, ""));
assertThat(result, is(ccmm().withXPath(
"count(//ccmm:dataset/ccmm:primary_language | //ccmm:dataset/ccmm:other_language)", equalTo("0"))));
}

@Test
Expand Down Expand Up @@ -1119,13 +1153,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"))));
}

Expand Down Expand Up @@ -1716,14 +1750,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
Expand Down Expand Up @@ -1909,6 +1955,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 = "<field name=\"value\">eng</field>";
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 {
Expand Down
2 changes: 2 additions & 0 deletions dspace/config/clarin-dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#------------------------------------------------------------------#
dspace.shortname = DSpace
dspace.name = CLARIN DSpace
# Prefix of the version string at the REST root (UI <meta name="Generator">), see dspace.cfg
dspace.version.prefix = CLARIN-DSpace

#------------------------------------------------------------------#
#---------------------------UPLOAD FILE----------------------------#
Expand Down
38 changes: 25 additions & 13 deletions dspace/config/crosswalks/oai/metadataFormats/ccmm.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
<!--
Language codes. LINDAT stores ISO 639-3, but stock DSpace stores 639-1 with an optional
region subtag ("en", "en_US", "de-DE"), so the subtag is stripped and the two-letter code
mapped to 639-3 before the EU register IRI is built. Document order is preserved - the
first code is the primary language - and duplicates are removed without reordering.
mapped to 639-3 before the EU register IRI is built. Document order is preserved and
duplicates are removed without reordering.
-->
<xsl:variable name="iso1to3">
<c k="ab">abk</c><c k="af">afr</c><c k="am">amh</c><c k="ar">ara</c><c k="as">asm</c><c k="az">aze</c>
Expand Down Expand Up @@ -190,6 +190,12 @@
else ())"/>
<xsl:variable name="languageCodes"
select="for $i in 1 to count($langAll) return $langAll[$i][not(. = $langAll[position() &lt; $i])]"/>
<!--
dc.language.iso has no order of importance, so only an item with exactly one language has a
primary language. A value that maps to no code may still be a second language, so it counts.
-->
<xsl:variable name="singleLanguage"
select="count($languageCodes) = 1 and count($langAll) = count($languageRaw[normalize-space()])"/>
<!--
local.additional.metadata is one blob of "Label (field_key):value" lines carried over from
the old Drupal catalogue. Splitting on the FIRST colon is safe: every key ends in ':' and
Expand Down Expand Up @@ -1111,8 +1117,7 @@
concepts; they are emitted unchanged rather than silently remapped (APC is a
broadening of AJP, and HBS has no single successor).
-->
<xsl:variable name="langCode" select="$languageCodes[1]"/>
<xsl:if test="$langCode">
<xsl:if test="$singleLanguage">
<!--
The register IRI alone: the scope note asks for "language label and/or its
3-letter code from" the register, and CCMM's own dataset-mini sample writes
Expand All @@ -1122,7 +1127,7 @@
asserting a label the register does not use.
-->
<ccmm:primary_language>
<ccmm:iri><xsl:value-of select="concat('http://publications.europa.eu/resource/authority/language/', upper-case($langCode))"/></ccmm:iri>
<ccmm:iri><xsl:value-of select="concat('http://publications.europa.eu/resource/authority/language/', upper-case($languageCodes[1]))"/></ccmm:iri>
</ccmm:primary_language>
</xsl:if>
</xsl:template>
Expand All @@ -1131,13 +1136,14 @@
<!-- other_language (optional) -->
<!-- ============================================================ -->
<xsl:template name="OtherLanguages">
<!-- every remaining code, in document order, so the positional name list stays aligned -->
<xsl:for-each select="2 to count($languageCodes)">
<xsl:variable name="i" select="."/>
<ccmm:other_language>
<ccmm:iri><xsl:value-of select="concat('http://publications.europa.eu/resource/authority/language/', upper-case($languageCodes[$i]))"/></ccmm:iri>
</ccmm:other_language>
</xsl:for-each>
<!-- every code, in document order, unless the item's only language is primary_language -->
<xsl:if test="not($singleLanguage)">
<xsl:for-each select="$languageCodes">
<ccmm:other_language>
<ccmm:iri><xsl:value-of select="concat('http://publications.europa.eu/resource/authority/language/', upper-case(.))"/></ccmm:iri>
</ccmm:other_language>
</xsl:for-each>
</xsl:if>
</xsl:template>

<!-- ============================================================ -->
Expand Down Expand Up @@ -1809,15 +1815,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.
-->
<xsl:variable name="perIri" as="element()*">
<xsl:for-each-group select="$deduped/*[not(ccmm:iri = $distributionIris)]" group-by="if (ccmm:iri) then string(ccmm:iri) else generate-id()">
<xsl:variable name="best" select="min(for $r in current-group() return cw:relationRank($r))"/>
<xsl:for-each-group select="current-group()[cw:relationRank(.) = $best]"
group-by="string(ccmm:resource_relation_type/ccmm:iri)">
<xsl:variable name="nth" select="position()"/>
<xsl:for-each select="current-group()[1]">
<!-- without the cw:assumed mark and its namespace, on every level -->
<xsl:copy copy-namespaces="no"><xsl:copy-of select="node()" copy-namespaces="no"/></xsl:copy>
<xsl:copy copy-namespaces="no">
<xsl:copy-of select="node()[not($nth &gt; 1 and self::ccmm:iri)]" copy-namespaces="no"/>
</xsl:copy>
</xsl:for-each>
</xsl:for-each-group>
</xsl:for-each-group>
Expand Down
1 change: 0 additions & 1 deletion dspace/config/crosswalks/oai/xoai.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
<Set ref="openaireDataSet"/>
<Format ref="oaidc"/>
<Format ref="oai_datacite"/>
<Format ref="ccmm"/>
<Description>
This context exports items following the openaire data archive rules.
</Description>
Expand Down
7 changes: 3 additions & 4 deletions dspace/config/dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 <meta name="Generator"> 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 <meta name="Generator"> 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.
Expand Down
Loading