Revision 697
Added by bojilova about 23 years ago
DocumentImpl.java | ||
---|---|---|
79 | 79 |
private String userupdated = null; |
80 | 80 |
private int rev; |
81 | 81 |
private int serverlocation; |
82 |
private int publicaccess;
|
|
82 |
private String publicaccess;
|
|
83 | 83 |
private long rootnodeid; |
84 | 84 |
private ElementNode rootNode = null; |
85 | 85 |
private TreeSet nodeRecordList = null; |
... | ... | |
143 | 143 |
*/ |
144 | 144 |
public DocumentImpl(Connection conn, long rootnodeid, String docname, |
145 | 145 |
String doctype, String docid, String action, String user, |
146 |
String pub, int serverCode) |
|
146 |
String pub, String catalogid, int serverCode)
|
|
147 | 147 |
throws SQLException, Exception |
148 | 148 |
{ |
149 | 149 |
this.conn = conn; |
... | ... | |
151 | 151 |
this.docname = docname; |
152 | 152 |
this.doctype = doctype; |
153 | 153 |
this.docid = docid; |
154 |
writeDocumentToDB(action, user, pub, serverCode); |
|
154 |
writeDocumentToDB(action, user, pub, catalogid, serverCode);
|
|
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
// NOT USED ANY MORE |
... | ... | |
236 | 236 |
return serverlocation; |
237 | 237 |
} |
238 | 238 |
|
239 |
public int getPublicaccess() {
|
|
239 |
public String getPublicaccess() {
|
|
240 | 240 |
return publicaccess; |
241 | 241 |
} |
242 | 242 |
|
... | ... | |
502 | 502 |
// DOCTITLE attr cleared from the db |
503 | 503 |
// sql.append("SELECT docname, doctype, rootnodeid, doctitle, "); |
504 | 504 |
sql.append("SELECT docname, doctype, rootnodeid, "); |
505 |
sql.append("date_created, date_updated, "); |
|
506 |
sql.append("user_owner, user_updated, server_location, ");
|
|
507 |
sql.append("rev FROM ").append(table);
|
|
505 |
sql.append("date_created, date_updated, user_owner, user_updated, ");
|
|
506 |
sql.append("server_location, public_access, rev");
|
|
507 |
sql.append(" FROM ").append(table); |
|
508 | 508 |
sql.append(" WHERE docid LIKE '").append(docid.getIdentifier()); |
509 | 509 |
sql.append("' and rev like '").append(docid.getRev()).append("'"); |
510 | 510 |
//System.out.println(sql.toString()); |
... | ... | |
528 | 528 |
this.userowner = rs.getString(6); |
529 | 529 |
this.userupdated = rs.getString(7); |
530 | 530 |
this.serverlocation = rs.getInt(8); |
531 |
this.rev = rs.getInt(9); |
|
531 |
this.publicaccess = rs.getString(9); |
|
532 |
this.rev = rs.getInt(10); |
|
532 | 533 |
} |
533 | 534 |
|
534 | 535 |
if (this.doctype != null) { |
... | ... | |
623 | 624 |
} |
624 | 625 |
} |
625 | 626 |
|
626 |
/** creates SQL code and inserts new document into DB connection |
|
627 |
default serverCode of 1*/ |
|
628 |
private void writeDocumentToDB(String action, String user) |
|
629 |
throws SQLException, Exception |
|
630 |
{ |
|
631 |
writeDocumentToDB(action, user, null, 1); |
|
632 |
} |
|
627 |
// NOT USED ANY MORE |
|
628 |
// /** creates SQL code and inserts new document into DB connection |
|
629 |
// default serverCode of 1*/ |
|
630 |
// private void writeDocumentToDB(String action, String user) |
|
631 |
// throws SQLException, Exception |
|
632 |
// { |
|
633 |
// writeDocumentToDB(action, user, null, 1); |
|
634 |
// } |
|
633 | 635 |
|
634 | 636 |
/** creates SQL code and inserts new document into DB connection */ |
635 | 637 |
private void writeDocumentToDB(String action, String user, String pub, |
636 |
int serverCode) |
|
638 |
String catalogid, int serverCode)
|
|
637 | 639 |
throws SQLException, Exception { |
638 | 640 |
try { |
639 | 641 |
PreparedStatement pstmt = null; |
... | ... | |
642 | 644 |
//AccessionNumber ac = new AccessionNumber(); |
643 | 645 |
//this.docid = ac.generate(docid, "INSERT"); |
644 | 646 |
pstmt = conn.prepareStatement( |
645 |
"INSERT INTO xml_documents " + |
|
646 |
"(docid, rootnodeid, docname, doctype, user_owner, user_updated, " + |
|
647 |
"date_created, date_updated, public_access, server_location) " + |
|
648 |
"VALUES (?, ?, ?, ?, ?, ?, sysdate, sysdate, ?, ?)"); |
|
647 |
"INSERT INTO xml_documents " + |
|
648 |
"(docid, rootnodeid, docname, doctype, " + |
|
649 |
"user_owner, user_updated, date_created, date_updated, " + |
|
650 |
"public_access, catalog_id, server_location) " + |
|
651 |
"VALUES (?, ?, ?, ?, ?, ?, sysdate, sysdate, ?, ?, ?)"); |
|
649 | 652 |
//note that the server_location is set to 1. |
650 | 653 |
//this means that "localhost" in the xml_replication table must |
651 | 654 |
//always be the first entry!!!!! |
... | ... | |
659 | 662 |
pstmt.setString(6, user); |
660 | 663 |
if ( pub == null ) { |
661 | 664 |
pstmt.setString(7, null); |
662 |
} else if ( pub.toUpperCase().equals("YES") ) { |
|
665 |
} else if ( pub.toUpperCase().equals("YES") || pub.equals("1") ) {
|
|
663 | 666 |
pstmt.setInt(7, 1); |
664 |
} else if ( pub.toUpperCase().equals("NO") ) { |
|
667 |
} else if ( pub.toUpperCase().equals("NO") || pub.equals("0") ) {
|
|
665 | 668 |
pstmt.setInt(7, 0); |
666 | 669 |
} |
667 |
pstmt.setInt(8, serverCode); |
|
670 |
pstmt.setString(8, catalogid); |
|
671 |
pstmt.setInt(9, serverCode); |
|
668 | 672 |
} else if (action.equals("UPDATE")) { |
669 | 673 |
|
670 | 674 |
// Save the old document entry in a backup table |
... | ... | |
684 | 688 |
"UPDATE xml_documents " + |
685 | 689 |
"SET rootnodeid = ?, docname = ?, doctype = ?, " + |
686 | 690 |
"user_updated = ?, date_updated = sysdate, " + |
687 |
"server_location = ?, rev = ?, public_access = ? " + |
|
691 |
"server_location = ?, rev = ?, public_access = ?, catalog_id = ? " +
|
|
688 | 692 |
"WHERE docid LIKE ?"); |
689 | 693 |
// Bind the values to the query |
690 | 694 |
pstmt.setLong(1, rootnodeid); |
... | ... | |
695 | 699 |
pstmt.setInt(6, thisrev); |
696 | 700 |
if ( pub == null ) { |
697 | 701 |
pstmt.setString(7, null); |
698 |
} else if ( pub.toUpperCase().equals("YES") ) { |
|
702 |
} else if ( pub.toUpperCase().equals("YES") || pub.equals("1") ) {
|
|
699 | 703 |
pstmt .setInt(7, 1); |
700 |
} else if ( pub.toUpperCase().equals("NO") ) { |
|
704 |
} else if ( pub.toUpperCase().equals("NO") || pub.equals("0") ) {
|
|
701 | 705 |
pstmt.setInt(7, 0); |
702 | 706 |
} |
703 |
pstmt.setString(8, this.docid); |
|
707 |
pstmt.setString(8, catalogid); |
|
708 |
pstmt.setString(9, this.docid); |
|
704 | 709 |
|
705 | 710 |
} else { |
706 | 711 |
System.err.println("Action not supported: " + action); |
... | ... | |
1114 | 1119 |
PreparedStatement pstmt = conn.prepareStatement( |
1115 | 1120 |
"INSERT INTO xml_revisions " + |
1116 | 1121 |
"(revisionid, docid, rootnodeid, docname, doctype, " + |
1117 |
"user_owner, user_updated, date_created, date_updated, server_location, " +
|
|
1118 |
"rev)" +
|
|
1122 |
"user_owner, user_updated, date_created, date_updated, " + |
|
1123 |
"server_location, rev, public_access, catalog_id) " +
|
|
1119 | 1124 |
"SELECT null, ?, rootnodeid, docname, doctype, " + |
1120 |
"user_owner, ?, sysdate, sysdate, server_location, rev "+ |
|
1125 |
"user_owner, ?, sysdate, sysdate, server_location, rev, " + |
|
1126 |
"public_access, catalog_id " + |
|
1121 | 1127 |
"FROM xml_documents " + |
1122 | 1128 |
"WHERE docid = ?"); |
1123 | 1129 |
// Bind the values to the query and execute it |
Also available in: Unified diff
- fixed missing replication of public_access
- new attribute catalog_id added in xml_documents and xml_revisions
as a FK to xml_catalog; catalog_id is replicated also