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;
}
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());
}
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);
}
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;
}
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, ',');
}
Aggregations