Project

General

Profile

« Previous | Next » 

Revision 2420

Added by sgarg over 19 years ago

Added code for updating xml_queryresult for action=delete and action=update

For both actions, the entries in xml_queryresult are deleted.
This works for action=update because deletion of entry is simple and the entries will be created again when the docid is part of a search result next time.

View differences:

DocumentImpl.java
2071 2071
        // run access db base on relation table and access object
2072 2072
        runRelationAndAccessHandler(accnum, user, groups, serverCode);
2073 2073

  
2074
        // Delete enteries from xml_queryresult for given docid if
2075
        // action is UPDATE
2076
        // These enteries will be created again when the docid is part of a
2077
        // result next time
2078
        if (action.equals("UPDATE")) {
2079
          try {
2080
              PreparedStatement pstmt = null;
2081
              pstmt = conn.prepareStatement(
2082
                      "DELETE FROM xml_queryresult WHERE docid = ?");
2083
              pstmt.setString(1, docid);
2084
              pstmt.execute();
2085
              pstmt.close();
2086
              conn.increaseUsageCount(1);
2087
          } catch (Exception e){
2088
              MetaCatUtil.debugMessage("Error in deleting enteries from "
2089
                                       + "xml_queryresult where docid is "
2090
                                       + docid + " in DBQuery.write: "
2091
                                       + e.getMessage(), 20);
2092
           }
2093

  
2094
        }
2095

  
2074 2096
        // Force replicate out the new document to each server in our server
2075 2097
        // list. Start the thread to replicate this new document out to the
2076 2098
        // other servers true mean it is xml document null is because no
......
2394 2416
            // Now delete it from the xml_index table
2395 2417
            boolean useXMLIndex = (new Boolean(MetaCatUtil
2396 2418
                    .getOption("usexmlindex"))).booleanValue();
2397
            //if (useXMLIndex) {
2419

  
2420
           //if (useXMLIndex) {
2398 2421
            pstmt = conn
2399 2422
                    .prepareStatement("DELETE FROM xml_index WHERE docid = ?");
2400 2423
            pstmt.setString(1, docid);
......
2403 2426
            conn.increaseUsageCount(1);
2404 2427
            //}
2405 2428

  
2406
            //stmt.execute("DELETE FROM xml_access WHERE docid = '" + docid +
2407
            // "'");
2408 2429
            // Now delete it from xml_access table
2409 2430
            pstmt = conn.prepareStatement(
2410 2431
                    "DELETE FROM xml_access WHERE accessfileid = ?");
......
2420 2441
            pstmt.close();
2421 2442
            conn.increaseUsageCount(1);
2422 2443

  
2444
            // Delete enteries from xml_queryresult
2445
            pstmt = conn.prepareStatement(
2446
                    "DELETE FROM xml_queryresult WHERE docid = ?");
2447
            pstmt.setString(1, docid);
2448
            pstmt.execute();
2449
            pstmt.close();
2450
            conn.increaseUsageCount(1);
2451

  
2423 2452
            // Delete it from relation table
2424 2453
            pstmt = conn.prepareStatement(
2425 2454
                    "DELETE FROM xml_relation WHERE docid = ?");
......
2449 2478

  
2450 2479
            conn.commit();
2451 2480
            conn.setAutoCommit(true);
2481

  
2452 2482
        } catch (Exception e) {
2453 2483
            MetaCatUtil.debugMessage("error in DocumentImpl.delete: "
2454 2484
                    + e.getMessage(), 30);

Also available in: Unified diff