1180 |
1180 |
nodeRecordMap.put(nodeId, currentNode);
|
1181 |
1181 |
}
|
1182 |
1182 |
|
1183 |
|
// Build a map of the node records that can be accessed by nodeId
|
1184 |
|
HashMap parentNodeRecordMap = new HashMap();
|
1185 |
|
Iterator ite = nodeRecordLists.iterator();
|
1186 |
|
while (ite.hasNext()) {
|
1187 |
|
NodeRecord currentNode = (NodeRecord) ite.next();
|
1188 |
|
Long nodeId = new Long(currentNode.getParentNodeId());
|
1189 |
|
parentNodeRecordMap.put(nodeId, currentNode);
|
1190 |
|
}
|
1191 |
|
|
1192 |
1183 |
// Opening separate db connection for deleting and writing
|
1193 |
1184 |
// XML Index -- be sure that it is all in one db transaction
|
1194 |
1185 |
int serialNumber = -1;
|
... | ... | |
1213 |
1204 |
if (currentNode.nodetype.equals("ELEMENT") ||
|
1214 |
1205 |
currentNode.nodetype.equals("ATTRIBUTE") ) {
|
1215 |
1206 |
|
1216 |
|
String nodedata = null;
|
1217 |
|
|
1218 |
|
if (currentNode.nodetype.equals("ELEMENT") ) {
|
1219 |
|
Long nodeid = new Long(currentNode.getNodeId());
|
1220 |
|
NodeRecord node =
|
1221 |
|
(NodeRecord) parentNodeRecordMap.get(nodeid);
|
1222 |
|
if(node!=null){
|
1223 |
|
nodedata = node.getNodeData();
|
1224 |
|
}
|
1225 |
|
} else {
|
1226 |
|
nodedata = currentNode.getNodeData();
|
1227 |
|
}
|
1228 |
|
|
1229 |
1207 |
if (atRootElement) {
|
1230 |
1208 |
rootNodeId = currentNode.getNodeId();
|
1231 |
1209 |
atRootElement = false;
|
1232 |
1210 |
}
|
1233 |
1211 |
traverseParents(nodeRecordMap, rootNodeId,
|
1234 |
1212 |
currentNode.getNodeId(),
|
1235 |
|
currentNode.getNodeId(), "", pathList, nodedata);
|
|
1213 |
currentNode.getNodeId(), "", pathList);
|
1236 |
1214 |
updateNodeIndex(dbConn, pathList);
|
1237 |
1215 |
}
|
1238 |
1216 |
}
|
... | ... | |
1269 |
1247 |
*/
|
1270 |
1248 |
private void traverseParents(HashMap records, long rootNodeId,
|
1271 |
1249 |
long leafNodeId, long id,
|
1272 |
|
String children, HashMap pathList, String nodedata) {
|
|
1250 |
String children, HashMap pathList) {
|
1273 |
1251 |
Long nodeId = new Long(id);
|
1274 |
1252 |
NodeRecord current = (NodeRecord)records.get(nodeId);
|
1275 |
1253 |
long parentId = current.getParentNodeId();
|
... | ... | |
1283 |
1261 |
}
|
1284 |
1262 |
MetaCatUtil.debugMessage("A: " + currentName +"\n", 60);
|
1285 |
1263 |
pathList.put(currentName, new PathIndexEntry(leafNodeId,
|
1286 |
|
currentName, docid, doctype, parentId, nodedata));
|
|
1264 |
currentName, docid, doctype, parentId));
|
1287 |
1265 |
}
|
1288 |
1266 |
currentName = "/" + currentName;
|
1289 |
1267 |
currentName = currentName + children;
|
1290 |
1268 |
if (parentId != 0) {
|
1291 |
1269 |
traverseParents(records, rootNodeId, leafNodeId,
|
1292 |
|
parentId, currentName, pathList, nodedata);
|
|
1270 |
parentId, currentName, pathList);
|
1293 |
1271 |
}
|
1294 |
1272 |
String path = current.getNodeName() + children;
|
1295 |
1273 |
if (!children.equals("")) {
|
1296 |
1274 |
MetaCatUtil.debugMessage("B: " + path +"\n", 60);
|
1297 |
1275 |
pathList.put(path, new PathIndexEntry(leafNodeId, path, docid,
|
1298 |
|
doctype, parentId, nodedata));
|
|
1276 |
doctype, parentId));
|
1299 |
1277 |
}
|
1300 |
1278 |
if (id == rootNodeId) {
|
1301 |
1279 |
String fullPath = '/' + path;
|
1302 |
1280 |
MetaCatUtil.debugMessage("C: " + fullPath +"\n", 60);
|
1303 |
1281 |
pathList.put(fullPath, new PathIndexEntry(leafNodeId, fullPath,
|
1304 |
|
docid, doctype, parentId, nodedata));
|
|
1282 |
docid, doctype, parentId));
|
1305 |
1283 |
}
|
1306 |
1284 |
}
|
1307 |
1285 |
}
|
Removed irrelevant code from previous commit