Revision 457
Added by bojilova over 23 years ago
DBSAXHandler.java | ||
---|---|---|
85 | 85 |
MetaCatUtil.debugMessage("start Document"); |
86 | 86 |
|
87 | 87 |
// Create the document node representation as root |
88 |
rootNode = new DBSAXNode(conn); |
|
88 |
rootNode = new DBSAXNode(conn, this.docid);
|
|
89 | 89 |
// Add the node to the stack, so that any text data can be |
90 | 90 |
// added as it is encountered |
91 | 91 |
nodeStack.push(rootNode); |
... | ... | |
95 | 95 |
public void endDocument() throws SAXException { |
96 | 96 |
currentDocument.setTitleFromChildElement(); |
97 | 97 |
MetaCatUtil.debugMessage("end Document"); |
98 |
if ((docid != null) && (!docid.equals(currentDocument.getDocID()))) { |
|
99 |
throw (new SAXException("New document ID generated:", |
|
100 |
new AccessionNumberGeneratedException(currentDocument.getDocID()))); |
|
101 |
} else { |
|
102 |
throw (new SAXException("New document ID generated:", |
|
103 |
new AccessionNumberGeneratedException(currentDocument.getDocID()))); |
|
104 |
} |
|
98 |
// if ((docid != null) && (!docid.equals(currentDocument.getDocID()))) {
|
|
99 |
// throw (new SAXException("New document ID generated:",
|
|
100 |
// new AccessionNumberGeneratedException(currentDocument.getDocID())));
|
|
101 |
// } else {
|
|
102 |
// throw (new SAXException("New document ID generated:",
|
|
103 |
// new AccessionNumberGeneratedException(currentDocument.getDocID())));
|
|
104 |
// }
|
|
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
/** SAX Handler that is called at the start of each XML element */ |
... | ... | |
137 | 137 |
try { |
138 | 138 |
currentDocument = new DocumentImpl(conn, rootNode.getNodeID(), |
139 | 139 |
docname, doctype, docid, action, user); |
140 |
} catch (AccessionNumberException ane) {
|
|
140 |
} catch (Exception ane) { |
|
141 | 141 |
throw (new SAXException("Error with " + action, ane)); |
142 | 142 |
} |
143 |
rootNode.writeDocID(currentDocument.getDocID()); |
|
143 |
// not needed any more |
|
144 |
//rootNode.writeDocID(currentDocument.getDocID()); |
|
144 | 145 |
} |
145 | 146 |
|
146 | 147 |
// Create the current node representation |
147 |
currentNode = new DBSAXNode(conn, localName, parentNode, currentDocument); |
|
148 |
currentNode = new DBSAXNode(conn, localName, parentNode, |
|
149 |
currentDocument.getRootNodeID(),docid, |
|
150 |
currentDocument.getDoctype()); |
|
148 | 151 |
|
149 | 152 |
// Add all of the attributes |
150 | 153 |
for (int i=0; i<atts.getLength(); i++) { |
151 |
currentNode.setAttribute(atts.getLocalName(i), atts.getValue(i)); |
|
154 |
currentNode.setAttribute(atts.getLocalName(i), atts.getValue(i), docid);
|
|
152 | 155 |
} |
153 | 156 |
|
154 | 157 |
// Add the node to the stack, so that any text data can be |
... | ... | |
181 | 184 |
} |
182 | 185 |
|
183 | 186 |
// Write the content of the node to the database |
184 |
currentNode.writeChildNodeToDB("TEXT", null, data); |
|
187 |
currentNode.writeChildNodeToDB("TEXT", null, data, docid);
|
|
185 | 188 |
} |
186 | 189 |
} |
187 | 190 |
|
... | ... | |
201 | 204 |
throws SAXException { |
202 | 205 |
MetaCatUtil.debugMessage("PI"); |
203 | 206 |
DBSAXNode currentNode = (DBSAXNode)nodeStack.peek(); |
204 |
currentNode.writeChildNodeToDB("PI", target, data); |
|
207 |
currentNode.writeChildNodeToDB("PI", target, data, docid);
|
|
205 | 208 |
} |
206 | 209 |
|
207 | 210 |
/** SAX Handler that is called at the end of each XML element */ |
... | ... | |
243 | 246 |
public void comment(char[] ch, int start, int length) throws SAXException { |
244 | 247 |
MetaCatUtil.debugMessage("COMMENT"); |
245 | 248 |
DBSAXNode currentNode = (DBSAXNode)nodeStack.peek(); |
246 |
currentNode.writeChildNodeToDB("COMMENT", null, new String(ch)); |
|
249 |
currentNode.writeChildNodeToDB("COMMENT", null, new String(ch), docid);
|
|
247 | 250 |
} |
248 | 251 |
|
249 | 252 |
/** |
Also available in: Unified diff
changes related to decrease the time of INSERT of document.
With these changes I inserted 200KB file for 3 minutes, 50KB for 50sec.
This is mainly simplifing the DBSAXNode class and
using batching feature of Oracle JDBC driver.