Skip to content

Commit

Permalink
fix the issue JabRef#8645
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyanghuo committed Jul 15, 2022
1 parent 92b7d7a commit 21829da
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Changed

- Now all the entries with no empty citationkey will be detected by "Check integrity",and a test of it has been added.
- The file column in the main table now shows the corresponding defined icon for the linked file [8930](https://github.com/JabRef/jabref/issues/8930).
- We improved the color of the selected entries and the color of the summary in the Import Entries Dialog in the dark theme. [#7927](https://github.com/JabRef/jabref/issues/7927)
- We upgraded to Lucene 9.2 for the fulltext search.
Expand All @@ -38,6 +39,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where A particular empty entry can be added without warning message [#8645](https://github.com/JabRef/jabref/issues/8645)
- We fixed an issue where linked files with the filetype "application/pdf" in an entry were not shown with the correct PDF-Icon in the main table [8930](https://github.com/JabRef/jabref/issues/8930)
- We fixed an issue where "open folder" for linked files did not open the folder and did not select the file unter certain Linux desktop environments [#8679](https://github.com/JabRef/jabref/issues/8679), [#8849](https://github.com/JabRef/jabref/issues/8849)
- We fixed an issue where the content of a big shared database library is not shown [#8788](https://github.com/JabRef/jabref/issues/8788)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import org.jabref.model.strings.StringUtil;

/**
* Currently only checks the key if there is an author, year, and title present.
* In the past only checks the key if there is an author, year, and title present.
* Currently checks the key all the time.
*/
public class CitationKeyChecker implements EntryChecker {

Expand All @@ -20,12 +21,10 @@ public List<IntegrityMessage> check(BibEntry entry) {
Optional<String> author = entry.getField(StandardField.AUTHOR);
Optional<String> title = entry.getField(StandardField.TITLE);
Optional<String> year = entry.getField(StandardField.YEAR);
if (author.isEmpty() || title.isEmpty() || year.isEmpty()) {
return Collections.emptyList();
}

if (StringUtil.isBlank(entry.getCitationKey())) {
String authorTitleYear = entry.getAuthorTitleYear(100);

return Collections.singletonList(new IntegrityMessage(
Localization.lang("empty citation key") + ": " + authorTitleYear, entry, InternalField.KEY_FIELD));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ private JabRefPreferences() {
// default time stamp follows ISO-8601. Reason: https://xkcd.com/1179/
defaults.put(TIME_STAMP_FORMAT, "yyyy-MM-dd");

defaults.put(GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE);
defaults.put(GENERATE_KEYS_BEFORE_SAVING, Boolean.TRUE);

defaults.put(USE_REMOTE_SERVER, Boolean.TRUE);
defaults.put(REMOTE_SERVER_PORT, 6050);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ void acceptsKeyFromTitleAndYear() {
assertEquals(Collections.emptyList(), checker.check(entry));
}

@Test
void emptyCitationKeyFromAuthorAndTitle() {
BibEntry entry = new BibEntry().withField(StandardField.AUTHOR, "Brown")
.withField(StandardField.TITLE, "The Title");
List<IntegrityMessage> expected = Collections.singletonList(new IntegrityMessage(Localization.lang("empty citation key") + ": " + entry.getAuthorTitleYear(100), entry, InternalField.KEY_FIELD));
assertEquals(expected, checker.check(entry));
}

@Test
void emptyCitationKey() {
BibEntry entry = new BibEntry().withField(StandardField.AUTHOR, "Brown")
Expand Down

0 comments on commit 21829da

Please sign in to comment.