Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support biblatex apa citation for legal entry types #8966

Merged
merged 10 commits into from
Aug 1, 2022
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
8 changes: 8 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 All @@ -31,6 +33,10 @@ public enum StandardField implements Field {
BOOKTITLE("booktitle", FieldProperty.BOOK_NAME),
BOOKTITLEADDON("booktitleaddon"),
CHAPTER("chapter"),
CITATION("citiation"),
CITATION_CITEORG("citation_citeorg"),
CITATION_CITEDATE("citation_citedate"),
CITATION_CITEINFO("citation_citeinfo"),
COMMENTATOR("commentator", FieldProperty.PERSON_NAMES),
COMMENT("comment"),
CROSSREF("crossref", FieldProperty.SINGLE_ENTRY_LINK),
Expand Down Expand Up @@ -113,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 @@ -21,7 +21,11 @@ public enum StandardEntryType implements EntryType {
Unpublished("Unpublished"),
// Biblatex
BookInBook("BookInBook"),
CONSTITUTION("Constitution"),
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
InReference("InReference"),
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