public static void mergeFromBibtex(JabRefFrame frame, BasePanel panel, ParserResult pr,
boolean importEntries, boolean importStrings,
boolean importGroups, boolean importSelectorWords)
throws KeyCollisionException {
BibtexDatabase fromDatabase = pr.getDatabase();
ArrayList<BibtexEntry> appendedEntries = new ArrayList<BibtexEntry>();
ArrayList<BibtexEntry> originalEntries = new ArrayList<BibtexEntry>();
BibtexDatabase database = panel.database();
BibtexEntry originalEntry;
NamedCompound ce = new NamedCompound(Globals.lang("Append database"));
MetaData meta = new MetaData(pr.getMetaData(), pr.getDatabase());
if (importEntries) { // Add entries
boolean overwriteOwner = Globals.prefs.getBoolean("overwriteOwner");
boolean overwriteTimeStamp = Globals.prefs.getBoolean("overwriteTimeStamp");
for (String key : fromDatabase.getKeySet()){
originalEntry = fromDatabase.getEntryById(key);
BibtexEntry be = (BibtexEntry) (originalEntry.clone());
be.setId(Util.createNeutralId());
Util.setAutomaticFields(be, overwriteOwner, overwriteTimeStamp);
database.insertEntry(be);
appendedEntries.add(be);
originalEntries.add(originalEntry);
ce.addEdit(new UndoableInsertEntry(database, be, panel));
}
}
if (importStrings) {
for (BibtexString bs : fromDatabase.getStringValues()){
if (!database.hasStringLabel(bs.getName())) {
database.addString(bs);
ce.addEdit(new UndoableInsertString(panel, database, bs));
}
}
}