Project

General

Profile

« Previous | Next » 

Revision 3147

Added by Chris Jones over 17 years ago

As part of a patch fix for:

http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2469

I've changed DocumentImpl.java in three locations:

buildIndex()
traverseParents()
updatePathIndex()

This patch modifies traverseParents(). It changes pathsFoundForIndexing from
a vector to a HashMap, and while it processes leaf node xpaths, relative xpaths,
and absolute xpaths, it populates this HashMap with PathIndexEntry objects
that will be inserted into the xml_path_index table. This method was incorrectly
indexing nodes of type ATTRIBUTE, because attributes stored their node data
in the same xml_nodes record, whereas nodes of type ELEMENT stored their data in
a subsequent child TEXT record. This was causing offsets to occur in the indexing
tables. I've added to variables in this method now, leafData and leafDataNumerical
to fix this offset. See the patch on buildIndex().

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
1364 1364
     */
1365 1365
    private void traverseParents(HashMap records, long rootNodeId,
1366 1366
            long leafNodeId, long id,
1367
            String children, HashMap pathList, Vector pathsFoundForIndexing) {
1368
    	Long nodeId = new Long(id);
1367
            String children, HashMap pathList, HashMap pathsFoundForIndexing) {
1368
    	  Long nodeId = new Long(id);
1369 1369
        NodeRecord current = (NodeRecord)records.get(nodeId);
1370 1370
        long parentId = current.getParentNodeId();
1371 1371
        String currentName = current.getNodeName();
1372
        String nodeData = current.getNodeData();
1373
        float nodeDataNumerical = current.getNodeDataNumerical();
1374
        NodeRecord leafRecord = (NodeRecord)records.get(leafNodeId);
1375
        String leafData = leafRecord.getNodeData();
1376
        float leafDataNumerical = leafRecord.getNodeDataNumerical();
1377
        
1372 1378
        if (current.getNodeType().equals("ELEMENT") ||
1373 1379
            current.getNodeType().equals("ATTRIBUTE") ) {
1374
        	
1380
        	  
1381
        	  // process leaf node xpaths
1375 1382
            if (children.equals("")) {
1376 1383
                if (current.getNodeType().equals("ATTRIBUTE")) {
1377 1384
                    currentName = "@" + currentName;
1378 1385
                }
1379 1386
                logMetacat.debug("A: " + currentName +"\n");
1380
                pathList.put(currentName, new PathIndexEntry(leafNodeId,
1381
                    currentName, docid, doctype, parentId));
1382
                if(MetaCatUtil.pathsForIndexing.contains(currentName)){
1383
                	logMetacat.debug("paths found " + currentName);
1384
                	pathsFoundForIndexing.add(currentName);
1387
                if ( !currentName.equals("") || !currentName.equals(null) ) {
1388
                  pathList.put(currentName, new PathIndexEntry(leafNodeId,
1389
                      currentName, docid, doctype, parentId));  
1385 1390
                }
1391
                if( MetaCatUtil.pathsForIndexing.contains(currentName) &&
1392
                    !leafData.equals("") ){
1393
                	logMetacat.debug("paths found for indexing: " + currentName);
1394
                	pathsFoundForIndexing.put(currentName, new PathIndexEntry(
1395
                            leafNodeId, currentName, docid, parentId, leafData,
1396
                            leafDataNumerical));
1397
                } 
1386 1398
            }
1387
            currentName = "/" + currentName;
1388
            currentName = currentName + children;
1399
            
1400
            // process relative xpaths
1401
            if ( !currentName.equals("") || !currentName.equals(null) ) {
1402
              currentName = "/" + currentName;
1403
              currentName = currentName + children;
1404
            }
1389 1405
            if (parentId != 0) {
1390 1406
                traverseParents(records, rootNodeId, leafNodeId,
1391 1407
                    parentId, currentName, pathList, pathsFoundForIndexing);
......
1396 1412
                logMetacat.debug("B: " + path +"\n");
1397 1413
                pathList.put(path, new PathIndexEntry(leafNodeId, path, docid,
1398 1414
                    doctype, parentId));
1399
                if(MetaCatUtil.pathsForIndexing.contains(path)){
1400
                	logMetacat.debug("paths found " + path);
1401
                	pathsFoundForIndexing.add(path);
1415
                if( MetaCatUtil.pathsForIndexing.contains(path) &&
1416
                    !leafData.equals("") ){
1417
                	logMetacat.debug("paths found for indexing: " + currentName);
1418
                	pathsFoundForIndexing.put(path, new PathIndexEntry(
1419
                            leafNodeId, path, docid, parentId, leafData,
1420
                            leafDataNumerical));
1402 1421
                }
1403 1422
            }
1423
            // process absolute xpaths
1404 1424
            if (id == rootNodeId) {
1405
                String fullPath = '/' + path;
1425
                String fullPath = "";
1426
                if ( !path.equals("") || !currentName.equals(null) ) {
1427
                  fullPath = '/' + path;
1428
                }
1406 1429
                logMetacat.debug("C: " + fullPath +"\n");
1407 1430
                pathList.put(fullPath, new PathIndexEntry(leafNodeId, fullPath,
1408 1431
                    docid, doctype, parentId));
1409
                if(MetaCatUtil.pathsForIndexing.contains(fullPath)){
1410
                	logMetacat.debug("paths found " + fullPath);
1411
                	pathsFoundForIndexing.add(fullPath);
1432
                if( MetaCatUtil.pathsForIndexing.contains(fullPath) &&
1433
                   !leafData.equals("") ){
1434
                	logMetacat.debug("paths found for indexing: " + currentName);
1435
                	pathsFoundForIndexing.put(fullPath, new PathIndexEntry(
1436
                            leafNodeId, fullPath, docid, parentId, leafData,
1437
                            leafDataNumerical));
1412 1438
                }
1413 1439
            }
1414 1440
        } 

Also available in: Unified diff