[英]Getting other metadata in ItemRequestForm in DSpace 6x
Clicking a restricted bitstream in DSpace will display a request form.单击 DSpace 中的受限比特流将显示请求表单。 The form displays the title of the item by default.
表单默认显示项目的标题。 In version 5x, I managed to get to display other metadata instead of title (eg citation).
在版本 5x 中,我设法显示其他元数据而不是标题(例如引文)。
The code I used to display:我用来显示的代码:
Metadatum[] titleDC = item.getMetadata("dc", "title", null, Item.ANY);
Metadatum[] citationDC = item.getMetadata("dc", "identifier", "citation", Item.ANY);
String document = "";
if (citationDC != null && citationDC.length > 0) {
document = citationDC[0].value;
} else {
if (titleDC != null && titleDC.length > 0)
document = titleDC[0].value;
}
itemRequest.addPara(document);
I cannot use this code in version 6x because of major changes in the source code.由于源代码的重大更改,我无法在版本 6x 中使用此代码。 Below is the default code in DSpace 6x to display the item's title:
以下是 DSpace 6x 中显示项目标题的默认代码:
String titleDC = item.getName();
if (titleDC != null && titleDC.length() > 0)
itemRequest.addPara(titleDC);
It seems there is no item.getMetadata
in version 6. My question is how to translate the version 5x code 6版好像没有
item.getMetadata
,我的问题是怎么翻译5x版的代码
Metadatum[] citationDC = item.getMetadata("dc", "identifier", "citation", Item.ANY);
into version 6?进入第 6 版?
Looking around in the DSpace 6x code, I managed to get other metadata to display (eg dc.identifier.citation ) instead of item title in ItemRequestForm.java
.环顾 DSpace 6x 代码,我设法让其他元数据显示(例如dc.identifier.citation )而不是
ItemRequestForm.java
中的项目标题。 Add to import import org.dspace.content.service.ItemService;
添加导入
import org.dspace.content.service.ItemService;
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
To display dc.identifier.citation显示dc.identifier.citation
String citationDC = itemService.getMetadataFirstValue(item, "dc", "identifier", "citation", Item.ANY);
String titleDC = item.getName();
String document = "";
if (citationDC != null && citationDC.length() > 0) {
document = citationDC;
} else {
if (titleDC != null && titleDC.length() > 0)
document = titleDC;
}
itemRequest.addPara(document);
I added a test as a fallback in case dc.identifier.citation does not exist.我添加了一个测试作为备用,以防dc.identifier.citation不存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.