-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add meaningful names in DublinCoreExtractor and use StringUtils.isNul…
…lOrEmpty
- Loading branch information
1 parent
9cc529f
commit 366aeed
Showing
1 changed file
with
28 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.FieldName; | ||
import org.jabref.model.entry.Month; | ||
import org.jabref.model.strings.StringUtil; | ||
|
||
import com.microsoft.applicationinsights.agent.internal.common.StringUtils; | ||
import org.apache.xmpbox.DateConverter; | ||
import org.apache.xmpbox.schema.DublinCoreSchema; | ||
|
||
|
@@ -69,16 +71,16 @@ private void extractYearAndMonth() { | |
List<String> dates = dcSchema.getUnqualifiedSequenceValueList("date"); | ||
if ((dates != null) && !dates.isEmpty()) { | ||
String date = dates.get(0).trim(); | ||
Calendar c = null; | ||
Calendar calender = null; | ||
try { | ||
c = DateConverter.toCalendar(date); | ||
calender = DateConverter.toCalendar(date); | ||
} catch (IOException ignored) { | ||
// Ignored | ||
} | ||
if (c != null) { | ||
bibEntry.setField(FieldName.YEAR, String.valueOf(c.get(Calendar.YEAR))); | ||
if (calender != null) { | ||
bibEntry.setField(FieldName.YEAR, String.valueOf(calender.get(Calendar.YEAR))); | ||
if (date.length() > 4) { | ||
Optional<Month> month = Month.getMonthByNumber(c.get(Calendar.MONTH) + 1); | ||
Optional<Month> month = Month.getMonthByNumber(calender.get(Calendar.MONTH) + 1); | ||
month.ifPresent(bibEntry::setMonth); | ||
} | ||
} | ||
|
@@ -92,9 +94,9 @@ private void extractYearAndMonth() { | |
* @param dcSchema Metadata in DublinCore format. | ||
*/ | ||
private void extractAbstract() { | ||
String s = dcSchema.getDescription(); | ||
if (s != null) { | ||
bibEntry.setField(FieldName.ABSTRACT, s); | ||
String description = dcSchema.getDescription(); | ||
if (!StringUtil.isNullOrEmpty(description)) { | ||
bibEntry.setField(FieldName.ABSTRACT, description); | ||
} | ||
} | ||
|
||
|
@@ -105,9 +107,9 @@ private void extractAbstract() { | |
* @param dcSchema Metadata in DublinCore format. | ||
*/ | ||
private void extractDOI() { | ||
String s = dcSchema.getIdentifier(); | ||
if (s != null) { | ||
bibEntry.setField(FieldName.DOI, s); | ||
String identifier = dcSchema.getIdentifier(); | ||
if (!StringUtils.isNullOrEmpty(identifier)) { | ||
bibEntry.setField(FieldName.DOI, identifier); | ||
} | ||
} | ||
|
||
|
@@ -154,9 +156,9 @@ private void extractBibTexFields() { | |
* @param dcSchema Metadata in DublinCore format. | ||
*/ | ||
private void extractRights() { | ||
String s = dcSchema.getRights(); | ||
if (s != null) { | ||
bibEntry.setField("rights", s); | ||
String rights = dcSchema.getRights(); | ||
if (!StringUtils.isNullOrEmpty(rights)) { | ||
bibEntry.setField("rights", rights); | ||
} | ||
} | ||
|
||
|
@@ -167,9 +169,9 @@ private void extractRights() { | |
* @param dcSchema Metadata in DublinCore format. | ||
*/ | ||
private void extractSource() { | ||
String s = dcSchema.getSource(); | ||
if (s != null) { | ||
bibEntry.setField("source", s); | ||
String source = dcSchema.getSource(); | ||
if (!StringUtils.isNullOrEmpty(source)) { | ||
bibEntry.setField("source", source); | ||
} | ||
} | ||
|
||
|
@@ -180,7 +182,7 @@ private void extractSource() { | |
*/ | ||
private void extractSubject() { | ||
List<String> subjects = dcSchema.getSubjects(); | ||
if (subjects != null) { | ||
if ((subjects != null) && !subjects.isEmpty()) { | ||
bibEntry.addKeywords(subjects, xmpPreferences.getKeywordSeparator()); | ||
} | ||
} | ||
|
@@ -192,9 +194,9 @@ private void extractSubject() { | |
* @param dcSchema Metadata in DublinCore format. | ||
*/ | ||
private void extractTitle() { | ||
String s = dcSchema.getTitle(); | ||
if (s != null) { | ||
bibEntry.setField(FieldName.TITLE, s); | ||
String title = dcSchema.getTitle(); | ||
if (!StringUtil.isNullOrEmpty(title)) { | ||
bibEntry.setField(FieldName.TITLE, title); | ||
} | ||
} | ||
|
||
|
@@ -205,11 +207,11 @@ private void extractTitle() { | |
* @param dcSchema Metadata in DublinCore format. | ||
*/ | ||
private void extractType() { | ||
List<String> l = dcSchema.getTypes(); | ||
if ((l != null) && !l.isEmpty()) { | ||
String s = l.get(0); | ||
if (s != null) { | ||
bibEntry.setType(s); | ||
List<String> types = dcSchema.getTypes(); | ||
if ((types != null) && !types.isEmpty()) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Siedlerchr
Member
|
||
String type = types.get(0); | ||
if (!StringUtils.isNullOrEmpty(type)) { | ||
bibEntry.setType(type); | ||
} | ||
} | ||
} | ||
|
Gotcha :-P