forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented JabRef#1345 - cleanup ISSN
- Loading branch information
Showing
24 changed files
with
124 additions
and
4 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
33 changes: 33 additions & 0 deletions
33
src/main/java/net/sf/jabref/logic/cleanup/ISSNCleanup.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,33 @@ | ||
package net.sf.jabref.logic.cleanup; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import net.sf.jabref.model.FieldChange; | ||
import net.sf.jabref.model.entry.BibEntry; | ||
|
||
|
||
public class ISSNCleanup implements CleanupJob { | ||
|
||
private static final Pattern ISSN_PATTERN_NODASH = Pattern.compile("^(\\d{4})(\\d{3}[\\dxX])$"); | ||
@Override | ||
public List<FieldChange> cleanup(BibEntry entry) { | ||
Optional<String> issn = entry.getFieldOptional("issn"); | ||
if (!issn.isPresent()) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
Matcher matcher = ISSN_PATTERN_NODASH.matcher(issn.get()); | ||
if (matcher.find()) { | ||
String result = matcher.replaceFirst("$1-$2"); | ||
entry.setField("issn", result); | ||
FieldChange change = new FieldChange(entry, "issn", issn.get(), result); | ||
return Collections.singletonList(change); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -1706,3 +1706,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2424,3 +2424,5 @@ Online_help_forum=Online-Hilfeforum | |
Custom= | ||
|
||
|
||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1608,3 +1608,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2394,3 +2394,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1652,3 +1652,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1627,3 +1627,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1727,3 +1727,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2372,3 +2372,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2403,3 +2403,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2799,3 +2799,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1621,3 +1621,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2371,3 +2371,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1564,3 +1564,5 @@ Online_help_forum=Onlineforum | |
Custom=Egna | ||
|
||
|
||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1640,3 +1640,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2395,3 +2395,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1634,3 +1634,5 @@ Online_help_forum= | |
Custom= | ||
|
||
Converts_HTML_code_to_Unicode.= | ||
|
||
Add_possibly_missing_dash_to_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