use of org.jabref.model.groups.AutomaticPersonsGroup in project jabref by JabRef.
the class GroupsParser method automaticPersonsGroupFromString.
private static AbstractGroup automaticPersonsGroupFromString(String string) {
if (!string.startsWith(MetadataSerializationConfiguration.AUTOMATIC_PERSONS_GROUP_ID)) {
throw new IllegalArgumentException("KeywordGroup cannot be created from \"" + string + "\".");
}
QuotedStringTokenizer tok = new QuotedStringTokenizer(string.substring(MetadataSerializationConfiguration.AUTOMATIC_PERSONS_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);
AutomaticPersonsGroup newGroup = new AutomaticPersonsGroup(name, context, field);
addGroupDetails(tok, newGroup);
return newGroup;
}
use of org.jabref.model.groups.AutomaticPersonsGroup in project jabref by JabRef.
the class GroupSerializerTest method serializeSingleAutomaticPersonGroup.
@Test
public void serializeSingleAutomaticPersonGroup() {
AutomaticPersonsGroup group = new AutomaticPersonsGroup("myAutomaticGroup", GroupHierarchyType.INDEPENDENT, "authors");
List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
assertEquals(Collections.singletonList("0 AutomaticPersonsGroup:myAutomaticGroup;0;authors;1;;;;"), serialization);
}
use of org.jabref.model.groups.AutomaticPersonsGroup in project jabref by JabRef.
the class GroupsParserTest method fromStringParsesAutomaticPersonGroup.
@Test
public void fromStringParsesAutomaticPersonGroup() throws Exception {
AutomaticPersonsGroup expected = new AutomaticPersonsGroup("myAutomaticGroup", GroupHierarchyType.INDEPENDENT, "authors");
AbstractGroup parsed = GroupsParser.fromString("AutomaticPersonsGroup:myAutomaticGroup;0;authors;1;;;;", ',');
assertEquals(expected, parsed);
}
Aggregations