Skip to content

Commit

Permalink
Support apa citation of some formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Ognimalf committed Jul 14, 2022
1 parent 2b73079 commit cc8dc5c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.BiblatexEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexSoftwareEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexAPAEntryTypeDefinitions;
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.IEEETranEntryTypeDefinitions;
Expand Down Expand Up @@ -157,6 +158,7 @@ public void initialize() {
.filter(e -> !recommendedEntries.contains(e))
.collect(Collectors.toList());
otherEntries.addAll(BiblatexSoftwareEntryTypeDefinitions.ALL);
otherEntries.addAll(BiblatexAPAEntryTypeDefinitions.ALL);
} else {
recommendedEntries = BibtexEntryTypeDefinitions.RECOMMENDED;
otherEntries = BibtexEntryTypeDefinitions.ALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.types.BiblatexEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexSoftwareEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexAPAEntryTypeDefinitions;
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.EntryTypeFactory;
Expand All @@ -21,7 +22,7 @@
public class BibEntryTypesManager {
public static final String ENTRYTYPE_FLAG = "jabref-entrytype: ";
private final InternalEntryTypes BIBTEX = new InternalEntryTypes(Stream.concat(BibtexEntryTypeDefinitions.ALL.stream(), IEEETranEntryTypeDefinitions.ALL.stream()).collect(Collectors.toList()));
private final InternalEntryTypes BIBLATEX = new InternalEntryTypes(Stream.concat(BiblatexEntryTypeDefinitions.ALL.stream(), BiblatexSoftwareEntryTypeDefinitions.ALL.stream()).collect(Collectors.toList()));
private final InternalEntryTypes BIBLATEX = new InternalEntryTypes(Stream.concat(BiblatexEntryTypeDefinitions.ALL.stream(), Stream.concat(BiblatexSoftwareEntryTypeDefinitions.ALL.stream(), BiblatexAPAEntryTypeDefinitions.ALL.stream())).collect(Collectors.toList()));

public BibEntryTypesManager() {
}
Expand Down Expand Up @@ -99,6 +100,7 @@ public List<BibEntryType> getAllCustomTypes(BibDatabaseMode mode) {
return customizedTypes.stream()
.filter(entryType -> BiblatexEntryTypeDefinitions.ALL.stream().noneMatch(biblatexType -> biblatexType.getType().equals(entryType.getType())))
.filter(entryType -> BiblatexSoftwareEntryTypeDefinitions.ALL.stream().noneMatch(biblatexSoftware -> biblatexSoftware.getType().equals(entryType.getType())))
.filter(entryType -> BiblatexAPAEntryTypeDefinitions.ALL.stream().noneMatch(biblatexAPA -> biblatexAPA.getType().equals(entryType.getType())))
.collect(Collectors.toList());
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/model/entry/field/StandardField.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ public enum StandardField implements Field {
ADDENDUM("addendum"),
ADDRESS("address"),
AFTERWORD("afterword", FieldProperty.PERSON_NAMES),
AMENDMENT("amendment"),
ANNOTE("annote"),
ANNOTATION("annotation"),
ANNOTATOR("annotator", FieldProperty.PERSON_NAMES),
ARCHIVEPREFIX("archiveprefix"),
ARTICLE("article"),
ASSIGNEE("assignee", FieldProperty.PERSON_NAMES),
AUTHOR("author", FieldProperty.PERSON_NAMES),
BOOKAUTHOR("bookauthor", FieldProperty.PERSON_NAMES),
Expand Down Expand Up @@ -117,12 +119,14 @@ public enum StandardField implements Field {
REVIEW("review"),
REVISION("revision"),
SCHOOL("school"),
SECTION("section", FieldProperty.NUMERIC),
SERIES("series"),
SHORTAUTHOR("shortauthor", FieldProperty.PERSON_NAMES),
SHORTEDITOR("shorteditor", FieldProperty.PERSON_NAMES),
SHORTTITLE("shorttitle"),
SORTKEY("sortkey"),
SORTNAME("sortname", FieldProperty.PERSON_NAMES),
SOURCE("source"),
SUBTITLE("subtitle"),
SWHID("swhid"),
TITLE("title"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.jabref.model.entry.types;

import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.BibEntryTypeBuilder;
import org.jabref.model.entry.field.StandardField;

import java.util.Arrays;
import java.util.List;

public class BiblatexAPAEntryTypeDefinitions {

private static final BibEntryType JURISDICTION = new BibEntryTypeBuilder()
.withType(StandardEntryType.JURISDICTION)
.withDetailFields(StandardField.ORGANIZATION, StandardField.CITATION_CITEORG, StandardField.CITATION_CITEDATE, StandardField.CITATION_CITEDATE, StandardField.ORIGDATE)
.withRequiredFields(StandardField.TITLE, StandardField.CITATION, StandardField.CITATION_CITEINFO, StandardField.URL, StandardField.DATE)
.build();

private static final BibEntryType LEGISLATION = new BibEntryTypeBuilder()
.withType(StandardEntryType.LEGISLATION)
.withImportantFields(StandardField.TITLEADDON, StandardField.ORIGDATE)
.withRequiredFields(StandardField.TITLE, StandardField.LOCATION, StandardField.URL, StandardField.DATE)
.build();

private static final BibEntryType LEGADMINMATERIAL = new BibEntryTypeBuilder()
.withType(StandardEntryType.LEGADMINMATERIAL)
.withImportantFields(StandardField.NUMBER, StandardField.SHORTTITLE, StandardField.NOTE, StandardField.KEYWORDS)
.withRequiredFields(StandardField.TITLE, StandardField.CITATION, StandardField.URL, StandardField.DATE)
.build();

private static final BibEntryType CONSTITUTION = new BibEntryTypeBuilder()
.withType(StandardEntryType.CONSTITUTION)
.withImportantFields(StandardField.ARTICLE, StandardField.AMENDMENT, StandardField.EVENTDATE, StandardField.KEYWORDS, StandardField.PART, StandardField.SECTION)
.withRequiredFields(StandardField.SOURCE, StandardField.TYPE)
.build();

public static final List<BibEntryType> ALL = Arrays.asList(JURISDICTION, LEGISLATION, LEGADMINMATERIAL, CONSTITUTION);
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,6 @@ public class BibtexEntryTypeDefinitions {
.withImportantFields(StandardField.EDITOR, StandardField.VOLUME, StandardField.NUMBER, StandardField.SERIES, StandardField.PAGES, StandardField.ADDRESS, StandardField.MONTH, StandardField.ORGANIZATION, StandardField.PUBLISHER, StandardField.NOTE)
.build();

/**
* A jurisdiction from court case.
* <p>
* Required fields: title, citation, CITATION+an:citeorg, CITATION+an:citedate, CITATION+an:citeinfo, url, date, origdate
* Optional fields: none
*/
private static final BibEntryType JURISDICTION_APA = new BibEntryTypeBuilder()
.withType(StandardEntryType.JURISDICTION_APA)
.withRequiredFields(StandardField.TITLE, StandardField.CITATION, StandardField.CITATION_CITEINFO, StandardField.URL, StandardField.DATE)
.withDetailFields(StandardField.ORGANIZATION, StandardField.CITATION_CITEORG, StandardField.CITATION_CITEDATE, StandardField.CITATION_CITEDATE, StandardField.ORIGDATE)
.build();

/**
* Technical documentation.
* Required field: title.
Expand Down Expand Up @@ -190,7 +178,7 @@ public class BibtexEntryTypeDefinitions {
.build();

public static final List<BibEntryType> ALL = Arrays.asList(ARTICLE, INBOOK, BOOK, BOOKLET, INCOLLECTION, CONFERENCE,
INPROCEEDINGS, PROCEEDINGS, MANUAL, MASTERSTHESIS, PHDTHESIS, TECHREPORT, UNPUBLISHED, MISC, JURISDICTION_APA);
INPROCEEDINGS, PROCEEDINGS, MANUAL, MASTERSTHESIS, PHDTHESIS, TECHREPORT, UNPUBLISHED, MISC);

public static final List<BibEntryType> RECOMMENDED = Arrays.asList(ARTICLE, BOOK, INPROCEEDINGS, TECHREPORT, MISC);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ public enum StandardEntryType implements EntryType {
Unpublished("Unpublished"),
// Biblatex
BookInBook("BookInBook"),
CONSTITUTION("Constitution"),
InReference("InReference"),
JURISDICTION_APA("Jurisdiction_apa"),
LEGISLATION("Legislation"),
LEGADMINMATERIAL("Legadminmaterial"),
JURISDICTION("Jurisdiction"),
MvBook("MvBook"),
MvCollection("MvCollection"),
MvProceedings("MvProceedings"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jabref.model.entry.field.UnknownField;
import org.jabref.model.entry.types.BiblatexEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexSoftwareEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexAPAEntryTypeDefinitions;
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.IEEETranEntryTypeDefinitions;
Expand Down Expand Up @@ -74,6 +75,7 @@ void allTypesBibtexAreCorrect() {
void allTypesBiblatexAreCorrect() {
TreeSet<BibEntryType> defaultTypes = new TreeSet<>(BiblatexEntryTypeDefinitions.ALL);
defaultTypes.addAll(BiblatexSoftwareEntryTypeDefinitions.ALL);
defaultTypes.addAll(BiblatexAPAEntryTypeDefinitions.ALL);

assertEquals(defaultTypes, entryTypesManager.getAllTypes(BibDatabaseMode.BIBLATEX));
}
Expand Down

0 comments on commit cc8dc5c

Please sign in to comment.