Project

General

Profile

« Previous | Next » 

Revision 575

Added by berkley about 24 years ago

added revision number tracking support to xml_documents and xml_revisions. Also added an updated flag as a replacement for date based replication handling.

View differences:

src/xmltables.sql
104 104
	user_owner	VARCHAR2(100),	-- the user owned the document
105 105
	user_updated	VARCHAR2(100),	-- the user updated the document
106 106
  server_location NUMBER(20), -- the server on which this document resides
107
  rev NUMBER(10) DEFAULT 1,  --the revision number of the document
107 108
	date_created	DATE,
108 109
	date_updated	DATE,
109 110
	public_access	NUMBER(1) DEFAULT 1, -- flag for public access
111
  updated NUMBER(1) DEFAULT 0,
110 112
   CONSTRAINT xml_documents_pk PRIMARY KEY (docid),
111 113
   CONSTRAINT xml_documents_rep_fk
112 114
    FOREIGN KEY (server_location) REFERENCES xml_replication, 
......
149 151
	user_owner	VARCHAR2(100),
150 152
	user_updated	VARCHAR2(100),
151 153
	server_location NUMBER(20),
154
  rev NUMBER(10),
152 155
	date_created	DATE,
153 156
	date_updated	DATE,
154 157
   CONSTRAINT xml_revisions_pk PRIMARY KEY (revisionid),
src/edu/ucsb/nceas/metacat/DocumentImpl.java
61 61
  private String system_id = null;
62 62
  private String userowner = null;
63 63
  private String userupdated = null;
64
  private int rev;
64 65
  private int serverlocation;
65 66
  private int publicaccess; 
66 67
  private long rootnodeid;
......
210 211
  public int getPublicaccess() {
211 212
    return publicaccess;
212 213
  }
214
  
215
  public int getRev() {
216
    return rev;
217
  }
213 218

  
214 219
  /**
215 220
   * Print a string representation of the XML document
......
399 404
        conn.prepareStatement("SELECT docname, doctype, rootnodeid,doctitle, " +
400 405
                              "date_created, date_updated, " + 
401 406
                              "user_owner, user_updated, server_location, " +
402
                              "public_access " +
407
                              "public_access, rev " +
403 408
                               "FROM xml_documents " +
404 409
                               "WHERE docid LIKE ?");
405 410
      // Bind the values to the query
......
419 424
        this.userupdated    = rs.getString(8);
420 425
        this.serverlocation = rs.getInt(9);
421 426
        this.publicaccess   = rs.getInt(10);
427
        this.rev            = rs.getInt(11);
422 428
      } 
423 429
      pstmt.close();
424 430

  
......
547 553

  
548 554
        // Save the old document entry in a backup table
549 555
        DocumentImpl.archiveDocRevision( conn, docid, user );
550

  
556
        DocumentImpl thisdoc = new DocumentImpl(conn, docid);
557
        int thisrev = thisdoc.getRev();
558
        thisrev++;
551 559
        // Delete index for the old version of docid
552 560
        // The new index is inserting on the next calls to DBSAXNode
553 561
        pstmt = conn.prepareStatement(
......
560 568
            "UPDATE xml_documents " +
561 569
            "SET rootnodeid = ?, docname = ?, doctype = ?, " +
562 570
            "user_updated = ?, date_updated = sysdate, " +
563
            "server_location = ? WHERE docid LIKE ?");
571
            "server_location = ?, rev = ? WHERE docid LIKE ?");
564 572
        // Bind the values to the query
565 573
        pstmt.setLong(1, rootnodeid);
566 574
        pstmt.setString(2, docname);
567 575
        pstmt.setString(3, doctype);
568 576
        pstmt.setString(4, user);
569 577
        pstmt.setInt(5, serverCode);
570
        pstmt.setString(6, this.docid);
578
        pstmt.setInt(6, thisrev);
579
        pstmt.setString(7, this.docid);
580

  
571 581
      } else {
572 582
        System.err.println("Action not supported: " + action);
573 583
      }
......
984 994
    PreparedStatement pstmt = conn.prepareStatement(
985 995
      "INSERT INTO xml_revisions " +
986 996
        "(revisionid, docid, rootnodeid, docname, doctype, doctitle, " +
987
        "user_owner, user_updated, date_created, date_updated, server_location) " +
997
        "user_owner, user_updated, date_created, date_updated, server_location, " +
998
        "rev)" +
988 999
      "SELECT null, ?, rootnodeid, docname, doctype, doctitle," + 
989
        "user_owner, ?, sysdate, sysdate, server_location "+
1000
        "user_owner, ?, sysdate, sysdate, server_location, rev "+
990 1001
      "FROM xml_documents " +
991 1002
      "WHERE docid = ?");
992 1003
    // Bind the values to the query and execute it

Also available in: Unified diff