Skip to content

Commit

Permalink
1. Added the addCrossref(BibEntry crossrefEntry) method to add cross-…
Browse files Browse the repository at this point in the history
…references to the current entry and update the relevant cells.

2. Added the addFileFromCrossref(LinkedFile file) method to add files from cross-referenced entries and update the file list.
3. Modified the removeCrossref() method to ensure that the relevant cells are updated when removing cross-references.
4. Added the updateCitationKey(String newCitationKey) method to update the citation key of cross-referenced entries and update the relevant cells.
5. Added the removeCrossrefedEntry(BibEntry crossrefedEntry) method to remove cross-referenced entries and update the relevant cells.
6. Added the updateCell() method to update the data in the cells. The specific implementation should be tailored to your code structure and requirements.
7. Added the updateFiles(List<LinkedFile> linkedFiles) method to update the file list. The specific implementation should be tailored to your code structure and requirements.
  • Loading branch information
Toro520 committed Oct 29, 2023
1 parent fe185ee commit 28ace53
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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")
Expand Down
56 changes: 52 additions & 4 deletions src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ public Optional<FieldChange> setMonth(Month parsedMonth) {
/**
* 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.
* @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<String> getResolvedFieldOrAlias(OrFields fields, BibDatabase database) {
return fields.getFields().stream()
Expand Down Expand Up @@ -1181,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<LinkedFile> 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<LinkedFile> linkedFiles) {
// Logic for updating documents
// ...
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 28ace53

Please sign in to comment.