Revision 134
Added by Matt Jones over 24 years ago
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
128 | 128 |
int nodeIndex; |
129 | 129 |
try { |
130 | 130 |
parentElement = (DBSAXElement)elementStack.peek(); |
131 |
parent_id = parentElement.getElementID();
|
|
131 |
parent_id = parentElement.getNodeID();
|
|
132 | 132 |
nodeIndex = parentElement.incChildNum(); |
133 | 133 |
} catch (EmptyStackException e) { |
134 | 134 |
parent_id = 0; |
... | ... | |
144 | 144 |
doctype = DBEntityResolver.doctype; |
145 | 145 |
DBSAXElement documentNode = (DBSAXElement)elementStack.peek(); |
146 | 146 |
documentNode.writeNodename(docname); |
147 |
new DBSAXDocument(conn, documentNode.getElementID(), docname, doctype);
|
|
147 |
new DBSAXDocument(conn, documentNode.getNodeID(), docname, doctype);
|
|
148 | 148 |
} |
149 | 149 |
// Create the current element representation |
150 | 150 |
currentElement = new DBSAXElement(conn, localName, parent_id, nodeIndex); |
src/edu/ucsb/nceas/metacat/ElementNode.java | ||
---|---|---|
60 | 60 |
public ElementNode (Connection conn, long nodeid, long parentnodeid, |
61 | 61 |
String nodename, String nodetype) { |
62 | 62 |
this(conn); |
63 |
setElementID(nodeid);
|
|
63 |
setNodeID(nodeid);
|
|
64 | 64 |
setParentID(parentnodeid); |
65 | 65 |
setTagName(nodename); |
66 | 66 |
setNodeType(nodetype); |
... | ... | |
125 | 125 |
|
126 | 126 |
try { |
127 | 127 |
if (nodetype.equals("ELEMENT") || nodetype.equals("DOCUMENT") ) { |
128 |
setElementID(element_id);
|
|
128 |
setNodeID(element_id);
|
|
129 | 129 |
setParentID(parentnodeid); |
130 | 130 |
setTagName(nodename); |
131 | 131 |
} |
src/edu/ucsb/nceas/metacat/DBSAXNode.java | ||
---|---|---|
42 | 42 |
writeChildNodeToDB("DOCUMENT", getTagName(), null, 0); |
43 | 43 |
} |
44 | 44 |
|
45 |
setElementID(getAssignedElementID());
|
|
45 |
setNodeID(getAssignedNodeID());
|
|
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
/** creates SQL code and inserts new node into DB connection */ |
... | ... | |
70 | 70 |
if (nodetype == "ELEMENT") { |
71 | 71 |
pstmt.setLong(3, getParentID()); |
72 | 72 |
} else { |
73 |
pstmt.setLong(3, getElementID());
|
|
73 |
pstmt.setLong(3, getNodeID());
|
|
74 | 74 |
} |
75 | 75 |
pstmt.setString(4, data); |
76 | 76 |
pstmt.setInt(5, nodeIndex); |
... | ... | |
101 | 101 |
|
102 | 102 |
// Bind the values to the query |
103 | 103 |
pstmt.setString(1, nodename); |
104 |
pstmt.setLong(2, getElementID());
|
|
104 |
pstmt.setLong(2, getNodeID());
|
|
105 | 105 |
// Do the insertion |
106 | 106 |
pstmt.execute(); |
107 | 107 |
pstmt.close(); |
... | ... | |
111 | 111 |
} |
112 | 112 |
|
113 | 113 |
/** look up the assigned element id from DB connection */ |
114 |
private long getAssignedElementID() {
|
|
114 |
private long getAssignedNodeID() {
|
|
115 | 115 |
long assigned_id=0; |
116 | 116 |
Statement stmt; |
117 | 117 |
try { |
src/edu/ucsb/nceas/metacat/DBSAXElement.java | ||
---|---|---|
42 | 42 |
writeChildNodeToDB("DOCUMENT", getTagName(), null, 0); |
43 | 43 |
} |
44 | 44 |
|
45 |
setElementID(getAssignedElementID());
|
|
45 |
setNodeID(getAssignedNodeID());
|
|
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
/** creates SQL code and inserts new node into DB connection */ |
... | ... | |
70 | 70 |
if (nodetype == "ELEMENT") { |
71 | 71 |
pstmt.setLong(3, getParentID()); |
72 | 72 |
} else { |
73 |
pstmt.setLong(3, getElementID());
|
|
73 |
pstmt.setLong(3, getNodeID());
|
|
74 | 74 |
} |
75 | 75 |
pstmt.setString(4, data); |
76 | 76 |
pstmt.setInt(5, nodeIndex); |
... | ... | |
101 | 101 |
|
102 | 102 |
// Bind the values to the query |
103 | 103 |
pstmt.setString(1, nodename); |
104 |
pstmt.setLong(2, getElementID());
|
|
104 |
pstmt.setLong(2, getNodeID());
|
|
105 | 105 |
// Do the insertion |
106 | 106 |
pstmt.execute(); |
107 | 107 |
pstmt.close(); |
... | ... | |
111 | 111 |
} |
112 | 112 |
|
113 | 113 |
/** look up the assigned element id from DB connection */ |
114 |
private long getAssignedElementID() {
|
|
114 |
private long getAssignedNodeID() {
|
|
115 | 115 |
long assigned_id=0; |
116 | 116 |
Statement stmt; |
117 | 117 |
try { |
src/edu/ucsb/nceas/metacat/BasicNode.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Name: BasicNode.java |
3 |
* Purpose: A Class that represents an XML element and its contents
|
|
3 |
* Purpose: A Class that represents an XML node and its contents
|
|
4 | 4 |
* Copyright: 2000 Regents of the University of California and the |
5 | 5 |
* National Center for Ecological Analysis and Synthesis |
6 | 6 |
* Authors: Matt Jones |
... | ... | |
15 | 15 |
import java.util.Enumeration; |
16 | 16 |
import java.util.Vector; |
17 | 17 |
|
18 |
/** A Class that represents an XML element and its contents */
|
|
18 |
/** A Class that represents an XML node and its contents */
|
|
19 | 19 |
public class BasicNode { |
20 | 20 |
|
21 | 21 |
private long node_id; |
... | ... | |
36 | 36 |
|
37 | 37 |
/** Construct a Basic Element |
38 | 38 |
* |
39 |
* @param tagname the name of the element
|
|
40 |
* @param parent_id the id number of the parent element
|
|
39 |
* @param tagname the name of the node
|
|
40 |
* @param parent_id the id number of the parent node
|
|
41 | 41 |
* @param nodeIndex - order of node among siblings in parent node |
42 |
* Every element initializes childNum to 0 when
|
|
42 |
* Every node initializes childNum to 0 when
|
|
43 | 43 |
* created and has interface incChildNum |
44 | 44 |
* when new child is created |
45 | 45 |
*/ |
... | ... | |
62 | 62 |
this.node_id = node_id; |
63 | 63 |
} |
64 | 64 |
|
65 |
/** convert the element to a string representation for display */
|
|
65 |
/** convert the node to a string representation for display */
|
|
66 | 66 |
/* MAKE THIS AN ABSTRACT METHOD?????? |
67 | 67 |
public String toString () |
68 | 68 |
{ |
... | ... | |
75 | 75 |
} |
76 | 76 |
*/ |
77 | 77 |
|
78 |
/** Get the id of this element */
|
|
78 |
/** Get the id of this node */
|
|
79 | 79 |
public long getNodeID() |
80 | 80 |
{ |
81 | 81 |
return node_id; |
82 | 82 |
} |
83 | 83 |
|
84 |
/** Set the id of this element */
|
|
84 |
/** Set the id of this node */
|
|
85 | 85 |
public void setNodeID(long node_id) |
86 | 86 |
{ |
87 | 87 |
this.node_id = node_id; |
88 | 88 |
} |
89 | 89 |
|
90 |
/** Get the parent id of this element */
|
|
90 |
/** Get the parent id of this node */
|
|
91 | 91 |
public long getParentID() |
92 | 92 |
{ |
93 | 93 |
return parent_id; |
94 | 94 |
} |
95 | 95 |
|
96 |
/** Set the parent id of this element */
|
|
96 |
/** Set the parent id of this node */
|
|
97 | 97 |
public void setParentID(long parent_id) |
98 | 98 |
{ |
99 | 99 |
this.parent_id = parent_id; |
100 | 100 |
} |
101 | 101 |
|
102 |
/** Get the name of this element */
|
|
102 |
/** Get the name of this node */
|
|
103 | 103 |
public String getTagName() |
104 | 104 |
{ |
105 | 105 |
return tagname; |
106 | 106 |
} |
107 | 107 |
|
108 |
/** Set the tagname of this element */
|
|
108 |
/** Set the name of this node */
|
|
109 | 109 |
public void setTagName(String tagname) |
110 | 110 |
{ |
111 | 111 |
this.tagname = tagname; |
... | ... | |
127 | 127 |
return buf.toString(); |
128 | 128 |
} |
129 | 129 |
|
130 |
/** Add a new attribute to this element, or set its value */
|
|
130 |
/** Add a new attribute to this node, or set its value */
|
|
131 | 131 |
public void setAttribute(String attName, String attValue) { |
132 | 132 |
if (attName != null) { |
133 | 133 |
// Enter the attribute in the hash table |
... | ... | |
143 | 143 |
return (String)attributes.get(attName); |
144 | 144 |
} |
145 | 145 |
|
146 |
/** Get nodeIndex of the node element */
|
|
146 |
/** Get nodeIndex of the node */ |
|
147 | 147 |
public int getNodeIndex() { |
148 | 148 |
return this.nodeIndex; |
149 | 149 |
} |
... | ... | |
173 | 173 |
return children.elements(); |
174 | 174 |
} |
175 | 175 |
|
176 |
/** increase childNum when new child for the element is created */
|
|
176 |
/** increase childNum when new child for the node is created */
|
|
177 | 177 |
public int incChildNum() { |
178 | 178 |
return ++this.childNum; |
179 | 179 |
} |
src/edu/ucsb/nceas/metacat/TextNode.java | ||
---|---|---|
34 | 34 |
public TextNode (Connection conn, long nodeid, long parentnodeid, |
35 | 35 |
String nodedata, String nodetype) { |
36 | 36 |
this.conn = conn; |
37 |
setElementID(nodeid);
|
|
37 |
setNodeID(nodeid);
|
|
38 | 38 |
setParentID(parentnodeid); |
39 | 39 |
setNodeData(nodedata); |
40 | 40 |
setNodeType(nodetype); |
Also available in: Unified diff
code consolidation, cleanup, and documentation