Search in sources :

Example 1 with SearchGroup

use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.

the class GroupTreeNodeViewModel method getDescription.

public String getDescription() {
    AbstractGroup group = node.getGroup();
    String shortDescription = "";
    boolean showDynamic = true;
    if (group instanceof ExplicitGroup) {
        shortDescription = GroupDescriptions.getShortDescriptionExplicitGroup((ExplicitGroup) group);
    } else if (group instanceof KeywordGroup) {
        shortDescription = GroupDescriptions.getShortDescriptionKeywordGroup((KeywordGroup) group, showDynamic);
    } else if (group instanceof SearchGroup) {
        shortDescription = GroupDescriptions.getShortDescription((SearchGroup) group, showDynamic);
    } else {
        shortDescription = GroupDescriptions.getShortDescriptionAllEntriesGroup();
    }
    return "<html>" + shortDescription + "</html>";
}
Also used : KeywordGroup(org.jabref.model.groups.KeywordGroup) AbstractGroup(org.jabref.model.groups.AbstractGroup) SearchGroup(org.jabref.model.groups.SearchGroup) ExplicitGroup(org.jabref.model.groups.ExplicitGroup)

Example 2 with SearchGroup

use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.

the class GroupSerializerTest method serializeSingleSearchGroup.

@Test
public void serializeSingleSearchGroup() {
    SearchGroup group = new SearchGroup("myExplicitGroup", GroupHierarchyType.INDEPENDENT, "author=harrer", true, true);
    List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
    assertEquals(Collections.singletonList("0 SearchGroup:myExplicitGroup;0;author=harrer;1;1;1;;;;"), serialization);
}
Also used : SearchGroup(org.jabref.model.groups.SearchGroup) GroupTreeNodeTest(org.jabref.model.groups.GroupTreeNodeTest) Test(org.junit.Test)

Example 3 with SearchGroup

use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.

the class GroupSerializerTest method serializeSingleSearchGroupWithRegex.

@Test
public void serializeSingleSearchGroupWithRegex() {
    SearchGroup group = new SearchGroup("myExplicitGroup", GroupHierarchyType.INCLUDING, "author=\"harrer\"", true, false);
    List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
    assertEquals(Collections.singletonList("0 SearchGroup:myExplicitGroup;2;author=\"harrer\";1;0;1;;;;"), serialization);
}
Also used : SearchGroup(org.jabref.model.groups.SearchGroup) GroupTreeNodeTest(org.jabref.model.groups.GroupTreeNodeTest) Test(org.junit.Test)

Example 4 with SearchGroup

use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.

the class GroupsParser method searchGroupFromString.

/**
     * Parses s and recreates the SearchGroup from it.
     *
     * @param s The String representation obtained from
     *          SearchGroup.toString(), or null if incompatible
     */
private static AbstractGroup searchGroupFromString(String s) {
    if (!s.startsWith(MetadataSerializationConfiguration.SEARCH_GROUP_ID)) {
        throw new IllegalArgumentException("SearchGroup cannot be created from \"" + s + "\".");
    }
    QuotedStringTokenizer tok = new QuotedStringTokenizer(s.substring(MetadataSerializationConfiguration.SEARCH_GROUP_ID.length()), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
    String name = tok.nextToken();
    int context = Integer.parseInt(tok.nextToken());
    String expression = tok.nextToken();
    boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
    boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
    // fields; these are ignored now, all fields are always searched
    return new SearchGroup(StringUtil.unquote(name, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR), GroupHierarchyType.getByNumberOrDefault(context), StringUtil.unquote(expression, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR), caseSensitive, regExp);
}
Also used : QuotedStringTokenizer(org.jabref.logic.util.strings.QuotedStringTokenizer) SearchGroup(org.jabref.model.groups.SearchGroup)

Aggregations

SearchGroup (org.jabref.model.groups.SearchGroup)4 GroupTreeNodeTest (org.jabref.model.groups.GroupTreeNodeTest)2 Test (org.junit.Test)2 QuotedStringTokenizer (org.jabref.logic.util.strings.QuotedStringTokenizer)1 AbstractGroup (org.jabref.model.groups.AbstractGroup)1 ExplicitGroup (org.jabref.model.groups.ExplicitGroup)1 KeywordGroup (org.jabref.model.groups.KeywordGroup)1