Skip to content

Commit

Permalink
Enable debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Jun 3, 2024
1 parent eaee5ed commit 1c4d2a1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ private BibDatabaseDiff(BibDatabaseContext originalDatabase, BibDatabaseContext
metaDataDiff = MetaDataDiff.compare(originalDatabase.getMetaData(), newDatabase.getMetaData());
preambleDiff = PreambleDiff.compare(originalDatabase, newDatabase);
bibStringDiffs = BibStringDiff.compare(originalDatabase.getDatabase(), newDatabase.getDatabase());
entryDiffs = getBibEntryDiffs(originalDatabase, newDatabase);
if (LOGGER.isDebugEnabled()) {
metaDataDiff.ifPresent(diff -> LOGGER.debug("Metadata differences: {}", diff));
preambleDiff.ifPresent(diff -> LOGGER.debug("Premble differences: {}", diff));
LOGGER.debug("BibString differences: {}", bibStringDiffs);
LOGGER.debug("Entry differences: {}", entryDiffs);
}
}

private List<BibEntryDiff> getBibEntryDiffs(BibDatabaseContext originalDatabase, BibDatabaseContext newDatabase) {
final List<BibEntryDiff> entryDiffs;
// Sort both databases according to a common sort key.
EntryComparator comparator = getEntryComparator();
List<BibEntry> originalEntriesSorted = originalDatabase.getDatabase().getEntriesSorted(comparator);
Expand All @@ -41,6 +51,7 @@ private BibDatabaseDiff(BibDatabaseContext originalDatabase, BibDatabaseContext
newEntriesSorted.removeIf(BibEntry::isEmpty);

entryDiffs = compareEntries(originalEntriesSorted, newEntriesSorted, originalDatabase.getMode());
return entryDiffs;
}

private static EntryComparator getEntryComparator() {
Expand Down Expand Up @@ -103,7 +114,6 @@ private static List<BibEntryDiff> compareEntries(List<BibEntry> originalEntries,
|| duplicateCheck.isDuplicate(originalEntry, bestEntry, mode)) {
matchedEntries.add(bestMatchIndex);
differences.add(new BibEntryDiff(originalEntry, newEntries.get(bestMatchIndex)));
LOGGER.debug("Matched {} with {}", originalEntry, newEntries.get(bestMatchIndex));
} else {
differences.add(new BibEntryDiff(originalEntry, null));
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/jabref/logic/bibtex/comparator/BibEntryDiff.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.logic.bibtex.comparator;

import java.util.StringJoiner;

import org.jabref.model.entry.BibEntry;

public class BibEntryDiff {
Expand All @@ -18,4 +20,12 @@ public BibEntry getOriginalEntry() {
public BibEntry getNewEntry() {
return newEntry;
}

@Override
public String toString() {
return new StringJoiner(",\n", BibEntryDiff.class.getSimpleName() + "[", "]")
.add("originalEntry=" + originalEntry)
.add("newEntry=" + newEntry)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ private void addToListIfDiff(List<Difference> changes, DifferenceType difference
if (isDefaultContentSelectors(originalContentSelectors) && isDefaultContentSelectors(newContentSelectors)) {
return;
}
}
if (differenceType == DifferenceType.GROUPS) {
} else if (differenceType == DifferenceType.GROUPS) {
Optional<GroupTreeNode> originalGroups = (Optional<GroupTreeNode>) originalObject;
Optional<GroupTreeNode> newGroups = (Optional<GroupTreeNode>) newObject;
if (isDefaultGroup(originalGroups) && isDefaultGroup(newGroups)) {
Expand Down Expand Up @@ -137,6 +136,7 @@ public String toString() {
"groupDiff=" + groupDiff +
", originalMetaData=" + originalMetaData +
", newMetaData=" + getNewMetaData() +
", getDifferences()=" + getDifferences(new GlobalCitationKeyPatterns(CitationKeyPattern.NULL_CITATION_KEY_PATTERN)) +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(originalPreamble, newPreamble);
}

@Override
public String toString() {
return "PreambleDiff{" +
"originalPreamble='" + originalPreamble + '\'' +
", newPreamble='" + newPreamble + '\'' +
'}';
}
}
2 changes: 2 additions & 0 deletions src/main/resources/tinylog.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ exception = strip: jdk.internal
[email protected] = debug

[email protected] = debug

[email protected] = debug

0 comments on commit 1c4d2a1

Please sign in to comment.