Revision 29
Added by Matt Jones over 24 years ago
DBSAXHandler.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import oracle.xml.parser.v2.SAXParser; |
24 | 24 |
|
25 |
class DBSAXHandler extends DefaultXMLDocumentHandler |
|
25 |
public class DBSAXHandler extends DefaultXMLDocumentHandler
|
|
26 | 26 |
{ |
27 | 27 |
|
28 | 28 |
private boolean debug = false; |
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import oracle.xml.parser.v2.SAXParser; |
24 | 24 |
|
25 |
class DBSAXHandler extends DefaultXMLDocumentHandler |
|
25 |
public class DBSAXHandler extends DefaultXMLDocumentHandler
|
|
26 | 26 |
{ |
27 | 27 |
|
28 | 28 |
private boolean debug = false; |
src/edu/ucsb/nceas/metacat/ElementNode.java | ||
---|---|---|
185 | 185 |
value.append('>'); |
186 | 186 |
return value.toString(); |
187 | 187 |
} |
188 |
|
|
189 | 188 |
} |
src/edu/ucsb/nceas/metacat/DBWriter.java | ||
---|---|---|
61 | 61 |
} |
62 | 62 |
} |
63 | 63 |
|
64 |
private DBSAXWriter( String filename, String user,
|
|
64 |
public DBSAXWriter( String filename, String user,
|
|
65 | 65 |
String password, String dbstring) |
66 | 66 |
throws IOException, |
67 | 67 |
SQLException, |
src/edu/ucsb/nceas/metacat/BasicNode.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
public class BasicElement { |
18 | 18 |
|
19 |
protected long element_id;
|
|
20 |
protected String tagname;
|
|
21 |
protected StringBuffer content;
|
|
22 |
protected long parent_id;
|
|
23 |
protected Hashtable attributes;
|
|
19 |
private long element_id;
|
|
20 |
private String tagname;
|
|
21 |
private StringBuffer content;
|
|
22 |
private long parent_id;
|
|
23 |
private Hashtable attributes;
|
|
24 | 24 |
|
25 | 25 |
public BasicElement () { |
26 | 26 |
content = new StringBuffer(); |
src/edu/ucsb/nceas/metacat/DBSAXNode.java | ||
---|---|---|
33 | 33 |
try { |
34 | 34 |
conn.setAutoCommit(false); |
35 | 35 |
PreparedStatement pstmt; |
36 |
if (parent_id != 0) {
|
|
36 |
if (getParentID() != 0) {
|
|
37 | 37 |
pstmt = conn.prepareStatement( |
38 | 38 |
"INSERT INTO xml_nodes (nodeid, nodetype, " + |
39 | 39 |
"nodename, parentnodeid) VALUES (null, ?, ?, ?)"); |
... | ... | |
46 | 46 |
// Bind the values to the query |
47 | 47 |
pstmt.setString(1, "ELEMENT"); |
48 | 48 |
pstmt.setString(2, getTagName()); |
49 |
if (parent_id != 0) {
|
|
50 |
pstmt.setLong(3, parent_id);
|
|
49 |
if (getParentID() != 0) {
|
|
50 |
pstmt.setLong(3, getParentID());
|
|
51 | 51 |
} |
52 | 52 |
// Do the insertion |
53 | 53 |
pstmt.execute(); |
54 | 54 |
pstmt.close(); |
55 |
this.element_id = getAssignedElementID();
|
|
55 |
setElementID(getAssignedElementID());
|
|
56 | 56 |
conn.commit(); |
57 | 57 |
conn.setAutoCommit(true); |
58 | 58 |
} catch (SQLException e) { |
... | ... | |
97 | 97 |
public void setAttribute(String attName, String attValue) { |
98 | 98 |
if (attName != null) { |
99 | 99 |
// Enter the attribute in the hash table |
100 |
attributes.put(attName, attValue);
|
|
100 |
super.setAttribute(attName, attValue);
|
|
101 | 101 |
|
102 | 102 |
// And enter the attribute in the database |
103 | 103 |
try { |
... | ... | |
130 | 130 |
"UPDATE xml_nodes SET nodedata = ? WHERE nodeid = ?"); |
131 | 131 |
|
132 | 132 |
// Bind the values to the query |
133 |
pstmt.setString(1, getContent());// The first ? is for NODEDATA
|
|
134 |
pstmt.setLong(2, element_id); // The second ? is for NODEID
|
|
133 |
pstmt.setString(1, getContent()); |
|
134 |
pstmt.setLong(2, getElementID());
|
|
135 | 135 |
|
136 | 136 |
// Do the update |
137 | 137 |
pstmt.execute(); |
src/edu/ucsb/nceas/metacat/DBReader.java | ||
---|---|---|
55 | 55 |
} |
56 | 56 |
} |
57 | 57 |
|
58 |
private DBReader( String user, String password, String dbstring)
|
|
58 |
public DBReader( String user, String password, String dbstring)
|
|
59 | 59 |
throws IOException, |
60 | 60 |
SQLException, |
61 | 61 |
ClassNotFoundException |
src/edu/ucsb/nceas/metacat/BasicElement.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
public class BasicElement { |
18 | 18 |
|
19 |
protected long element_id;
|
|
20 |
protected String tagname;
|
|
21 |
protected StringBuffer content;
|
|
22 |
protected long parent_id;
|
|
23 |
protected Hashtable attributes;
|
|
19 |
private long element_id;
|
|
20 |
private String tagname;
|
|
21 |
private StringBuffer content;
|
|
22 |
private long parent_id;
|
|
23 |
private Hashtable attributes;
|
|
24 | 24 |
|
25 | 25 |
public BasicElement () { |
26 | 26 |
content = new StringBuffer(); |
src/edu/ucsb/nceas/metacat/DBSAXElement.java | ||
---|---|---|
33 | 33 |
try { |
34 | 34 |
conn.setAutoCommit(false); |
35 | 35 |
PreparedStatement pstmt; |
36 |
if (parent_id != 0) {
|
|
36 |
if (getParentID() != 0) {
|
|
37 | 37 |
pstmt = conn.prepareStatement( |
38 | 38 |
"INSERT INTO xml_nodes (nodeid, nodetype, " + |
39 | 39 |
"nodename, parentnodeid) VALUES (null, ?, ?, ?)"); |
... | ... | |
46 | 46 |
// Bind the values to the query |
47 | 47 |
pstmt.setString(1, "ELEMENT"); |
48 | 48 |
pstmt.setString(2, getTagName()); |
49 |
if (parent_id != 0) {
|
|
50 |
pstmt.setLong(3, parent_id);
|
|
49 |
if (getParentID() != 0) {
|
|
50 |
pstmt.setLong(3, getParentID());
|
|
51 | 51 |
} |
52 | 52 |
// Do the insertion |
53 | 53 |
pstmt.execute(); |
54 | 54 |
pstmt.close(); |
55 |
this.element_id = getAssignedElementID();
|
|
55 |
setElementID(getAssignedElementID());
|
|
56 | 56 |
conn.commit(); |
57 | 57 |
conn.setAutoCommit(true); |
58 | 58 |
} catch (SQLException e) { |
... | ... | |
97 | 97 |
public void setAttribute(String attName, String attValue) { |
98 | 98 |
if (attName != null) { |
99 | 99 |
// Enter the attribute in the hash table |
100 |
attributes.put(attName, attValue);
|
|
100 |
super.setAttribute(attName, attValue);
|
|
101 | 101 |
|
102 | 102 |
// And enter the attribute in the database |
103 | 103 |
try { |
... | ... | |
130 | 130 |
"UPDATE xml_nodes SET nodedata = ? WHERE nodeid = ?"); |
131 | 131 |
|
132 | 132 |
// Bind the values to the query |
133 |
pstmt.setString(1, getContent());// The first ? is for NODEDATA
|
|
134 |
pstmt.setLong(2, element_id); // The second ? is for NODEID
|
|
133 |
pstmt.setString(1, getContent()); |
|
134 |
pstmt.setLong(2, getElementID());
|
|
135 | 135 |
|
136 | 136 |
// Do the update |
137 | 137 |
pstmt.execute(); |
src/edu/ucsb/nceas/metacat/ReaderElement.java | ||
---|---|---|
185 | 185 |
value.append('>'); |
186 | 186 |
return value.toString(); |
187 | 187 |
} |
188 |
|
|
189 | 188 |
} |
src/edu/ucsb/nceas/metacat/DBSAXWriter.java | ||
---|---|---|
61 | 61 |
} |
62 | 62 |
} |
63 | 63 |
|
64 |
private DBSAXWriter( String filename, String user,
|
|
64 |
public DBSAXWriter( String filename, String user,
|
|
65 | 65 |
String password, String dbstring) |
66 | 66 |
throws IOException, |
67 | 67 |
SQLException, |
DBReader.java | ||
---|---|---|
55 | 55 |
} |
56 | 56 |
} |
57 | 57 |
|
58 |
private DBReader( String user, String password, String dbstring)
|
|
58 |
public DBReader( String user, String password, String dbstring)
|
|
59 | 59 |
throws IOException, |
60 | 60 |
SQLException, |
61 | 61 |
ClassNotFoundException |
BasicElement.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
public class BasicElement { |
18 | 18 |
|
19 |
protected long element_id;
|
|
20 |
protected String tagname;
|
|
21 |
protected StringBuffer content;
|
|
22 |
protected long parent_id;
|
|
23 |
protected Hashtable attributes;
|
|
19 |
private long element_id;
|
|
20 |
private String tagname;
|
|
21 |
private StringBuffer content;
|
|
22 |
private long parent_id;
|
|
23 |
private Hashtable attributes;
|
|
24 | 24 |
|
25 | 25 |
public BasicElement () { |
26 | 26 |
content = new StringBuffer(); |
DBSAXElement.java | ||
---|---|---|
33 | 33 |
try { |
34 | 34 |
conn.setAutoCommit(false); |
35 | 35 |
PreparedStatement pstmt; |
36 |
if (parent_id != 0) {
|
|
36 |
if (getParentID() != 0) {
|
|
37 | 37 |
pstmt = conn.prepareStatement( |
38 | 38 |
"INSERT INTO xml_nodes (nodeid, nodetype, " + |
39 | 39 |
"nodename, parentnodeid) VALUES (null, ?, ?, ?)"); |
... | ... | |
46 | 46 |
// Bind the values to the query |
47 | 47 |
pstmt.setString(1, "ELEMENT"); |
48 | 48 |
pstmt.setString(2, getTagName()); |
49 |
if (parent_id != 0) {
|
|
50 |
pstmt.setLong(3, parent_id);
|
|
49 |
if (getParentID() != 0) {
|
|
50 |
pstmt.setLong(3, getParentID());
|
|
51 | 51 |
} |
52 | 52 |
// Do the insertion |
53 | 53 |
pstmt.execute(); |
54 | 54 |
pstmt.close(); |
55 |
this.element_id = getAssignedElementID();
|
|
55 |
setElementID(getAssignedElementID());
|
|
56 | 56 |
conn.commit(); |
57 | 57 |
conn.setAutoCommit(true); |
58 | 58 |
} catch (SQLException e) { |
... | ... | |
97 | 97 |
public void setAttribute(String attName, String attValue) { |
98 | 98 |
if (attName != null) { |
99 | 99 |
// Enter the attribute in the hash table |
100 |
attributes.put(attName, attValue);
|
|
100 |
super.setAttribute(attName, attValue);
|
|
101 | 101 |
|
102 | 102 |
// And enter the attribute in the database |
103 | 103 |
try { |
... | ... | |
130 | 130 |
"UPDATE xml_nodes SET nodedata = ? WHERE nodeid = ?"); |
131 | 131 |
|
132 | 132 |
// Bind the values to the query |
133 |
pstmt.setString(1, getContent());// The first ? is for NODEDATA
|
|
134 |
pstmt.setLong(2, element_id); // The second ? is for NODEID
|
|
133 |
pstmt.setString(1, getContent()); |
|
134 |
pstmt.setLong(2, getElementID());
|
|
135 | 135 |
|
136 | 136 |
// Do the update |
137 | 137 |
pstmt.execute(); |
ReaderElement.java | ||
---|---|---|
185 | 185 |
value.append('>'); |
186 | 186 |
return value.toString(); |
187 | 187 |
} |
188 |
|
|
189 | 188 |
} |
Makefile | ||
---|---|---|
5 | 5 |
|
6 | 6 |
USER=jones |
7 | 7 |
|
8 |
PW=your-pw-goes-here
|
|
8 |
PW=you-pw-goes-here |
|
9 | 9 |
|
10 | 10 |
default: all |
11 | 11 |
|
DBSAXWriter.java | ||
---|---|---|
61 | 61 |
} |
62 | 62 |
} |
63 | 63 |
|
64 |
private DBSAXWriter( String filename, String user,
|
|
64 |
public DBSAXWriter( String filename, String user,
|
|
65 | 65 |
String password, String dbstring) |
66 | 66 |
throws IOException, |
67 | 67 |
SQLException, |
Also available in: Unified diff
general cleanup and documentation