在DSpace中点击一个受限的位流会显示一个请求表单。该表单默认显示项目的标题。在 5x 版中,我设法让它显示其他元数据,而不是标题(例如引用)。
我用来显示的代码。
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);
在6x版中我不能使用这段代码,因为源代码有重大变化。下面是DSpace 6x中显示项目标题的默认代码。
String titleDC = item.getName();
if (titleDC != null && titleDC.length() > 0)
itemRequest.addPara(titleDC);
似乎没有 item.getMetadata
在第6版中,我的问题是如何翻译5x版的代码。我的问题是如何翻译5x版本的代码?
Metadatum[] citationDC = item.getMetadata("dc", "identifier", "citation", Item.ANY);
进入6版本?
在DSpace 6x的代码中,我设法让其他元数据显示(例如 dc.标识符.引文)而不是项目标题。ItemRequestForm.java
. 添加到进口 import org.dspace.content.service.ItemService;
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
要显示 dc.标识符.引文
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);
我添加了一个测试作为后备方案,以防 dc.标识符.引文 不存在。