Changeset 54

Show
Ignore:
Timestamp:
02/22/10 18:48:09 (2 years ago)
Author:
ke
Message:

DB tree: further bugfixes (DB handler was returning 0 instead of -1 for non-existing parents, node status was not being set), more to come

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • kahina/trunk/src/org/kahina/data/tree/KahinaDbTree.java

    r53 r54  
    100100                int treeID = getID(); 
    101101                addNodeStatement = db.prepareStatement("INSERT INTO " + NODE_TABLE_NAME 
    102                                 + " (id, tree, nodeCaption, edgeLabel) VALUES (?, " + treeID 
    103                                 + ", ?, ?)"); 
     102                                + " (id, tree, nodeCaption, edgeLabel, status) VALUES (?, " 
     103                                + treeID + ", ?, ?, ?)"); 
    104104                addEdgeStatement = db.prepareStatement("UPDATE " + NODE_TABLE_NAME 
    105105                                + " SET realParent = ? WHERE id = ? AND tree = " + treeID); 
     
    154154                        addNodeStatement.setString(2, caption); 
    155155                        addNodeStatement.setString(3, label); 
     156                        addNodeStatement.setInt(4, nodeStatus); 
    156157                        addNodeStatement.execute(); 
    157158                } catch (SQLException e) 
     
    309310                        // the most common case, for which we have precalculated the virtual 
    310311                        // children 
    311                         return getVirtualChildren(nodeID); 
     312                        List<Integer> result = getVirtualChildren(nodeID); 
     313                        return result; 
    312314                } 
    313315                if (nodeID == getRootID(layer) || nodeLayer >= layer) 
  • kahina/trunk/src/org/kahina/io/database/DatabaseHandler.java

    r50 r54  
    7474                                return defaultValue; 
    7575                        } 
    76                         return resultSet.getInt(1); 
    77                 } catch (SQLException e) 
    78                 { 
    79                         throw new KahinaException("SQL error.", e); 
    80                 } 
    81         } 
    82  
     76                        int result = resultSet.getInt(1); 
     77                        if (resultSet.wasNull()) 
     78                        { 
     79                                return defaultValue; 
     80                        } 
     81                        return result; 
     82                } catch (SQLException e) 
     83                { 
     84                        throw new KahinaException("SQL error.", e); 
     85                } 
     86        } 
     87 
     88        // TODO treat NULL values appropriately 
    8389        public List<Integer> queryIntList(PreparedStatement statement) 
    8490        { 
     
    98104        } 
    99105 
     106        // TODO treat NULL values appropriately 
    100107        public Set<Integer> queryIntSet(PreparedStatement statement) 
    101108        { 
     
    129136                                return defaultValue; 
    130137                        } 
    131                         return resultSet.getString(1); 
     138                        String result = resultSet.getString(1); 
     139                        if (resultSet.wasNull()) 
     140                        { 
     141                                return defaultValue; 
     142                        } 
     143                        return result; 
    132144                } catch (SQLException e) 
    133145                { 
  • kahina/trunk/src/org/kahina/test/KahinaTreeTest.java

    r53 r54  
    2424 
    2525public class KahinaTreeTest 
    26 { 
     26{       
    2727    public static void main(String[] args) 
    2828    { 
  • kahina/trunk/src/org/kahina/visual/tree/KahinaTreeView.java

    r52 r54  
    607607        nodeBorderColor = new HashMap<Integer, Color>(); 
    608608        resetAllStructures(); 
     609        System.err.println("F"); 
    609610        calculateCoordinates(); 
    610611    } 
     
    626627        FontMetrics fm = getFontMetrics(new Font(Font.SANS_SERIF,Font.PLAIN, fontSize), new BasicStroke(1), fontSize); 
    627628        nodeHeight = fm.getHeight(); 
    628          
     629 
    629630        createNodeLayers(); 
    630631        System.err.println(showLevels()); 
     
    652653                    int nodeLabelWidth = fm.stringWidth(getContentfulTreeModel().getNodeCaption(node)); 
    653654                    if (maxNodeWidth < nodeLabelWidth) maxNodeWidth = nodeLabelWidth; 
    654                     ArrayList<Integer> children = getVisibleVirtualChildren(treeModel, node);            
     655                    ArrayList<Integer> children = getVisibleVirtualChildren(treeModel, node); 
    655656                    subtreeWidths.put(node,constructWidthVector(children)); 
    656657                    //System.err.println("  Node:" + node + " VisChildren:" + children + " WidthVector:" + subtreeWidths.get(node)); 
     
    832833        for (int i = 0; i < descendants.size(); i++) 
    833834        { 
    834             if (!nodeIsVisible(descendants.get(i))) 
    835             { 
    836                 descendants.addAll(treeModel.getChildren(descendants.remove(i),treeLayer)); 
     835                boolean nodeIsVisible = nodeIsVisible(descendants.get(i)); 
     836            if (!nodeIsVisible) 
     837            { 
     838                List<Integer> x = treeModel.getChildren(descendants.remove(i),treeLayer); 
     839                descendants.addAll(x); 
    837840                i--; 
    838841            }