use of org.jabref.model.groups.AutomaticKeywordGroup in project jabref by JabRef.
the class GroupNodeViewModelTest method treeOfAutomaticKeywordGroupIsCombined.
@Test
public void treeOfAutomaticKeywordGroupIsCombined() throws Exception {
BibEntry entryOne = new BibEntry().withField("keywords", "A > B > B1, A > C");
BibEntry entryTwo = new BibEntry().withField("keywords", "A > D, E");
BibEntry entryThree = new BibEntry().withField("keywords", "A > B > B2");
databaseContext.getDatabase().insertEntries(entryOne, entryTwo, entryThree);
AutomaticKeywordGroup group = new AutomaticKeywordGroup("Keywords", GroupHierarchyType.INDEPENDENT, "keywords", ',', '>');
GroupNodeViewModel groupViewModel = getViewModelForGroup(group);
WordKeywordGroup expectedGroupA = new WordKeywordGroup("A", GroupHierarchyType.INCLUDING, "keywords", "A", true, ',', true);
WordKeywordGroup expectedGroupB = new WordKeywordGroup("B", GroupHierarchyType.INCLUDING, "keywords", "A > B", true, ',', true);
WordKeywordGroup expectedGroupB1 = new WordKeywordGroup("B1", GroupHierarchyType.INCLUDING, "keywords", "A > B > B1", true, ',', true);
WordKeywordGroup expectedGroupB2 = new WordKeywordGroup("B2", GroupHierarchyType.INCLUDING, "keywords", "A > B > B2", true, ',', true);
WordKeywordGroup expectedGroupC = new WordKeywordGroup("C", GroupHierarchyType.INCLUDING, "keywords", "A > C", true, ',', true);
WordKeywordGroup expectedGroupD = new WordKeywordGroup("D", GroupHierarchyType.INCLUDING, "keywords", "A > D", true, ',', true);
WordKeywordGroup expectedGroupE = new WordKeywordGroup("E", GroupHierarchyType.INCLUDING, "keywords", "E", true, ',', true);
GroupNodeViewModel expectedA = getViewModelForGroup(expectedGroupA);
GroupTreeNode expectedB = expectedA.addSubgroup(expectedGroupB);
expectedB.addSubgroup(expectedGroupB1);
expectedB.addSubgroup(expectedGroupB2);
expectedA.addSubgroup(expectedGroupC);
expectedA.addSubgroup(expectedGroupD);
GroupNodeViewModel expectedE = getViewModelForGroup(expectedGroupE);
ObservableList<GroupNodeViewModel> expected = FXCollections.observableArrayList(expectedA, expectedE);
assertEquals(expected, groupViewModel.getChildren());
}
use of org.jabref.model.groups.AutomaticKeywordGroup in project jabref by JabRef.
the class GroupSerializerTest method serializeSingleAutomaticKeywordGroup.
@Test
public void serializeSingleAutomaticKeywordGroup() {
AutomaticGroup group = new AutomaticKeywordGroup("myAutomaticGroup", GroupHierarchyType.INDEPENDENT, "keywords", ',', '>');
List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
assertEquals(Collections.singletonList("0 AutomaticKeywordGroup:myAutomaticGroup;0;keywords;,;>;1;;;;"), serialization);
}
use of org.jabref.model.groups.AutomaticKeywordGroup in project jabref by JabRef.
the class GroupsParserTest method fromStringParsesAutomaticKeywordGroup.
@Test
public void fromStringParsesAutomaticKeywordGroup() throws Exception {
AutomaticGroup expected = new AutomaticKeywordGroup("myAutomaticGroup", GroupHierarchyType.INDEPENDENT, "keywords", ',', '>');
AbstractGroup parsed = GroupsParser.fromString("AutomaticKeywordGroup:myAutomaticGroup;0;keywords;,;>;1;;;;", ',');
assertEquals(expected, parsed);
}
use of org.jabref.model.groups.AutomaticKeywordGroup in project jabref by JabRef.
the class GroupsParser method automaticKeywordGroupFromString.
private static AbstractGroup automaticKeywordGroupFromString(String string) {
if (!string.startsWith(MetadataSerializationConfiguration.AUTOMATIC_KEYWORD_GROUP_ID)) {
throw new IllegalArgumentException("KeywordGroup cannot be created from \"" + string + "\".");
}
QuotedStringTokenizer tok = new QuotedStringTokenizer(string.substring(MetadataSerializationConfiguration.AUTOMATIC_KEYWORD_GROUP_ID.length()), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
String name = StringUtil.unquote(tok.nextToken(), MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
GroupHierarchyType context = GroupHierarchyType.getByNumberOrDefault(Integer.parseInt(tok.nextToken()));
String field = StringUtil.unquote(tok.nextToken(), MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
Character delimiter = tok.nextToken().charAt(0);
Character hierarchicalDelimiter = tok.nextToken().charAt(0);
AutomaticKeywordGroup newGroup = new AutomaticKeywordGroup(name, context, field, delimiter, hierarchicalDelimiter);
addGroupDetails(tok, newGroup);
return newGroup;
}
Aggregations