use of org.globalbioticinteractions.doi.MalformedDOIException in project eol-globi-data by jhpoelen.
the class InteractionImporter method studyOf.
private StudyImpl studyOf(Map<String, String> l) {
String referenceCitation = l.get(REFERENCE_CITATION);
DOI doi = null;
String doiString = l.get(REFERENCE_DOI);
try {
doi = StringUtils.isBlank(doiString) ? null : DOI.create(doiString);
} catch (MalformedDOIException e) {
LogUtil.logWarningIfPossible(l, "found malformed doi [" + doiString + "]", logger);
}
StudyImpl study1 = new StudyImpl(l.get(REFERENCE_ID), doi, referenceCitation);
final String referenceUrl = l.get(REFERENCE_URL);
if (StringUtils.isBlank(study1.getExternalId()) && StringUtils.isNotBlank(referenceUrl)) {
study1.setExternalId(referenceUrl);
}
return study1;
}
use of org.globalbioticinteractions.doi.MalformedDOIException in project eol-globi-data by jhpoelen.
the class ReferenceUtil method generateReferenceCitation.
public static String generateReferenceCitation(Map<String, String> properties) {
StringBuilder citation = new StringBuilder();
append(citation, properties.get(DatasetImporterForMetaTable.AUTHOR), ", ");
append(citation, properties.get(DatasetImporterForMetaTable.YEAR), ". ");
append(citation, properties.get(DatasetImporterForMetaTable.TITLE), ". ");
append(citation, properties.get(DatasetImporterForMetaTable.JOURNAL), properties.containsKey(DatasetImporterForMetaTable.VOLUME) || properties.containsKey(DatasetImporterForMetaTable.NUMBER) || properties.containsKey(DatasetImporterForMetaTable.PAGES) ? ", " : ". ");
append(citation, properties.get(DatasetImporterForMetaTable.VOLUME), properties.containsKey(DatasetImporterForMetaTable.NUMBER) ? "(" : (properties.containsKey(DatasetImporterForMetaTable.PAGES) ? ", " : ". "));
append(citation, properties.get(DatasetImporterForMetaTable.NUMBER), properties.containsKey(DatasetImporterForMetaTable.VOLUME) ? ")" : "");
if (properties.containsKey(DatasetImporterForMetaTable.NUMBER)) {
citation.append(properties.containsKey(DatasetImporterForMetaTable.PAGES) ? ", " : ".");
}
append(citation, properties.get(DatasetImporterForMetaTable.PAGES), ". ", "pp.");
String citationFromId = null;
if (properties.containsKey(DatasetImporterForTSV.REFERENCE_DOI)) {
String str = properties.get(DatasetImporterForTSV.REFERENCE_DOI);
if (StringUtils.isNoneBlank(str)) {
try {
DOI doi = DOI.create(str);
citationFromId = doi.toPrintableDOI();
} catch (MalformedDOIException e) {
// ignore malformed DOIs here
}
}
}
if (StringUtils.isBlank(citationFromId) && properties.containsKey(DatasetImporterForTSV.REFERENCE_URL)) {
citationFromId = properties.get(DatasetImporterForTSV.REFERENCE_URL);
}
if (StringUtils.isNoneBlank(citationFromId)) {
citation.append(citationFromId);
}
return StringUtils.trim(citation.toString());
}
use of org.globalbioticinteractions.doi.MalformedDOIException in project eol-globi-data by jhpoelen.
the class DatasetImporterForPensoft method addDOIReferenceIfAvailable.
private static void addDOIReferenceIfAvailable(String doiString, TreeMap<String, String> references) {
try {
final DOI doiObj = DOI.create(doiString);
references.put(DatasetImporterForTSV.REFERENCE_DOI, doiString);
references.put(DatasetImporterForTSV.REFERENCE_URL, doiObj.toURI().toString());
} catch (MalformedDOIException e) {
// ignore
}
}
use of org.globalbioticinteractions.doi.MalformedDOIException in project eol-globi-data by jhpoelen.
the class ExternalIdUtil method urlForExternalId.
public static String urlForExternalId(String externalId) {
URI uri = null;
String url = null;
if (externalId != null) {
for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) {
String idPrefix = idPrefixToUrlPrefix.getKey();
if (StringUtils.startsWith(externalId, idPrefix)) {
if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) {
try {
DOI doi = DOI.create(externalId);
url = doi.toURI().toString();
} catch (MalformedDOIException e) {
LOG.warn("found malformed doi [" + externalId + "]", e);
}
} else {
url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, "");
}
String suffix = getURLSuffixMap().get(idPrefix);
if (StringUtils.isNotBlank(suffix)) {
url = url + suffix;
}
}
if (url != null) {
try {
URIBuilder uriBuilder = new URIBuilder(url);
uri = uriBuilder.build();
// URL ur= new URL(url);
// uri = new URI(ur.getProtocol(), ur.getUserInfo(), ur.getHost(), ur.getPort(), ur.getPath(), ur.getQuery(), ur.getRef());
} catch (URISyntaxException e) {
//
}
break;
}
}
}
return uri == null ? null : uri.toString();
}
use of org.globalbioticinteractions.doi.MalformedDOIException in project eol-globi-data by jhpoelen.
the class CypherQueryBuilder method extractDOIs.
private static List<DOI> extractDOIs(List<String> accordingToParams) {
List<DOI> dois = new ArrayList<>();
for (String accordingToParam : accordingToParams) {
try {
DOI doi = DOI.create(accordingToParam);
dois.add(doi);
} catch (MalformedDOIException e) {
//
}
}
return dois;
}
Aggregations