mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Bibliographic external database feature on submission - DS-1252
This commit is contained in:

committed by
kstamatis

parent
fcfbd89229
commit
067b9ef79b
@@ -517,6 +517,18 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>backport-util-concurrent</groupId>
|
||||
<artifactId>backport-util-concurrent</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.flexjson</groupId>
|
||||
<artifactId>flexjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -0,0 +1,87 @@
|
||||
package org.dspace.submit.importer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImportResultBean
|
||||
{
|
||||
private boolean scheduled;
|
||||
|
||||
private int tot;
|
||||
|
||||
private int failure;
|
||||
|
||||
private int success;
|
||||
|
||||
private int warning;
|
||||
|
||||
private List<SingleImportResultBean> details;
|
||||
|
||||
public boolean isScheduled()
|
||||
{
|
||||
return scheduled;
|
||||
}
|
||||
|
||||
public void setScheduled(boolean scheduled)
|
||||
{
|
||||
this.scheduled = scheduled;
|
||||
}
|
||||
|
||||
public int getTot()
|
||||
{
|
||||
return tot;
|
||||
}
|
||||
|
||||
public void setTot(int tot)
|
||||
{
|
||||
this.tot = tot;
|
||||
}
|
||||
|
||||
public int getFailure()
|
||||
{
|
||||
return failure;
|
||||
}
|
||||
|
||||
public int getSuccess()
|
||||
{
|
||||
return success;
|
||||
}
|
||||
|
||||
public int getWarning()
|
||||
{
|
||||
return warning;
|
||||
}
|
||||
|
||||
public List<SingleImportResultBean> getDetails()
|
||||
{
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<SingleImportResultBean> details)
|
||||
{
|
||||
this.details = details;
|
||||
int success = 0;
|
||||
int failure = 0;
|
||||
int warning = 0;
|
||||
if (details != null)
|
||||
{
|
||||
for (SingleImportResultBean result : details)
|
||||
{
|
||||
switch (result.getStatus())
|
||||
{
|
||||
case SingleImportResultBean.ERROR:
|
||||
failure++;
|
||||
break;
|
||||
case SingleImportResultBean.WARNING:
|
||||
warning++;
|
||||
break;
|
||||
case SingleImportResultBean.SUCCESS:
|
||||
success++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.failure = failure;
|
||||
this.success = success;
|
||||
this.warning = warning;
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.dspace.submit.importer;
|
||||
|
||||
import org.dspace.eperson.EPerson;
|
||||
|
||||
public interface Importer
|
||||
{
|
||||
public ImportResultBean ingest(String data, EPerson eperson);
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package org.dspace.submit.importer;
|
||||
|
||||
public class ImporterException extends RuntimeException {
|
||||
|
||||
private int total;
|
||||
|
||||
private int limit;
|
||||
|
||||
private String pluginName;
|
||||
|
||||
public ImporterException(String cause, int tot, int limit, String pluginName) {
|
||||
super(cause);
|
||||
this.total = tot;
|
||||
this.limit = limit;
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
public void setPluginName(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package org.dspace.submit.importer;
|
||||
/*
|
||||
* Per ogni item che viene importato viene effettuato
|
||||
* il set del metadato dc.identifier.source e il nome
|
||||
* della classe istanziata.
|
||||
* Tutti gli _importer estendono questa classe.
|
||||
*/
|
||||
public interface ItemImport {
|
||||
|
||||
public void setSource(String source);
|
||||
|
||||
public String getSource();
|
||||
|
||||
public void setRecord(String record);
|
||||
|
||||
public String getRecord();
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package org.dspace.submit.importer;
|
||||
|
||||
public class SingleImportResultBean
|
||||
{
|
||||
public static final int ERROR = 2;
|
||||
|
||||
public static final int WARNING = 1;
|
||||
|
||||
public static final int SUCCESS = 0;
|
||||
|
||||
private int status;
|
||||
|
||||
private int witemId;
|
||||
|
||||
private String message;
|
||||
|
||||
private String importIdentifier;
|
||||
|
||||
private String importData;
|
||||
|
||||
public SingleImportResultBean(int status, int itemId, String message,
|
||||
String importIdentifier, String importData)
|
||||
{
|
||||
super();
|
||||
this.status = status;
|
||||
this.witemId = itemId;
|
||||
this.message = message;
|
||||
this.importIdentifier = importIdentifier;
|
||||
this.importData = importData;
|
||||
}
|
||||
|
||||
public int getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public int getWitemId()
|
||||
{
|
||||
return witemId;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getImportIdentifier()
|
||||
{
|
||||
return importIdentifier;
|
||||
}
|
||||
|
||||
public String getImportData()
|
||||
{
|
||||
return importData;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,208 @@
|
||||
package org.dspace.submit.importer.arxiv;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.dspace.submit.importer.ItemImport;
|
||||
import org.jdom.JDOMException;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class ArXivItem implements ItemImport {
|
||||
|
||||
// Nome della classe istanziata
|
||||
private String source;
|
||||
// Valore del metadato source
|
||||
private String record;
|
||||
|
||||
private List<String[]> authors = new LinkedList<String[]>();
|
||||
|
||||
private String year;
|
||||
|
||||
private String articleTitle;
|
||||
|
||||
private String splashPageUrl;
|
||||
|
||||
private String comment;
|
||||
|
||||
private String summary;
|
||||
|
||||
private String pdfUrl;
|
||||
|
||||
private String journalRef;
|
||||
|
||||
private String doi;
|
||||
|
||||
private List<String> primaryCategory = new LinkedList<String>();
|
||||
|
||||
private List<String> category = new LinkedList<String>();
|
||||
|
||||
public ArXivItem(Element dataRoot) throws JDOMException, IOException,
|
||||
ParserConfigurationException, SAXException
|
||||
{
|
||||
articleTitle = XMLUtils.getElementValue(dataRoot, "title");
|
||||
summary = XMLUtils.getElementValue(dataRoot, "summary");
|
||||
year = XMLUtils.getElementValue(dataRoot, "published");
|
||||
splashPageUrl = XMLUtils.getElementValue(dataRoot, "id");
|
||||
comment= XMLUtils.getElementValue(dataRoot, "arxiv:comment");
|
||||
|
||||
List<Element> links = XMLUtils.getElementList(dataRoot, "link");
|
||||
if (links != null)
|
||||
{
|
||||
for (Element link : links)
|
||||
{
|
||||
if ("related".equals(link.getAttribute("rel")) && "pdf".equals(link.getAttribute("title")))
|
||||
{
|
||||
pdfUrl = link.getAttribute("href");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doi = XMLUtils.getElementValue(dataRoot, "arxiv:doi");
|
||||
journalRef = XMLUtils.getElementValue(dataRoot, "arxiv:journal_ref");
|
||||
|
||||
List<Element> primaryCategoryList = XMLUtils.getElementList(dataRoot, "arxiv:primary_category");
|
||||
if (primaryCategoryList != null)
|
||||
{
|
||||
for (Element primaryCategoryElement : primaryCategoryList)
|
||||
{
|
||||
primaryCategory.add(primaryCategoryElement.getAttribute("term"));
|
||||
}
|
||||
}
|
||||
|
||||
List<Element> categoryList = XMLUtils.getElementList(dataRoot, "category");
|
||||
if (categoryList != null)
|
||||
{
|
||||
for (Element categoryElement : categoryList)
|
||||
{
|
||||
category.add(categoryElement.getAttribute("term"));
|
||||
}
|
||||
}
|
||||
|
||||
List<Element> authorList = XMLUtils.getElementList(dataRoot, "author");
|
||||
if (authorList != null)
|
||||
{
|
||||
for (Element authorElement : authorList)
|
||||
{
|
||||
String nomeCompleto = authorElement.getTextContent();
|
||||
String[] nomeSplit = nomeCompleto.split("\\s+");
|
||||
String nome = "";
|
||||
String cognome = "";
|
||||
if (nomeSplit.length > 2)
|
||||
{
|
||||
String senzaPunti = nomeCompleto.replace("\\.", "");
|
||||
String[] tmp = senzaPunti.split("\\s+");
|
||||
|
||||
int start = 1;
|
||||
if (tmp.length == nomeSplit.length)
|
||||
{
|
||||
for (int idx = 2; idx < tmp.length; idx++)
|
||||
{
|
||||
if (tmp[idx].length() > 1)
|
||||
{
|
||||
start = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < start; i++)
|
||||
{
|
||||
nome += nomeSplit[i];
|
||||
}
|
||||
for (int i = start; i < nomeSplit.length; i++)
|
||||
{
|
||||
cognome += nomeSplit[i];
|
||||
}
|
||||
}
|
||||
else if (nomeSplit.length == 2)
|
||||
{
|
||||
nome = nomeSplit[0];
|
||||
cognome = nomeSplit[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
cognome = nomeCompleto;
|
||||
}
|
||||
authors.add(new String[]{nome, cognome});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String[]> getAuthors()
|
||||
{
|
||||
return authors;
|
||||
}
|
||||
|
||||
public String getYear()
|
||||
{
|
||||
return year;
|
||||
}
|
||||
|
||||
public String getArticleTitle()
|
||||
{
|
||||
return articleTitle;
|
||||
}
|
||||
|
||||
public String getSplashPageUrl()
|
||||
{
|
||||
return splashPageUrl;
|
||||
}
|
||||
|
||||
public String getComment()
|
||||
{
|
||||
return comment;
|
||||
}
|
||||
|
||||
public String getSummary()
|
||||
{
|
||||
return summary;
|
||||
}
|
||||
|
||||
public String getPdfUrl()
|
||||
{
|
||||
return pdfUrl;
|
||||
}
|
||||
|
||||
public String getDoi()
|
||||
{
|
||||
return doi;
|
||||
}
|
||||
|
||||
public String getJournalRef()
|
||||
{
|
||||
return journalRef;
|
||||
}
|
||||
|
||||
public List<String> getPrimaryCategory()
|
||||
{
|
||||
return primaryCategory;
|
||||
}
|
||||
|
||||
public List<String> getCategory()
|
||||
{
|
||||
return category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecord(String record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
@@ -0,0 +1,284 @@
|
||||
package org.dspace.submit.importer.crossref;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.dspace.submit.importer.ItemImport;
|
||||
import org.jdom.JDOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class CrossrefItem implements ItemImport
|
||||
{
|
||||
// Nome della classe istanziata
|
||||
private String source;
|
||||
// Valore del metadato source
|
||||
private String record;
|
||||
|
||||
private String doi;
|
||||
|
||||
private String itemType;
|
||||
|
||||
private String issn;
|
||||
|
||||
private String eissn;
|
||||
|
||||
private String isbn;
|
||||
|
||||
private String seriesTitle;
|
||||
|
||||
private String journalTitle;
|
||||
|
||||
private String volumeTitle;
|
||||
|
||||
private List<String[]> authors = new LinkedList<String[]>();
|
||||
|
||||
private List<String[]> editors = new LinkedList<String[]>();
|
||||
|
||||
private List<String[]> translators = new LinkedList<String[]>();
|
||||
|
||||
private List<String[]> chairs = new LinkedList<String[]>();
|
||||
|
||||
private String volume;
|
||||
|
||||
private String issue;
|
||||
|
||||
private String firstPage;
|
||||
|
||||
private String lastPage;
|
||||
|
||||
private String editionNumber;
|
||||
|
||||
private String year;
|
||||
|
||||
private String publicationType;
|
||||
|
||||
private String articleTitle;
|
||||
|
||||
public CrossrefItem(InputStream xmlData) throws JDOMException, IOException,
|
||||
ParserConfigurationException, SAXException
|
||||
{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
Document inDoc = db.parse(xmlData);
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
Element queryResult = XMLUtils.getSingleElement(xmlRoot, "query_result");
|
||||
Element body = XMLUtils.getSingleElement(xmlRoot, "body");
|
||||
Element dataRoot = XMLUtils.getSingleElement(xmlRoot, "query");
|
||||
loadData(dataRoot);
|
||||
}
|
||||
|
||||
public CrossrefItem(Element dataRoot) {
|
||||
loadData(dataRoot);
|
||||
}
|
||||
|
||||
private void loadData(Element dataRoot) {
|
||||
String status = dataRoot.getAttribute("status");
|
||||
// <xsd:enumeration value="resolved"/>
|
||||
// <xsd:enumeration value="unresolved"/>
|
||||
// <xsd:enumeration value="multiresolved"/>
|
||||
// <xsd:enumeration value="malformed"/>
|
||||
if (!"resolved".equals(status)) {
|
||||
String msg = XMLUtils.getElementValue(dataRoot, "msg");
|
||||
String exMsg = status + " - " + msg;
|
||||
throw new RuntimeException(exMsg);
|
||||
}
|
||||
doi = XMLUtils.getElementValue(dataRoot, "doi");
|
||||
itemType = doi != null ? XMLUtils.getElementAttribute(dataRoot, "doi",
|
||||
"type") : "unspecified";
|
||||
|
||||
List<Element> identifier = XMLUtils.getElementList(dataRoot, "issn");
|
||||
for (Element ident : identifier)
|
||||
{
|
||||
if ("print".equalsIgnoreCase(ident.getAttribute("type"))
|
||||
|| StringUtils.isNotBlank(ident.getAttribute("type")))
|
||||
{
|
||||
issn = ident.getTextContent().trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
eissn = ident.getTextContent().trim();
|
||||
}
|
||||
}
|
||||
|
||||
isbn = XMLUtils.getElementValue(dataRoot, "isbn");
|
||||
editionNumber = XMLUtils.getElementValue(dataRoot, "editionNumber");
|
||||
volume = XMLUtils.getElementValue(dataRoot, "volume");
|
||||
issue = XMLUtils.getElementValue(dataRoot, "issue");
|
||||
year = XMLUtils.getElementValue(dataRoot, "year");
|
||||
firstPage = XMLUtils.getElementValue(dataRoot, "first_page");
|
||||
lastPage = XMLUtils.getElementValue(dataRoot, "last_page");
|
||||
seriesTitle = XMLUtils.getElementValue(dataRoot, "series_title");
|
||||
journalTitle = XMLUtils.getElementValue(dataRoot, "journal_title");
|
||||
volumeTitle = XMLUtils.getElementValue(dataRoot, "volume_title");
|
||||
articleTitle = XMLUtils.getElementValue(dataRoot, "article_title");
|
||||
publicationType = XMLUtils.getElementValue(dataRoot, "pubblication_type");
|
||||
|
||||
List<Element> contributors = XMLUtils.getElementList(dataRoot, "contributors");
|
||||
List<Element> contributor = null;
|
||||
if (contributors != null && contributors.size() > 0)
|
||||
{
|
||||
contributor = XMLUtils.getElementList(contributors.get(0), "contributor");
|
||||
|
||||
for (Element contrib : contributor) {
|
||||
|
||||
String givenName = XMLUtils.getElementValue(contrib, "given_name");
|
||||
String surname = XMLUtils.getElementValue(contrib, "surname");
|
||||
|
||||
if ("editor".equalsIgnoreCase(contrib
|
||||
.getAttribute("contributor_role")))
|
||||
{
|
||||
editors.add(new String[] { givenName, surname });
|
||||
}
|
||||
else if ("chair".equalsIgnoreCase(contrib
|
||||
.getAttribute("contributor_role")))
|
||||
{
|
||||
chairs.add(new String[] { givenName, surname });
|
||||
}
|
||||
else if ("translator".equalsIgnoreCase(contrib
|
||||
.getAttribute("contributor_role")))
|
||||
{
|
||||
translators.add(new String[] { givenName, surname });
|
||||
}
|
||||
else
|
||||
{
|
||||
authors.add(new String[] { givenName, surname });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getDoi()
|
||||
{
|
||||
return doi;
|
||||
}
|
||||
|
||||
public String getItemType()
|
||||
{
|
||||
return itemType;
|
||||
}
|
||||
|
||||
public String getIssn()
|
||||
{
|
||||
return issn;
|
||||
}
|
||||
|
||||
public String getEissn()
|
||||
{
|
||||
return eissn;
|
||||
}
|
||||
|
||||
public String getIsbn()
|
||||
{
|
||||
return isbn;
|
||||
}
|
||||
|
||||
public String getSeriesTitle()
|
||||
{
|
||||
return seriesTitle;
|
||||
}
|
||||
|
||||
public String getJournalTitle()
|
||||
{
|
||||
return journalTitle;
|
||||
}
|
||||
|
||||
public String getVolumeTitle()
|
||||
{
|
||||
return volumeTitle;
|
||||
}
|
||||
|
||||
public List<String[]> getAuthors()
|
||||
{
|
||||
return authors;
|
||||
}
|
||||
|
||||
public List<String[]> getEditors()
|
||||
{
|
||||
return editors;
|
||||
}
|
||||
|
||||
public List<String[]> getTranslators()
|
||||
{
|
||||
return translators;
|
||||
}
|
||||
|
||||
public List<String[]> getChairs()
|
||||
{
|
||||
return chairs;
|
||||
}
|
||||
|
||||
public String getVolume()
|
||||
{
|
||||
return volume;
|
||||
}
|
||||
|
||||
public String getIssue()
|
||||
{
|
||||
return issue;
|
||||
}
|
||||
|
||||
public String getFirstPage()
|
||||
{
|
||||
return firstPage;
|
||||
}
|
||||
|
||||
public String getLastPage()
|
||||
{
|
||||
return lastPage;
|
||||
}
|
||||
|
||||
public String getEditionNumber()
|
||||
{
|
||||
return editionNumber;
|
||||
}
|
||||
|
||||
public String getYear()
|
||||
{
|
||||
return year;
|
||||
}
|
||||
|
||||
public String getPublicationType()
|
||||
{
|
||||
return publicationType;
|
||||
}
|
||||
|
||||
public String getArticleTitle()
|
||||
{
|
||||
return articleTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecord(String record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
@@ -0,0 +1,389 @@
|
||||
package org.dspace.submit.importer.pubmed;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.dspace.submit.importer.ItemImport;
|
||||
import org.jdom.JDOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class PubmedItem implements ItemImport
|
||||
{
|
||||
// Nome della classe istanziata
|
||||
private String source;
|
||||
// Valore del metadato source
|
||||
private String record;
|
||||
|
||||
private String pubmedID;
|
||||
|
||||
private String doi;
|
||||
|
||||
private String issn;
|
||||
|
||||
private String eissn;
|
||||
|
||||
private String journalTitle;
|
||||
|
||||
private String title;
|
||||
|
||||
private String pubblicationModel;
|
||||
|
||||
private String year;
|
||||
|
||||
private String volume;
|
||||
|
||||
private String issue;
|
||||
|
||||
private String language;
|
||||
|
||||
private List<String> type = new LinkedList<String>();
|
||||
|
||||
private List<String> primaryKeywords = new LinkedList<String>();
|
||||
|
||||
private List<String> secondaryKeywords = new LinkedList<String>();
|
||||
|
||||
private List<String> primaryMeshHeadings = new LinkedList<String>();
|
||||
|
||||
private List<String> secondaryMeshHeadings = new LinkedList<String>();
|
||||
|
||||
private String startPage;
|
||||
|
||||
private String endPage;
|
||||
|
||||
private String summary;
|
||||
|
||||
private String status;
|
||||
|
||||
private List<String[]> authors = new LinkedList<String[]>();
|
||||
|
||||
public PubmedItem(InputStream xmlData) throws JDOMException, IOException,
|
||||
ParserConfigurationException, SAXException
|
||||
{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
Document inDoc = db.parse(xmlData);
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
Element pubArticle = XMLUtils
|
||||
.getSingleElement(xmlRoot, "PubmedArticle");
|
||||
|
||||
loadData(pubArticle);
|
||||
}
|
||||
|
||||
public PubmedItem(Element xmlArticle) {
|
||||
loadData(xmlArticle);
|
||||
}
|
||||
|
||||
private void loadData(Element pubArticle) {
|
||||
Map<String, String> mounthToNum = new HashMap<String, String>();
|
||||
mounthToNum.put("Jan", "01");
|
||||
mounthToNum.put("Feb", "02");
|
||||
mounthToNum.put("Mar", "03");
|
||||
mounthToNum.put("Apr", "04");
|
||||
mounthToNum.put("May", "05");
|
||||
mounthToNum.put("Jun", "06");
|
||||
mounthToNum.put("Jul", "07");
|
||||
mounthToNum.put("Aug", "08");
|
||||
mounthToNum.put("Sep", "09");
|
||||
mounthToNum.put("Oct", "10");
|
||||
mounthToNum.put("Nov", "11");
|
||||
mounthToNum.put("Dec", "12");
|
||||
|
||||
Element medline = XMLUtils.getSingleElement(pubArticle, "MedlineCitation");
|
||||
|
||||
Element article = XMLUtils.getSingleElement(medline, "Article");
|
||||
Element pubmed = XMLUtils.getSingleElement(pubArticle, "PubmedData");
|
||||
|
||||
Element identifierList = XMLUtils.getSingleElement(pubmed, "ArticleIdList");
|
||||
if (identifierList != null)
|
||||
{
|
||||
List<Element> identifiers = XMLUtils.getElementList(identifierList, "ArticleId");
|
||||
if (identifiers != null)
|
||||
{
|
||||
for (Element id : identifiers)
|
||||
{
|
||||
if ("pubmed".equals(id.getAttribute("IdType")))
|
||||
{
|
||||
pubmedID = id.getTextContent().trim();
|
||||
}
|
||||
else if ("doi".equals(id.getAttribute("IdType")))
|
||||
{
|
||||
doi = id.getTextContent().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status = XMLUtils.getElementValue(pubmed, "PublicationStatus");
|
||||
pubblicationModel = XMLUtils.getElementAttribute(medline, "Article", "PubModel");
|
||||
title = XMLUtils.getElementValue(article, "ArticleTitle");
|
||||
Element abstractElement = XMLUtils.getSingleElement(medline, "Abstract");
|
||||
if (abstractElement == null)
|
||||
{
|
||||
abstractElement = XMLUtils.getSingleElement(medline, "OtherAbstract");
|
||||
}
|
||||
if (abstractElement != null)
|
||||
{
|
||||
summary = XMLUtils.getElementValue(abstractElement, "AbstractText");
|
||||
}
|
||||
|
||||
Element authorList = XMLUtils.getSingleElement(article, "AuthorList");
|
||||
if (authorList != null)
|
||||
{
|
||||
List<Element> authorsElement = XMLUtils.getElementList(authorList, "Author");
|
||||
if (authorsElement != null)
|
||||
{
|
||||
for (Element author : authorsElement)
|
||||
{
|
||||
if (StringUtils.isBlank(XMLUtils.getElementValue(author, "CollectiveName")))
|
||||
{
|
||||
authors.add(new String[]{XMLUtils.getElementValue(author, "ForeName"),XMLUtils.getElementValue(author, "LastName")});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element journal = XMLUtils.getSingleElement(article, "Journal");
|
||||
if (journal != null)
|
||||
{
|
||||
List<Element> jnumbers = XMLUtils.getElementList(journal, "ISSN");
|
||||
if (jnumbers != null)
|
||||
{
|
||||
for (Element jnumber : jnumbers)
|
||||
{
|
||||
if ("Print".equals(jnumber.getAttribute("IssnType")))
|
||||
{
|
||||
issn = jnumber.getTextContent().trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
eissn = jnumber.getTextContent().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
journalTitle = XMLUtils.getElementValue(journal, "Title");
|
||||
Element journalIssueElement = XMLUtils.getSingleElement(journal, "JournalIssue");
|
||||
if (journalIssueElement != null)
|
||||
{
|
||||
volume = XMLUtils.getElementValue(journalIssueElement, "Volume");
|
||||
issue = XMLUtils.getElementValue(journalIssueElement, "Issue");
|
||||
|
||||
Element pubDataElement = XMLUtils.getSingleElement(journalIssueElement, "PubDate");
|
||||
|
||||
if (pubDataElement != null)
|
||||
{
|
||||
year = XMLUtils.getElementValue(pubDataElement, "Year");
|
||||
String mounth = XMLUtils.getElementValue(pubDataElement, "Month");
|
||||
String day = XMLUtils.getElementValue(pubDataElement, "Day");
|
||||
if (StringUtils.isNotBlank(mounth) && mounthToNum.containsKey(mounth))
|
||||
{
|
||||
year += "-" + mounthToNum.get(mounth);
|
||||
if (StringUtils.isNotBlank(day))
|
||||
{
|
||||
year += "-" + (day.length() == 1 ? "0" + day : day);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
language = XMLUtils.getElementValue(article, "Language");
|
||||
|
||||
Element publicationTypeList = XMLUtils.getSingleElement(article, "PublicationTypeList");
|
||||
if (publicationTypeList != null)
|
||||
{
|
||||
List<Element> publicationTypes = XMLUtils.getElementList(publicationTypeList, "PublicationType");
|
||||
for (Element publicationType : publicationTypes)
|
||||
{
|
||||
type.add(publicationType.getTextContent().trim());
|
||||
}
|
||||
}
|
||||
|
||||
Element keywordsList = XMLUtils.getSingleElement(medline, "KeywordList");
|
||||
if (keywordsList != null)
|
||||
{
|
||||
List<Element> keywords = XMLUtils.getElementList(keywordsList, "Keyword");
|
||||
for (Element keyword : keywords)
|
||||
{
|
||||
if ("Y".equals(keyword.getAttribute("MajorTopicYN")))
|
||||
{
|
||||
primaryKeywords.add(keyword.getTextContent().trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
secondaryKeywords.add(keyword.getTextContent().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element meshHeadingsList = XMLUtils.getSingleElement(medline, "MeshHeadingList");
|
||||
if (meshHeadingsList != null)
|
||||
{
|
||||
List<Element> meshHeadings = XMLUtils.getElementList(meshHeadingsList, "MeshHeading");
|
||||
for (Element meshHeading : meshHeadings)
|
||||
{
|
||||
if ("Y".equals(XMLUtils.getElementAttribute(meshHeading, "DescriptorName", "MajorTopicYN")))
|
||||
{
|
||||
primaryMeshHeadings.add(XMLUtils.getElementValue(meshHeading, "DescriptorName"));
|
||||
}
|
||||
else
|
||||
{
|
||||
secondaryMeshHeadings.add(XMLUtils.getElementValue(meshHeading, "DescriptorName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Element paginationElement = XMLUtils.getSingleElement(article, "Pagination");
|
||||
if (paginationElement != null)
|
||||
{
|
||||
startPage = XMLUtils.getElementValue(paginationElement, "StartPage");
|
||||
endPage = XMLUtils.getElementValue(paginationElement, "EndPage");
|
||||
if (StringUtils.isBlank(startPage))
|
||||
{
|
||||
startPage = XMLUtils.getElementValue(paginationElement, "MedlinePgn");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getPubmedID()
|
||||
{
|
||||
return pubmedID;
|
||||
}
|
||||
|
||||
public String getDoi()
|
||||
{
|
||||
return doi;
|
||||
}
|
||||
|
||||
public String getIssn()
|
||||
{
|
||||
return issn;
|
||||
}
|
||||
|
||||
public String getEissn()
|
||||
{
|
||||
return eissn;
|
||||
}
|
||||
|
||||
public String getJournalTitle()
|
||||
{
|
||||
return journalTitle;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getPubblicationModel()
|
||||
{
|
||||
return pubblicationModel;
|
||||
}
|
||||
|
||||
public String getYear()
|
||||
{
|
||||
return year;
|
||||
}
|
||||
|
||||
public String getVolume()
|
||||
{
|
||||
return volume;
|
||||
}
|
||||
|
||||
public String getIssue()
|
||||
{
|
||||
return issue;
|
||||
}
|
||||
|
||||
public String getLanguage()
|
||||
{
|
||||
return language;
|
||||
}
|
||||
|
||||
public List<String> getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<String> getPrimaryKeywords()
|
||||
{
|
||||
return primaryKeywords;
|
||||
}
|
||||
|
||||
public List<String> getSecondaryKeywords()
|
||||
{
|
||||
return secondaryKeywords;
|
||||
}
|
||||
|
||||
public List<String> getPrimaryMeshHeadings()
|
||||
{
|
||||
return primaryMeshHeadings;
|
||||
}
|
||||
|
||||
public List<String> getSecondaryMeshHeadings()
|
||||
{
|
||||
return secondaryMeshHeadings;
|
||||
}
|
||||
|
||||
public String getStartPage()
|
||||
{
|
||||
return startPage;
|
||||
}
|
||||
|
||||
public String getEndPage()
|
||||
{
|
||||
return endPage;
|
||||
}
|
||||
|
||||
public String getSummary()
|
||||
{
|
||||
return summary;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public List<String[]> getAuthors()
|
||||
{
|
||||
return authors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecord(String record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.importer.arxiv.ArXivItem;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
public class ArXivLookupProvider extends ConfigurableLookupProvider {
|
||||
private ArXivService arXivService;
|
||||
private boolean searchProvider = true;
|
||||
|
||||
public void setArXivService(ArXivService arXivService) {
|
||||
this.arXivService = arXivService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupportedIdentifiers() {
|
||||
return Arrays.asList(new String[] { ARXIV, DOI });
|
||||
}
|
||||
|
||||
public void setSearchProvider(boolean searchProvider)
|
||||
{
|
||||
this.searchProvider = searchProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSearchProvider() {
|
||||
return searchProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> getByIdentifier(
|
||||
Context context, Map<String, String> keys) throws HttpException, IOException {
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
if (keys != null) {
|
||||
String doi = keys.get(DOI);
|
||||
String arxivid = keys.get(ARXIV);
|
||||
List<ArXivItem> items = new ArrayList<ArXivItem>();
|
||||
if (StringUtils.isNotBlank(doi)) {
|
||||
Set<String> dois = new HashSet<String>();
|
||||
dois.add(doi);
|
||||
items.addAll(arXivService.getByDOIs(dois));
|
||||
}
|
||||
if (StringUtils.isNotBlank(arxivid)) {
|
||||
items.add(arXivService.getByArXivIDs(arxivid));
|
||||
}
|
||||
|
||||
for (ArXivItem item : items) {
|
||||
results.add(convert(item));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> search(Context context, String title,
|
||||
String author, int year) throws HttpException, IOException {
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
List<ArXivItem> items = arXivService.searchByTerm(title, author, year);
|
||||
for (ArXivItem item : items) {
|
||||
results.add(convert(item));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return "arxiv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> getByDOIs(Context context, Set<String> doiToSearch)
|
||||
throws HttpException, IOException {
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
if (doiToSearch != null && doiToSearch.size() > 0) {
|
||||
List<ArXivItem> items = arXivService.getByDOIs(doiToSearch);
|
||||
|
||||
for (ArXivItem item : items) {
|
||||
results.add(convert(item));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
@@ -0,0 +1,206 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.submit.importer.arxiv.ArXivItem;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
public class ArXivService
|
||||
{
|
||||
private int timeout = 1000;
|
||||
|
||||
public void setTimeout(int timeout)
|
||||
{
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public List<ArXivItem> getByDOIs(Set<String> dois) throws HttpException,
|
||||
IOException
|
||||
{
|
||||
if (dois != null && dois.size() > 0)
|
||||
{
|
||||
String doisQuery = StringUtils.join(dois.iterator(), " OR ");
|
||||
return search(doisQuery, null, 100);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ArXivItem> searchByTerm(String title, String author, int year)
|
||||
throws HttpException, IOException
|
||||
{
|
||||
StringBuffer query = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(title))
|
||||
{
|
||||
query.append("ti:\"").append(title).append("\"");
|
||||
}
|
||||
if (StringUtils.isNotBlank(author))
|
||||
{
|
||||
// [FAU]
|
||||
if (query.length() > 0)
|
||||
query.append(" AND ");
|
||||
query.append("au:\"").append(author).append("\"");
|
||||
}
|
||||
return search(query.toString(), "", 10);
|
||||
}
|
||||
|
||||
private List<ArXivItem> search(String query, String arxivid, int max_result)
|
||||
throws IOException, HttpException
|
||||
{
|
||||
List<ArXivItem> results = new ArrayList<ArXivItem>();
|
||||
if (!ConfigurationManager.getBooleanProperty("remoteservice.demo"))
|
||||
{
|
||||
GetMethod method = null;
|
||||
try
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
client.setTimeout(timeout);
|
||||
method = new GetMethod("http://export.arxiv.org/api/query");
|
||||
NameValuePair id = new NameValuePair("id_list", arxivid);
|
||||
NameValuePair queryParam = new NameValuePair("search_query",
|
||||
query);
|
||||
NameValuePair count = new NameValuePair("max_results",
|
||||
String.valueOf(max_result));
|
||||
method.setQueryString(new NameValuePair[] { id, queryParam,
|
||||
count });
|
||||
// Execute the method.
|
||||
int statusCode = client.executeMethod(method);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK)
|
||||
{
|
||||
if (statusCode == HttpStatus.SC_BAD_REQUEST)
|
||||
throw new RuntimeException("Query arXiv non valida");
|
||||
else
|
||||
throw new RuntimeException("Chiamata http fallita: "
|
||||
+ method.getStatusLine());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
Document inDoc = db.parse(method.getResponseBodyAsStream());
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
List<Element> dataRoots = XMLUtils.getElementList(xmlRoot,
|
||||
"entry");
|
||||
|
||||
for (Element dataRoot : dataRoots)
|
||||
{
|
||||
ArXivItem crossitem;
|
||||
|
||||
crossitem = new ArXivItem(dataRoot);
|
||||
if (crossitem != null)
|
||||
{
|
||||
results.add(crossitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
"Identificativo arXiv non valido o inesistente");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (method != null)
|
||||
{
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InputStream stream = null;
|
||||
try
|
||||
{
|
||||
File file = new File(
|
||||
ConfigurationManager.getProperty("dspace.dir")
|
||||
+ "/config/crosswalks/demo/arxiv.xml");
|
||||
stream = new FileInputStream(file);
|
||||
try
|
||||
{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
Document inDoc = db.parse(stream);
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
List<Element> dataRoots = XMLUtils.getElementList(xmlRoot,
|
||||
"entry");
|
||||
for (Element dataRoot : dataRoots)
|
||||
{
|
||||
ArXivItem crossitem = new ArXivItem(dataRoot);
|
||||
|
||||
if (crossitem != null)
|
||||
{
|
||||
results.add(crossitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
"Identificativo arXiv non valido o inesistente");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public ArXivItem getByArXivIDs(String raw) throws HttpException,
|
||||
IOException
|
||||
{
|
||||
if (StringUtils.isNotBlank(raw))
|
||||
{
|
||||
raw = raw.trim();
|
||||
if (raw.startsWith("http://arxiv.org/abs/"))
|
||||
{
|
||||
raw = raw.substring("http://arxiv.org/abs/".length());
|
||||
}
|
||||
else if (raw.toLowerCase().startsWith("arxiv:"))
|
||||
{
|
||||
raw = raw.substring("arxiv:".length());
|
||||
}
|
||||
List<ArXivItem> result = search("", raw, 1);
|
||||
if (result != null && result.size() > 0)
|
||||
{
|
||||
return result.get(0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
|
||||
public abstract class ConfigurableLookupProvider implements SubmissionLookupProvider {
|
||||
protected SubmissionLookupPublication convert(Object bean) {
|
||||
try {
|
||||
return SubmissionLookupUtils.convert(getShortName(), bean);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.importer.crossref.CrossrefItem;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
import org.jdom.JDOMException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class CrossRefLookupProvider extends ConfigurableLookupProvider {
|
||||
private CrossRefService crossrefService;
|
||||
|
||||
private boolean searchProvider = true;
|
||||
|
||||
public void setSearchProvider(boolean searchProvider)
|
||||
{
|
||||
this.searchProvider = searchProvider;
|
||||
}
|
||||
|
||||
public void setCrossrefService(CrossRefService crossrefService) {
|
||||
this.crossrefService = crossrefService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupportedIdentifiers() {
|
||||
return Arrays.asList(new String[] { DOI });
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> getByIdentifier(Context context,
|
||||
Map<String, String> keys) throws HttpException, IOException {
|
||||
if (keys != null && keys.containsKey(DOI)) {
|
||||
Set<String> dois = new HashSet<String>();
|
||||
dois.add(keys.get(DOI));
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
List<CrossrefItem> items = null;
|
||||
try {
|
||||
items = crossrefService.search(context, dois);
|
||||
} catch (JDOMException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (SAXException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
if (items != null) {
|
||||
for (CrossrefItem p : items) {
|
||||
results.add(convert(p));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> search(Context context, String title,
|
||||
String author, int year) throws HttpException, IOException {
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
List<CrossrefItem> items = null;
|
||||
items = crossrefService.search(context, title, author, year, 10);
|
||||
if (items != null) {
|
||||
for (CrossrefItem p : items) {
|
||||
results.add(convert(p));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSearchProvider() {
|
||||
return searchProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return "crossref";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> getByDOIs(Context context, Set<String> doiToSearch)
|
||||
throws HttpException, IOException {
|
||||
if (doiToSearch != null) {
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
List<CrossrefItem> items = null;
|
||||
try {
|
||||
items = crossrefService.search(context, doiToSearch);
|
||||
} catch (JDOMException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} catch (SAXException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
if (items != null) {
|
||||
for (CrossrefItem p : items) {
|
||||
results.add(convert(p));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,176 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.submit.importer.crossref.CrossrefItem;
|
||||
import org.jdom.JDOMException;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import flexjson.JSONDeserializer;
|
||||
|
||||
public class CrossRefService {
|
||||
|
||||
private static final Logger log = Logger.getLogger(CrossRefService.class);
|
||||
|
||||
private int timeout = 1000;
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public List<CrossrefItem> search(Context context, Set<String> dois) throws HttpException,
|
||||
IOException, JDOMException, ParserConfigurationException,
|
||||
SAXException {
|
||||
List<CrossrefItem> results = new ArrayList<CrossrefItem>();
|
||||
if (dois != null && dois.size() > 0) {
|
||||
for (String record : dois) {
|
||||
try
|
||||
{
|
||||
if (!ConfigurationManager
|
||||
.getBooleanProperty("remoteservice.demo")) {
|
||||
GetMethod method = null;
|
||||
try {
|
||||
String apiKey = ConfigurationManager
|
||||
.getProperty("crossref.api-key");
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
client.setConnectionTimeout(timeout);
|
||||
method = new GetMethod(
|
||||
"http://www.crossref.org/openurl/");
|
||||
|
||||
NameValuePair pid = new NameValuePair("pid", apiKey);
|
||||
NameValuePair noredirect = new NameValuePair(
|
||||
"noredirect", "true");
|
||||
NameValuePair id = new NameValuePair("id", record);
|
||||
method.setQueryString(new NameValuePair[] { pid,
|
||||
noredirect, id });
|
||||
// Execute the method.
|
||||
int statusCode = client.executeMethod(method);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
throw new RuntimeException(
|
||||
"Chiamata http fallita: "
|
||||
+ method.getStatusLine());
|
||||
}
|
||||
|
||||
CrossrefItem crossitem;
|
||||
try {
|
||||
crossitem = new CrossrefItem(
|
||||
method.getResponseBodyAsStream());
|
||||
results.add(crossitem);
|
||||
} catch (Exception e) {
|
||||
log.warn(LogManager
|
||||
.getHeader(
|
||||
context,
|
||||
"retrieveRecordDOI",
|
||||
record
|
||||
+ " DOI non valido o inesistente: "
|
||||
+ e.getMessage()));
|
||||
}
|
||||
} finally {
|
||||
if (method != null) {
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InputStream stream = null;
|
||||
try {
|
||||
File file = new File(
|
||||
ConfigurationManager.getProperty("dspace.dir")
|
||||
+ "/config/crosswalks/demo/doi.xml");
|
||||
stream = new FileInputStream(file);
|
||||
results.add(new CrossrefItem(stream));
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RuntimeException rt)
|
||||
{
|
||||
rt.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public NameValuePair[] buildQueryPart(String title, String author, int year, int count) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(title)) {
|
||||
sb.append(title);
|
||||
}
|
||||
sb.append(" ");
|
||||
if (StringUtils.isNotBlank(author)) {
|
||||
sb.append(author);
|
||||
}
|
||||
String q = sb.toString().trim();
|
||||
NameValuePair qParam = new NameValuePair("q", title);
|
||||
NameValuePair yearParam = new NameValuePair("year",
|
||||
year != -1?String.valueOf(year):"");
|
||||
NameValuePair countParam = new NameValuePair("rows",
|
||||
count!= -1?String.valueOf(count):"");
|
||||
|
||||
NameValuePair[] query = new NameValuePair[] { qParam,
|
||||
yearParam, countParam };
|
||||
return query;
|
||||
}
|
||||
|
||||
public List<CrossrefItem> search(Context context, String title, String authors, int year,
|
||||
int count) throws IOException, HttpException {
|
||||
List<CrossrefItem> results = new ArrayList<CrossrefItem>();
|
||||
GetMethod method = null;
|
||||
try {
|
||||
NameValuePair[] query = buildQueryPart(title, authors, year, count);
|
||||
HttpClient client = new HttpClient();
|
||||
client.setTimeout(timeout);
|
||||
method = new GetMethod("http://search.labs.crossref.org/dois");
|
||||
|
||||
method.setQueryString(query);
|
||||
// Execute the method.
|
||||
int statusCode = client.executeMethod(method);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
throw new RuntimeException("Chiamata http fallita: "
|
||||
+ method.getStatusLine());
|
||||
}
|
||||
|
||||
JSONDeserializer<List<Map>> des = new JSONDeserializer<List<Map>>();
|
||||
List<Map> json = des.deserialize(method.getResponseBodyAsString());
|
||||
Set<String> dois = new HashSet<String>();
|
||||
for (Map r : json) {
|
||||
dois.add(SubmissionLookupUtils.normalizeDOI((String) r.get("doi")));
|
||||
}
|
||||
method.releaseConnection();
|
||||
|
||||
return search(context, dois);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} finally {
|
||||
if (method != null) {
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
public interface EnhancerSubmissionLookup {
|
||||
|
||||
List<String> getValues(
|
||||
SubmissionLookupPublication publication);
|
||||
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LookupProvidersCheck {
|
||||
private List<String> providersOk = new ArrayList<String>();
|
||||
private List<String> providersErr = new ArrayList<String>();
|
||||
public List<String> getProvidersOk() {
|
||||
return providersOk;
|
||||
}
|
||||
public void setProvidersOk(List<String> providersOk) {
|
||||
this.providersOk = providersOk;
|
||||
}
|
||||
public List<String> getProvidersErr() {
|
||||
return providersErr;
|
||||
}
|
||||
public void setProvidersErr(List<String> providersErr) {
|
||||
this.providersErr = providersErr;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.submit.importer.pubmed.PubmedItem;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
public class PubmedLookupProvider extends ConfigurableLookupProvider {
|
||||
private boolean searchProvider = true;
|
||||
private static Logger log = Logger.getLogger(PubmedLookupProvider.class);
|
||||
|
||||
private PubmedService pubmedService;
|
||||
|
||||
public void setPubmedService(PubmedService pubmedService) {
|
||||
this.pubmedService = pubmedService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupportedIdentifiers() {
|
||||
return Arrays.asList(new String[] { PUBMED, DOI });
|
||||
}
|
||||
|
||||
public void setSearchProvider(boolean searchProvider)
|
||||
{
|
||||
this.searchProvider = searchProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSearchProvider() {
|
||||
return searchProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return "pubmed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> getByIdentifier(Context context,
|
||||
Map<String, String> keys) throws HttpException, IOException {
|
||||
String pmid = keys != null ? keys.get(PUBMED) : null;
|
||||
String doi = keys != null ? keys.get(DOI) : null;
|
||||
SubmissionLookupPublication publication = null;
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
if (pmid != null && doi == null) {
|
||||
try
|
||||
{
|
||||
publication = convert(pubmedService.getByPubmedID(pmid));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error(LogManager.getHeader(context, "getByIdentifier", "pmid="+pmid), e);
|
||||
}
|
||||
if (publication != null)
|
||||
results.add(publication);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<PubmedItem> pubmedResults = pubmedService.search(doi, pmid);
|
||||
if (pubmedResults != null) {
|
||||
for (PubmedItem p : pubmedResults) {
|
||||
results.add(convert(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> search(Context context, String title,
|
||||
String author, int year) throws HttpException, IOException {
|
||||
List<PubmedItem> pubmedResults = pubmedService.search(title, author,
|
||||
year);
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
if (pubmedResults != null) {
|
||||
for (PubmedItem p : pubmedResults) {
|
||||
results.add(convert(p));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubmissionLookupPublication> getByDOIs(Context context,
|
||||
Set<String> doiToSearch)
|
||||
throws HttpException, IOException {
|
||||
StringBuffer query = new StringBuffer();
|
||||
for (String d : doiToSearch) {
|
||||
if (query.length() > 0) {
|
||||
query.append(" OR ");
|
||||
}
|
||||
query.append(d).append("[AI]");
|
||||
}
|
||||
|
||||
List<PubmedItem> pubmedResults = pubmedService.search(query.toString());
|
||||
List<SubmissionLookupPublication> results = new ArrayList<SubmissionLookupPublication>();
|
||||
if (pubmedResults != null) {
|
||||
for (PubmedItem p : pubmedResults) {
|
||||
results.add(convert(p));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
@@ -0,0 +1,276 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.submit.importer.pubmed.PubmedItem;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class PubmedService {
|
||||
private int timeout = 1000;
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public PubmedItem getByPubmedID(String pubmedid) throws HttpException,
|
||||
IOException, ParserConfigurationException, SAXException {
|
||||
List<String> ids = new ArrayList<String>();
|
||||
ids.add(pubmedid.trim());
|
||||
List<PubmedItem> items = getByPubmedIDs(ids);
|
||||
if (items != null && items.size() > 0)
|
||||
{
|
||||
return items.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<PubmedItem> search(String title, String author, int year)
|
||||
throws HttpException, IOException {
|
||||
StringBuffer query = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(title)) {
|
||||
query.append("((").append(title).append("[TI]) OR (");
|
||||
// [TI] non funziona sempre, titolo di capitoli di libro
|
||||
query.append("(").append(title).append("[book]))");
|
||||
}
|
||||
if (StringUtils.isNotBlank(author)) {
|
||||
// [FAU]
|
||||
if (query.length() > 0)
|
||||
query.append(" AND ");
|
||||
query.append("(").append(author).append("[AU])");
|
||||
}
|
||||
if (year != -1)
|
||||
{
|
||||
// [DP]
|
||||
if (query.length() > 0)
|
||||
query.append(" AND ");
|
||||
query.append(year).append("[DP]");
|
||||
}
|
||||
return search(query.toString());
|
||||
}
|
||||
|
||||
public List<PubmedItem> search(String query) throws IOException,
|
||||
HttpException {
|
||||
List<PubmedItem> results = null;
|
||||
if (!ConfigurationManager.getBooleanProperty("remoteservice.demo")) {
|
||||
GetMethod method = null;
|
||||
try {
|
||||
HttpClient client = new HttpClient();
|
||||
client.setTimeout(timeout);
|
||||
method = new GetMethod(
|
||||
"http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi");
|
||||
|
||||
NameValuePair db = new NameValuePair("db", "pubmed");
|
||||
NameValuePair datetype = new NameValuePair("datetype", "edat");
|
||||
NameValuePair retmax = new NameValuePair("retmax", "10");
|
||||
NameValuePair queryParam = new NameValuePair("term",
|
||||
query.toString());
|
||||
method.setQueryString(new NameValuePair[] { db, queryParam,
|
||||
retmax, datetype });
|
||||
// Execute the method.
|
||||
int statusCode = client.executeMethod(method);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
throw new RuntimeException(
|
||||
"Chiamata al webservice fallita: "
|
||||
+ method.getStatusLine());
|
||||
}
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder builder;
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
|
||||
Document inDoc = builder.parse(method
|
||||
.getResponseBodyAsStream());
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
Element idList = XMLUtils.getSingleElement(xmlRoot,
|
||||
"IdList");
|
||||
List<String> pubmedIDs = XMLUtils.getElementValueList(
|
||||
idList, "Id");
|
||||
results = getByPubmedIDs(pubmedIDs);
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SAXException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
if (method != null) {
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InputStream stream = null;
|
||||
try {
|
||||
File file = new File(
|
||||
ConfigurationManager.getProperty("dspace.dir")
|
||||
+ "/config/crosswalks/demo/pubmed-search.xml");
|
||||
stream = new FileInputStream(file);
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document inDoc = builder.parse(stream);
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
Element idList = XMLUtils.getSingleElement(xmlRoot, "IdList");
|
||||
List<String> pubmedIDs = XMLUtils.getElementValueList(idList,
|
||||
"Id");
|
||||
results = getByPubmedIDs(pubmedIDs);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public List<PubmedItem> getByPubmedIDs(List<String> pubmedIDs)
|
||||
throws HttpException, IOException, ParserConfigurationException, SAXException {
|
||||
List<PubmedItem> results = new ArrayList<PubmedItem>();
|
||||
if (!ConfigurationManager.getBooleanProperty("remoteservice.demo")) {
|
||||
GetMethod method = null;
|
||||
try {
|
||||
HttpClient client = new HttpClient();
|
||||
client.setTimeout(5 * timeout);
|
||||
method = new GetMethod(
|
||||
"http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi");
|
||||
|
||||
NameValuePair db = new NameValuePair("db", "pubmed");
|
||||
NameValuePair retmode = new NameValuePair("retmode", "xml");
|
||||
NameValuePair rettype = new NameValuePair("rettype", "full");
|
||||
NameValuePair id = new NameValuePair("id", StringUtils.join(pubmedIDs.iterator(), ","));
|
||||
method.setQueryString(new NameValuePair[] { db, retmode,
|
||||
rettype, id });
|
||||
// Execute the method.
|
||||
int statusCode = client.executeMethod(method);
|
||||
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
throw new RuntimeException(
|
||||
"Chiamata al webservice fallita: "
|
||||
+ method.getStatusLine());
|
||||
}
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document inDoc = builder.parse(method.getResponseBodyAsStream());
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
List<Element> pubArticles = XMLUtils
|
||||
.getElementList(xmlRoot, "PubmedArticle");
|
||||
|
||||
for (Element xmlArticle : pubArticles)
|
||||
{
|
||||
PubmedItem pubmedItem = null;
|
||||
try {
|
||||
pubmedItem = new PubmedItem(xmlArticle);
|
||||
results.add(pubmedItem);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
"PubmedID non valido o inesistente: "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
} finally {
|
||||
if (method != null) {
|
||||
method.releaseConnection();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InputStream stream = null;
|
||||
try {
|
||||
File file = new File(
|
||||
ConfigurationManager.getProperty("dspace.dir")
|
||||
+ "/config/crosswalks/demo/pubmed.xml");
|
||||
stream = new FileInputStream(file);
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document inDoc = builder.parse(stream);
|
||||
|
||||
Element xmlRoot = inDoc.getDocumentElement();
|
||||
List<Element> pubArticles = XMLUtils
|
||||
.getElementList(xmlRoot, "PubmedArticle");
|
||||
|
||||
for (Element xmlArticle : pubArticles)
|
||||
{
|
||||
PubmedItem pubmedItem = null;
|
||||
try {
|
||||
pubmedItem = new PubmedItem(xmlArticle);
|
||||
results.add(pubmedItem);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
"PubmedID non valido o inesistente: "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} finally {
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<PubmedItem> search(String doi, String pmid) throws HttpException, IOException {
|
||||
StringBuffer query = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(doi)) {
|
||||
query.append(doi);
|
||||
query.append("[AID]");
|
||||
}
|
||||
if (StringUtils.isNotBlank(pmid)) {
|
||||
// [FAU]
|
||||
if (query.length() > 0)
|
||||
query.append(" OR ");
|
||||
query.append(pmid).append("[PMID]");
|
||||
}
|
||||
return search(query.toString());
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
public interface SubmissionLookupProvider {
|
||||
public final static String DOI = "doi";
|
||||
public final static String PUBMED = "pubmed";
|
||||
public final static String ARXIV = "arxiv";
|
||||
public final static String REPEC = "repec";
|
||||
public final static String SCOPUSEID = "scopuseid";
|
||||
public final static String TYPE = "type";
|
||||
|
||||
List<String> getSupportedIdentifiers();
|
||||
|
||||
boolean isSearchProvider();
|
||||
|
||||
String getShortName();
|
||||
|
||||
List<SubmissionLookupPublication> search(Context context, String title, String author,
|
||||
int year) throws HttpException, IOException;
|
||||
|
||||
List<SubmissionLookupPublication> getByIdentifier(Context context, Map<String, String> keys)
|
||||
throws HttpException, IOException;
|
||||
|
||||
List<SubmissionLookupPublication> getByDOIs(Context context, Set<String> doiToSearch) throws HttpException, IOException;
|
||||
|
||||
}
|
@@ -0,0 +1,569 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.DCInput;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.util.EnhancedSubmissionLookupPublication;
|
||||
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
||||
import org.dspace.submit.util.SubmissionLookupDTO;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||
|
||||
public class SubmissionLookupService {
|
||||
|
||||
public static final String SL_NAMESPACE_PREFIX = "http://www.dspace.org/sl/";
|
||||
|
||||
public static final String MANUAL_USER_INPUT = "manual";
|
||||
|
||||
private static Logger log = Logger.getLogger(SubmissionLookupUtils.class);
|
||||
|
||||
// Patter to extract the converter name if any
|
||||
private static final Pattern converterPattern = Pattern
|
||||
.compile(".*\\((.*)\\)");
|
||||
|
||||
// attenzione inizializzato dal metodo init
|
||||
private Properties configuration;
|
||||
|
||||
private static final String NOT_FOUND_DOI = "NOT-FOUND-DOI";
|
||||
|
||||
public static final String SEPARATOR_VALUE = "#######";
|
||||
|
||||
private static final String SEPARATOR_VALUE_REGEX = SEPARATOR_VALUE;
|
||||
|
||||
private List<String> extraMetadataToKeep;
|
||||
|
||||
private Map<String, EnhancerSubmissionLookup> enhancedMetadata;
|
||||
|
||||
private List<SubmissionLookupProvider> providers;
|
||||
|
||||
private Map<String, List<SubmissionLookupProvider>> idents2provs;
|
||||
|
||||
private List<SubmissionLookupProvider> searchProviders;
|
||||
|
||||
private synchronized void init() {
|
||||
if (configuration != null)
|
||||
return;
|
||||
String configFilePath = ConfigurationManager.getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + "crosswalks"
|
||||
+ File.separator + "submission-lookup-mapping.properties";
|
||||
configuration = new Properties();
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(configFilePath);
|
||||
configuration.load(fis);
|
||||
} catch (Exception notfound) {
|
||||
throw new IllegalArgumentException(
|
||||
"Impossibile leggere la configurazione per il SubmissionLookupService (database esterno -> SURplus)",
|
||||
notfound);
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage(), ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setExtraMetadataToKeep(List<String> extraMetadataToKeep) {
|
||||
this.extraMetadataToKeep = extraMetadataToKeep;
|
||||
}
|
||||
|
||||
public List<String> getExtraMetadataToKeep() {
|
||||
return extraMetadataToKeep;
|
||||
}
|
||||
|
||||
public void setEnhancedMetadata(
|
||||
Map<String, EnhancerSubmissionLookup> enhancedMetadata) {
|
||||
this.enhancedMetadata = enhancedMetadata;
|
||||
}
|
||||
|
||||
public Map<String, EnhancerSubmissionLookup> getEnhancedMetadata() {
|
||||
return enhancedMetadata;
|
||||
}
|
||||
|
||||
public void setProviders(List<SubmissionLookupProvider> providers) {
|
||||
this.providers = providers;
|
||||
this.idents2provs = new HashMap<String, List<SubmissionLookupProvider>>();
|
||||
this.searchProviders = new ArrayList<SubmissionLookupProvider>();
|
||||
|
||||
if (providers != null) {
|
||||
for (SubmissionLookupProvider p : providers) {
|
||||
if (p.isSearchProvider()) {
|
||||
searchProviders.add(p);
|
||||
}
|
||||
List<String> suppIdentifiers = p.getSupportedIdentifiers();
|
||||
if (suppIdentifiers != null) {
|
||||
for (String ident : suppIdentifiers) {
|
||||
List<SubmissionLookupProvider> tmp = idents2provs
|
||||
.get(ident);
|
||||
if (tmp == null) {
|
||||
tmp = new ArrayList<SubmissionLookupProvider>();
|
||||
idents2provs.put(ident, tmp);
|
||||
}
|
||||
tmp.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getIdentifiers() {
|
||||
List<String> identifiers = new ArrayList<String>();
|
||||
identifiers.add("doi");
|
||||
identifiers.add("pubmed");
|
||||
identifiers.add("arxiv");
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
public Map<String, List<SubmissionLookupProvider>> getProvidersIdentifiersMap() {
|
||||
return idents2provs;
|
||||
}
|
||||
|
||||
public void merge(String formName, Item item, ItemSubmissionLookupDTO dto) {
|
||||
init();
|
||||
SubmissionLookupPublication lookupPub = dto
|
||||
.getTotalPublication(providers);
|
||||
EnhancedSubmissionLookupPublication itemLookup = new EnhancedSubmissionLookupPublication(
|
||||
enhancedMetadata, lookupPub);
|
||||
Set<String> addedMetadata = new HashSet<String>();
|
||||
for (String field : itemLookup.getFields()) {
|
||||
String metadata = getMetadata(formName, itemLookup, field);
|
||||
if (StringUtils.isBlank(metadata)) {
|
||||
continue;
|
||||
}
|
||||
if (item.getMetadata(metadata).length == 0
|
||||
|| addedMetadata.contains(metadata)) {
|
||||
addedMetadata.add(metadata);
|
||||
String[] md = splitMetadata(metadata);
|
||||
if (isValidMetadata(formName, md)) {
|
||||
if (isRepeatableMetadata(formName, md)) {
|
||||
for (String value : itemLookup.getValues(field)) {
|
||||
String[] splitValue = splitValue(value);
|
||||
if (splitValue[3] != null) {
|
||||
item.addMetadata(md[0], md[1], md[2], md[3],
|
||||
splitValue[0], splitValue[1],
|
||||
Integer.parseInt(splitValue[2]));
|
||||
} else {
|
||||
item.addMetadata(md[0], md[1], md[2], md[3],
|
||||
value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String value = itemLookup.getFirstValue(field);
|
||||
String[] splitValue = splitValue(value);
|
||||
if (splitValue[3] != null) {
|
||||
item.addMetadata(md[0], md[1], md[2], md[3],
|
||||
splitValue[0], splitValue[1],
|
||||
Integer.parseInt(splitValue[2]));
|
||||
} else {
|
||||
item.addMetadata(md[0], md[1], md[2], md[3], value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// creo un nuovo context per il check di esistenza dei metadata di cache
|
||||
Context context = null;
|
||||
try {
|
||||
context = new Context();
|
||||
for (SubmissionLookupPublication pub : dto.getPublications()) {
|
||||
String providerName = pub.getProviderName();
|
||||
if (providerName != MANUAL_USER_INPUT) {
|
||||
for (String field : pub.getFields()) {
|
||||
String metadata = getMetadata(formName, pub, field);
|
||||
if (StringUtils.isBlank(metadata)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] md = splitMetadata(metadata);
|
||||
if (isValidMetadata(formName, md)) {
|
||||
makeSureMetadataExist(context, providerName, md[1],
|
||||
md[2]);
|
||||
if (isRepeatableMetadata(formName, md)) {
|
||||
for (String value : pub.getValues(field)) {
|
||||
String[] splitValue = splitValue(value);
|
||||
item.addMetadata(providerName, md[1],
|
||||
md[2], md[3], splitValue[0],
|
||||
splitValue[1],
|
||||
Integer.parseInt(splitValue[2]));
|
||||
}
|
||||
} else {
|
||||
String[] splitValue = splitValue(pub
|
||||
.getFirstValue(field));
|
||||
item.addMetadata(providerName, md[1], md[2],
|
||||
md[3], splitValue[0], splitValue[1],
|
||||
Integer.parseInt(splitValue[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
} finally {
|
||||
if (context != null && context.isValid()) {
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeSureMetadataExist(Context context, String schema,
|
||||
String element, String qualifier) {
|
||||
try {
|
||||
context.turnOffAuthorisationSystem();
|
||||
boolean create = false;
|
||||
MetadataSchema mdschema = MetadataSchema.find(context, schema);
|
||||
MetadataField mdfield = null;
|
||||
if (mdschema == null) {
|
||||
mdschema = new MetadataSchema(SL_NAMESPACE_PREFIX + schema,
|
||||
schema);
|
||||
mdschema.create(context);
|
||||
create = true;
|
||||
} else {
|
||||
mdfield = MetadataField.findByElement(context,
|
||||
mdschema.getSchemaID(), element, qualifier);
|
||||
}
|
||||
|
||||
if (mdfield == null) {
|
||||
mdfield = new MetadataField(mdschema, element, qualifier,
|
||||
"Campo utilizzato per la cache del provider submission-lookup: "
|
||||
+ schema);
|
||||
mdfield.create(context);
|
||||
create = true;
|
||||
}
|
||||
if (create) {
|
||||
context.commit();
|
||||
}
|
||||
context.restoreAuthSystemState();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRepeatableMetadata(String formName, String[] md) {
|
||||
try {
|
||||
DCInput dcinput = getDCInput(formName, md[0], md[1], md[2]);
|
||||
if (dcinput != null) {
|
||||
return dcinput.isRepeatable();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isValidMetadata(String formName, String[] md) {
|
||||
try {
|
||||
if (extraMetadataToKeep != null
|
||||
&& extraMetadataToKeep.contains(StringUtils.join(
|
||||
Arrays.copyOfRange(md, 0, 3), "."))) {
|
||||
return true;
|
||||
}
|
||||
return getDCInput(formName, md[0], md[1], md[2])!=null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private DCInput getDCInput(String formName, String schema,
|
||||
String element, String qualifier) throws DCInputsReaderException
|
||||
{
|
||||
DCInputSet dcinputset = new DCInputsReader().getInputs(formName);
|
||||
for (int idx = 0; idx < dcinputset.getNumberPages(); idx++)
|
||||
{
|
||||
for (DCInput dcinput : dcinputset.getPageRows(idx, true, true))
|
||||
{
|
||||
if (dcinput.getSchema().equals(schema)
|
||||
&& dcinput.getElement().equals(element)
|
||||
&& (dcinput.getQualifier() != null && dcinput
|
||||
.getQualifier().equals(qualifier))
|
||||
|| (dcinput.getQualifier() == null && qualifier == null))
|
||||
{
|
||||
return dcinput;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String[] splitValue(String value) {
|
||||
String[] splitted = value.split(SEPARATOR_VALUE_REGEX);
|
||||
String[] result = new String[6];
|
||||
result[0] = splitted[0];
|
||||
result[2] = "-1";
|
||||
result[3] = "-1";
|
||||
result[4] = "-1";
|
||||
if (splitted.length > 1) {
|
||||
result[5] = "splitted";
|
||||
if (StringUtils.isNotBlank(splitted[1])) {
|
||||
result[1] = splitted[1];
|
||||
}
|
||||
if (splitted.length > 2) {
|
||||
result[2] = String.valueOf(Integer.parseInt(splitted[2]));
|
||||
if (splitted.length > 3) {
|
||||
result[3] = String.valueOf(Integer.parseInt(splitted[3]));
|
||||
if (splitted.length > 4) {
|
||||
result[4] = String.valueOf(Integer
|
||||
.parseInt(splitted[4]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String[] splitMetadata(String metadata) {
|
||||
String[] mdSplit = new String[3];
|
||||
if (StringUtils.isNotBlank(metadata)) {
|
||||
String tmpSplit[] = metadata.split("\\.");
|
||||
if (tmpSplit.length == 4) {
|
||||
mdSplit = new String[4];
|
||||
mdSplit[0] = tmpSplit[0];
|
||||
mdSplit[1] = tmpSplit[1];
|
||||
mdSplit[2] = tmpSplit[2];
|
||||
mdSplit[3] = tmpSplit[3];
|
||||
} else if (tmpSplit.length == 3) {
|
||||
mdSplit = new String[4];
|
||||
mdSplit[0] = tmpSplit[0];
|
||||
mdSplit[1] = tmpSplit[1];
|
||||
mdSplit[2] = tmpSplit[2];
|
||||
mdSplit[3] = null;
|
||||
} else if (tmpSplit.length == 2) {
|
||||
mdSplit = new String[4];
|
||||
mdSplit[0] = tmpSplit[0];
|
||||
mdSplit[1] = tmpSplit[1];
|
||||
mdSplit[2] = null;
|
||||
mdSplit[3] = null;
|
||||
}
|
||||
}
|
||||
return mdSplit;
|
||||
}
|
||||
|
||||
private String getMetadata(String formName,
|
||||
SubmissionLookupPublication itemLookup, String name) {
|
||||
String type = itemLookup.getType();
|
||||
String md = configuration.getProperty(
|
||||
type + "." + name,
|
||||
configuration.getProperty(formName + "." + name,
|
||||
configuration.getProperty(name)));
|
||||
if (md != null && md.contains("|")) {
|
||||
String[] cond = md.trim().split("\\|");
|
||||
for (int idx = 1; idx < cond.length; idx++) {
|
||||
boolean temp = itemLookup.getFields().contains(cond[idx]);
|
||||
if (temp) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return cond[0];
|
||||
}
|
||||
return md;
|
||||
}
|
||||
|
||||
public SubmissionLookupDTO getSubmissionLookupDTO(
|
||||
HttpServletRequest request, String uuidSubmission) {
|
||||
SubmissionLookupDTO dto = (SubmissionLookupDTO) request.getSession()
|
||||
.getAttribute("submission_lookup_" + uuidSubmission);
|
||||
if (dto == null) {
|
||||
dto = new SubmissionLookupDTO();
|
||||
storeDTOs(request, uuidSubmission, dto);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
public void invalidateDTOs(HttpServletRequest request, String uuidSubmission) {
|
||||
request.getSession().removeAttribute(
|
||||
"submission_lookup_" + uuidSubmission);
|
||||
}
|
||||
|
||||
public void storeDTOs(HttpServletRequest request, String uuidSubmission,
|
||||
SubmissionLookupDTO dto) {
|
||||
request.getSession().setAttribute(
|
||||
"submission_lookup_" + uuidSubmission, dto);
|
||||
}
|
||||
|
||||
public List<SubmissionLookupProvider> getSearchProviders() {
|
||||
return searchProviders;
|
||||
}
|
||||
|
||||
public List<ItemSubmissionLookupDTO> searchByTerms(Context context,
|
||||
String title, String author, int year) {
|
||||
List<SubmissionLookupPublication> publications = new ArrayList<SubmissionLookupPublication>();
|
||||
List<String> timeoutProviders = new ArrayList<String>();
|
||||
for (SubmissionLookupProvider provider : searchProviders) {
|
||||
List<SubmissionLookupPublication> pPublications = null;
|
||||
try {
|
||||
pPublications = provider.search(context, title, author, year);
|
||||
} catch (SocketTimeoutException st) {
|
||||
timeoutProviders.add(provider.getShortName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (pPublications != null) {
|
||||
publications.addAll(pPublications);
|
||||
}
|
||||
}
|
||||
return buildItemSubmissionLookupDTO(context, publications, true,
|
||||
timeoutProviders);
|
||||
}
|
||||
|
||||
public List<ItemSubmissionLookupDTO> searchByIdentifiers(Context context,
|
||||
Map<String, String> keys) {
|
||||
Set<String> ids = keys.keySet();
|
||||
List<SubmissionLookupPublication> publications = new ArrayList<SubmissionLookupPublication>();
|
||||
List<String> timeoutProviders = new ArrayList<String>();
|
||||
for (SubmissionLookupProvider provider : providers) {
|
||||
for (String id : ids) {
|
||||
if (provider.getSupportedIdentifiers().contains(id)) {
|
||||
List<SubmissionLookupPublication> pPublications = null;
|
||||
try {
|
||||
pPublications = provider.getByIdentifier(context, keys);
|
||||
} catch (SocketTimeoutException st) {
|
||||
timeoutProviders.add(provider.getShortName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (pPublications != null) {
|
||||
publications.addAll(pPublications);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return buildItemSubmissionLookupDTO(context, publications,
|
||||
!ids.contains(SubmissionLookupProvider.DOI), timeoutProviders);
|
||||
}
|
||||
|
||||
private List<ItemSubmissionLookupDTO> buildItemSubmissionLookupDTO(
|
||||
Context context, List<SubmissionLookupPublication> publications,
|
||||
boolean extend, List<String> evictProviders) {
|
||||
Map<String, List<SubmissionLookupPublication>> doi2publications = new HashMap<String, List<SubmissionLookupPublication>>();
|
||||
Map<String, Set<String>> provider2foundDOIs = new HashMap<String, Set<String>>();
|
||||
List<String> foundDOIs = new ArrayList<String>();
|
||||
List<SubmissionLookupPublication> allPublications = new ArrayList<SubmissionLookupPublication>();
|
||||
allPublications.addAll(publications);
|
||||
|
||||
for (SubmissionLookupPublication publication : publications) {
|
||||
String doi = publication
|
||||
.getFirstValue(SubmissionLookupProvider.DOI);
|
||||
if (doi == null) {
|
||||
doi = NOT_FOUND_DOI;
|
||||
} else {
|
||||
doi = SubmissionLookupUtils.normalizeDOI(doi);
|
||||
if (!foundDOIs.contains(doi))
|
||||
{
|
||||
foundDOIs.add(doi);
|
||||
}
|
||||
Set<String> tmp = provider2foundDOIs.get(publication
|
||||
.getProviderName());
|
||||
if (tmp == null) {
|
||||
tmp = new HashSet<String>();
|
||||
provider2foundDOIs.put(publication.getProviderName(), tmp);
|
||||
}
|
||||
tmp.add(doi);
|
||||
}
|
||||
|
||||
List<SubmissionLookupPublication> tmp = doi2publications.get(doi);
|
||||
if (tmp == null) {
|
||||
tmp = new ArrayList<SubmissionLookupPublication>();
|
||||
doi2publications.put(doi, tmp);
|
||||
}
|
||||
tmp.add(publication);
|
||||
}
|
||||
|
||||
if (extend) {
|
||||
for (SubmissionLookupProvider provider : idents2provs
|
||||
.get(SubmissionLookupProvider.DOI)) {
|
||||
if (evictProviders != null
|
||||
&& evictProviders.contains(provider.getShortName())) {
|
||||
continue;
|
||||
}
|
||||
Set<String> doiToSearch = new HashSet<String>();
|
||||
Set<String> alreadyFoundDOIs = provider2foundDOIs.get(provider
|
||||
.getShortName());
|
||||
for (String doi : foundDOIs) {
|
||||
if (alreadyFoundDOIs == null
|
||||
|| !alreadyFoundDOIs.contains(doi)) {
|
||||
doiToSearch.add(doi);
|
||||
}
|
||||
}
|
||||
List<SubmissionLookupPublication> pPublications = null;
|
||||
try {
|
||||
if (doiToSearch.size() > 0) {
|
||||
pPublications = provider
|
||||
.getByDOIs(context, doiToSearch);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (pPublications != null) {
|
||||
allPublications.addAll(pPublications);
|
||||
for (SubmissionLookupPublication publication : pPublications) {
|
||||
String doi = publication
|
||||
.getFirstValue(SubmissionLookupProvider.DOI);
|
||||
List<SubmissionLookupPublication> tmp = doi2publications
|
||||
.get(doi);
|
||||
if (tmp == null) {
|
||||
tmp = new ArrayList<SubmissionLookupPublication>();
|
||||
doi2publications.put(doi, tmp);
|
||||
}
|
||||
tmp.add(publication);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemSubmissionLookupDTO> result = new ArrayList<ItemSubmissionLookupDTO>();
|
||||
|
||||
for (String doi : foundDOIs) {
|
||||
ItemSubmissionLookupDTO dto = new ItemSubmissionLookupDTO(
|
||||
doi2publications.get(doi));
|
||||
result.add(dto);
|
||||
}
|
||||
|
||||
List<SubmissionLookupPublication> noDOIs = doi2publications
|
||||
.get(NOT_FOUND_DOI);
|
||||
if (noDOIs != null) {
|
||||
for (SubmissionLookupPublication p : noDOIs) {
|
||||
List<SubmissionLookupPublication> single = new ArrayList<SubmissionLookupPublication>();
|
||||
single.add(p);
|
||||
ItemSubmissionLookupDTO dto = new ItemSubmissionLookupDTO(
|
||||
single);
|
||||
result.add(dto);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<SubmissionLookupProvider> getProviders() {
|
||||
return providers;
|
||||
}
|
||||
}
|
@@ -0,0 +1,217 @@
|
||||
package org.dspace.submit.lookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.DCValue;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.crosswalk.IConverter;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.PluginManager;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
|
||||
public class SubmissionLookupUtils {
|
||||
private static Logger log = Logger.getLogger(SubmissionLookupUtils.class);
|
||||
|
||||
/** Location of config file */
|
||||
private static final String configFilePath = ConfigurationManager
|
||||
.getProperty("dspace.dir")
|
||||
+ File.separator
|
||||
+ "config"
|
||||
+ File.separator + "crosswalks" + File.separator;
|
||||
|
||||
private static final Map<String, Properties> importerProps = new HashMap<String, Properties>();
|
||||
|
||||
// Patter to extract the converter name if any
|
||||
private static final Pattern converterPattern = Pattern
|
||||
.compile(".*\\((.*)\\)");
|
||||
|
||||
public static LookupProvidersCheck getProvidersCheck(Context context,
|
||||
Item item, String dcSchema, String dcElement, String dcQualifier) {
|
||||
try {
|
||||
LookupProvidersCheck check = new LookupProvidersCheck();
|
||||
MetadataSchema[] schemas = MetadataSchema.findAll(context);
|
||||
DCValue[] values = item.getMetadata(dcSchema, dcElement, dcQualifier, Item.ANY);
|
||||
|
||||
for (MetadataSchema schema : schemas)
|
||||
{
|
||||
boolean error = false;
|
||||
if (schema.getNamespace().startsWith(SubmissionLookupService.SL_NAMESPACE_PREFIX))
|
||||
{
|
||||
DCValue[] slCache = item.getMetadata(schema.getName(), dcElement, dcQualifier, Item.ANY);
|
||||
if (slCache.length == 0)
|
||||
continue;
|
||||
|
||||
if (slCache.length != values.length)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int idx = 0; idx < values.length; idx++)
|
||||
{
|
||||
DCValue v = values[idx];
|
||||
DCValue sl = slCache[idx];
|
||||
// FIXME gestire authority e possibilita' multiple:
|
||||
// match non sicuri, affiliation, etc.
|
||||
if (!v.value.equals(sl.value))
|
||||
{
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
check.getProvidersErr().add(schema.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
check.getProvidersOk().add(schema.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return check;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static SubmissionLookupPublication convert(String shortName,
|
||||
Object bean) throws SecurityException, NoSuchMethodException,
|
||||
IllegalArgumentException, IllegalAccessException,
|
||||
InvocationTargetException {
|
||||
SubmissionLookupPublication publication = new SubmissionLookupPublication(
|
||||
shortName);
|
||||
Field[] fields = bean.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getType() == String.class) {
|
||||
Method getter = bean.getClass().getMethod(
|
||||
"get" + field.getName().substring(0, 1).toUpperCase()
|
||||
+ field.getName().substring(1));
|
||||
|
||||
String value = (String) getter.invoke(bean);
|
||||
|
||||
addMetadata(shortName, publication, field.getName(), value);
|
||||
|
||||
} else if (field.getType() == List.class) {
|
||||
ParameterizedType pt = (ParameterizedType) field
|
||||
.getGenericType();
|
||||
|
||||
Method getter = bean.getClass().getMethod(
|
||||
"get" + field.getName().substring(0, 1).toUpperCase()
|
||||
+ field.getName().substring(1));
|
||||
|
||||
if (pt.getActualTypeArguments()[0] instanceof GenericArrayType) { // nomi
|
||||
// di
|
||||
// persone
|
||||
List<String[]> values = (List<String[]>) getter
|
||||
.invoke(bean);
|
||||
if (values != null) {
|
||||
for (String[] nvalue : values) {
|
||||
String value = nvalue[1] + ", " + nvalue[0];
|
||||
addMetadata(shortName, publication,
|
||||
field.getName(), value);
|
||||
}
|
||||
}
|
||||
} else { // metadati ripetibili
|
||||
List<String> values = (List<String>) getter.invoke(bean);
|
||||
if (values != null) {
|
||||
for (String value : values) {
|
||||
addMetadata(shortName, publication,
|
||||
field.getName(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return publication;
|
||||
}
|
||||
|
||||
private static void addMetadata(String config,
|
||||
SubmissionLookupPublication publication, String name, String value) {
|
||||
String md = getSubmissionLoookupConfiguration(config).getProperty(name);
|
||||
|
||||
if (StringUtils.isBlank(md)) {
|
||||
return;
|
||||
} else {
|
||||
md = md.trim();
|
||||
}
|
||||
|
||||
Matcher converterMatcher = converterPattern.matcher(md);
|
||||
String converterName = null;
|
||||
if (converterMatcher.matches()) {
|
||||
converterName = converterMatcher.group(1);
|
||||
md = md.replaceAll("\\(" + converterName + "\\)", "");
|
||||
}
|
||||
IConverter converter = (IConverter) PluginManager.getNamedPlugin(
|
||||
IConverter.class, converterName);
|
||||
|
||||
String nValue;
|
||||
if (converter != null) {
|
||||
nValue = converter.makeConversion(value);
|
||||
} else {
|
||||
nValue = value;
|
||||
}
|
||||
publication.add(md, nValue);
|
||||
}
|
||||
|
||||
private static synchronized Properties getSubmissionLoookupConfiguration(
|
||||
String config) {
|
||||
Properties properties = importerProps.get(config);
|
||||
if (properties != null) {
|
||||
return properties;
|
||||
}
|
||||
// Read in configuration
|
||||
properties = new Properties();
|
||||
importerProps.put(config, properties);
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(configFilePath + config
|
||||
+ "-submission.properties");
|
||||
properties.load(fis);
|
||||
} catch (Exception notfound) {
|
||||
throw new IllegalArgumentException(
|
||||
"Impossibile leggere la configurazione per il SubmissionLookupProvider "
|
||||
+ config, notfound);
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException ioe) {
|
||||
log.error(ioe.getMessage(), ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static String normalizeDOI(String doi) {
|
||||
if (doi != null)
|
||||
{
|
||||
return doi.trim().replaceAll("^http://dx.doi.org/", "")
|
||||
.replaceAll("^doi:", "");
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* SelectCollectionStep.java
|
||||
*
|
||||
* Version: $Revision: 3738 $
|
||||
*
|
||||
* Date: $Date: 2009-04-24 06:32:12 +0200 (ven, 24 apr 2009) $
|
||||
*
|
||||
* Copyright (c) 2002-2009, The DSpace Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the DSpace Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
import org.dspace.submit.lookup.SubmissionLookupService;
|
||||
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
||||
import org.dspace.submit.util.SubmissionLookupDTO;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
/**
|
||||
* SelectCollection Step which processes the collection that the user selected
|
||||
* in that step of the DSpace Submission process
|
||||
* <P>
|
||||
* This class performs all the behind-the-scenes processing that
|
||||
* this particular step requires. This class's methods are utilized
|
||||
* by both the JSP-UI and the Manakin XML-UI
|
||||
*
|
||||
* @see org.dspace.app.util.SubmissionConfig
|
||||
* @see org.dspace.app.util.SubmissionStepConfig
|
||||
* @see org.dspace.submit.AbstractProcessingStep
|
||||
*
|
||||
* @author Tim Donohue
|
||||
* @version $Revision: 3738 $
|
||||
*/
|
||||
public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
{
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
*
|
||||
* (Do NOT use status of 0, since it corresponds to STATUS_COMPLETE flag
|
||||
* defined in the JSPStepManager class)
|
||||
**************************************************************************/
|
||||
// no collection was selected
|
||||
public static final int STATUS_NO_COLLECTION = 1;
|
||||
|
||||
// invalid collection or error finding collection
|
||||
public static final int STATUS_INVALID_COLLECTION = 2;
|
||||
|
||||
public static final int STATUS_NO_SUUID = 3;
|
||||
|
||||
public static final int STATUS_SUBMISSION_EXPIRED = 4;
|
||||
|
||||
private SubmissionLookupService slService = new DSpace()
|
||||
.getServiceManager().getServiceByName(
|
||||
SubmissionLookupService.class.getCanonicalName(),
|
||||
SubmissionLookupService.class);
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(StartSubmissionLookupStep.class);
|
||||
|
||||
/**
|
||||
* Do any processing of the information input by the user, and/or perform
|
||||
* step processing (if no user interaction required)
|
||||
* <P>
|
||||
* It is this method's job to save any data to the underlying database, as
|
||||
* necessary, and return error messages (if any) which can then be processed
|
||||
* by the appropriate user interface (JSP-UI or XML-UI)
|
||||
* <P>
|
||||
* NOTE: If this step is a non-interactive step (i.e. requires no UI), then
|
||||
* it should perform *all* of its processing in this method!
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @return Status or error flag which will be processed by
|
||||
* doPostProcessing() below! (if STATUS_COMPLETE or 0 is returned,
|
||||
* no errors occurred!)
|
||||
*/
|
||||
public int doProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// First we find the collection which was selected
|
||||
int id = Util.getIntParameter(request, "collectionid");
|
||||
String titolo = request.getParameter("search_title");
|
||||
String date = request.getParameter("search_year");
|
||||
String autori = request.getParameter("search_authors");
|
||||
String uuidSubmission = request.getParameter("suuid");
|
||||
String uuidLookup = request.getParameter("iuuid");
|
||||
|
||||
if (StringUtils.isBlank(uuidSubmission))
|
||||
{
|
||||
return STATUS_NO_SUUID;
|
||||
}
|
||||
|
||||
SubmissionLookupDTO submissionDTO = slService.getSubmissionLookupDTO(
|
||||
request, uuidSubmission);
|
||||
|
||||
if (submissionDTO == null)
|
||||
{
|
||||
return STATUS_SUBMISSION_EXPIRED;
|
||||
}
|
||||
|
||||
ItemSubmissionLookupDTO itemLookup = null;
|
||||
if (StringUtils.isNotBlank(uuidLookup))
|
||||
{
|
||||
itemLookup = submissionDTO.getLookupItem(uuidLookup);
|
||||
if (itemLookup == null)
|
||||
{
|
||||
return STATUS_SUBMISSION_EXPIRED;
|
||||
}
|
||||
}
|
||||
// if the user didn't select a collection,
|
||||
// send him/her back to "select a collection" page
|
||||
if (id < 0)
|
||||
{
|
||||
return STATUS_NO_COLLECTION;
|
||||
}
|
||||
|
||||
// try to load the collection
|
||||
Collection col = Collection.find(context, id);
|
||||
|
||||
// Show an error if the collection is invalid
|
||||
if (col == null)
|
||||
{
|
||||
return STATUS_INVALID_COLLECTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
// create our new Workspace Item
|
||||
WorkspaceItem wi = WorkspaceItem.create(context, col, true);
|
||||
DCInputSet inputSet = null;
|
||||
try {
|
||||
inputSet = new DCInputsReader().getInputs(col.getHandle());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (itemLookup != null)
|
||||
{
|
||||
slService.merge(inputSet.getFormName(), wi.getItem(),
|
||||
itemLookup);
|
||||
}
|
||||
else
|
||||
{
|
||||
SubmissionLookupPublication manualPub = new SubmissionLookupPublication(
|
||||
SubmissionLookupService.MANUAL_USER_INPUT);
|
||||
manualPub.add("title", titolo);
|
||||
manualPub.add("year", date);
|
||||
manualPub.add("allauthors", autori);
|
||||
|
||||
Enumeration e = request.getParameterNames();
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
String parameterName = (String) e.nextElement();
|
||||
String parameterValue = request.getParameter(parameterName);
|
||||
|
||||
if (parameterName.startsWith("identifier_")
|
||||
&& StringUtils.isNotBlank(parameterValue)) {
|
||||
manualPub.add(
|
||||
parameterName.substring("identifier_".length()),
|
||||
parameterValue);
|
||||
}
|
||||
}
|
||||
List<SubmissionLookupPublication> publications = new ArrayList<SubmissionLookupPublication>();
|
||||
publications.add(manualPub);
|
||||
ItemSubmissionLookupDTO dto = new ItemSubmissionLookupDTO(publications);
|
||||
slService.merge(inputSet.getFormName(), wi.getItem(), dto);
|
||||
}
|
||||
|
||||
// update Submission Information with this Workspace Item
|
||||
subInfo.setSubmissionItem(wi);
|
||||
|
||||
// commit changes to database
|
||||
context.commit();
|
||||
|
||||
// need to reload current submission process config,
|
||||
// since it is based on the Collection selected
|
||||
subInfo.reloadSubmissionConfig(request);
|
||||
}
|
||||
|
||||
slService.invalidateDTOs(request, uuidSubmission);
|
||||
// no errors occurred
|
||||
return STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the number of pages that this "step" extends over. This method
|
||||
* is used to build the progress bar.
|
||||
* <P>
|
||||
* This method may just return 1 for most steps (since most steps consist of
|
||||
* a single page). But, it should return a number greater than 1 for any
|
||||
* "step" which spans across a number of HTML pages. For example, the
|
||||
* configurable "Describe" step (configured using input-forms.xml) overrides
|
||||
* this method to return the number of pages that are defined by its
|
||||
* configuration file.
|
||||
* <P>
|
||||
* Steps which are non-interactive (i.e. they do not display an interface to
|
||||
* the user) should return a value of 1, so that they are only processed
|
||||
* once!
|
||||
*
|
||||
* @param request
|
||||
* The HTTP Request
|
||||
* @param subInfo
|
||||
* The current submission information object
|
||||
*
|
||||
* @return the number of pages in this step
|
||||
*/
|
||||
public int getNumberOfPages(HttpServletRequest request,
|
||||
SubmissionInfo subInfo) throws ServletException
|
||||
{
|
||||
// there is always just one page in the "select a collection" step!
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package org.dspace.submit.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.dspace.submit.lookup.EnhancerSubmissionLookup;
|
||||
|
||||
public class EnhancedSubmissionLookupPublication extends SubmissionLookupPublication {
|
||||
private SubmissionLookupPublication lookupPublication;
|
||||
private Map<String, EnhancerSubmissionLookup> enhancedMetadata;
|
||||
|
||||
private Map<String, List<String>> cacheEnhanched = new HashMap<String, List<String>>();
|
||||
|
||||
public EnhancedSubmissionLookupPublication(Map<String, EnhancerSubmissionLookup> enhancedMetadata, SubmissionLookupPublication pub) {
|
||||
super(pub.getProviderName());
|
||||
this.lookupPublication = pub;
|
||||
this.enhancedMetadata = enhancedMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFields() {
|
||||
Set<String> eFields = new HashSet<String>();
|
||||
if (lookupPublication.getFields() != null)
|
||||
{
|
||||
for (String s : lookupPublication.getFields())
|
||||
{
|
||||
eFields.add(s);
|
||||
}
|
||||
}
|
||||
if (enhancedMetadata != null)
|
||||
{
|
||||
for (String s : enhancedMetadata.keySet())
|
||||
{
|
||||
if (getValues(s) != null)
|
||||
{
|
||||
eFields.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return eFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFirstValue(String md) {
|
||||
List<String> values = getValues(md);
|
||||
if (values != null && values.size() > 0)
|
||||
{
|
||||
return values.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getValues(String md) {
|
||||
if (enhancedMetadata != null && enhancedMetadata.keySet().contains(md))
|
||||
{
|
||||
if (cacheEnhanched != null && cacheEnhanched.keySet().contains(md))
|
||||
{
|
||||
return cacheEnhanched.get(md);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnhancerSubmissionLookup enhancer = enhancedMetadata.get(md);
|
||||
List<String> values = enhancer.getValues(this);
|
||||
cacheEnhanched.put(md, values);
|
||||
return values;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return lookupPublication.getValues(md);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
package org.dspace.submit.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.dspace.submit.lookup.SubmissionLookupProvider;
|
||||
|
||||
public class ItemSubmissionLookupDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private static final String MERGED_PUBLICATION_PROVIDER = "merged";
|
||||
|
||||
private List<SubmissionLookupPublication> publications;
|
||||
private String uuid;
|
||||
|
||||
public ItemSubmissionLookupDTO(List<SubmissionLookupPublication> publications) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.publications = publications;
|
||||
}
|
||||
|
||||
public List<SubmissionLookupPublication> getPublications() {
|
||||
return publications;
|
||||
}
|
||||
|
||||
public Set<String> getProviders() {
|
||||
Set<String> orderedProviders = new LinkedHashSet<String>();
|
||||
for (SubmissionLookupPublication p : publications)
|
||||
{
|
||||
orderedProviders.add(p.getProviderName());
|
||||
}
|
||||
return orderedProviders;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public SubmissionLookupPublication getTotalPublication(
|
||||
List<SubmissionLookupProvider> providers) {
|
||||
if (publications == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (publications.size() == 1)
|
||||
{
|
||||
return publications.get(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SubmissionLookupPublication pub = new SubmissionLookupPublication(
|
||||
MERGED_PUBLICATION_PROVIDER);
|
||||
for (SubmissionLookupProvider prov : providers)
|
||||
{
|
||||
for (SubmissionLookupPublication p : publications)
|
||||
{
|
||||
if (!p.getProviderName().equals(prov.getShortName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String field : p.getFields())
|
||||
{
|
||||
List<String> values = p.getValues(field);
|
||||
if (values != null && values.size() > 0)
|
||||
{
|
||||
if (!pub.getFields().contains(field))
|
||||
{
|
||||
for (String v : values)
|
||||
{
|
||||
pub.add(field, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return pub;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
package org.dspace.submit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.submit.lookup.EnhancerSubmissionLookup;
|
||||
|
||||
public class RepeatableToSingleValueEnhancer implements
|
||||
EnhancerSubmissionLookup {
|
||||
private String separator = ",";
|
||||
private boolean separatorWhitespaceAfter = true;
|
||||
private List<String> singleValues;
|
||||
|
||||
@Override
|
||||
public List<String> getValues(SubmissionLookupPublication publication) {
|
||||
List<String> values = new ArrayList<String>();
|
||||
for (String s : singleValues) {
|
||||
if (publication.getValues(s) != null) {
|
||||
values.addAll(publication.getValues(s));
|
||||
}
|
||||
}
|
||||
if (values.size() > 0) {
|
||||
String v = StringUtils.join(values.iterator(), separator
|
||||
+ (separatorWhitespaceAfter ? " " : ""));
|
||||
List<String> res = new ArrayList<String>();
|
||||
res.add(v);
|
||||
return res;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
if ("\\n".equals(separator))
|
||||
{
|
||||
this.separator = "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.separator = separator;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSeparatorWhitespaceAfter() {
|
||||
return separatorWhitespaceAfter;
|
||||
}
|
||||
|
||||
public void setSeparatorWhitespaceAfter(boolean separatorWhitespaceAfter) {
|
||||
this.separatorWhitespaceAfter = separatorWhitespaceAfter;
|
||||
}
|
||||
|
||||
public List<String> getSingleValues() {
|
||||
return singleValues;
|
||||
}
|
||||
|
||||
public void setSingleValues(List<String> singleValues) {
|
||||
this.singleValues = singleValues;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package org.dspace.submit.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SubmissionLookupDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private List<ItemSubmissionLookupDTO> items;
|
||||
|
||||
public SubmissionLookupDTO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public void setItems(List<ItemSubmissionLookupDTO> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public ItemSubmissionLookupDTO getLookupItem(String uuidLookup) {
|
||||
if (items != null)
|
||||
{
|
||||
for (ItemSubmissionLookupDTO item : items)
|
||||
{
|
||||
if (item.getUUID().equals(uuidLookup))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package org.dspace.submit.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.submit.lookup.SubmissionLookupProvider;
|
||||
|
||||
public class SubmissionLookupPublication implements Serializable {
|
||||
private String providerName;
|
||||
|
||||
private Map<String, List<String>> storage = new HashMap<String, List<String>>();
|
||||
|
||||
public SubmissionLookupPublication(String providerName) {
|
||||
this.providerName = providerName;
|
||||
}
|
||||
|
||||
// necessario per poter effettuare la serializzazione in JSON dei dati
|
||||
public Map<String, List<String>> getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
public Set<String> getFields() {
|
||||
return storage.keySet();
|
||||
}
|
||||
|
||||
public List<String> remove(String md) {
|
||||
return storage.remove(md);
|
||||
}
|
||||
|
||||
public void add(String md, String nValue) {
|
||||
if (StringUtils.isNotBlank(nValue))
|
||||
{
|
||||
List<String> tmp = storage.get(md);
|
||||
if (tmp == null) {
|
||||
tmp = new ArrayList<String>();
|
||||
storage.put(md, tmp);
|
||||
}
|
||||
tmp.add(nValue);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFirstValue(String md) {
|
||||
List<String> tmp = storage.get(md);
|
||||
if (tmp == null || tmp.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return tmp.get(0);
|
||||
}
|
||||
|
||||
public List<String> getValues(String md) {
|
||||
return storage.get(md);
|
||||
}
|
||||
|
||||
public String getProviderName() {
|
||||
return providerName;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return getFirstValue(SubmissionLookupProvider.TYPE);
|
||||
}
|
||||
}
|
@@ -1676,3 +1676,33 @@ jsp.layout.navbar-admin.accesscontrol = Access Control
|
||||
jsp.layout.navbar-admin.contents = Content
|
||||
jsp.layout.navbar-admin.items = Items
|
||||
jsp.layout.navbar-admin.settings = General Settings
|
||||
|
||||
jsp.submit.start-lookup-submission.title = Nuova proposta di immissione
|
||||
jsp.submit.start-lookup-submission.heading = Nuova proposta di immissione: recupera i dati da database bibliografici
|
||||
jsp.submit.start-lookup-submission.tabs.search = Form di ricerca
|
||||
jsp.submit.start-lookup-submission.tabs.result = Risultati
|
||||
jsp.submit.start-lookup-submission.identifiers = Ricerca per identificativo
|
||||
|
||||
jsp.submit.start-lookup-submission.identifiers.hints = Inserisci gli identificativi della pubblicazione, generalmente è sufficiente digitare un unico identificativo preferibilmente il DOI.
|
||||
jsp.submit.start-lookup-submission.identifier-doi = DOI (Digital Object Identifier)
|
||||
jsp.submit.start-lookup-submission.identifier-doi.hint = es. 10.1392/dironix
|
||||
jsp.submit.start-lookup-submission.identifier-pubmed = PubMed ID
|
||||
jsp.submit.start-lookup-submission.identifier-pubmed.hint = es. 20524090
|
||||
jsp.submit.start-lookup-submission.identifier-arxiv = arXiv ID
|
||||
jsp.submit.start-lookup-submission.identifier-arxiv.hint = es. arXiv:1302.1497
|
||||
jsp.submit.start-lookup-submission.search = Ricerca libera
|
||||
|
||||
jsp.submit.start-lookup-submission.search.hints = Insert base info about publication: either <b>title or the couple author / year</b> is required.<br/>If you known an unique identifier about publication like <b>DOI, Pubmed, arXiv</b> you can switch on the <span id="link-ricerca-identificatore">identifier search mode</span>.
|
||||
jsp.submit.start-lookup-submission.search.title = Title
|
||||
jsp.submit.start-lookup-submission.search.year = Year
|
||||
jsp.submit.start-lookup-submission.search.authors = Authors/Publishers
|
||||
jsp.submit.start-lookup-submission.identifier.lookup = Search
|
||||
jsp.submit.start-lookup-submission.search-go = Search
|
||||
jsp.submit.start-lookup-submission.exit = Exit
|
||||
jsp.submit.start-lookup-submission.search-loading.title = Loading...
|
||||
jsp.submit.start-lookup-submission.search-loading.hint = We are contact the external service to retrieve the publication if you desire. Waiting the complete request, if you close this windows the request abort.
|
||||
jsp.submit.edit-metadata.affiliation.select = Multiple possible matches, please select
|
||||
jsp.submit.edit-metadata.affiliation.other = Other
|
||||
jsp.submit.start-lookup-submission.no-collection-warn.title = Warning, no collection
|
||||
jsp.submit.start-lookup-submission.no-collection-warn.hint = The collection of the pubblication is required.
|
||||
jsp.submit.start-lookup-submission.manual-submission = Default mode Submission
|
||||
|
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||
|
||||
<bean class="org.dspace.submit.lookup.SubmissionLookupService"
|
||||
name="org.dspace.submit.lookup.SubmissionLookupService">
|
||||
<property name="providers">
|
||||
<list>
|
||||
<!-- <ref bean="scopusLookupProvider" /> -->
|
||||
<ref bean="pubmedLookupProvider" />
|
||||
<ref bean="crossrefLookupProvider" />
|
||||
<ref bean="arxivLookupProvider" />
|
||||
</list>
|
||||
</property>
|
||||
<property name="extraMetadataToKeep">
|
||||
<list>
|
||||
<value>dc.import.contributorauthor</value>
|
||||
<value>dc.import.contributoreditor</value>
|
||||
<value>dc.import.contributortranslator</value>
|
||||
<!-- <value>dc.description.scopusurl</value>
|
||||
<value>dc.description.scopuscitationcount</value>
|
||||
<value>dc.description.scopuscitationurl</value>-->
|
||||
</list>
|
||||
</property>
|
||||
<property name="enhancedMetadata">
|
||||
<map>
|
||||
<entry key="allauthors">
|
||||
<bean class="org.dspace.submit.util.RepeatableToSingleValueEnhancer">
|
||||
<property name="separator" value="\n" />
|
||||
<property name="separatorWhitespaceAfter" value="false" />
|
||||
<property name="singleValues">
|
||||
<list>
|
||||
<value>authors</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</entry>
|
||||
<entry key="allkeywords">
|
||||
<bean class="org.dspace.submit.util.RepeatableToSingleValueEnhancer">
|
||||
<property name="separator" value=";" />
|
||||
<property name="singleValues">
|
||||
<list>
|
||||
<value>keywords</value>
|
||||
<value>mesh</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean class="org.dspace.submit.lookup.PubmedService" name="pubmedService" />
|
||||
<bean class="org.dspace.submit.lookup.PubmedLookupProvider"
|
||||
name="pubmedLookupProvider">
|
||||
<property name="pubmedService" ref="pubmedService" />
|
||||
<property name="searchProvider" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.dspace.submit.lookup.ArXivService" name="arXivService" />
|
||||
<bean class="org.dspace.submit.lookup.ArXivLookupProvider"
|
||||
name="arxivLookupProvider">
|
||||
<property name="arXivService" ref="arXivService" />
|
||||
<property name="searchProvider" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.dspace.submit.lookup.CrossRefService" name="crossrefService" />
|
||||
<bean class="org.dspace.submit.lookup.CrossRefLookupProvider"
|
||||
name="crossrefLookupProvider">
|
||||
<property name="crossrefService" ref="crossrefService" />
|
||||
<property name="searchProvider" value="false" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -130,7 +130,6 @@
|
||||
<dependency>
|
||||
<groupId>net.sf.flexjson</groupId>
|
||||
<artifactId>flexjson</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@@ -0,0 +1,154 @@
|
||||
package org.dspace.app.webui.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.submit.lookup.SubmissionLookupService;
|
||||
import org.dspace.submit.util.ItemSubmissionLookupDTO;
|
||||
import org.dspace.submit.util.SubmissionLookupDTO;
|
||||
import org.dspace.submit.util.SubmissionLookupPublication;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
import flexjson.JSONSerializer;
|
||||
|
||||
public class SubmissionLookupJSONRequest extends JSONRequest {
|
||||
|
||||
private SubmissionLookupService service = new DSpace().getServiceManager()
|
||||
.getServiceByName(SubmissionLookupService.class.getName(),
|
||||
SubmissionLookupService.class);
|
||||
|
||||
private static Logger log = Logger
|
||||
.getLogger(SubmissionLookupJSONRequest.class);
|
||||
|
||||
@Override
|
||||
public void doJSONRequest(Context context, HttpServletRequest req,
|
||||
HttpServletResponse resp) throws AuthorizeException, IOException
|
||||
{
|
||||
String suuid = req.getParameter("s_uuid");
|
||||
SubmissionLookupDTO subDTO = service.getSubmissionLookupDTO(req, suuid);
|
||||
if ("identifiers".equalsIgnoreCase(req.getParameter("type"))) {
|
||||
Map<String, String> identifiers = new HashMap<String, String>();
|
||||
Enumeration e = req.getParameterNames();
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
String parameterName = (String) e.nextElement();
|
||||
String parameterValue = req.getParameter(parameterName);
|
||||
|
||||
if (parameterName.startsWith("identifier_")
|
||||
&& StringUtils.isNotBlank(parameterValue)) {
|
||||
identifiers.put(
|
||||
parameterName.substring("identifier_".length()),
|
||||
parameterValue);
|
||||
}
|
||||
}
|
||||
|
||||
List<ItemSubmissionLookupDTO> result = service
|
||||
.searchByIdentifiers(context, identifiers);
|
||||
subDTO.setItems(result);
|
||||
service.storeDTOs(req, suuid, subDTO);
|
||||
List<Map<String, Object>> dto = getLightResultList(result);
|
||||
JSONSerializer serializer = new JSONSerializer();
|
||||
serializer.rootName("result");
|
||||
serializer.deepSerialize(dto, resp.getWriter());
|
||||
} else if ("search".equalsIgnoreCase(req.getParameter("type"))) {
|
||||
String title = req.getParameter("title");
|
||||
String author = req.getParameter("authors");
|
||||
int year = UIUtil.getIntParameter(req, "year");
|
||||
|
||||
List<ItemSubmissionLookupDTO> result = service.searchByTerms(context, title,
|
||||
author, year);
|
||||
|
||||
subDTO.setItems(result);
|
||||
service.storeDTOs(req, suuid, subDTO);
|
||||
List<Map<String, Object>> dto = getLightResultList(result);
|
||||
JSONSerializer serializer = new JSONSerializer();
|
||||
serializer.rootName("result");
|
||||
serializer.deepSerialize(dto, resp.getWriter());
|
||||
} else if ("details".equalsIgnoreCase(req.getParameter("type"))) {
|
||||
String i_uuid = req.getParameter("i_uuid");
|
||||
JSONSerializer serializer = new JSONSerializer();
|
||||
serializer.rootName("result");
|
||||
Map<String, Object> dto = getDetails(subDTO.getLookupItem(i_uuid),
|
||||
context);
|
||||
serializer.deepSerialize(dto, resp.getWriter());
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> getDetails(ItemSubmissionLookupDTO item,
|
||||
Context context) {
|
||||
List<String> fieldOrder = getFieldOrderFromConfiguration();
|
||||
SubmissionLookupPublication totalData = item.getTotalPublication(service.getProviders());
|
||||
Set<String> availableFields = totalData.getFields();
|
||||
List<String[]> fieldsLabels = new ArrayList<String[]>();
|
||||
for (String f : fieldOrder) {
|
||||
if (availableFields.contains(f)) {
|
||||
try {
|
||||
fieldsLabels.add(new String[] {
|
||||
f,
|
||||
I18nUtil.getMessage("jsp.submission-lookup.detail."
|
||||
+ f, context) });
|
||||
} catch (MissingResourceException e) {
|
||||
fieldsLabels.add(new String[] { f, f });
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
String uuid = item.getUUID();
|
||||
SubmissionLookupPublication pub = item.getTotalPublication(service.getProviders());
|
||||
data.put("uuid", uuid);
|
||||
data.put("providers", item.getProviders());
|
||||
data.put("publication", pub);
|
||||
data.put("fieldsLabels", fieldsLabels);
|
||||
return data;
|
||||
}
|
||||
|
||||
private List<String> getFieldOrderFromConfiguration() {
|
||||
String config = ConfigurationManager
|
||||
.getProperty("submission-lookup.detail.fields");
|
||||
if (config == null) {
|
||||
config = "title,authors,editors,years,doi,pmid,eid,arxiv,journal,jissn,jeissn,volume,issue,serie,sissn,seissn,abstract,mesh,keywords,subtype";
|
||||
}
|
||||
List<String> result = new ArrayList<String>();
|
||||
String[] split = config.split(",");
|
||||
for (String s : split) {
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
result.add(s.trim());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getLightResultList(
|
||||
List<ItemSubmissionLookupDTO> result) {
|
||||
List<Map<String, Object>> publications = new ArrayList<Map<String, Object>>();
|
||||
for (ItemSubmissionLookupDTO item : result) {
|
||||
String uuid = item.getUUID();
|
||||
SubmissionLookupPublication pub = item.getTotalPublication(service.getProviders());
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("uuid", uuid);
|
||||
data.put("providers", item.getProviders());
|
||||
data.put("title", pub.getFirstValue("title"));
|
||||
data.put("authors",pub.getValues("authors")!=null?
|
||||
StringUtils.join(pub.getValues("authors").iterator(), ", "):"");
|
||||
data.put("issued", pub.getFirstValue("issued"));
|
||||
publications.add(data);
|
||||
}
|
||||
return publications;
|
||||
}
|
||||
}
|
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* JSPSelectCollectionStep.java
|
||||
*
|
||||
* Version: $Revision$
|
||||
*
|
||||
* Date: $Date$
|
||||
*
|
||||
* Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
|
||||
* Institute of Technology. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Hewlett-Packard Company nor the name of the
|
||||
* Massachusetts Institute of Technology nor the names of their
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package org.dspace.app.webui.submit.step;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.webui.submit.JSPStep;
|
||||
import org.dspace.app.webui.submit.JSPStepManager;
|
||||
import org.dspace.app.webui.util.JSPManager;
|
||||
import org.dspace.app.webui.util.UIUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.AuthorizeManager;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.lookup.SubmissionLookupProvider;
|
||||
import org.dspace.submit.lookup.SubmissionLookupService;
|
||||
import org.dspace.submit.step.StartSubmissionLookupStep;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
/**
|
||||
* Step which controls selecting an item from external database service to auto fill metadata
|
||||
* for DSpace JSP-UI
|
||||
* <P>
|
||||
* This JSPStep class works with the SubmissionController servlet
|
||||
* for the JSP-UI
|
||||
* <P>
|
||||
* The following methods are called in this order:
|
||||
* <ul>
|
||||
* <li>Call doPreProcessing() method</li>
|
||||
* <li>If showJSP() was specified from doPreProcessing(), then the JSP
|
||||
* specified will be displayed</li>
|
||||
* <li>If showJSP() was not specified from doPreProcessing(), then the
|
||||
* doProcessing() method is called an the step completes immediately</li>
|
||||
* <li>Call doProcessing() method on appropriate AbstractProcessingStep after the user returns from the JSP, in order
|
||||
* to process the user input</li>
|
||||
* <li>Call doPostProcessing() method to determine if more user interaction is
|
||||
* required, and if further JSPs need to be called.</li>
|
||||
* <li>If there are more "pages" in this step then, the process begins again
|
||||
* (for the new page).</li>
|
||||
* <li>Once all pages are complete, control is forwarded back to the
|
||||
* SubmissionController, and the next step is called.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see org.dspace.app.webui.servlet.SubmissionController
|
||||
* @see org.dspace.app.webui.submit.JSPStep
|
||||
* @see org.dspace.submit.step.StartSubmissionLookupStep
|
||||
*
|
||||
* @author Andrea Bollini
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class JSPStartSubmissionLookupStep extends JSPStep
|
||||
{
|
||||
/** JSP which displays HTML for this Class * */
|
||||
private static final String START_LOOKUP_JSP = "/submit/start-lookup-submission.jsp";
|
||||
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(JSPStartSubmissionLookupStep.class);
|
||||
|
||||
SubmissionLookupService slService = new DSpace().getServiceManager()
|
||||
.getServiceByName(
|
||||
SubmissionLookupService.class.getCanonicalName(),
|
||||
SubmissionLookupService.class);
|
||||
/**
|
||||
* Do any pre-processing to determine which JSP (if any) is used to generate
|
||||
* the UI for this step. This method should include the gathering and
|
||||
* validating of all data required by the JSP. In addition, if the JSP
|
||||
* requires any variable to passed to it on the Request, this method should
|
||||
* set those variables.
|
||||
* <P>
|
||||
* If this step requires user interaction, then this method must call the
|
||||
* JSP to display, using the "showJSP()" method of the JSPStepManager class.
|
||||
* <P>
|
||||
* If this step doesn't require user interaction OR you are solely using
|
||||
* Manakin for your user interface, then this method may be left EMPTY,
|
||||
* since all step processing should occur in the doProcessing() method.
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*/
|
||||
public void doPreProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
if (request.getAttribute("no.collection") == null
|
||||
|| !(Boolean) request.getAttribute("no.collection"))
|
||||
{
|
||||
request.setAttribute("s_uuid", UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Possible parameters from JSP:
|
||||
*
|
||||
* collection= <collection_id> - a collection that has already been
|
||||
* selected!
|
||||
*
|
||||
* With no parameters, this servlet prepares for display of the Select
|
||||
* Collection JSP.
|
||||
*/
|
||||
String collectionID = request.getParameter("collection");
|
||||
Collection col = null;
|
||||
|
||||
if (collectionID != null)
|
||||
{
|
||||
col = Collection.find(context, Integer.parseInt(collectionID));
|
||||
}
|
||||
|
||||
// if we already have a valid collection, then we can forward directly
|
||||
// to post-processing
|
||||
if (col != null)
|
||||
{
|
||||
log.debug("Select Collection page skipped, since a Collection ID was already found. Collection ID="
|
||||
+ collectionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
// gather info for JSP page
|
||||
Community com = UIUtil.getCommunityLocation(request);
|
||||
|
||||
Collection[] collections;
|
||||
|
||||
if (com != null)
|
||||
{
|
||||
// In a community. Show collections in that community only.
|
||||
collections = Collection.findAuthorized(context, com,
|
||||
Constants.ADD);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show all collections
|
||||
collections = Collection.findAuthorized(context, null,
|
||||
Constants.ADD);
|
||||
}
|
||||
|
||||
// This is a special case, where the user came back to this
|
||||
// page after not selecting a collection. This will display
|
||||
// the "Please select a collection" message to the user
|
||||
if (collectionID != null && Integer.parseInt(collectionID) == -1)
|
||||
{
|
||||
// specify "no collection" error message should be displayed
|
||||
request.setAttribute("no.collection", Boolean.TRUE);
|
||||
}
|
||||
|
||||
// save collections to request for JSP
|
||||
request.setAttribute("collections", collections);
|
||||
|
||||
List<String> identifiers = slService.getIdentifiers();
|
||||
|
||||
Map<String, List<SubmissionLookupProvider>> identifiers2providers = slService
|
||||
.getProvidersIdentifiersMap();
|
||||
List<SubmissionLookupProvider> searchProviders = slService
|
||||
.getSearchProviders();
|
||||
request.setAttribute("identifiers2providers", identifiers2providers);
|
||||
request.setAttribute("searchProviders", searchProviders);
|
||||
request.setAttribute("identifiers", slService.getIdentifiers());
|
||||
// we need to load the select collection JSP
|
||||
JSPStepManager
|
||||
.showJSP(request, response, subInfo, START_LOOKUP_JSP);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do any post-processing after the step's backend processing occurred (in
|
||||
* the doProcessing() method).
|
||||
* <P>
|
||||
* It is this method's job to determine whether processing completed
|
||||
* successfully, or display another JSP informing the users of any potential
|
||||
* problems/errors.
|
||||
* <P>
|
||||
* If this step doesn't require user interaction OR you are solely using
|
||||
* Manakin for your user interface, then this method may be left EMPTY,
|
||||
* since all step processing should occur in the doProcessing() method.
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
* @param status
|
||||
* any status/errors reported by doProcessing() method
|
||||
*/
|
||||
public void doPostProcessing(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo, int status)
|
||||
throws ServletException, IOException, SQLException,
|
||||
AuthorizeException
|
||||
{
|
||||
// if the user didn't select a collection,
|
||||
// send him/her back to "select a collection" page
|
||||
if (status == StartSubmissionLookupStep.STATUS_NO_COLLECTION)
|
||||
{
|
||||
// specify "no collection" error message should be displayed
|
||||
request.setAttribute("no.collection", new Boolean(true));
|
||||
|
||||
// reload this page, by re-calling doPreProcessing()
|
||||
doPreProcessing(context, request, response, subInfo);
|
||||
}
|
||||
else if (status == StartSubmissionLookupStep.STATUS_INVALID_COLLECTION)
|
||||
{
|
||||
JSPManager.showInvalidIDError(request, response, request
|
||||
.getParameter("collectionid"), Constants.COLLECTION);
|
||||
}
|
||||
else if (status == StartSubmissionLookupStep.STATUS_NO_SUUID)
|
||||
{
|
||||
// specify "no suuid" error message should be displayed
|
||||
request.setAttribute("no.suuid", new Boolean(true));
|
||||
|
||||
// reload this page, by re-calling doPreProcessing()
|
||||
doPreProcessing(context, request, response, subInfo);
|
||||
}
|
||||
else if (status == StartSubmissionLookupStep.STATUS_SUBMISSION_EXPIRED)
|
||||
{
|
||||
// specify "no collection" error message should be displayed
|
||||
request.setAttribute("expired", new Boolean(true));
|
||||
|
||||
// reload this page, by re-calling doPreProcessing()
|
||||
doPreProcessing(context, request, response, subInfo);
|
||||
}
|
||||
else if (status != StartSubmissionLookupStep.STATUS_COMPLETE)
|
||||
{
|
||||
// specify "no suuid" error message should be displayed
|
||||
request.setAttribute("no.suuid", new Boolean(true));
|
||||
|
||||
// reload this page, by re-calling doPreProcessing()
|
||||
doPreProcessing(context, request, response, subInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URL path (e.g. /submit/review-metadata.jsp) of the JSP
|
||||
* which will review the information that was gathered in this Step.
|
||||
* <P>
|
||||
* This Review JSP is loaded by the 'Verify' Step, in order to dynamically
|
||||
* generate a submission verification page consisting of the information
|
||||
* gathered in all the enabled submission steps.
|
||||
*
|
||||
* @param context
|
||||
* current DSpace context
|
||||
* @param request
|
||||
* current servlet request object
|
||||
* @param response
|
||||
* current servlet response object
|
||||
* @param subInfo
|
||||
* submission info object
|
||||
*/
|
||||
public String getReviewJSP(Context context, HttpServletRequest request,
|
||||
HttpServletResponse response, SubmissionInfo subInfo)
|
||||
{
|
||||
return NO_JSP; //at this time, you cannot review what collection you selected.
|
||||
}
|
||||
}
|
284
dspace-jspui/src/main/webapp/submit/start-lookup-submission.jsp
Normal file
284
dspace-jspui/src/main/webapp/submit/start-lookup-submission.jsp
Normal file
@@ -0,0 +1,284 @@
|
||||
<%--
|
||||
- UI page for start of a submission with lookup on external sources.
|
||||
-
|
||||
- Required attributes:
|
||||
- collections - Array of collection objects to show in the drop-down.
|
||||
collectionID - the collection ID of preference for the user
|
||||
identifiers2providers
|
||||
searchProviders
|
||||
--%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||
|
||||
<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %>
|
||||
|
||||
<%@ page import="org.dspace.content.Collection" %>
|
||||
<%@ page import="org.dspace.submit.lookup.SubmissionLookupProvider" %>
|
||||
<%@ page import="java.lang.Boolean" %>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ page import="java.util.Map" %>
|
||||
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
|
||||
prefix="c" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
|
||||
prefix="fmt" %>
|
||||
|
||||
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||
<%@ taglib uri="http://ajaxtags.org/tags/ajax" prefix="ajax"%>
|
||||
|
||||
<%
|
||||
String contextPath = "/dspace-jspui";
|
||||
request.setAttribute("LanguageSwitch", "hide");
|
||||
|
||||
//get collections to choose from
|
||||
Collection[] collections =
|
||||
(Collection[]) request.getAttribute("collections");
|
||||
|
||||
//get community handle
|
||||
int communityId = (Integer) request.getAttribute("collectionID");
|
||||
|
||||
//check if we need to display the "no collection selected" error
|
||||
Boolean noCollection = (Boolean) request.getAttribute("no.collection");
|
||||
Boolean nosuuid = (Boolean) request.getAttribute("nouuid");
|
||||
Boolean expired = (Boolean) request.getAttribute("expired");
|
||||
|
||||
Map<String, List<SubmissionLookupProvider>> identifiers2providers = (Map<String, List<SubmissionLookupProvider>>) request.getAttribute("identifiers2providers");
|
||||
List<SubmissionLookupProvider> searchProviders = (List<SubmissionLookupProvider>) request.getAttribute("searchProviders");
|
||||
List<String> identifiers = (List<String>) request.getAttribute("identifiers");
|
||||
String uuid = (String) request.getAttribute("s_uuid");
|
||||
%>
|
||||
<c:set var="dspace.layout.head" scope="request">
|
||||
<script type="text/javascript" src="<%= request.getContextPath() %>/js/submission-lookup.js"></script>
|
||||
</c:set>
|
||||
|
||||
<dspace:layout locbar="off"
|
||||
navbar="off"
|
||||
titlekey="jsp.submit.start-lookup-submission.title"
|
||||
nocache="true">
|
||||
|
||||
<h1><fmt:message key="jsp.submit.start-lookup-submission.heading"/></h1>
|
||||
<% if (collections.length > 0)
|
||||
{
|
||||
//if no collection was selected, display an error
|
||||
if((noCollection != null) && (noCollection.booleanValue()==true))
|
||||
{
|
||||
%>
|
||||
<div class="error-message">
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.no-collection"/></p>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
//if no collection was selected, display an error
|
||||
if((nosuuid != null) && (nosuuid.booleanValue()==true))
|
||||
{
|
||||
%>
|
||||
<div class="error-message">
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.nosuuid"/></p>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
//if no collection was selected, display an error
|
||||
if((expired != null) && (expired.booleanValue()==true))
|
||||
{
|
||||
%>
|
||||
<div class="error-message">
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.expired"/></p>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-search"><fmt:message key="jsp.submit.start-lookup-submission.tabs.search" /></a></li>
|
||||
<li><a href="#tabs-result"><fmt:message key="jsp.submit.start-lookup-submission.tabs.result" /></a></li>
|
||||
</ul>
|
||||
<div id="tabs-search">
|
||||
<form id="form-submission" action="" method="post">
|
||||
<input type="hidden" id="suuid" name="suuid" value="<%= uuid %>"/>
|
||||
<input type="hidden" id="iuuid" name="iuuid" value=""/>
|
||||
<input type="hidden" id="collectionid" name="collectionid" value=""/>
|
||||
<div id="tabs-search-accordion">
|
||||
<%
|
||||
if (searchProviders != null && searchProviders.size() > 0) {
|
||||
%>
|
||||
<h3><a href="#"><fmt:message key="jsp.submit.start-lookup-submission.search"/></a></h3>
|
||||
<div>
|
||||
|
||||
<%
|
||||
for (SubmissionLookupProvider provider : searchProviders)
|
||||
{
|
||||
%>
|
||||
<img style="vertical-align: middle;" src="<%= request.getContextPath() %>/image/submission-lookup-small-<%= provider.getShortName() %>.jpg" />
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.search.hints"/></p>
|
||||
<br/><br/><table>
|
||||
<tr><td style="vertical-align: top;"><span><fmt:message key="jsp.submit.start-lookup-submission.search.title"/>:</span></td><td>
|
||||
<textarea class="submission-lookup-search" name="search_title" id="search_title" cols="50" row="4"></textarea>
|
||||
<br/> </td><td> </td></tr>
|
||||
|
||||
<tr><td><span><fmt:message key="jsp.submit.start-lookup-submission.search.year"/>:</span></td><td>
|
||||
<input class="submission-lookup-search" type="text" size="7" name="search_year" id="search_year" />
|
||||
<br/> </td><td> </td></tr>
|
||||
|
||||
<tr><td><span><fmt:message key="jsp.submit.start-lookup-submission.search.authors"/>:</span></td><td>
|
||||
<textarea class="submission-lookup-search" name="search_authors" id="search_authors"cols="50" row="4"></textarea>
|
||||
<br/> </td><td> </td></tr>
|
||||
|
||||
<tr><td> </td><td> </td>
|
||||
<td align="right">
|
||||
<button type="button" id="search_go"><fmt:message key="jsp.submit.start-lookup-submission.search-go"/></button>
|
||||
<button type="button" class="exit"><fmt:message key="jsp.submit.start-lookup-submission.exit"/></button>
|
||||
<br/> </td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<% } %>
|
||||
<h3><a href="#"><fmt:message key="jsp.submit.start-lookup-submission.identifiers"/></a></h3>
|
||||
<div>
|
||||
<% if (identifiers != null && identifiers.size()>0) {
|
||||
%>
|
||||
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.identifiers.hints"/></p>
|
||||
<br/><br/><table>
|
||||
<%
|
||||
for (String identifier : identifiers)
|
||||
{
|
||||
%>
|
||||
<c:set var="identifier"><%= identifier %></c:set>
|
||||
<tr><td><span class="submission-lookup-label"><fmt:message key="jsp.submit.start-lookup-submission.identifier-${identifier}"/>:</span></td><td>
|
||||
<span class="submission-lookup-hint"><fmt:message key="jsp.submit.start-lookup-submission.identifier-${identifier}.hint"/></span><br/>
|
||||
<input class="submission-lookup-identifier" type="text" size="50" name="identifier_<%= identifier%>" id="identifier_<%= identifier%>" /><br/> </td><td class="submission-lookup-providers">
|
||||
<%
|
||||
for (SubmissionLookupProvider provider : identifiers2providers.get(identifier))
|
||||
{
|
||||
%>
|
||||
<img src="<%= request.getContextPath() %>/image/submission-lookup-small-<%= provider.getShortName() %>.jpg" />
|
||||
<%
|
||||
}
|
||||
%></td></tr><%
|
||||
} %>
|
||||
<tr><td> </td><td> </td><td><br/>
|
||||
<button type="button" id="lookup_idenfifiers"><fmt:message key="jsp.submit.start-lookup-submission.identifier.lookup"/></button>
|
||||
<button type="button" class="exit"><fmt:message key="jsp.submit.start-lookup-submission.exit"/></button></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<%
|
||||
|
||||
} %>
|
||||
|
||||
<h3><a href="#"><fmt:message key="jsp.submit.start-lookup-submission.manual-submission"/></a></h3>
|
||||
<div id="manual-accordion"> </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="tabs-result">
|
||||
<div id="empty-result">
|
||||
<p>Nessun risultato disponibile</p>
|
||||
</div>
|
||||
<div id="result-list"></div>
|
||||
<div id="manual-submission">
|
||||
Seleziona la tipologia della pubblicazione:
|
||||
<select id="select-collection-manual">
|
||||
<option value="-1">Seleziona</option>
|
||||
<% for (Collection c : collections) { %>
|
||||
<option value="<%= c.getID() %>"><%= c.getName() %></option>
|
||||
<% } %>
|
||||
</select>
|
||||
<button id="manual-submission-button" type="button">Inserisci manualmente</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="hidden-area" style="display: none;">
|
||||
<div id="select-collection-div">
|
||||
<select id="select-collection">
|
||||
<% for (Collection c : collections) { %>
|
||||
<option value="<%= c.getID() %>"><%= c.getName() %></option>
|
||||
<% } %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="no-collection-warn" title="<fmt:message key="jsp.submit.start-lookup-submission.no-collection-warn.title" />">
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.no-collection-warn.hint" /></p>
|
||||
</div>
|
||||
<div id="loading-search-result" title="<fmt:message key="jsp.submit.start-lookup-submission.search-loading.title" />">
|
||||
<p><fmt:message key="jsp.submit.start-lookup-submission.search-loading.hint" /></p>
|
||||
<center><img src="<%= request.getContextPath() %>/sherpa/image/ajax-loader-big.gif"/></center>
|
||||
</div>
|
||||
|
||||
<% } else { %>
|
||||
<p class="submitFormWarn"><fmt:message key="jsp.submit.select-collection.none-authorized"/></p>
|
||||
<% } %>
|
||||
<div>
|
||||
In alternativa è possibile utilizzare l'import automatico da file bibliografico (BibTeX, ISI): <button id="fileimport"><fmt:message key="jsp.mydspace.main.import.button"/></button>
|
||||
</div>
|
||||
<p><fmt:message key="jsp.general.goto"/><br />
|
||||
<a href="<%= request.getContextPath() %>"><fmt:message key="jsp.general.home"/></a><br />
|
||||
<a href="<%= request.getContextPath() %>/mydspace"><fmt:message key="jsp.general.mydspace" /></a>
|
||||
</p>
|
||||
<script type="text/javascript"><!--
|
||||
var j = jQuery.noConflict();
|
||||
j('#tabs').tabs({
|
||||
select: function( event, ui ) {
|
||||
if ('tabs-result' == j(ui.panel).attr('id'))
|
||||
{
|
||||
j('#manual-submission').appendTo(j(ui.panel));
|
||||
}
|
||||
else
|
||||
{
|
||||
j('#manual-submission').appendTo(j('#manual-accordion'));
|
||||
}
|
||||
}
|
||||
});
|
||||
j('#tabs-search-accordion').accordion({
|
||||
change: function( event, ui ) {
|
||||
if ('manual-accordion' == ui.newContent.attr('id'))
|
||||
{
|
||||
j('#manual-submission').appendTo(ui.newContent);
|
||||
}
|
||||
}
|
||||
});
|
||||
j('#link-ricerca-identificatore').click(function(){
|
||||
j('#tabs-search-accordion').accordion({'active': 1});
|
||||
});
|
||||
j('button').button();
|
||||
j('#manual-submission-button').click(function(event){
|
||||
var colman = j('#select-collection-manual').val();
|
||||
if (colman != -1)
|
||||
{
|
||||
j('#collectionid').val(colman);
|
||||
j('#form-submission').submit();
|
||||
}
|
||||
else
|
||||
{
|
||||
j('#no-collection-warn').dialog("open");
|
||||
}
|
||||
});
|
||||
j('#no-collection-warn').dialog({autoOpen: false,modal: true});
|
||||
j('#lookup_idenfifiers').click(function(){
|
||||
submissionLookupIdentifiers(j('input.submission-lookup-identifier'));
|
||||
});
|
||||
j('#search_go').click(function(){
|
||||
submissionLookupSearch(j('.submission-lookup-search'));
|
||||
});
|
||||
j('button.exit').click(function(event){
|
||||
event.preventDefault();
|
||||
window.location = "<%= request.getContextPath() %>/mydspace";
|
||||
});
|
||||
j('#fileimport').click(function(event){
|
||||
event.preventDefault();
|
||||
window.location = "<%= request.getContextPath() %>/tools/import";
|
||||
});
|
||||
j('#loading-search-result').dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
onClose: function(){
|
||||
j(this).data('ajaxCall').abort();
|
||||
},
|
||||
width: 600
|
||||
});
|
||||
--></script>
|
||||
|
||||
</dspace:layout>
|
@@ -0,0 +1,23 @@
|
||||
pmid = dc.identifier.pmid
|
||||
doi = dc.identifier.doi
|
||||
jissn = dc.relation.issn
|
||||
jeissn = dc.relation.eissn
|
||||
journal = dc.relation.ispartofjournal
|
||||
title = dc.title
|
||||
issued = dc.date.issued
|
||||
volume = dc.relation.volume
|
||||
issue = dc.relation.issue
|
||||
language = dc.language.iso
|
||||
subtype = dc.type.contribution
|
||||
#keywords = dc.subject
|
||||
mesh = dc.subject
|
||||
firstpage = dc.relation.firstpage
|
||||
lastpage = dc.relation.lastpage
|
||||
abstract = dc.description.abstract
|
||||
publicationstatus = dc.type.publicationstatus
|
||||
#authorsWithAffiliations = dc.contributor.author
|
||||
#authors = dc.contributor.author|authorsWithAffiliations
|
||||
authorsWithAffiliations =
|
||||
authors =
|
||||
articleNumber = dc.relation.article
|
||||
#to see enhancer visit spring-dspace-addon-submissionlookup-services.xml
|
@@ -1243,6 +1243,7 @@ plugin.sequence.org.dspace.plugin.SiteHomeProcessor = \
|
||||
# comment out this line if you disable Discovery
|
||||
plugin.named.org.dspace.app.webui.json.JSONRequest = \
|
||||
org.dspace.app.webui.discovery.DiscoveryJSONRequest = discovery,\
|
||||
org.dspace.app.webui.json.SubmissionLookupJSONRequest = submissionLookup,\
|
||||
org.dspace.app.webui.json.UploadProgressJSON = uploadProgress
|
||||
|
||||
|
||||
|
@@ -88,6 +88,15 @@
|
||||
<workflow-editable>false</workflow-editable>
|
||||
</step>
|
||||
|
||||
<!-- Uncomment this to make available the bibliographic import from external source - note ONLY for JSPUI -->
|
||||
<!-- <step id="collection">
|
||||
<heading></heading> can specify heading, if you want it to appear in Progress Bar
|
||||
<processing-class>org.dspace.submit.step.StartSubmissionLookupStep</processing-class>
|
||||
<jspui-binding>org.dspace.submit.step.JSPStartSubmissionLookupStep</jspui-binding>
|
||||
<xmlui-binding>org.dspace.app.xmlui.aspect.submission.submit.SelectCollectionStep</xmlui-binding>
|
||||
<workflow-editable>false</workflow-editable>
|
||||
</step> -->
|
||||
|
||||
<!-- The "complete" step is a "special step" which is *REQUIRED* to be-->
|
||||
<!-- in this section! In DSpace, when a submission is completed, -->
|
||||
<!-- a workflow is automatically kicked off (if one exists) -->
|
||||
|
Reference in New Issue
Block a user