Search in sources :

Example 1 with AutomaticPersonsGroup

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;
}
Also used : QuotedStringTokenizer(org.jabref.logic.util.strings.QuotedStringTokenizer) GroupHierarchyType(org.jabref.model.groups.GroupHierarchyType) AutomaticPersonsGroup(org.jabref.model.groups.AutomaticPersonsGroup)

Example 2 with AutomaticPersonsGroup

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);
}
Also used : AutomaticPersonsGroup(org.jabref.model.groups.AutomaticPersonsGroup) GroupTreeNodeTest(org.jabref.model.groups.GroupTreeNodeTest) Test(org.junit.Test)

Example 3 with AutomaticPersonsGroup

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);
}
Also used : AbstractGroup(org.jabref.model.groups.AbstractGroup) AutomaticPersonsGroup(org.jabref.model.groups.AutomaticPersonsGroup) Test(org.junit.Test)

Aggregations

AutomaticPersonsGroup (org.jabref.model.groups.AutomaticPersonsGroup)3 Test (org.junit.Test)2 QuotedStringTokenizer (org.jabref.logic.util.strings.QuotedStringTokenizer)1 AbstractGroup (org.jabref.model.groups.AbstractGroup)1 GroupHierarchyType (org.jabref.model.groups.GroupHierarchyType)1 GroupTreeNodeTest (org.jabref.model.groups.GroupTreeNodeTest)1