![](/img/trans.png)
[英]Getting a modified version of ItemRequestForm.java to work in DSpace version 6x
[英]Getting other metadata in ItemRequestForm in DSpace 6x
單擊 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);
6版好像沒有item.getMetadata
,我的問題是怎么翻譯5x版的代碼
Metadatum[] citationDC = item.getMetadata("dc", "identifier", "citation", Item.ANY);
進入第 6 版?
環顧 DSpace 6x 代碼,我設法讓其他元數據顯示(例如dc.identifier.citation )而不是ItemRequestForm.java
中的項目標題。 添加導入import org.dspace.content.service.ItemService;
private final transient ItemService itemService
= ContentServiceFactory.getInstance().getItemService();
顯示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);
我添加了一個測試作為備用,以防dc.identifier.citation不存在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.