Skip to content

Commit

Permalink
More fields added to FieldName
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Jul 21, 2016
1 parent 32319ff commit 795c726
Show file tree
Hide file tree
Showing 34 changed files with 221 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private void setupPrevEntry() {
prevEntry.setField(FieldName.YEAR, "2008");
prevEntry.setField(FieldName.JOURNAL, "BibTeX journal");
prevEntry.setField(FieldName.PUBLISHER, "JabRef publishing");
prevEntry.setField("address", "Trondheim");
prevEntry.setField(FieldName.ADDRESS, "Trondheim");
prevEntry.setField("www", "https://github.com/JabRef");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public boolean processQuery(String query, ImportInspector inspector, OutputPrint
entry.setField(FieldName.TITLE, title);
});

entry.getFieldOptional("institution").ifPresent(
institution -> entry.setField("institution", new UnicodeToLatexFormatter().format(institution)));
entry.getFieldOptional(FieldName.INSTITUTION).ifPresent(
institution -> entry.setField(FieldName.INSTITUTION, new UnicodeToLatexFormatter().format(institution)));
// Do not use the provided key
// entry.clearField(InternalBibtexFields.KEY_FIELD);
inspector.addEntry(entry);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/sf/jabref/importer/fetcher/GVKParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,13 @@ private BibEntry parseEntry(Element e) {
result.setField(FieldName.YEAR, year);
}
if (address != null) {
result.setField("address", address);
result.setField(FieldName.ADDRESS, address);
}
if (series != null) {
result.setField("series", series);
result.setField(FieldName.SERIES, series);
}
if (edition != null) {
result.setField("edition", edition);
result.setField(FieldName.EDITION, edition);
}
if (isbn != null) {
result.setField(FieldName.ISBN, isbn);
Expand Down Expand Up @@ -427,13 +427,13 @@ private BibEntry parseEntry(Element e) {
result.setField(FieldName.URL, url);
}
if (note != null) {
result.setField("note", note);
result.setField(FieldName.NOTE, note);
}

if ("article".equals(entryType) && (journal != null)) {
result.setField(FieldName.JOURNAL, journal);
} else if ("incollection".equals(entryType) && (booktitle != null)) {
result.setField("booktitle", booktitle);
result.setField(FieldName.BOOKTITLE, booktitle);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ private BibEntry cleanup(BibEntry entry) {
String sourceField = "";
if ("article".equals(type)) {
sourceField = FieldName.JOURNAL;
entry.clearField("booktitle");
entry.clearField(FieldName.BOOKTITLE);
} else if ("inproceedings".equals(type)) {
sourceField = "booktitle";
sourceField = FieldName.BOOKTITLE;
}
if (entry.hasField(sourceField)) {
String fullName = entry.getField(sourceField);
Expand All @@ -393,7 +393,7 @@ private BibEntry cleanup(BibEntry entry) {
if (parts.length == 3) {
fullName += parts[2];
}
String note = entry.getField("note");
String note = entry.getField(FieldName.NOTE);
if ("Early Access".equals(note)) {
entry.setField(FieldName.YEAR, "to be published");
entry.clearField(FieldName.MONTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
comments
.add("Secondary Authors: " + entry.getValue());
} else if ("NT".equals(entry.getKey())) {
hm.put("note", entry
hm.put(FieldName.NOTE, entry
.getValue().toString());
} else if ("PB".equals(entry.getKey())) {
hm.put(FieldName.PUBLISHER, entry
Expand All @@ -131,7 +131,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
comments
.add("Tertiary Title: " + entry.getValue());
} else if ("ED".equals(entry.getKey())) {
hm.put("edition", entry
hm.put(FieldName.EDITION, entry
.getValue().toString());
} else if ("TW".equals(entry.getKey())) {
type[1] = entry.getValue()
Expand All @@ -152,7 +152,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
address = entry.getValue()
.toString();
} else if ("LG".equals(entry.getKey())) {
hm.put("language", entry
hm.put(FieldName.LANGUAGE, entry
.getValue().toString());
} else if ("CO".equals(entry.getKey())) {
country = entry.getValue()
Expand Down Expand Up @@ -239,14 +239,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
}
} else if ("inbook".equals(bibtexType)) {
if (titleST != null) {
hm.put("booktitle", titleST);
hm.put(FieldName.BOOKTITLE, titleST);
}
if (titleTI != null) {
hm.put(FieldName.TITLE, titleTI);
}
} else {
if (titleST != null) {
hm.put("booktitle", titleST); // should not
hm.put(FieldName.BOOKTITLE, titleST); // should not
}
// happen, I
// think
Expand All @@ -262,7 +262,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {

// concatenate address and country
if (address != null) {
hm.put("address", address + (country == null ? "" : ", " + country));
hm.put(FieldName.ADDRESS, address + (country == null ? "" : ", " + country));
}

if (!comments.isEmpty()) { // set comment if present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
} else if ("PU- ".equals(code)) {
setOrAppend(b, FieldName.PUBLISHER, line.substring(4).trim(), ", ");
} else if ("SE- ".equals(code)) {
setOrAppend(b, "series", line.substring(4).trim(), ", ");
setOrAppend(b, FieldName.SERIES, line.substring(4).trim(), ", ");
} else if ("IS- ".equals(code)) {
setOrAppend(b, FieldName.ISBN, line.substring(4).trim(), ", ");
} else if ("KW- ".equals(code)) {
setOrAppend(b, FieldName.KEYWORDS, line.substring(4).trim(), ", ");
} else if ("NT- ".equals(code)) {
setOrAppend(b, "note", line.substring(4).trim(), ", ");
setOrAppend(b, FieldName.NOTE, line.substring(4).trim(), ", ");
} else if ("PD- ".equals(code)) {
setOrAppend(b, "physicaldimensions", line.substring(4).trim(), ", ");
} else if ("DT- ".equals(code)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
type = "misc"; //
}
} else if ("7".equals(prefix)) {
hm.put("edition", val);
hm.put(FieldName.EDITION, val);
} else if ("C".equals(prefix)) {
hm.put("address", val);
hm.put(FieldName.ADDRESS, val);
} else if ("D".equals(prefix)) {
hm.put(FieldName.YEAR, val);
} else if ("8".equals(prefix)) {
Expand All @@ -189,14 +189,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
if ("article".equals(type)) {
hm.put(FieldName.JOURNAL, val);
} else if ("book".equals(type) || "inbook".equals(type)) {
hm.put("series", val);
hm.put(FieldName.SERIES, val);
} else {
/* type = inproceedings */
hm.put("booktitle", val);
hm.put(FieldName.BOOKTITLE, val);
}
} else if ("I".equals(prefix)) {
if ("phdthesis".equals(type)) {
hm.put("school", val);
hm.put(FieldName.SCHOOL, val);
} else {
hm.put(FieldName.PUBLISHER, val);
}
Expand All @@ -222,7 +222,7 @@ else if ("P".equals(prefix)) {
String[] tokens = val.split("\\s");
artnum = tokens[1];
} else {
hm.put("note", val);
hm.put(FieldName.NOTE, val);
}
} else if ("K".equals(prefix)) {
hm.put(FieldName.KEYWORDS, val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,24 @@ public ParserResult importEntries(String text) {
// the content of the "tech" field seems to contain the number of the technical report
e.setField(FieldName.NUMBER, parser.getElementText());
} else if (FieldName.DOI.equals(ln)
|| "institution".equals(ln)
|| FieldName.INSTITUTION.equals(ln)
|| "location".equals(ln)
|| FieldName.NUMBER.equals(ln)
|| "note".equals(ln)
|| FieldName.NOTE.equals(ln)
|| FieldName.TITLE.equals(ln)
|| FieldName.PAGES.equals(ln)
|| FieldName.PUBLISHER.equals(ln)
|| FieldName.VOLUME.equals(ln)
|| FieldName.YEAR.equals(ln)) {
e.setField(ln, parser.getElementText());
} else if ("booktitle".equals(ln)) {
} else if (FieldName.BOOKTITLE.equals(ln)) {
String booktitle = parser.getElementText();
if (booktitle.startsWith("In ")) {
// special treatment for parsing of
// "In proceedings of..." references
booktitle = booktitle.substring(3);
}
e.setField("booktitle", booktitle);
e.setField(FieldName.BOOKTITLE, booktitle);
} else if ("raw_string".equals(ln)) {
// raw input string is ignored
} else {
Expand All @@ -200,13 +200,13 @@ public ParserResult importEntries(String text) {

if (noteSB.length() > 0) {
String note;
if (e.hasField("note")) {
if (e.hasField(FieldName.NOTE)) {
// "note" could have been set during the parsing as FreeCite also returns "note"
note = e.getFieldOptional("note").get().concat(Globals.NEWLINE).concat(noteSB.toString());
note = e.getFieldOptional(FieldName.NOTE).get().concat(Globals.NEWLINE).concat(noteSB.toString());
} else {
note = noteSB.toString();
}
e.setField("note", note);
e.setField(FieldName.NOTE, note);
}

// type has been derived from "genre"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
Type = "inproceedings";
}
} else if ("JO".equals(beg)) {
hm.put("booktitle", value);
hm.put(FieldName.BOOKTITLE, value);
} else if ("AU".equals(beg)) {
String author = IsiImporter.isiAuthorsConvert(value.replace("EOLEOL", " and "));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) {
} else {
// Probably book chapter or from proceeding, go for book chapter
entry.setType("incollection");
nametype = "booktitle";
nametype = FieldName.BOOKTITLE;
entry.setField(FieldName.ISBN, isbn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private void addBookInformation(HashMap<String, String> fields, Book book) {
}

putIfValueNotNull(fields, "volume", book.getVolume());
putIfValueNotNull(fields, "edition", book.getEdition());
putIfValueNotNull(fields, FieldName.EDITION, book.getEdition());
putIfValueNotNull(fields, "medium", book.getMedium());
putIfValueNotNull(fields, "reportnumber", book.getReportNumber());

Expand Down Expand Up @@ -406,7 +406,7 @@ private void addNotes(HashMap<String, String> fields, List<GeneralNote> generalN
notes.add(note.getContent());
}
}
fields.put("note", join(notes, ", "));
fields.put(FieldName.NOTE, join(notes, ", "));
}

private void addInvestigators(HashMap<String, String> fields, InvestigatorList investigatorList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,21 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
//store the fields in a map
Map<String, String> hashMap = new HashMap<>();
hashMap.put("PG", FieldName.PAGES);
hashMap.put("PL", "address");
hashMap.put("PL", FieldName.ADDRESS);
hashMap.put("PHST", "history");
hashMap.put("PST", "publication-status");
hashMap.put("VI", FieldName.VOLUME);
hashMap.put("LA", "language");
hashMap.put("LA", "language");
hashMap.put("LA", FieldName.LANGUAGE);
hashMap.put("LA", FieldName.LANGUAGE);
hashMap.put("PUBM", "model");
hashMap.put("RN", "registry-number");
hashMap.put("NM", "substance-name");
hashMap.put("OCI", "copyright-owner");
hashMap.put("CN", "corporate");
hashMap.put("IP", FieldName.ISSUE);
hashMap.put("EN", "edition");
hashMap.put("EN", FieldName.EDITION);
hashMap.put("GS", "gene-symbol");
hashMap.put("GN", "note");
hashMap.put("GN", FieldName.NOTE);
hashMap.put("GR", "grantno");
hashMap.put("SO", "source");
hashMap.put("NR", "number-of-references");
Expand Down Expand Up @@ -341,10 +341,10 @@ private void addTitles(Map<String, String> hm, String lab, String val, String ty
}
}
} else if ("BTI".equals(lab) || "CTI".equals(lab)) {
hm.put("booktitle", val);
hm.put(FieldName.BOOKTITLE, val);
} else if ("JT".equals(lab)) {
if ("inproceedings".equals(type)) {
hm.put("booktitle", val);
hm.put(FieldName.BOOKTITLE, val);
} else {
hm.put(FieldName.JOURNAL, val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
} else if ((matcher = OvidImporter.INCOLLECTION_PATTERN.matcher(content)).find()) {
h.put(FieldName.EDITOR, matcher.group(1).replace(" (Ed)", ""));
h.put(FieldName.YEAR, matcher.group(2));
h.put("booktitle", matcher.group(3));
h.put(FieldName.BOOKTITLE, matcher.group(3));
h.put(FieldName.PAGES, matcher.group(4));
h.put("address", matcher.group(5));
h.put(FieldName.ADDRESS, matcher.group(5));
h.put(FieldName.PUBLISHER, matcher.group(6));
} else if ((matcher = OvidImporter.BOOK_PATTERN.matcher(content)).find()) {
h.put(FieldName.YEAR, matcher.group(1));
h.put(FieldName.PAGES, matcher.group(2));
h.put("address", matcher.group(3));
h.put(FieldName.ADDRESS, matcher.group(3));
h.put(FieldName.PUBLISHER, matcher.group(4));

}
Expand All @@ -184,7 +184,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
h.put("entrytype", "inproceedings");
}
} else if (fieldName.startsWith("Language")) {
h.put("language", content);
h.put(FieldName.LANGUAGE, content);
} else if (fieldName.startsWith("Author Keywords")) {
content = content.replace(";", ",").replace(" ", " ");
h.put(FieldName.KEYWORDS, content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,13 @@ public ParserResult importDatabase(Path filePath, Charset defaultEncoding) {
entry.setField(FieldName.TITLE, title);
}
if (conference != null) {
entry.setField("booktitle", conference);
entry.setField(FieldName.BOOKTITLE, conference);
}
if (DOI != null) {
entry.setField(FieldName.DOI, DOI);
}
if (series != null) {
entry.setField("series", series);
entry.setField(FieldName.SERIES, series);
}
if (volume != null) {
entry.setField(FieldName.VOLUME, volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private void parseAuthors(BibEntry be, BufferedReader in) throws IOException {
be.setField(FieldName.AUTHOR, String.join(" and ", authors));
}
if (institutions.length() > 0) {
be.setField("institution", institutions.toString());
be.setField(FieldName.INSTITUTION, institutions.toString());
}
}

Expand Down
Loading

0 comments on commit 795c726

Please sign in to comment.