Skip to content

Commit 41dcd57

Browse files
authored
Revert "Mark some methods as deprecated in BibEntry and BibDatabase (#1913)" (#2023)
This reverts commit a9eb978. # Conflicts: # src/main/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporter.java # src/main/java/net/sf/jabref/model/database/BibDatabase.java # src/main/java/net/sf/jabref/model/entry/BibEntry.java # src/test/java/net/sf/jabref/logic/search/DatabaseSearcherTest.java
1 parent 443b3b7 commit 41dcd57

32 files changed

+173
-137
lines changed

src/jmh/java/net/sf/jabref/benchmarks/Benchmarks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void init() throws Exception {
5858
entry.setField("keyword", "testkeyword");
5959
entry.setField("year", "1" + i);
6060
entry.setField("rnd", "2" + randomizer.nextInt());
61-
database.insertEntryWithDuplicationCheck(entry);
61+
database.insertEntry(entry);
6262
}
6363
BibtexDatabaseWriter<StringSaveSession> databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new);
6464
StringSaveSession saveSession = databaseWriter.savePartOfDatabase(

src/main/java/net/sf/jabref/collab/EntryAddChange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public EntryAddChange(BibEntry diskEntry) {
3131
@Override
3232
public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound undoEdit) {
3333
diskEntry.setId(IdGenerator.next());
34-
panel.getDatabase().insertEntryWithDuplicationCheck(diskEntry);
35-
secondary.insertEntryWithDuplicationCheck(diskEntry);
34+
panel.getDatabase().insertEntry(diskEntry);
35+
secondary.insertEntry(diskEntry);
3636
undoEdit.addEdit(new UndoableInsertEntry(panel.getDatabase(), diskEntry, panel));
3737
return true;
3838
}

src/main/java/net/sf/jabref/gui/BasePanel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ private void paste() {
830830
// independently of the copied
831831
// ones.
832832
be.setId(IdGenerator.next());
833-
bibDatabaseContext.getDatabase().insertEntryWithDuplicationCheck(be);
833+
bibDatabaseContext.getDatabase().insertEntry(be);
834834

835835
ce.addEdit(new UndoableInsertEntry(bibDatabaseContext.getDatabase(), be, BasePanel.this));
836836

@@ -1138,7 +1138,7 @@ public BibEntry newEntry(EntryType type) {
11381138
String id = IdGenerator.next();
11391139
final BibEntry be = new BibEntry(id, actualType.getName());
11401140
try {
1141-
bibDatabaseContext.getDatabase().insertEntryWithDuplicationCheck(be);
1141+
bibDatabaseContext.getDatabase().insertEntry(be);
11421142
// Set owner/timestamp if options are enabled:
11431143
List<BibEntry> list = new ArrayList<>();
11441144
list.add(be);
@@ -1305,7 +1305,7 @@ public void listen(EntryRemovedEvent removedEntryEvent) {
13051305
public void insertEntry(final BibEntry bibEntry) {
13061306
if (bibEntry != null) {
13071307
try {
1308-
bibDatabaseContext.getDatabase().insertEntryWithDuplicationCheck(bibEntry);
1308+
bibDatabaseContext.getDatabase().insertEntry(bibEntry);
13091309
if (Globals.prefs.getBoolean(JabRefPreferences.USE_OWNER)) {
13101310
// Set owner field to default value
13111311
UpdateField.setAutomaticFields(bibEntry, true, true, Globals.prefs.getUpdateFieldPreferences());

src/main/java/net/sf/jabref/gui/DuplicateSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void run() {
124124
// and adding merged entries:
125125
if (!toAdd.isEmpty()) {
126126
for (BibEntry entry : toAdd) {
127-
panel.getDatabase().insertEntryWithDuplicationCheck(entry);
127+
panel.getDatabase().insertEntry(entry);
128128
ce.addEdit(new UndoableInsertEntry(panel.getDatabase(), entry, panel));
129129
}
130130
panel.markBaseChanged();

src/main/java/net/sf/jabref/gui/externalfiles/DroppedFileHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private boolean tryXmpImport(String fileName, ExternalFileType fileType, NamedCo
294294

295295
aXmpEntriesInFile.setId(IdGenerator.next());
296296
edits.addEdit(new UndoableInsertEntry(panel.getDatabase(), aXmpEntriesInFile, panel));
297-
panel.getDatabase().insertEntryWithDuplicationCheck(aXmpEntriesInFile);
297+
panel.getDatabase().insertEntry(aXmpEntriesInFile);
298298
doLink(aXmpEntriesInFile, fileType, destFilename, true, edits);
299299

300300
}

src/main/java/net/sf/jabref/gui/importer/EntryFromFileCreatorManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public int addEntriesFromFiles(List<File> files,
147147
if (!database.containsEntryWithId(entry.get().getId())) {
148148
// Work around SIDE EFFECT of creator.createEntry. The EntryFromPDFCreator also creates the entry in the table
149149
// Therefore, we only insert the entry if it is not already present
150-
if (database.insertEntryWithDuplicationCheck(entry.get())) {
150+
if (database.insertEntry(entry.get())) {
151151
importGUIMessages.add("Problem importing " + f.getPath() + ": Insert into BibDatabase failed.");
152152
} else {
153153
count++;

src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ private void generateKeyForEntry(BibEntry entry) {
459459

460460
entry.setId(IdGenerator.next());
461461
// Add the entry to the database we are working with:
462-
database.insertEntryWithDuplicationCheck(entry);
462+
database.insertEntry(entry);
463463

464464
// Generate a unique key:
465465
BibtexKeyPatternUtil.makeLabel(localMetaData, database, entry,
@@ -502,7 +502,7 @@ private void generateKeys() {
502502
for (BibEntry entry : entries) {
503503

504504
entry.setId(IdGenerator.next());
505-
database.insertEntryWithDuplicationCheck(entry);
505+
database.insertEntry(entry);
506506

507507
BibtexKeyPatternUtil.makeLabel(localMetaData, database, entry,
508508
Globals.prefs.getBibtexKeyPatternPreferences());
@@ -736,7 +736,7 @@ private void addSelectedEntries(NamedCompound ce, final List<BibEntry> selected)
736736
}
737737

738738
entry.setId(IdGenerator.next());
739-
panel.getDatabase().insertEntryWithDuplicationCheck(entry);
739+
panel.getDatabase().insertEntry(entry);
740740
ce.addEdit(new UndoableInsertEntry(panel.getDatabase(), entry, panel));
741741

742742
}

src/main/java/net/sf/jabref/gui/importer/ImportMenuItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private ParserResult mergeImportResults(List<ImportFormatReader.UnknownFormatImp
206206

207207
// Merge entries:
208208
for (BibEntry entry : pr.getDatabase().getEntries()) {
209-
database.insertEntryWithDuplicationCheck(entry);
209+
database.insertEntry(entry);
210210
}
211211

212212
// Merge strings:
@@ -233,7 +233,7 @@ private ParserResult mergeImportResults(List<ImportFormatReader.UnknownFormatImp
233233
if (markEntries) {
234234
EntryMarker.markEntry(entry, EntryMarker.IMPORT_MARK_LEVEL, false, new NamedCompound(""));
235235
}
236-
database.insertEntryWithDuplicationCheck(entry);
236+
database.insertEntry(entry);
237237
}
238238
}
239239
}

src/main/java/net/sf/jabref/gui/importer/actions/AppendDatabaseAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static void mergeFromBibtex(JabRefFrame frame, BasePanel panel, ParserRe
118118
be.setId(IdGenerator.next());
119119
UpdateField.setAutomaticFields(be, overwriteOwner, overwriteTimeStamp,
120120
Globals.prefs.getUpdateFieldPreferences());
121-
database.insertEntryWithDuplicationCheck(be);
121+
database.insertEntry(be);
122122
appendedEntries.add(be);
123123
originalEntries.add(originalEntry);
124124
ce.addEdit(new UndoableInsertEntry(database, be, panel));

src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Object getColumnValue(BibEntry entry) {
9494

9595
Optional<String> content = Optional.empty();
9696
for (String field : bibtexFields) {
97-
content = entry.getResolvedFieldOrAlias(field, database.orElse(null));
97+
content = BibDatabase.getResolvedField(field, entry, database.orElse(null));
9898
if (content.isPresent()) {
9999
isNameColumn = InternalBibtexFields.getFieldProperties(field).contains(FieldProperty.PERSON_NAMES);
100100
break;
@@ -127,7 +127,7 @@ public JLabel getHeaderLabel() {
127127
* The reasons for being different are (combinations may also happen):
128128
* - The entry has a crossref where the field content is obtained from
129129
* - The field has a string in it (which getColumnValue() resolves)
130-
* - There are some alias fields. For example, if the entry has a date field but no year field, getResolvedFieldOrAlias()
130+
* - There are some alias fields. For example, if the entry has a date field but no year field, getResolvedField()
131131
* will return the year value from the date field when queried for year
132132
*
133133
*
@@ -148,7 +148,7 @@ public boolean isResolved(BibEntry entry) {
148148
return false;
149149
} else {
150150
plainFieldContent = entry.getField(field);
151-
resolvedFieldContent = entry.getResolvedFieldOrAlias(field, database.orElse(null));
151+
resolvedFieldContent = BibDatabase.getResolvedField(field, entry, database.orElse(null));
152152
}
153153

154154
if (resolvedFieldContent.isPresent()) {

0 commit comments

Comments
 (0)