Skip to content

Commit 1503036

Browse files
authored
Metadata citation improvements (geonetwork#8607)
* Metadata citation improvements: - BibTex: change data entry type to misc (data seems not valid: https://en.wikipedia.org/wiki/BibTeX\#Entry_types). - RIS: add support for PY (publication year), DA (publication date) LA (language) fields. * Metadata citation improvements: add option to save the citation to a file
1 parent 695f619 commit 1503036

File tree

11 files changed

+115
-7
lines changed

11 files changed

+115
-7
lines changed

schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/formatter/citation/base.xsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
88
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
99
xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
10+
xmlns:lan="http://standards.iso.org/iso/19115/-3/lan/1.0"
1011
xmlns:xs="http://www.w3.org/2001/XMLSchema"
1112
xmlns:xlink="http://www.w3.org/1999/xlink"
1213
xmlns:gn-fn-iso19115-3.2018="http://geonetwork-opensource.org/xsl/functions/profiles/iso19115-3.2018"
@@ -92,6 +93,10 @@
9293
('publication', 'revision')]/
9394
cit:date/gco:*[. != '']"/>
9495

96+
97+
<xsl:variable name="datasetLanguage"
98+
select="$metadata/mdb:identificationInfo/*/mri:defaultLocale/*/lan:language/*/@codeListValue"/>
99+
95100
<xsl:variable name="publicationDates" as="node()*">
96101
<xsl:perform-sort select="$dates">
97102
<xsl:sort select="." order="descending"/>
@@ -163,6 +168,7 @@
163168
<doiUrl><xsl:value-of select="$doiUrl"/></doiUrl>
164169
<xsl:copy-of select="$translatedKeywords"/>
165170
<additionalCitation><xsl:value-of select="$additionalCitation"/></additionalCitation>
171+
<language><xsl:value-of select="$datasetLanguage" /></language>
166172
</citation>
167173

168174
</xsl:template>

schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/formatter/citation/common.xsl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
<xsl:template mode="citation" match="citation[lower-case($format) = 'bibtex']">
7373
<!-- https://en.wikipedia.org/wiki/BibTeX -->
74-
<textResponse>@data{<xsl:value-of select="uuid"/>,
74+
<textResponse>@misc{<xsl:value-of select="uuid"/>,
7575
author = {<xsl:value-of select="normalize-space(string-join(authorsNameAndOrgList/*, ', '))"/>},
7676
publisher = {<xsl:value-of select="normalize-space(string-join(publishersNameAndOrgList/*, ', '))"/>},
7777
title = {<xsl:value-of select="normalize-space(translatedTitle)"/>},
@@ -91,7 +91,10 @@
9191
<xsl:text>AU - </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>&#13;&#10;</xsl:text>
9292
</xsl:for-each>
9393
<xsl:text>TI - </xsl:text><xsl:value-of select="normalize-space(translatedTitle)"/><xsl:text>&#13;&#10;</xsl:text>
94-
<!-- TODO: LA, ET -->
94+
<!-- TODO: ET -->
95+
<xsl:if test="language != ''">
96+
<xsl:text>LA - </xsl:text><xsl:value-of select="language"/><xsl:text>&#13;&#10;</xsl:text>
97+
</xsl:if>
9598
<xsl:for-each select="publishersNameAndOrgList/*[. != '']">
9699
<xsl:text>PB - </xsl:text><xsl:value-of select="normalize-space(.)"/><xsl:text>&#13;&#10;</xsl:text>
97100
</xsl:for-each>
@@ -103,6 +106,10 @@
103106
<xsl:text>DO - </xsl:text><xsl:value-of select="doi"/><xsl:text>&#13;&#10;</xsl:text>
104107
</xsl:if>
105108
<xsl:text>ID - </xsl:text><xsl:value-of select="uuid"/><xsl:text>&#13;&#10;</xsl:text>
109+
<xsl:if test="lastPublicationDate != ''">
110+
<xsl:text>DA - </xsl:text><xsl:value-of select="concat(replace(substring(lastPublicationDate, 1, 12), '-', '/'), '/')" /><xsl:text>&#13;&#10;</xsl:text>
111+
<xsl:text>PY - </xsl:text><xsl:value-of select="substring(lastPublicationDate, 1, 4)" /><xsl:text>&#13;&#10;</xsl:text>
112+
</xsl:if>
106113
<xsl:text>ER -</xsl:text>
107114
</textResponse>
108115
</xsl:template>

schemas/iso19139/src/main/plugin/iso19139/formatter/citation/base.xsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
<xsl:variable name="langId"
6363
select="gn-fn-iso19139:getLangId($metadata, $language)"/>
6464

65+
<xsl:variable name="datasetLanguage"
66+
select="$metadata/gmd:identificationInfo/*/gmd:language/*/@codeListValue"/>
67+
6568
<xsl:variable name="authors"
6669
select="$metadata/gmd:identificationInfo/*/gmd:pointOfContact/
6770
*[gmd:role/*/@codeListValue = $authorRolesList]"/>
@@ -167,6 +170,7 @@
167170
<doiUrl><xsl:value-of select="$doiUrl"/></doiUrl>
168171
<xsl:copy-of select="$translatedKeywords"/>
169172
<additionalCitation><xsl:value-of select="$additionalCitation"/></additionalCitation>
173+
<language><xsl:value-of select="$datasetLanguage" /></language>
170174
</citation>
171175
</xsl:template>
172176
</xsl:stylesheet>

services/src/test/resources/org/fao/geonet/api/records/formatters/iso19115-3.2018-citation-bibtex.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@data{{uuid},
1+
@misc{{uuid},
22
author = {Production géomatique et traitement de données (SPW - Secrétariat général - SPW Digital - Département Données transversales - Production géomatique et traitement de données)},
33
publisher = {},
44
title = {Utilisation du Sol en Wallonie - WALOUS 2018},

services/src/test/resources/org/fao/geonet/api/records/formatters/iso19115-3.2018-citation-ris.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
TY - DATA
22
AU - Production géomatique et traitement de données (SPW - Secrétariat général - SPW Digital - Département Données transversales - Production géomatique et traitement de données)
33
TI - Utilisation du Sol en Wallonie - WALOUS 2018
4+
LA - fre
45
KW - Données de base
56
KW - Nature et environnement
67
KW - Aménagement du territoire
@@ -20,4 +21,6 @@ KW - UTS
2021
KW - COSW
2122
UR - http://localhost:8080/srv/api/records/{uuid}
2223
ID - {uuid}
24+
DA - 2020/10/30/
25+
PY - 2020
2326
ER -

services/src/test/resources/org/fao/geonet/api/records/formatters/iso19139-citation-bibtex.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@data{{uuid},
1+
@misc{{uuid},
22
author = {},
33
publisher = {},
44
title = {CORINE Land Cover Change 2012-2018 (vector), Europe, 6-yearly - version 2020_20u1, May 2020},

services/src/test/resources/org/fao/geonet/api/records/formatters/iso19139-citation-ris.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
TY - DATA
22
TI - CORINE Land Cover Change 2012-2018 (vector), Europe, 6-yearly - version 2020_20u1, May 2020
3+
LA - eng
34
KW - Land cover
45
KW - EEA39
56
KW - landscape
@@ -14,4 +15,6 @@ KW - Water
1415
UR - https://doi.org/10.2909/f30f1000-7cf8-43bb-872c-5eb093911b24
1516
DO - 10.2909/f30f1000-7cf8-43bb-872c-5eb093911b24
1617
ID - {uuid}
18+
DA - 2020/05/13/
19+
PY - 2020
1720
ER -

web-ui/src/main/resources/catalog/components/metadataactions/MetadataActionsDirective.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,23 @@
632632
return "../api/records/" + scope.md.uuid + "/formatters/citation?format=";
633633
}
634634

635+
var getCitationFormatExtension = function (format) {
636+
if (format === "text") {
637+
return "txt";
638+
} else {
639+
return format ? format : "txt";
640+
}
641+
};
642+
643+
scope.getCitationFilename = function () {
644+
return (
645+
"citation-" +
646+
scope.md.uuid +
647+
"." +
648+
getCitationFormatExtension(scope.currentFormat)
649+
);
650+
};
651+
635652
scope.getCitation = function (format) {
636653
return $http
637654
.get(buildUrl() + format, {

web-ui/src/main/resources/catalog/components/metadataactions/partials/citation.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ <h2>
1414
</h2>
1515
</div>
1616
<div>
17+
<div
18+
class="gn-copy-to-clipboard-button-floatright gn-margin-left-sm"
19+
gn-save-text-button=""
20+
data-file-name="{{ getCitationFilename() }}"
21+
></div>
22+
1723
<div
1824
class="gn-copy-to-clipboard-button-floatright"
1925
gn-copy-to-clipboard-button=""

web-ui/src/main/resources/catalog/components/utility/UtilityDirective.js

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,12 @@
11941194
*
11951195
* The code to be used in a HTML page:
11961196
*
1197-
* <span gn-copy-to-clipboard=""></span>
1197+
* <span gn-copy-to-clipboard-button=""></span>
11981198
* eg. for citation
11991199
*
12001200
* or
12011201
*
1202-
* <span gn-copy-to-clipboard="" data-text="{{::r.locUrl}}" gn-copy-button-only="true"></span>
1202+
* <span gn-copy-to-clipboard-button="" data-text="{{::r.locUrl}}" gn-copy-button-only="true"></span>
12031203
* eg. copy UUID or link URL
12041204
*
12051205
* or
@@ -1261,6 +1261,67 @@
12611261
}
12621262
]);
12631263

1264+
/*
1265+
* @description
1266+
* Save a file with a string in an input field, the parent element text
1267+
* or the results of a promise.
1268+
*
1269+
* The code to be used in a HTML page:
1270+
*
1271+
* <span gn-save-text-button="" data-file-name="citation.txt"></span>
1272+
* eg. for citation
1273+
*
1274+
* <span gn-save-text-button="" data-text="{{::r.locUrl}}"></span>
1275+
* eg. save UUID or link URL
1276+
*
1277+
* or
1278+
*
1279+
* <button gn-save-text-button="" get-text-fn="getListOfUuids()"/>
1280+
* eg. UUID of record with indexing errors
1281+
*/
1282+
module.directive("gnSaveTextButton", [
1283+
"$q",
1284+
function ($q) {
1285+
return {
1286+
restrict: "A",
1287+
replace: true,
1288+
template:
1289+
"<a class=\"{{::btnClass || 'btn btn-default btn-xs'}}\" " +
1290+
' ng-click="save()" ' +
1291+
' href=""' +
1292+
' title="{{::title | translate}}">' +
1293+
' <i class="fa fa-download"></i>' +
1294+
"</a>",
1295+
scope: {
1296+
btnClass: "@",
1297+
getTextFn: "&?",
1298+
fileName: "@"
1299+
},
1300+
link: function linkFn(scope, element, attr) {
1301+
scope.title = attr["tooltip"] || "saveToFile";
1302+
scope.fileName = scope.fileName || "file.txt";
1303+
scope.save = function () {
1304+
var promise = undefined;
1305+
1306+
if (angular.isFunction(scope.getTextFn)) {
1307+
promise = scope.getTextFn();
1308+
} else {
1309+
promise = $q.when(
1310+
attr["text"] ? attr["text"] : element.parent().text().trim()
1311+
);
1312+
}
1313+
1314+
promise.then(function (text) {
1315+
var blob = new Blob([text], { type: "text/plain;charset=utf-8" });
1316+
// Bootstrap FileSaver
1317+
saveAs(blob, scope.fileName);
1318+
});
1319+
};
1320+
}
1321+
};
1322+
}
1323+
]);
1324+
12641325
/**
12651326
* @ngdoc directive
12661327
* @name gn_utility.directive:gnMetadataPicker

0 commit comments

Comments
 (0)