Search in sources :

Example 6 with GlobalBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern 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 7 with GlobalBibtexKeyPattern

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

the class SynchronizationTestSimulator method setUp.

@Before
public void setUp() throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
    this.dbmsConnection = TestConnector.getTestDBMSConnection(dbmsType);
    GlobalBibtexKeyPattern pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
    clientContextA = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX), DatabaseLocation.SHARED, ',', pattern);
    clientContextA.getDBMSSynchronizer().openSharedDatabase(dbmsConnection);
    clientContextB = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX), DatabaseLocation.SHARED, ',', pattern);
    clientContextB.getDBMSSynchronizer().openSharedDatabase(dbmsConnection);
    eventListenerB = new SynchronizationTestEventListener();
    clientContextB.getDBMSSynchronizer().registerListener(eventListenerB);
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) Defaults(org.jabref.model.Defaults) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Before(org.junit.Before)

Example 8 with GlobalBibtexKeyPattern

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

the class PreferencesMigrations method migrateTypedKeyPrefs.

private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences oldPatternPrefs) throws BackingStoreException {
    LOGGER.info("Found old Bibtex Key patterns which will be migrated to new version.");
    GlobalBibtexKeyPattern keyPattern = GlobalBibtexKeyPattern.fromPattern(prefs.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN));
    for (String key : oldPatternPrefs.keys()) {
        keyPattern.addBibtexKeyPattern(key, oldPatternPrefs.get(key, null));
    }
    prefs.putKeyPattern(keyPattern);
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern)

Aggregations

GlobalBibtexKeyPattern (org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern)8 Charset (java.nio.charset.Charset)2 LatexFieldFormatterPreferences (org.jabref.logic.bibtex.LatexFieldFormatterPreferences)2 AbstractBibtexKeyPattern (org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern)2 SaveOrderConfig (org.jabref.model.metadata.SaveOrderConfig)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ParserResult (org.jabref.logic.importer.ParserResult)1 OS (org.jabref.logic.util.OS)1 Defaults (org.jabref.model.Defaults)1 DatabaseBibtexKeyPattern (org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern)1 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)1 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)1 GroupTreeNode (org.jabref.model.groups.GroupTreeNode)1 ContentSelector (org.jabref.model.metadata.ContentSelector)1