Revision 6912
Added by ben leinfelder almost 13 years ago
src/edu/ucsb/nceas/metacat/DBUtil.java | ||
---|---|---|
437 | 437 |
/** |
438 | 438 |
* return all docids with a given doctype |
439 | 439 |
*/ |
440 |
public static Vector<String> getAllDocidsByType(String doctype, boolean includeRevs) throws SQLException { |
|
440 |
public static Vector<String> getAllDocidsByType(String doctype, boolean includeRevs, int serverLocation) throws SQLException {
|
|
441 | 441 |
Vector<String> resultVector = new Vector<String>(); |
442 | 442 |
String sep = "."; |
443 | 443 |
try { |
... | ... | |
456 | 456 | |
457 | 457 |
sb.append("SELECT docid, rev FROM " + "( " + "SELECT docid, rev " |
458 | 458 |
+ "FROM xml_documents "); |
459 |
sb.append("WHERE true "); |
|
459 | 460 |
if (doctype != null) { |
460 |
sb.append("WHERE doctype LIKE ? ");
|
|
461 |
sb.append("AND doctype LIKE ? ");
|
|
461 | 462 |
} |
463 |
if (serverLocation > 0) { |
|
464 |
sb.append("AND server_location = ' " + serverLocation + "' "); |
|
465 |
} |
|
466 |
|
|
462 | 467 |
if (includeRevs) { |
463 | 468 |
sb.append("UNION " + "SELECT docid, rev " + "FROM xml_revisions "); |
469 |
sb.append("WHERE true "); |
|
464 | 470 |
if (doctype != null) { |
465 |
sb.append("WHERE doctype LIKE ?");
|
|
471 |
sb.append("AND doctype LIKE ?");
|
|
466 | 472 |
} |
473 |
if (serverLocation > 0) { |
|
474 |
sb.append("AND server_location = ' " + serverLocation + "' "); |
|
475 |
} |
|
467 | 476 |
} |
468 | 477 |
sb.append(") subquery GROUP BY docid, rev"); |
469 | 478 |
pstmt = dbConn.prepareStatement(sb.toString()); |
src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
public boolean upgrade() throws AdminException { |
46 | 46 |
boolean success = true; |
47 |
// include ORE? |
|
47 |
|
|
48 |
// do not include ORE or data, but can generate SystemMetadata for ALL records |
|
48 | 49 |
boolean includeOre = false; |
49 | 50 |
boolean downloadData = false; |
50 | ||
51 |
int serverLocation = -1; |
|
52 |
|
|
51 | 53 |
try { |
52 |
//get the list of ids with no SM |
|
53 |
//List<String> idList = IdentifierManager.getInstance().getLocalIdsWithNoSystemMetadata(true); |
|
54 |
List<String> idList = DBUtil.getAllDocidsByType(null, true); |
|
54 |
// get list of ALL docids at ALL server locations |
|
55 |
List<String> idList = DBUtil.getAllDocidsByType(null, true, serverLocation); |
|
55 | 56 |
Collections.sort(idList); |
56 | 57 | |
57 | 58 |
// generate based on this list |
src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateORE.java | ||
---|---|---|
1 |
package edu.ucsb.nceas.metacat.admin.upgrade; |
|
2 |
/** |
|
3 |
* '$RCSfile$' |
|
4 |
* Purpose: A Class for upgrading the database to version 1.5 |
|
5 |
* Copyright: 2000 Regents of the University of California and the |
|
6 |
* National Center for Ecological Analysis and Synthesis |
|
7 |
* Authors: Saurabh Garg |
|
8 |
* |
|
9 |
* '$Author$' |
|
10 |
* '$Date$' |
|
11 |
* '$Revision$' |
|
12 |
* |
|
13 |
* This program is free software; you can redistribute it and/or modify |
|
14 |
* it under the terms of the GNU General Public License as published by |
|
15 |
* the Free Software Foundation; either version 2 of the License, or |
|
16 |
* (at your option) any later version. |
|
17 |
* |
|
18 |
* This program is distributed in the hope that it will be useful, |
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
* GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License |
|
24 |
* along with this program; if not, write to the Free Software |
|
25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
*/ |
|
27 | ||
28 | ||
29 |
import java.util.List; |
|
30 | ||
31 |
import org.apache.commons.logging.Log; |
|
32 |
import org.apache.commons.logging.LogFactory; |
|
33 | ||
34 |
import edu.emory.mathcs.backport.java.util.Collections; |
|
35 |
import edu.ucsb.nceas.metacat.DBUtil; |
|
36 |
import edu.ucsb.nceas.metacat.admin.AdminException; |
|
37 |
import edu.ucsb.nceas.metacat.dataone.SystemMetadataFactory; |
|
38 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
|
39 |
import edu.ucsb.nceas.utilities.SortedProperties; |
|
40 | ||
41 |
public class GenerateORE implements UpgradeUtilityInterface { |
|
42 | ||
43 |
private static Log log = LogFactory.getLog(GenerateORE.class); |
|
44 |
|
|
45 |
public boolean upgrade() throws AdminException { |
|
46 |
boolean success = true; |
|
47 |
|
|
48 |
// include ORE, data, for this server only |
|
49 |
boolean includeOre = true; |
|
50 |
boolean downloadData = true; |
|
51 |
int serverLocation = 1; |
|
52 | ||
53 |
try { |
|
54 |
// get only local ids for this server |
|
55 |
List<String> idList = DBUtil.getAllDocidsByType(null, true, serverLocation); |
|
56 |
Collections.sort(idList); |
|
57 | ||
58 |
// generate based on this list |
|
59 |
SystemMetadataFactory.generateSystemMetadata(idList, includeOre, downloadData); |
|
60 |
} catch (Exception e) { |
|
61 |
String msg = "Problem generating missing system metadata: " + e.getMessage(); |
|
62 |
log.error(msg, e); |
|
63 |
success = false; |
|
64 |
throw new AdminException(msg); |
|
65 |
} |
|
66 |
return success; |
|
67 |
} |
|
68 |
|
|
69 |
public static void main(String [] ags){ |
|
70 | ||
71 |
try { |
|
72 |
// set up the properties based on the test/deployed configuration of the workspace |
|
73 |
SortedProperties testProperties = |
|
74 |
new SortedProperties("test/test.properties"); |
|
75 |
testProperties.load(); |
|
76 |
String metacatContextDir = testProperties.getProperty("metacat.contextDir"); |
|
77 |
PropertyService.getInstance(metacatContextDir + "/WEB-INF"); |
|
78 |
// now run it |
|
79 |
GenerateORE upgrader = new GenerateORE(); |
|
80 |
upgrader.upgrade(); |
|
81 |
|
|
82 |
} catch (Exception ex) { |
|
83 |
System.out.println("Exception:" + ex.getMessage()); |
|
84 |
ex.printStackTrace(); |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
0 | 88 |
Also available in: Unified diff
-generate system meta for all docids, even those not originating on the server (replicas from the past)
-generate ORE docs and download remote data only for those documents that originated on this server being upgraded.
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5522