Revision 3753
Added by Jing Tao almost 17 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
1799 | 1799 |
} |
1800 | 1800 |
} |
1801 | 1801 |
|
1802 |
/** |
|
1803 |
* Look up the node data from the database, but some node would be shown |
|
1804 |
* because of access control |
|
1805 |
* |
|
1806 |
* @param rootnodeid |
|
1807 |
* the id of the root node of the node tree to look up |
|
1808 |
* @param accessControl |
|
1809 |
* the hashtable has control info |
|
1810 |
*/ |
|
1811 |
private TreeSet getPartNodeRecordList(long rootnodeid, |
|
1812 |
Hashtable accessControl) throws McdbException |
|
1813 |
{ |
|
1814 |
PreparedStatement pstmt = null; |
|
1815 |
DBConnection dbconn = null; |
|
1816 |
int serialNumber = -1; |
|
1817 |
TreeSet nodeRecordList = new TreeSet(new NodeComparator()); |
|
1818 |
long nodeid = 0; |
|
1819 |
long parentnodeid = 0; |
|
1820 |
long nodeindex = 0; |
|
1821 |
String nodetype = null; |
|
1822 |
String nodename = null; |
|
1823 |
String nodeprefix = null; |
|
1824 |
String nodedata = null; |
|
1825 |
float nodedatanumerical = -1; |
|
1826 |
String sql = "SELECT nodeid,parentnodeid,nodeindex, " |
|
1827 |
+ "nodetype,nodename,nodeprefix,nodedata,nodedatanumerical " |
|
1828 |
+ "FROM xml_nodes WHERE rootnodeid = ?"; |
|
1829 | 1802 |
|
1830 |
// go through the access control for some nodes |
|
1831 |
Enumeration en = accessControl.elements(); |
|
1832 |
while (en.hasMoreElements()) { |
|
1833 |
SubTree tree = (SubTree) en.nextElement(); |
|
1834 |
long startId = tree.getStartNodeId(); |
|
1835 |
long endId = tree.getEndNodeId(); |
|
1836 |
sql = sql + " AND(nodeid < " + startId + " OR nodeid > " + endId |
|
1837 |
+ ")"; |
|
1838 |
|
|
1839 |
} |
|
1840 |
logMetacat.info("The final query to select part node tree: " |
|
1841 |
+ sql); |
|
1842 |
|
|
1843 |
try { |
|
1844 |
dbconn = DBConnectionPool |
|
1845 |
.getDBConnection("DocumentImpl.getPartNodeRecordList"); |
|
1846 |
serialNumber = dbconn.getCheckOutSerialNumber(); |
|
1847 |
pstmt = dbconn.prepareStatement(sql); |
|
1848 |
|
|
1849 |
// Bind the values to the query |
|
1850 |
pstmt.setLong(1, rootnodeid); |
|
1851 |
pstmt.execute(); |
|
1852 |
ResultSet rs = pstmt.getResultSet(); |
|
1853 |
boolean tableHasRows = rs.next(); |
|
1854 |
while (tableHasRows) { |
|
1855 |
nodeid = rs.getLong(1); |
|
1856 |
parentnodeid = rs.getLong(2); |
|
1857 |
nodeindex = rs.getLong(3); |
|
1858 |
nodetype = rs.getString(4); |
|
1859 |
nodename = rs.getString(5); |
|
1860 |
nodeprefix = rs.getString(6); |
|
1861 |
nodedata = rs.getString(7); |
|
1862 |
logMetacat.debug("Node data in read process before normalize=== "+nodedata); |
|
1863 |
nodedata = MetaCatUtil.normalize(nodedata); |
|
1864 |
logMetacat.debug("Node data in read process after normalize==== "+nodedata); |
|
1865 |
nodedatanumerical = rs.getFloat(8); |
|
1866 |
|
|
1867 |
// add the data to the node record list hashtable |
|
1868 |
NodeRecord currentRecord = new NodeRecord(nodeid, parentnodeid, |
|
1869 |
nodeindex, nodetype, nodename, nodeprefix, nodedata, nodedatanumerical); |
|
1870 |
nodeRecordList.add(currentRecord); |
|
1871 |
|
|
1872 |
// Advance to the next node |
|
1873 |
tableHasRows = rs.next(); |
|
1874 |
} |
|
1875 |
pstmt.close(); |
|
1876 |
|
|
1877 |
} catch (SQLException e) { |
|
1878 |
throw new McdbException( |
|
1879 |
"Error in DocumentImpl.getPartNodeRecordList " |
|
1880 |
+ e.getMessage()); |
|
1881 |
} finally { |
|
1882 |
try { |
|
1883 |
pstmt.close(); |
|
1884 |
} catch (SQLException ee) { |
|
1885 |
logMetacat.error( |
|
1886 |
"error in DocumentImpl.getPartNodeRecordList: " |
|
1887 |
+ ee.getMessage()); |
|
1888 |
} finally { |
|
1889 |
DBConnectionPool.returnDBConnection(dbconn, serialNumber); |
|
1890 |
} |
|
1891 |
} |
|
1892 |
|
|
1893 |
if (!nodeRecordList.isEmpty()) { |
|
1894 |
|
|
1895 |
return nodeRecordList; |
|
1896 |
} else { |
|
1897 |
|
|
1898 |
throw new McdbException("Error getting node data: " + docid); |
|
1899 |
} |
|
1900 |
} |
|
1901 |
|
|
1902 | 1803 |
/** |
1903 | 1804 |
* Look up the node data from the database |
1904 | 1805 |
* |
Also available in: Unified diff
Remove an obsolete private method getPartNodeRecordList.