Revision 3814
Added by Jing Tao over 16 years ago
src/edu/ucsb/nceas/metacat/EML201DocumentCorrector.java | ||
---|---|---|
1 |
package edu.ucsb.nceas.metacat; |
|
2 |
|
|
3 |
/** |
|
4 |
* Before Metacat 1.8.1 release, Metacat uses the eml201 schema with the tag |
|
5 |
* RELEASE_EML_2_0_1_UPDATE_5. Unfortunately, this tag points at wrong version |
|
6 |
* of eml-resource.xsd. In this schema, the element "references" has an attribute named |
|
7 |
* "system" and the attribute has a default value "document". Metacat will add |
|
8 |
* the attribute system="document" to "references" element even the orginal eml didn't have it |
|
9 |
* (this is another bug and see bug 1601), so this causes metacat generated some invalid eml201 |
|
10 |
* documents. This class provides a path to fix the existed invalid eml201 documents. It will |
|
11 |
* remove the attribute system="document" of the element "references" in xml_nodes and xml_index |
|
12 |
* tables. |
|
13 |
* @author tao |
|
14 |
* |
|
15 |
*/ |
|
16 |
public class EML201DocumentCorrector implements Runnable |
|
17 |
{ |
|
18 |
/** |
|
19 |
* Default constructor |
|
20 |
* |
|
21 |
*/ |
|
22 |
public EML201DocumentCorrector() |
|
23 |
{ |
|
24 |
|
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* It will remove the records - attribute system="document" of element "refrence" |
|
29 |
* in both xml_nodes and xml_index table |
|
30 |
*/ |
|
31 |
public void run() |
|
32 |
{ |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
/* |
|
37 |
* Generate the sql command to delete the records in xml_node table |
|
38 |
*/ |
|
39 |
private String generateXML_NodeDeletingSQL() |
|
40 |
{ |
|
41 |
String sql ="delete from xml_nodes where nodetype='ATTRIBUTE' and nodename='system' and nodevalue='document' "+ |
|
42 |
"and parentnodeid in (select nodeid from xml_nodes where nodetype='ELEMENT' and nodename='references') and docid in "+ |
|
43 |
"(select docid from xml_documents where doctype ='eml://ecoinformatics.org/eml-2.0.1'"; |
|
44 |
return sql; |
|
45 |
} |
|
46 |
|
|
47 |
/* |
|
48 |
* Generate the sql command to delete the records in xml_nidex table; |
|
49 |
*/ |
|
50 |
private String generateXML_IndexDeletingSQL() |
|
51 |
{ |
|
52 |
String sql ="delete from xml_index where path ='references/@system' AND docid in "+ |
|
53 |
"(select docid from xml_documents where doctype ='eml://ecoinformatics.org/eml-2.0.1'"; |
|
54 |
return sql; |
|
55 |
} |
|
56 |
} |
|
0 | 57 |
Also available in: Unified diff
A class to correct invalid eml201 documents. Metacat 1.8.0 and ealier version points incorrect eml-resource.xsd. We need fix eml documents.
Haven't done yet.