Search in sources :

Example 1 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class BibtexKeyPatternPanel method getKeyPatternAsDatabaseBibtexKeyPattern.

public DatabaseBibtexKeyPattern getKeyPatternAsDatabaseBibtexKeyPattern() {
    DatabaseBibtexKeyPattern res = new DatabaseBibtexKeyPattern(Globals.prefs.getKeyPattern());
    fillPatternUsingPanelData(res);
    return res;
}
Also used : DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern)

Example 2 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class BibtexDatabaseWriterTest method writeMetadata.

@Test
public void writeMetadata() throws Exception {
    DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(mock(GlobalBibtexKeyPattern.class));
    bibtexKeyPattern.setDefaultValue("test");
    metaData.setCiteKeyPattern(bibtexKeyPattern);
    StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), new SavePreferences());
    assertEquals(OS.NEWLINE + "@Comment{jabref-meta: keypatterndefault:test;}" + OS.NEWLINE, session.getStringValue());
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern) Test(org.junit.Test)

Example 3 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class BibtexParserTest method integrationTestCustomKeyPattern.

@Test
public void integrationTestCustomKeyPattern() throws IOException {
    ParserResult result = BibtexParser.parse(new StringReader("@comment{jabref-meta: keypattern_article:articleTest;}" + OS.NEWLINE + "@comment{jabref-meta: keypatterndefault:test;}"), importFormatPreferences);
    GlobalBibtexKeyPattern pattern = mock(GlobalBibtexKeyPattern.class);
    AbstractBibtexKeyPattern bibtexKeyPattern = result.getMetaData().getCiteKeyPattern(pattern);
    AbstractBibtexKeyPattern expectedPattern = new DatabaseBibtexKeyPattern(pattern);
    expectedPattern.setDefaultValue("test");
    expectedPattern.addBibtexKeyPattern("article", "articleTest");
    assertEquals(expectedPattern, bibtexKeyPattern);
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) StringReader(java.io.StringReader) DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern) AbstractBibtexKeyPattern(org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern) Test(org.junit.Test)

Example 4 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class MetaData method getCiteKeyPattern.

/**
     * @return the stored label patterns
     */
public AbstractBibtexKeyPattern getCiteKeyPattern(GlobalBibtexKeyPattern globalPattern) {
    Objects.requireNonNull(globalPattern);
    AbstractBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(globalPattern);
    // Add stored key patterns
    citeKeyPatterns.forEach(bibtexKeyPattern::addBibtexKeyPattern);
    getDefaultCiteKeyPattern().ifPresent(bibtexKeyPattern::setDefaultValue);
    return bibtexKeyPattern;
}
Also used : DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern) AbstractBibtexKeyPattern(org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern)

Example 5 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class MakeLabelWithDatabaseTest method setUp.

@Before
public void setUp() {
    database = new BibDatabase();
    entry = new BibEntry();
    entry.setField("author", "John Doe");
    entry.setField("year", "2016");
    entry.setField("title", "An awesome paper on JabRef");
    database.insertEntry(entry);
    pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
    bibtexKeyPattern = new DatabaseBibtexKeyPattern(pattern);
    preferences = new BibtexKeyPatternPreferences("", "", false, true, true, pattern, ',');
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern) BibDatabase(org.jabref.model.database.BibDatabase) Before(org.junit.Before)

Aggregations

DatabaseBibtexKeyPattern (org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern)7 GlobalBibtexKeyPattern (org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern)4 Test (org.junit.Test)4 AbstractBibtexKeyPattern (org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern)3 StringReader (java.io.StringReader)1 ParserResult (org.jabref.logic.importer.ParserResult)1 BibDatabase (org.jabref.model.database.BibDatabase)1 BibEntry (org.jabref.model.entry.BibEntry)1 Before (org.junit.Before)1