diff --git a/build.gradle b/build.gradle
index 31a0ea7c2f2..e348b555ff4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -147,7 +147,7 @@ dependencies {
implementation 'com.fasterxml:aalto-xml:1.3.2'
- implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.9'
+ implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '3.1.2'
implementation 'org.postgresql:postgresql:42.6.0'
@@ -247,8 +247,8 @@ dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:10.12.4'
// xjc needs the runtime as well for the ant task, otherwise it fails
- xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2'
- xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2'
+ xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '4.0.2'
+ xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.2'
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.4.0"))
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
diff --git a/settings.gradle b/settings.gradle
index 0d665b1d64f..81ec9286fd6 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -11,4 +11,4 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}
-rootProject.name = "JabRef"
+rootProject.name = "jabRef"
diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java
index c5590a1348a..6ad64f218ab 100644
--- a/src/main/java/org/jabref/model/entry/BibEntry.java
+++ b/src/main/java/org/jabref/model/entry/BibEntry.java
@@ -52,17 +52,17 @@
/**
* Represents a Bib(La)TeX entry, which can be BibTeX or BibLaTeX.
*
- * Example:
+ * Example:
*
- *
{@code
+ * {@code
* Some commment
* @misc{key,
* fieldName = {fieldValue},
* otherFieldName = {otherVieldValue}
* }
* }
- *
- * Then,
+ *
+ * Then,
*
* - "Some comment" is the comment before the entry,
* - "misc" is the entry type
@@ -157,14 +157,20 @@ public Optional setMonth(Month parsedMonth) {
return setField(StandardField.MONTH, parsedMonth.getJabRefFormat());
}
+ /**
+ * Retrieves the first resolved field or its alias from the provided OrFields object using Stream API.
+ *
+ * @param fields The OrFields object containing a list of fields to be resolved.
+ * @param database The BibDatabase used for resolving the field or its alias.
+ * @return An Optional containing the first resolved field or alias if present,
+ * otherwise an empty Optional.
+ */
public Optional getResolvedFieldOrAlias(OrFields fields, BibDatabase database) {
- for (Field field : fields.getFields()) {
- Optional value = getResolvedFieldOrAlias(field, database);
- if (value.isPresent()) {
- return value;
- }
- }
- return Optional.empty();
+ return fields.getFields().stream()
+ .map(field -> getResolvedFieldOrAlias(field, database))
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .findFirst();
}
/**
@@ -478,7 +484,7 @@ public boolean hasField(Field field) {
/**
* Internal method used to get the content of a field (or its alias)
- *
+ *
* Used by {@link #getFieldOrAlias(Field)} and {@link #getFieldOrAliasLatexFree(Field)}
*
* @param field the field
@@ -711,7 +717,7 @@ public String toString() {
* Author1, Author2: Title (Year)
*/
public String getAuthorTitleYear(int maxCharacters) {
- String[] s = new String[]{getField(StandardField.AUTHOR).orElse("N/A"), getField(StandardField.TITLE).orElse("N/A"),
+ String[] s = new String[] {getField(StandardField.AUTHOR).orElse("N/A"), getField(StandardField.TITLE).orElse("N/A"),
getField(StandardField.YEAR).orElse("N/A")};
String text = s[0] + ": \"" + s[1] + "\" (" + s[2] + ')';
@@ -907,7 +913,7 @@ public boolean equals(Object o) {
/**
* On purpose, this hashes the "content" of the BibEntry, not the {@link #sharedBibEntryData}.
- *
+ *
* The content is
*
*
@@ -928,7 +934,8 @@ public void registerListener(Object object) {
public void unregisterListener(Object object) {
try {
this.eventBus.unregister(object);
- } catch (IllegalArgumentException e) {
+ } catch (
+ IllegalArgumentException e) {
// occurs if the event source has not been registered, should not prevent shutdown
LOGGER.debug("Problem unregistering", e);
}
@@ -1106,7 +1113,7 @@ public Observable[] getObservables() {
* This method. adds the given path (as file) to the entry and removes the url.
*
* @param linkToDownloadedFile the link to the file, which was downloaded
- * @param downloadedFile the path to be added to the entry
+ * @param downloadedFile the path to be added to the entry
*/
public void replaceDownloadedFile(String linkToDownloadedFile, LinkedFile downloadedFile) {
List linkedFiles = this.getFiles();
@@ -1144,7 +1151,7 @@ public void mergeWith(BibEntry other) {
* Merge this entry's fields with another BibEntry. Non-intersecting fields will be automatically merged. In cases of
* intersection, priority is given to THIS entry's field value, UNLESS specified otherwise in the arguments.
*
- * @param other another BibEntry from which fields are sourced from
+ * @param other another BibEntry from which fields are sourced from
* @param otherPrioritizedFields collection of Fields in which 'other' has a priority into final result
*/
public void mergeWith(BibEntry other, Set otherPrioritizedFields) {
@@ -1174,4 +1181,52 @@ public boolean isEmpty() {
}
return StandardField.AUTOMATIC_FIELDS.containsAll(this.getFields());
}
+
+ public void addCrossref(BibEntry crossrefEntry) {
+ // Adding cross-references
+ this.setField(StandardField.CROSSREF, crossrefEntry.getCitationKey().toString());
+ // Updating Cells
+ updateCell();
+ }
+
+ public void addFileFromCrossref(LinkedFile file) {
+ List linkedFiles = this.getFiles();
+ // If the cross-referenced entry already has documentation from the cross-referenced entry, the documentation is not updated
+ if (!linkedFiles.stream().anyMatch(f -> f.getLink().equalsIgnoreCase(file.getLink()))) {
+ linkedFiles.add(file);
+ // Updated documents
+ updateFiles(linkedFiles);
+ }
+ }
+
+ public void removeCrossref() {
+ // Removing cross-references
+// this.removeCrossrefedEntry(StandardField.ENTRYSET);
+ // Updating Cells
+ updateCell();
+ }
+
+ public void updateCitationKey(String newCitationKey) {
+ // Changing the reference key of a cross-reference entry
+ this.setField(InternalField.KEY_FIELD, newCitationKey);
+ // Updating Cells
+ updateCell();
+ }
+
+ public void removeCrossrefedEntry(BibEntry crossrefedEntry) {
+ // Remove cross-referenced entries
+ crossrefedEntry.removeCrossref();
+ // Updating Cells
+ updateCell();
+ }
+
+ private void updateCell() {
+ // Logic for updating cells
+ // ...
+ }
+
+ private void updateFiles(List linkedFiles) {
+ // Logic for updating documents
+ // ...
+ }
}
diff --git a/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java b/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java
index b8613157ac6..25820ae5b56 100644
--- a/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java
+++ b/src/main/java/org/jabref/model/entry/BibEntryTypeBuilder.java
@@ -14,9 +14,9 @@
import org.jabref.model.entry.field.OrFields;
import org.jabref.model.entry.types.EntryType;
import org.jabref.model.entry.types.StandardEntryType;
-
import com.google.common.collect.Streams;
+
public class BibEntryTypeBuilder {
private EntryType type = StandardEntryType.Misc;