Project

General

Profile

« Previous | Next » 

Revision 1361

Added by Jing Tao almost 22 years ago

If a text node was split into two parts, now it will be combined.

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
411 411
          Vector results = new Vector();
412 412
          Enumeration keylist = docListResult.keys();
413 413
          StringBuffer doclist = new StringBuffer();
414
          Hashtable parentidList = new Hashtable();
415
          Hashtable returnFieldValue = new Hashtable();
414 416
          while(keylist.hasMoreElements())
415 417
          {
416 418
            doclist.append("'");
......
434 436
            tableHasRows = rs.next();
435 437
            while(tableHasRows) 
436 438
            {
439
              ReturnFieldValue returnValue = new ReturnFieldValue();
437 440
              docid = rs.getString(1).trim();
438
              //if ( !hasPermission(user, groups, docid) ) {
439
                // Advance to the next record in the cursor
440
                //tableHasRows = rs.next();
441
                //continue;
442
              //}
443 441
              fieldname = rs.getString(2);
444 442
              fielddata = rs.getString(3);
445
              
446
              document = new StringBuffer();
447
  
448
              document.append("<param name=\"");
449
              document.append(fieldname);
450
              document.append("\">");
451
              document.append(fielddata);
452
              document.append("</param>");
453
  
454
              tableHasRows = rs.next();
443
              String parentId = rs.getString(4);
444
                         
445
              StringBuffer value = new StringBuffer();
446
              if (!parentidList.containsKey(parentId))
447
              {
448
                // don't need to merger nodedata 
449
                value.append("<param name=\"");
450
                value.append(fieldname);
451
                value.append("\">");
452
                value.append(fielddata);
453
                value.append("</param>");
454
                //set returnvalue
455
                returnValue.setDocid(docid);
456
                returnValue.setFieldValue(fielddata);
457
                returnValue.setXMLFieldValue(value.toString());
458
                // Store it in hastable
459
                parentidList.put(parentId, returnValue);
460
              }
461
              else
462
              {
463
                // need to merge nodedata if they have same parent id ant
464
                // node type is text
465
                fielddata = (String)((ReturnFieldValue)
466
                       parentidList.get(parentId)).getFieldValue() +  fielddata;
467
                value.append("<param name=\"");
468
                value.append(fieldname);
469
                value.append("\">");
470
                value.append(fielddata);
471
                value.append("</param>");
472
                returnValue.setDocid(docid);
473
                returnValue.setFieldValue(fielddata);
474
                returnValue.setXMLFieldValue(value.toString());
475
                // remove the old return value from paretnidList
476
                parentidList.remove(parentId);
477
                // store the new return value in parentidlit
478
                parentidList.put(parentId, returnValue);
479
              }
480
               tableHasRows = rs.next();
481
            }//while
482
            rs.close();
483
            pstmt.close();
455 484
            
485
            // put the merger node data info into doclistReult
486
            Enumeration xmlFieldValue = parentidList.elements();
487
            while( xmlFieldValue.hasMoreElements() )
488
            {
489
              ReturnFieldValue object = (ReturnFieldValue)
490
                                         xmlFieldValue.nextElement();
491
              docid = object.getDocid();
456 492
              if (docListResult.containsKey(docid))
457 493
              {
458
                String removedelement = (String)docListResult.remove(docid);
459
                docListResult.put(docid, removedelement + document.toString());
494
                  String removedelement = (String)docListResult.remove(docid);
495
                  docListResult.put(docid, removedelement +
496
                                    object.getXMLFieldValue());
460 497
              }
461 498
              else
462 499
              {
463
                docListResult.put(docid, document.toString()); 
500
                  docListResult.put(docid, object.getXMLFieldValue()); 
464 501
              }
465
            }
502
            }//while
466 503
            double docListResultEnd = System.currentTimeMillis()/1000;
467 504
            MetaCatUtil.debugMessage("Time for prepare doclistresult after"+
468 505
                                      " execute extended query: "
469 506
                                    +(docListResultEnd-extendedQueryEnd), 30);
470
            rs.close();
471
            pstmt.close();
472 507
            
508
            
473 509
            // get attribures return
474 510
            docListResult = getAttributeValueForReturn
475 511
                                      (qspec,docListResult, doclist.toString());
......
1704 1740
      return zOut;
1705 1741
    }//else
1706 1742
  }//getZippedPackage()
1743
  
1744
   private class ReturnFieldValue
1745
  {
1746
    private String docid          = null; //return field value for this docid
1747
    private String fieldValue     = null;
1748
    private String xmlFieldValue  = null; //return field value in xml format
1749

  
1750
    
1751
    public void setDocid(String myDocid)
1752
    {
1753
      docid = myDocid;
1754
    }
1755
    
1756
    public String getDocid()
1757
    {
1758
      return docid;
1759
    }
1760
    
1761
    public void setFieldValue(String myValue)
1762
    {
1763
      fieldValue = myValue;
1764
    }
1765
    
1766
    public String getFieldValue()
1767
    {
1768
      return fieldValue;
1769
    }
1770
    
1771
    public void setXMLFieldValue(String xml)
1772
    {
1773
      xmlFieldValue = xml;
1774
    }
1775
    
1776
    public String getXMLFieldValue()
1777
    {
1778
      return xmlFieldValue;
1779
    }
1780
    
1707 1781
   
1782
  }
1783
   
1708 1784
}

Also available in: Unified diff