Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Cleanup for copying over physcial review article id as the page n… #7025

Merged
merged 11 commits into from
Oct 20, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;

import org.jabref.logic.cleanup.FieldFormatterCleanup;
import org.jabref.logic.formatter.bibtexfields.ClearFormatter;
Expand Down Expand Up @@ -37,6 +38,7 @@ public class DoiFetcher implements IdBasedFetcher, EntryBasedFetcher {
public static final String NAME = "DOI";

private static final String APS_JOURNAL_ORG_DOI_ID = "1103";
private static final String APS_SUFFIX = "([\\w]+\\.)([\\w]+\\.)([\\w]+)";

private static final Logger LOGGER = LoggerFactory.getLogger(DoiFetcher.class);

Expand Down Expand Up @@ -141,11 +143,14 @@ private void setPageCountToArticleId(BibEntry entry, String doiAsString) {
entry.setField(StandardField.PAGES, articleId);
}

// checks if the entry is an APS journal by comparing the organization id and the suffix format
private boolean isAPSJournal(BibEntry entry, String doiAsString) {
if (!entry.getType().equals(StandardEntryType.Article)) {
return false;
}
Pattern apsSuffixPattern = Pattern.compile(APS_SUFFIX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move that line one as well to private static final then it's good !

String suffix = doiAsString.substring(doiAsString.lastIndexOf('/') + 1);
String organizationId = doiAsString.substring(doiAsString.indexOf('.') + 1, doiAsString.indexOf('/'));
return organizationId.equals(APS_JOURNAL_ORG_DOI_ID);
return organizationId.equals(APS_JOURNAL_ORG_DOI_ID) && apsSuffixPattern.matcher(suffix).matches();
}
}