[metacat-cvs] metacat/src/edu/ucsb/nceas/metacat DocumentImpl.java

Saurabh Garg sgarg at ecoinformatics.org
Thu Nov 10 13:40:54 PST 2005


sgarg       05/11/10 13:40:54

  Modified:    src/edu/ucsb/nceas/metacat DocumentImpl.java
  Log:
  Removed the call to indexing function in DBSAXHandler and added a call to indexing function IndexingQueue
  
  Revision  Changes    Path
  1.174     +25 -20    metacat/src/edu/ucsb/nceas/metacat/DocumentImpl.java
  
  Index: DocumentImpl.java
  ===================================================================
  RCS file: /cvs/metacat/src/edu/ucsb/nceas/metacat/DocumentImpl.java,v
  retrieving revision 1.173
  retrieving revision 1.174
  diff -u -r1.173 -r1.174
  --- DocumentImpl.java	2 Nov 2005 18:16:54 -0000	1.173
  +++ DocumentImpl.java	10 Nov 2005 21:40:54 -0000	1.174
  @@ -7,8 +7,8 @@
    *    Release: @release@
    *
    *   '$Author: sgarg $'
  - *     '$Date: 2005/11/02 18:16:54 $'
  - * '$Revision: 1.173 $'
  + *     '$Date: 2005/11/10 21:40:54 $'
  + * '$Revision: 1.174 $'
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
  @@ -1211,7 +1211,6 @@
           //DocumentIdentifier doc = null;
           //String doc = MetaCatUtil.getDocIdFromAccessionNumber(docid);
           String doc = docid;
  -        //System.out.println("The doc is-----!!!!!!!!!!!!!!!!!! "+doc);
           /*try {
               doc = new DocumentIdentifier(docid);
           } catch (AccessionNumberException e){
  @@ -1255,9 +1254,7 @@
               // Step through all of the node records we were given
               // and build the new index and update the database
               it = nodeRecordLists.iterator();
  -            //System.out.println("before iterator!!!!!!!!!!!1");
               while (it.hasNext()) {
  -                //System.out.println("here!!!!!!!!!!!!!!!");
                   NodeRecord currentNode = (NodeRecord) it.next();
                   HashMap pathList = new HashMap();
                   if (currentNode.nodetype.equals("ELEMENT") ||
  @@ -1314,12 +1311,14 @@
                                               + " xml_nodes n, xml_index i WHERE"
                                               + " (" + pathList
                                               + " ) AND n.parentnodeid=i.nodeid AND"
  -                                            + " n.nodetype LIKE 'TEXT' and n.docid = ?");
  +                                            + " n.nodetype LIKE 'TEXT' and n.docid = ?"
  +                                            + " order by n.parentnodeid");
   
               pstmt.setString(1, doc);
   
               pstmt.execute();
               rs = pstmt.getResultSet();
  +            dbConn.increaseUsageCount(1);
   
               int count = 0;
   
  @@ -1345,7 +1344,8 @@
   
                       pstmt1.execute();
                       pstmt1.close();
  -
  +                    dbConn.increaseUsageCount(1);
  +                    
                       count++;
                   }
               }
  @@ -1355,7 +1355,7 @@
               dbConn.increaseUsageCount(1);
   
               logMetacat.warn("Indexed " + count
  -                                              + " records from xml_nodes");
  +                                              + " records for docid: " + docid);
   
               dbConn.commit();
           } catch (SQLException e) {
  @@ -2238,9 +2238,8 @@
                       conn.setAutoCommit(true);
   
                       // write to xml_node complete. start the indexing thread.
  -                    DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
  -                    dbx.runIndexingThread();
  -                } catch (Exception e) {
  +                    addDocidToIndexingQueue(docid, rev);
  +               } catch (Exception e) {
                       conn.rollback();
                       conn.setAutoCommit(true);
                       //if it is a eml2 document, we need delete online data
  @@ -2309,12 +2308,8 @@
               //System.out.println("commit!!!!!!!!!!!!!!!!!111");
               conn.commit();
               conn.setAutoCommit(true);
  -            
  -            // write to xml_node complete. start the indexing thread.
  -            DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
  -            //System.out.println("here!!!!!!!adf");
  -            dbx.runIndexingThread();
  -            //System.out.println("here!!!!!!!adfadfa");
  +
  +            addDocidToIndexingQueue(docid, rev);
           } catch (Exception e) {
               e.printStackTrace();
               conn.rollback();
  @@ -2368,6 +2363,15 @@
           return (accnum);
       }
   
  +    
  +    private static void addDocidToIndexingQueue(String docid, String rev){
  +        boolean useXMLIndex =
  +            (new Boolean(MetaCatUtil.getOption("usexmlindex"))).booleanValue();
  +        if (useXMLIndex) {
  +            	IndexingQueue.getInstance().add(docid + "." + rev);
  +        }
  +    }
  +
       /**
        * Write an XML file to the database during replication
        *
  @@ -2464,11 +2468,12 @@
               
               // write to xml_node complete. start the indexing thread.
               // this only for xml_documents
  -            DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
               if (!isRevision)
               {
  -                dbx.runIndexingThread();
  +            	addDocidToIndexingQueue(docid, rev);
               }
  +            
  +            DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
               rootId = dbx.getRootNodeId();
               docType = dbx.getDocumentType();
               docName = dbx.getDocumentName();
  
  
  


More information about the Metacat-cvs mailing list