Package net.sf.jabref.groups

Examples of net.sf.jabref.groups.AbstractGroup


        }
    }

    protected AbstractAction getAction(GroupTreeNode node) {
        AbstractAction action = new AddToGroupAction(node);
        AbstractGroup group = node.getGroup();
        action.setEnabled(group.supportsAdd());
        return action;
    }
View Full Code Here


            // Create a lookup map for finding the parent to add each group to:
            HashMap<String, GroupTreeNode> groups = new HashMap<String, GroupTreeNode>();
            LinkedHashMap<GroupTreeNode, String> parentIds = new LinkedHashMap<GroupTreeNode, String>();
           
            while ( rs.next()) {
                AbstractGroup group = null;
                String typeId = findGroupTypeName(rs.getString("group_types_id"), conn);
                if (typeId.equals(AllEntriesGroup.ID)) {
                    // register the id of the root node:
                    groups.put(rs.getString("groups_id"), rootNode);
                }
                else if (typeId.equals(ExplicitGroup.ID)) {
                    group = new ExplicitGroup(rs.getString("label"),
                            rs.getInt("hierarchical_context"));
                }
                else if (typeId.equals(KeywordGroup.ID)) {
                    System.out.println("Keyw: "+ rs.getBoolean("case_sensitive"));
                    group = new KeywordGroup(rs.getString("label"),
                            Util.unquote(rs.getString("search_field"), '\\'),
                            Util.unquote(rs.getString("search_expression"), '\\'),
                            rs.getBoolean("case_sensitive"), rs.getBoolean("reg_exp"),
                            rs.getInt("hierarchical_context"));
                }
                else if (typeId.equals(SearchGroup.ID)) {
                    System.out.println("Search: "+ rs.getBoolean("case_sensitive"));
                    group = new SearchGroup(rs.getString("label"),
                            Util.unquote(rs.getString("search_expression"), '\\'),
                            rs.getBoolean("case_sensitive"), rs.getBoolean("reg_exp"),
                            rs.getInt("hierarchical_context"));
                }

                if (group != null) {
                    GroupTreeNode node = new GroupTreeNode(group);
                    parentIds.put(node, rs.getString("parent_id"));
                    groups.put(rs.getString("groups_id"), node);
                }
            }
            statement.close();

            // Ok, we have collected a map of all groups and their parent IDs,
            // and another map of all group IDs and their group nodes.
            // Now we need to build the groups tree:
            for (Iterator<GroupTreeNode> i=parentIds.keySet().iterator(); i.hasNext();) {
                GroupTreeNode node = i.next();
                String parentId = parentIds.get(node);
                // Look up the parent:
                GroupTreeNode parent = groups.get(parentId);
                if (parent == null) {
                    // TODO: missing parent
                }
                else {
                    parent.add(node);
                }
            }

            // If we have explicit groups, set up group membership:
            res = processDMLWithResults(conn, "SELECT * FROM entry_group;");
            if (res instanceof Statement) {
                statement = (Statement)res;
                rs = statement.getResultSet();
                while ( rs.next()) {
                    String entryId = rs.getString("entries_id"),
                            groupId = rs.getString("groups_id");
                    GroupTreeNode node = groups.get(groupId);
                    if ((node != null) && (node.getGroup() instanceof ExplicitGroup)) {
                        ExplicitGroup group = (ExplicitGroup)node.getGroup();
                        group.addEntry(entries.get(entryId));
                    } else {
                        // TODO: unable to find explicit group with the given id
                    }
                }
                statement.close();
View Full Code Here

     *            The output (PrintStream or Connection) object to which the DML should be written.
     */
  private static int dmlPopTab_GP_worker (GroupTreeNode cursor, int parentID,
            int ID, Object out) throws SQLException{

        AbstractGroup group = cursor.getGroup();
        String searchField = null, searchExpr = null, caseSensitive = null, reg_exp = null;
        int hierContext = group.getHierarchicalContext();
        if (group instanceof KeywordGroup) {
            searchField = ((KeywordGroup)group).getSearchField();
            searchExpr = ((KeywordGroup)group).getSearchExpression();
            caseSensitive = ((KeywordGroup)group).isCaseSensitive() ? "1" : "0";
            reg_exp = ((KeywordGroup)group).isRegExp() ? "1" : "0";
        }
        else if (group instanceof SearchGroup) {
            searchExpr = ((SearchGroup)group).getSearchExpression();
            caseSensitive = ((SearchGroup)group).isCaseSensitive() ? "1" : "0";
            reg_exp = ((SearchGroup)group).isRegExp() ? "1" : "0";
        }

        // Protect all quotes in the group descriptions:
        if (searchField != null)
            searchField = Util.quote(searchField, "\"", '\\');
        if (searchExpr != null)
            searchExpr = Util.quote(searchExpr, "\"", '\\');

        // handle DML according to output type
        processDML(out, "INSERT INTO groups (groups_id, label, parent_id, group_types_id, search_field, "
            +"search_expression, case_sensitive, reg_exp, hierarchical_context) "
              + "VALUES (" + ID + ", \"" + cursor.getGroup().getName()
              + "\", " + parentID
                      +", (SELECT group_types_id FROM group_types where label=\""+group.getTypeId()+"\")"
                      +", "+(searchField != null ? "\""+searchField+"\"" : "NULL")
                      +", "+(searchExpr != null ? "\""+searchExpr+"\"" : "NULL")
                      +", "+(caseSensitive != null ? "\""+caseSensitive+"\"" : "NULL")
                      +", "+(reg_exp != null ? "\""+reg_exp+"\"" : "NULL")
                      +", "+hierContext
View Full Code Here

TOP

Related Classes of net.sf.jabref.groups.AbstractGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.