forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add entry based on ISSN number JabRef#10124 (JabRef#10178)
* Add: implementing the ISSN Fetcher * Add: implementing methods of IssnFetcher class * Substantially changes on IssnFetcher class * Substantial changes of IssnFetcher * Implementing the performSearchById method for IssnFetcher class * Saving changes for branch updating * Started to implement the ISSN search logic * Refactor the performSearchById method * Add the IssnFetcher on WebFetcher class and add unit tests * Implement search based on the ISSN number * Change the ISSN Checker validation of a valid checksum * refactor to use exiting journal info fetcher * reafactor * add button next to journal field * fix tests and checkstyle * arch test * Fuuu checkstyle --------- Co-authored-by: Siedlerchr <[email protected]>
- Loading branch information
1 parent
5b34fe8
commit 86870cb
Showing
16 changed files
with
225 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/org/jabref/logic/importer/fetcher/IssnFetcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jabref.logic.importer.fetcher; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.jabref.logic.importer.EntryBasedFetcher; | ||
import org.jabref.logic.importer.FetcherException; | ||
import org.jabref.logic.importer.IdBasedFetcher; | ||
import org.jabref.logic.journals.JournalInformation; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.StandardField; | ||
|
||
/** | ||
* Fetcher to generate the BibTex entry from an ISSN. | ||
* As an ISSN ist just a journal identifier, so we only return journal title and publisher | ||
* The idea is to use the {@link JournalInformationFetcher} to do a request for a given ISSN. | ||
*/ | ||
|
||
public class IssnFetcher implements EntryBasedFetcher, IdBasedFetcher { | ||
|
||
private final JournalInformationFetcher journalInformationFetcher; | ||
|
||
public IssnFetcher() { | ||
this.journalInformationFetcher = new JournalInformationFetcher(); | ||
} | ||
|
||
@Override | ||
public List<BibEntry> performSearch(BibEntry entry) throws FetcherException { | ||
Optional<String> issn = entry.getField(StandardField.ISSN); | ||
if (issn.isPresent()) { | ||
Optional<JournalInformation> journalInformation = journalInformationFetcher.getJournalInformation(issn.get(), ""); | ||
return journalInformation.map(journalInfo -> journalInformationToBibEntry(journalInfo, issn.get())).stream().toList(); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ISSN"; | ||
} | ||
|
||
@Override | ||
public Optional<BibEntry> performSearchById(String identifier) throws FetcherException { | ||
Optional<JournalInformation> journalInformation = journalInformationFetcher.getJournalInformation(identifier, ""); | ||
return journalInformation.map(journalInfo -> journalInformationToBibEntry(journalInfo, identifier)); | ||
} | ||
|
||
private BibEntry journalInformationToBibEntry(JournalInformation journalInfo, String issn) { | ||
return new BibEntry().withField(StandardField.JOURNALTITLE, journalInfo.title()).withField(StandardField.PUBLISHER, journalInfo.publisher()).withField(StandardField.ISSN, issn); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.