Search in sources :

Example 21 with FieldFormatterCleanup

use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.

the class zbMATH method doPostCleanup.

@Override
public void doPostCleanup(BibEntry entry) {
    new MoveFieldCleanup("msc2010", FieldName.KEYWORDS).cleanup(entry);
    new MoveFieldCleanup("fjournal", FieldName.JOURNAL).cleanup(entry);
    new FieldFormatterCleanup(FieldName.JOURNAL, new RemoveBracesFormatter()).cleanup(entry);
    new FieldFormatterCleanup(FieldName.TITLE, new RemoveBracesFormatter()).cleanup(entry);
}
Also used : RemoveBracesFormatter(org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) MoveFieldCleanup(org.jabref.logic.cleanup.MoveFieldCleanup)

Example 22 with FieldFormatterCleanup

use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.

the class IsbnViaEbookDeFetcher method doPostCleanup.

@Override
public void doPostCleanup(BibEntry entry) {
    // We MUST NOT clean the URL. this is the deal with ebook.de
    // DO NOT add following code:
    // new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
    // Fetcher returns page numbers as "30 Seiten" -> remove every non-digit character in the PAGETOTAL field
    entry.getField(FieldName.PAGETOTAL).ifPresent(pages -> entry.setField(FieldName.PAGETOTAL, pages.replaceAll("[\\D]", "")));
    new FieldFormatterCleanup(FieldName.PAGETOTAL, new NormalizePagesFormatter()).cleanup(entry);
    new FieldFormatterCleanup(FieldName.AUTHOR, new NormalizeNamesFormatter()).cleanup(entry);
}
Also used : NormalizeNamesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)

Example 23 with FieldFormatterCleanup

use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.

the class CleanupActionsListModelTest method resetSetsFormattersToPassedList.

@Test
public void resetSetsFormattersToPassedList() throws Exception {
    CleanupActionsListModel model = new CleanupActionsListModel(Collections.emptyList());
    FieldFormatterCleanups defaultFormatters = mock(FieldFormatterCleanups.class);
    List<FieldFormatterCleanup> formatters = Arrays.asList(new FieldFormatterCleanup("test", new ClearFormatter()));
    when(defaultFormatters.getConfiguredActions()).thenReturn(formatters);
    model.reset(defaultFormatters);
    assertEquals(formatters, model.getAllActions());
}
Also used : CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) ClearFormatter(org.jabref.logic.formatter.bibtexfields.ClearFormatter) Test(org.junit.Test)

Example 24 with FieldFormatterCleanup

use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.

the class CleanupWorkerTest method cleanupMonthChangesNumberToBibtex.

@Test
public void cleanupMonthChangesNumberToBibtex() {
    CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("month", new NormalizeMonthFormatter()))));
    BibEntry entry = new BibEntry();
    entry.setField("month", "01");
    worker.cleanup(preset, entry);
    Assert.assertEquals(Optional.of("#jan#"), entry.getField("month"));
}
Also used : NormalizeMonthFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter) BibEntry(org.jabref.model.entry.BibEntry) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) Test(org.junit.Test)

Example 25 with FieldFormatterCleanup

use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.

the class CleanupWorkerTest method cleanupDatesConvertsToCorrectFormat.

@Test
public void cleanupDatesConvertsToCorrectFormat() {
    CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("date", new NormalizeDateFormatter()))));
    BibEntry entry = new BibEntry();
    entry.setField("date", "01/1999");
    worker.cleanup(preset, entry);
    Assert.assertEquals(Optional.of("1999-01"), entry.getField("date"));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) Test(org.junit.Test)

Aggregations

FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)33 Test (org.junit.Test)22 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)20 LowerCaseFormatter (org.jabref.logic.formatter.casechanger.LowerCaseFormatter)10 BibEntry (org.jabref.model.entry.BibEntry)9 ClearFormatter (org.jabref.logic.formatter.bibtexfields.ClearFormatter)7 NormalizePagesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)5 MoveFieldCleanup (org.jabref.logic.cleanup.MoveFieldCleanup)3 IdentityFormatter (org.jabref.logic.formatter.IdentityFormatter)3 NormalizeDateFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter)3 NormalizeMonthFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter)3 StringReader (java.io.StringReader)2 NormalizeNamesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter)2 RemoveBracesFormatter (org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter)2 UpperCaseFormatter (org.jabref.logic.formatter.casechanger.UpperCaseFormatter)2 ParserResult (org.jabref.logic.importer.ParserResult)2 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1