/
ExporterReferences.java
73 lines (62 loc) · 2.87 KB
/
ExporterReferences.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package org.eol.globi.export;
import org.apache.commons.lang3.StringUtils;
import org.eol.globi.domain.Study;
import org.eol.globi.util.ExternalIdUtil;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
public class ExporterReferences extends ExporterBase {
public static final String IDENTIFIER = "http://purl.org/dc/terms/identifier";
public static final String FULL_REFERENCE = "http://eol.org/schema/reference/full_reference";
public static final String DOI = "http://purl.org/ontology/bibo/doi";
public static final String URI = "http://purl.org/ontology/bibo/uri";
@Override
protected String[] getFields() {
return new String[]{
IDENTIFIER,
"http://eol.org/schema/reference/publicationType",
FULL_REFERENCE,
"http://eol.org/schema/reference/primaryTitle",
"http://purl.org/dc/terms/title",
"http://purl.org/ontology/bibo/pages",
"http://purl.org/ontology/bibo/pageStart",
"http://purl.org/ontology/bibo/pageEnd",
"http://purl.org/ontology/bibo/volume",
"http://purl.org/ontology/bibo/edition",
"http://purl.org/dc/terms/publisher",
"http://purl.org/ontology/bibo/authorList",
"http://purl.org/ontology/bibo/editorList",
"http://purl.org/dc/terms/created",
"http://purl.org/dc/terms/language",
URI,
DOI,
"http://schemas.talis.com/2005/address/schema#localityName"};
}
@Override
protected String getRowType() {
return "http://eol.org/schema/reference/Reference";
}
@Override
protected void doExportStudy(Study study, Writer writer, boolean includeHeader) throws IOException {
Map<String, String> properties = new HashMap<String, String>();
properties.put(IDENTIFIER, referenceIdForStudy(study));
properties.put(FULL_REFERENCE, referenceForStudy(study));
properties.put(DOI, study.getDOI());
properties.put(URI, ExternalIdUtil.infoURLForExternalId(study.getExternalId()));
writeProperties(writer, properties);
}
public static String referenceIdForStudy(Study study) {
return "globi:ref:" + study.getNodeID();
}
private String referenceForStudy(Study study) {
StringBuilder reference = new StringBuilder();
String contributor = study.getContributor();
reference.append(StringUtils.isBlank(contributor) ? "" : contributor + " ");
String publicationYear = study.getPublicationYear();
reference.append(StringUtils.isBlank(publicationYear) ? "" : ("(" + publicationYear + ") "));
String description = study.getDescription();
reference.append(description);
return reference.toString();
}
}