Project

General

Profile

« Previous | Next » 

Revision 23

adding recursive build for ReaderElement

View differences:

DBReader.java
31 31
     } else {
32 32
        try {
33 33
                    
34
          String nodeid = args[0];
34
          String nodeidstr = args[0];
35
          long nodeid = (new Long(nodeidstr).longValue());
35 36
          String user     = args[1];
36 37
          String password = args[2];
37 38
          String dbstring = null;
......
77 78
     return conn;
78 79
  }
79 80

  
80
  public String readDocument(String nodeid) {
81
  public String readDocument(long nodeid) {
81 82
    StringBuffer doc = new StringBuffer();
82 83

  
83 84
    System.out.println("\nGetting document with nodeid: " + nodeid + "\n");
84
    BasicElement element = readNodeFromDB(nodeid);
85
    //BasicElement element = readNodeFromDB(nodeid);
86
    ReaderElement element = new ReaderElement(conn, nodeid);
85 87
    doc.append(element);
86 88

  
87 89
    return (doc.toString());
88 90
  }
89 91

  
90 92
  /** look up the assigned element id from DB connection */
91
  private BasicElement readNodeFromDB(String nodeid) {
93
  private BasicElement readNodeFromDB(long nodeid) {
92 94
      long element_id=0;
93 95
      long nodeparentid=0;
94 96
      String nodetype=null;
......
98 100
      PreparedStatement pstmt;
99 101
      try {
100 102
        pstmt = 
101
          conn.prepareStatement("SELECT nodeid,nodeparentid,nodetype,
102
                  nodename,nodedata FROM xml_nodes WHERE nodeid = ?");
103
          conn.prepareStatement("SELECT nodeid,nodeparentid,nodetype, " +
104
                  "nodename,nodedata FROM xml_nodes WHERE nodeid = ?");
103 105
        // Bind the values to the query
104
        pstmt.setString(1, nodeid);
106
        pstmt.setLong(1, nodeid);
105 107

  
106 108
        pstmt.execute();
107 109
        try {
......
130 132
        System.out.println("Error getting id: " + e.getMessage());
131 133
      }
132 134

  
135
      BasicElement element = null;
133 136
      if (nodetype.equals("ELEMENT")) {
134
        BasicElement element = 
135
                 new BasicElement(element_id,nodename,nodeparentid);
137
        element = new BasicElement(element_id,nodename,nodeparentid);
136 138
        element.appendContent(nodedata);
137 139
      }
138 140

  
......
143 145
                                "nodename,nodedata FROM xml_nodes " +
144 146
                                "WHERE nodeparentid = ?");
145 147
        // Bind the values to the query
146
        pstmt.setString(1, nodeid);
148
        pstmt.setLong(1, nodeid);
147 149

  
148 150
        pstmt.execute();
149 151
        try {

Also available in: Unified diff