Skip to content

Commit

Permalink
refactor: reintroduce standard entry type
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Aug 23, 2019
1 parent e7f9a40 commit 8ea1277
Show file tree
Hide file tree
Showing 99 changed files with 583 additions and 630 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.LastFocusedTabPreferences;

Expand Down Expand Up @@ -526,7 +526,7 @@ private Node createToolbar() {
pushToApplicationsManager.setToolBarButton(pushToApplicationButton);

HBox rightSide = new HBox(
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, BibtexEntryType.Article, dialogService, Globals.prefs, stateManager)),
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, StandardEntryType.Article, dialogService, Globals.prefs, stateManager)),
factory.createIconButton(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, stateManager)),
new Separator(Orientation.VERTICAL),
factory.createIconButton(StandardActions.UNDO, new OldDatabaseCommandWrapper(Actions.UNDO, this, stateManager)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.PreferencesService;

Expand Down Expand Up @@ -156,7 +156,7 @@ private Node getEntryNode(BibEntry entry) {
}

private IconTheme.JabRefIcons getIcon(EntryType type) {
if (BibtexEntryType.Book.equals(type)) {
if (StandardEntryType.Book.equals(type)) {
return IconTheme.JabRefIcons.BOOK;
}
return IconTheme.JabRefIcons.ARTICLE;
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.StandardEntryType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -78,33 +78,33 @@ public void export(final BibDatabaseContext databaseContext, final Path resultFi
bibEntry.getCiteKeyOptional().ifPresent(entry::setId);

EntryType i = bibEntry.getType();
if (BibtexEntryType.Article.equals(i)) {
if (StandardEntryType.Article.equals(i)) {
parse(new Article(), bibEntry, entry);
} else if (BibtexEntryType.Book.equals(i)) {
} else if (StandardEntryType.Book.equals(i)) {
parse(new Book(), bibEntry, entry);
} else if (BibtexEntryType.Booklet.equals(i)) {
} else if (StandardEntryType.Booklet.equals(i)) {
parse(new Booklet(), bibEntry, entry);
} else if (BibtexEntryType.Conference.equals(i)) {
} else if (StandardEntryType.Conference.equals(i)) {
parse(new Conference(), bibEntry, entry);
} else if (BibtexEntryType.InBook.equals(i)) {
} else if (StandardEntryType.InBook.equals(i)) {
parseInbook(new Inbook(), bibEntry, entry);
} else if (BibtexEntryType.InCollection.equals(i)) {
} else if (StandardEntryType.InCollection.equals(i)) {
parse(new Incollection(), bibEntry, entry);
} else if (BibtexEntryType.InProceedings.equals(i)) {
} else if (StandardEntryType.InProceedings.equals(i)) {
parse(new Inproceedings(), bibEntry, entry);
} else if (BibtexEntryType.MastersThesis.equals(i)) {
} else if (StandardEntryType.MastersThesis.equals(i)) {
parse(new Mastersthesis(), bibEntry, entry);
} else if (BibtexEntryType.Manual.equals(i)) {
} else if (StandardEntryType.Manual.equals(i)) {
parse(new Manual(), bibEntry, entry);
} else if (BibtexEntryType.Misc.equals(i)) {
} else if (StandardEntryType.Misc.equals(i)) {
parse(new Misc(), bibEntry, entry);
} else if (BibtexEntryType.PhdThesis.equals(i)) {
} else if (StandardEntryType.PhdThesis.equals(i)) {
parse(new Phdthesis(), bibEntry, entry);
} else if (BibtexEntryType.Proceedings.equals(i)) {
} else if (StandardEntryType.Proceedings.equals(i)) {
parse(new Proceedings(), bibEntry, entry);
} else if (BibtexEntryType.TechReport.equals(i)) {
} else if (StandardEntryType.TechReport.equals(i)) {
parse(new Techreport(), bibEntry, entry);
} else if (BibtexEntryType.Unpublished.equals(i)) {
} else if (StandardEntryType.Unpublished.equals(i)) {
parse(new Unpublished(), bibEntry, entry);
} else {
LOGGER.warn("unexpected type appeared");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.identifier.ArXivIdentifier;
import org.jabref.model.entry.identifier.DOI;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.strings.StringUtil;
import org.jabref.model.util.OptionalUtil;

Expand Down Expand Up @@ -405,7 +405,7 @@ public Optional<String> getDate() {
}

public BibEntry toBibEntry(Character keywordDelimiter) {
BibEntry bibEntry = new BibEntry(BibtexEntryType.Article);
BibEntry bibEntry = new BibEntry(StandardEntryType.Article);
bibEntry.setField(StandardField.EPRINTTYPE, "arXiv");
bibEntry.setField(StandardField.AUTHOR, String.join(" and ", authorNames));
bibEntry.addKeywords(categories, keywordDelimiter);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.identifier.DOI;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.util.OptionalUtil;

import org.apache.http.client.utils.URIBuilder;
Expand Down Expand Up @@ -156,9 +156,9 @@ private String toAuthors(JSONArray authors) {
private EntryType convertType(String type) {
switch (type) {
case "journal-article":
return BibtexEntryType.Article;
return StandardEntryType.Article;
default:
return BibtexEntryType.Misc;
return StandardEntryType.Misc;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.model.strings.StringUtil;

import org.apache.http.client.utils.URIBuilder;
Expand Down Expand Up @@ -58,7 +58,7 @@ public static BibEntry parseBibJSONtoBibtex(JSONObject bibJsonEntry, Character k
// Fields that are accessible in the journal part of the BibJson object
Field[] journalSingleFields = {StandardField.PUBLISHER, StandardField.NUMBER, StandardField.VOLUME};

BibEntry entry = new BibEntry(BibtexEntryType.Article);
BibEntry entry = new BibEntry(StandardEntryType.Article);

// Authors
if (bibJsonEntry.has("author")) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jabref/logic/importer/fetcher/IEEE.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.identifier.DOI;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;

import org.apache.http.client.utils.URIBuilder;
import org.json.JSONArray;
Expand Down Expand Up @@ -66,16 +66,16 @@ private static BibEntry parseJsonRespone(JSONObject jsonEntry, Character keyword

switch (jsonEntry.optString("content_type")) {
case "Books":
entry.setType(BibtexEntryType.Book);
entry.setType(StandardEntryType.Book);
break;
case "Conferences":
entry.setType(BibtexEntryType.InProceedings);
entry.setType(StandardEntryType.InProceedings);
break;
case "Courses":
entry.setType(BibtexEntryType.Misc);
entry.setType(StandardEntryType.Misc);
break;
default:
entry.setType(BibtexEntryType.Article);
entry.setType(StandardEntryType.Article);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.jabref.model.entry.Month;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;

import org.apache.http.client.utils.URIBuilder;
import org.json.JSONArray;
Expand Down Expand Up @@ -58,11 +58,11 @@ public static BibEntry parseSpringerJSONtoBibtex(JSONObject springerJsonEntry) {
String isbn = springerJsonEntry.optString("isbn");
if (com.google.common.base.Strings.isNullOrEmpty(isbn)) {
// Probably article
entry.setType(BibtexEntryType.Article);
entry.setType(StandardEntryType.Article);
nametype = StandardField.JOURNAL;
} else {
// Probably book chapter or from proceeding, go for book chapter
entry.setType(BibtexEntryType.InCollection);
entry.setType(StandardEntryType.InCollection);
nametype = StandardField.BOOKTITLE;
entry.setField(StandardField.ISBN, isbn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -94,50 +94,50 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
for (Entry entry : entries) {
BibEntry bibEntry = new BibEntry();
if (entry.getArticle() != null) {
bibEntry.setType(BibtexEntryType.Article);
bibEntry.setType(StandardEntryType.Article);
parse(entry.getArticle(), fields);
} else if (entry.getBook() != null) {
bibEntry.setType(BibtexEntryType.Book);
bibEntry.setType(StandardEntryType.Book);
parse(entry.getBook(), fields);
} else if (entry.getBooklet() != null) {
bibEntry.setType(BibtexEntryType.Booklet);
bibEntry.setType(StandardEntryType.Booklet);
parse(entry.getBooklet(), fields);
} else if (entry.getConference() != null) {
bibEntry.setType(BibtexEntryType.Conference);
bibEntry.setType(StandardEntryType.Conference);
parse(entry.getConference(), fields);
} else if (entry.getInbook() != null) {
bibEntry.setType(BibtexEntryType.InBook);
bibEntry.setType(StandardEntryType.InBook);
parseInbook(entry.getInbook(), fields);
} else if (entry.getIncollection() != null) {
bibEntry.setType(BibtexEntryType.InCollection);
bibEntry.setType(StandardEntryType.InCollection);
Incollection incollection = entry.getIncollection();
if (incollection.getChapter() != null) {
fields.put(StandardField.CHAPTER, String.valueOf(incollection.getChapter()));
}
parse(incollection, fields);
} else if (entry.getInproceedings() != null) {
bibEntry.setType(BibtexEntryType.InProceedings);
bibEntry.setType(StandardEntryType.InProceedings);
parse(entry.getInproceedings(), fields);
} else if (entry.getManual() != null) {
bibEntry.setType(BibtexEntryType.Manual);
bibEntry.setType(StandardEntryType.Manual);
parse(entry.getManual(), fields);
} else if (entry.getMastersthesis() != null) {
bibEntry.setType(BibtexEntryType.MastersThesis);
bibEntry.setType(StandardEntryType.MastersThesis);
parse(entry.getMastersthesis(), fields);
} else if (entry.getMisc() != null) {
bibEntry.setType(BibtexEntryType.Misc);
bibEntry.setType(StandardEntryType.Misc);
parse(entry.getMisc(), fields);
} else if (entry.getPhdthesis() != null) {
bibEntry.setType(BibtexEntryType.PhdThesis);
bibEntry.setType(StandardEntryType.PhdThesis);
parse(entry.getPhdthesis(), fields);
} else if (entry.getProceedings() != null) {
bibEntry.setType(BibtexEntryType.Proceedings);
bibEntry.setType(StandardEntryType.Proceedings);
parse(entry.getProceedings(), fields);
} else if (entry.getTechreport() != null) {
bibEntry.setType(BibtexEntryType.TechReport);
bibEntry.setType(StandardEntryType.TechReport);
parse(entry.getTechreport(), fields);
} else if (entry.getUnpublished() != null) {
bibEntry.setType(BibtexEntryType.Unpublished);
bibEntry.setType(StandardEntryType.Unpublished);
parse(entry.getUnpublished(), fields);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.StandardEntryType;

/**
* Imports a Biblioscape Tag File. The format is described on
Expand Down Expand Up @@ -196,37 +196,37 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
}
type[i] = type[i].toLowerCase(Locale.ROOT);
if (type[i].contains("article")) {
bibtexType = BibtexEntryType.Article;
bibtexType = StandardEntryType.Article;
} else if (type[i].contains("journal")) {
bibtexType = BibtexEntryType.Article;
bibtexType = StandardEntryType.Article;
} else if (type[i].contains("book section")) {
bibtexType = BibtexEntryType.InBook;
bibtexType = StandardEntryType.InBook;
} else if (type[i].contains("book")) {
bibtexType = BibtexEntryType.Book;
bibtexType = StandardEntryType.Book;
} else if (type[i].contains("conference")) {
bibtexType = BibtexEntryType.InProceedings;
bibtexType = StandardEntryType.InProceedings;
} else if (type[i].contains("proceedings")) {
bibtexType = BibtexEntryType.InProceedings;
bibtexType = StandardEntryType.InProceedings;
} else if (type[i].contains("report")) {
bibtexType = BibtexEntryType.TechReport;
bibtexType = StandardEntryType.TechReport;
} else if (type[i].contains("thesis")
&& type[i].contains("master")) {
bibtexType = BibtexEntryType.MastersThesis;
bibtexType = StandardEntryType.MastersThesis;
} else if (type[i].contains("thesis")) {
bibtexType = BibtexEntryType.PhdThesis;
bibtexType = StandardEntryType.PhdThesis;
}
}

// depending on bibtexType, decide where to place the titleRT and
// titleTI
if (bibtexType.equals(BibtexEntryType.Article)) {
if (bibtexType.equals(StandardEntryType.Article)) {
if (titleST != null) {
hm.put(StandardField.JOURNAL, titleST);
}
if (titleTI != null) {
hm.put(StandardField.TITLE, titleTI);
}
} else if (bibtexType.equals(BibtexEntryType.InBook)) {
} else if (bibtexType.equals(StandardEntryType.InBook)) {
if (titleST != null) {
hm.put(StandardField.BOOKTITLE, titleST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;

/**
* @implNote implemented by reverse-engineering <a href="https://github.com/SeerLabs/CiteSeerX/blob/4df28a98083be2829ec4c56ebbac09eb7772d379/src/java/edu/psu/citeseerx/domain/BiblioTransformer.java#L155-L249">the implementation by CiteSeerX</a>
Expand Down Expand Up @@ -50,11 +50,11 @@ public List<BibEntry> parseEntries(InputStream inputStream) throws ParseExceptio
if (matcherType.find()) {
switch (matcherType.group(1)) {
case "article":
entry.setType(BibtexEntryType.Article);
entry.setType(StandardEntryType.Article);
break;
case "unknown":
default:
entry.setType(BibtexEntryType.Misc);
entry.setType(StandardEntryType.Misc);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.field.UnknownField;
import org.jabref.model.entry.types.BibtexEntryType;
import org.jabref.model.entry.types.StandardEntryType;

/**
* Importer for COPAC format.
Expand Down Expand Up @@ -110,7 +110,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {

// Copac does not contain enough information on the type of the
// document. A book is assumed.
BibEntry b = new BibEntry(BibtexEntryType.Book);
BibEntry b = new BibEntry(StandardEntryType.Book);

String[] lines = entry.split("\n");

Expand Down
Loading

0 comments on commit 8ea1277

Please sign in to comment.