1
|
package edu.ucsb.nceas.metacat.annotation;
|
2
|
|
3
|
import java.io.InputStream;
|
4
|
import java.io.InputStreamReader;
|
5
|
import java.io.StringWriter;
|
6
|
import java.net.URL;
|
7
|
import java.net.URLEncoder;
|
8
|
import java.sql.PreparedStatement;
|
9
|
import java.sql.SQLException;
|
10
|
import java.util.ArrayList;
|
11
|
import java.util.Arrays;
|
12
|
import java.util.Iterator;
|
13
|
import java.util.List;
|
14
|
import java.util.Map;
|
15
|
import java.util.Vector;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
import org.apache.wicket.protocol.http.mock.MockHttpServletRequest;
|
19
|
import org.dataone.service.types.v1.Identifier;
|
20
|
import org.dataone.service.types.v1.Session;
|
21
|
import org.dataone.service.types.v1.Subject;
|
22
|
import org.ecoinformatics.datamanager.parser.Attribute;
|
23
|
import org.ecoinformatics.datamanager.parser.DataPackage;
|
24
|
import org.ecoinformatics.datamanager.parser.Entity;
|
25
|
import org.ecoinformatics.datamanager.parser.generic.DataPackageParserInterface;
|
26
|
import org.ecoinformatics.datamanager.parser.generic.Eml200DataPackageParser;
|
27
|
import org.w3c.dom.Document;
|
28
|
import org.w3c.dom.NodeList;
|
29
|
|
30
|
import com.hp.hpl.jena.ontology.AllValuesFromRestriction;
|
31
|
import com.hp.hpl.jena.ontology.Individual;
|
32
|
import com.hp.hpl.jena.ontology.ObjectProperty;
|
33
|
import com.hp.hpl.jena.ontology.OntClass;
|
34
|
import com.hp.hpl.jena.ontology.OntModel;
|
35
|
import com.hp.hpl.jena.ontology.Ontology;
|
36
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
37
|
import com.hp.hpl.jena.rdf.model.Property;
|
38
|
import com.hp.hpl.jena.rdf.model.Resource;
|
39
|
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
|
40
|
|
41
|
import edu.ucsb.nceas.metacat.DBUtil;
|
42
|
import edu.ucsb.nceas.metacat.DocumentImpl;
|
43
|
import edu.ucsb.nceas.metacat.IdentifierManager;
|
44
|
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
|
45
|
import edu.ucsb.nceas.metacat.database.DBConnection;
|
46
|
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
|
47
|
import edu.ucsb.nceas.metacat.dataone.MNodeService;
|
48
|
import edu.ucsb.nceas.metacat.properties.PropertyService;
|
49
|
import edu.ucsb.nceas.metacat.replication.ReplicationService;
|
50
|
import edu.ucsb.nceas.metacat.util.DocumentUtil;
|
51
|
import edu.ucsb.nceas.utilities.SortedProperties;
|
52
|
import edu.ucsb.nceas.utilities.XMLUtilities;
|
53
|
|
54
|
public class DatapackageSummarizer {
|
55
|
|
56
|
private static Logger logMetacat = Logger.getLogger(DatapackageSummarizer.class);
|
57
|
|
58
|
public static String rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
59
|
public static String rdfs = "http://www.w3.org/2000/01/rdf-schema#";
|
60
|
public static String owl = "http://www.w3.org/2002/07/owl#";
|
61
|
public static String oboe = "http://ecoinformatics.org/oboe/oboe.1.0/oboe.owl#";
|
62
|
public static String oboe_core = "http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#";
|
63
|
public static String oa = "http://www.w3.org/ns/oa#";
|
64
|
public static String oa_source = "http://www.w3.org/ns/oa.rdf";
|
65
|
public static String dcterms = "http://purl.org/dc/terms/";
|
66
|
public static String dcterms_source = "http://dublincore.org/2012/06/14/dcterms.rdf";
|
67
|
public static String foaf = "http://xmlns.com/foaf/0.1/";
|
68
|
public static String foaf_source = "http://xmlns.com/foaf/spec/index.rdf";
|
69
|
public static String prov = "http://www.w3.org/ns/prov#";
|
70
|
public static String prov_source = "http://www.w3.org/ns/prov.owl";
|
71
|
public static String cito = "http://purl.org/spar/cito/";
|
72
|
|
73
|
// for looking up concepts in BioPortal
|
74
|
static final String REST_URL = "http://data.bioontology.org";
|
75
|
static final String API_KEY = "LOGIN_TO_BIOPORTAL";
|
76
|
|
77
|
// package visibility for testing only
|
78
|
boolean randomize = false;
|
79
|
|
80
|
/**
|
81
|
* Generate annotation for given metadata identifier
|
82
|
* @param metadataPid
|
83
|
*/
|
84
|
public String generateAnnotation(Identifier metadataPid) throws Exception {
|
85
|
|
86
|
DataPackage dataPackage = this.getDataPackage(metadataPid);
|
87
|
|
88
|
OntModel m = ModelFactory.createOntologyModel();
|
89
|
Ontology ont = m.createOntology("http://annotation/" + metadataPid.getValue());
|
90
|
|
91
|
// TODO: import the ontologies we use
|
92
|
ont.addImport(m.createResource(oboe));
|
93
|
m.addSubModel(ModelFactory.createOntologyModel().read(oboe));
|
94
|
|
95
|
ont.addImport(m.createResource(oa));
|
96
|
m.addSubModel(ModelFactory.createOntologyModel().read(oa_source));
|
97
|
|
98
|
ont.addImport(m.createResource(dcterms));
|
99
|
m.addSubModel(ModelFactory.createOntologyModel().read(dcterms_source));
|
100
|
|
101
|
ont.addImport(m.createResource(foaf));
|
102
|
m.addSubModel(ModelFactory.createOntologyModel().read(foaf_source));
|
103
|
|
104
|
ont.addImport(m.createResource(prov));
|
105
|
//m.addSubModel(ModelFactory.createOntologyModel().read(prov_source));
|
106
|
|
107
|
ont.addImport(m.createResource(cito));
|
108
|
|
109
|
// properties
|
110
|
ObjectProperty hasBodyProperty = m.getObjectProperty(oa + "hasBody");
|
111
|
ObjectProperty hasTargetProperty = m.getObjectProperty(oa + "hasTarget");
|
112
|
ObjectProperty hasSourceProperty = m.getObjectProperty(oa + "hasSource");
|
113
|
ObjectProperty hasSelectorProperty = m.getObjectProperty(oa + "hasSelector");
|
114
|
ObjectProperty annotatedByProperty = m.getObjectProperty(oa + "annotatedBy");
|
115
|
Property identifierProperty = m.getProperty(dcterms + "identifier");
|
116
|
Property conformsToProperty = m.getProperty(dcterms + "conformsTo");
|
117
|
Property nameProperty = m.getProperty(foaf + "name");
|
118
|
Property rdfValue = m.getProperty(rdf + "value");
|
119
|
|
120
|
ObjectProperty ofCharacteristic = m.getObjectProperty(oboe_core + "ofCharacteristic");
|
121
|
ObjectProperty usesStandard = m.getObjectProperty(oboe_core + "usesStandard");
|
122
|
|
123
|
// classes
|
124
|
OntClass measurementClass = m.getOntClass(oboe_core + "Measurement");
|
125
|
OntClass characteristicClass = m.getOntClass(oboe_core + "Characteristic");
|
126
|
OntClass standardClass = m.getOntClass(oboe_core + "Standard");
|
127
|
|
128
|
Resource annotationClass = m.getOntClass(oa + "Annotation");
|
129
|
Resource specificResourceClass = m.getOntClass(oa + "SpecificResource");
|
130
|
Resource fragmentSelectorClass = m.getOntClass(oa + "FragmentSelector");
|
131
|
Resource entityClass = m.getResource(prov + "Entity");
|
132
|
Resource personClass = m.getResource(prov + "Person");
|
133
|
|
134
|
int cnt = 1;
|
135
|
|
136
|
// these apply to every attribute annotation
|
137
|
Individual meta1 = m.createIndividual(ont.getURI() + "#meta" + cnt, entityClass);
|
138
|
Individual p1 = m.createIndividual(ont.getURI() + "#person" + cnt, personClass);
|
139
|
p1.addProperty(nameProperty, "Ben Leinfelder");
|
140
|
meta1.addProperty(identifierProperty, metadataPid.getValue());
|
141
|
|
142
|
// loop through the tables and attributes
|
143
|
Entity[] entities = dataPackage.getEntityList();
|
144
|
for (Entity entity: entities) {
|
145
|
String entityName = entity.getName();
|
146
|
logMetacat.debug("Entity name: " + entityName);
|
147
|
Attribute[] attributes = entity.getAttributeList().getAttributes();
|
148
|
int attributeCount = 1;
|
149
|
for (Attribute attribute: attributes) {
|
150
|
|
151
|
String attributeName = attribute.getName();
|
152
|
String attributeLabel = attribute.getLabel();
|
153
|
String attributeDefinition = attribute.getDefinition();
|
154
|
String attributeType = attribute.getAttributeType();
|
155
|
String attributeScale = attribute.getMeasurementScale();
|
156
|
String attributeUnitType = attribute.getUnitType();
|
157
|
String attributeUnit = attribute.getUnit();
|
158
|
String attributeDomain = attribute.getDomain().getClass().getSimpleName();
|
159
|
|
160
|
logMetacat.debug("Attribute name: " + attributeName);
|
161
|
logMetacat.debug("Attribute label: " + attributeLabel);
|
162
|
logMetacat.debug("Attribute definition: " + attributeDefinition);
|
163
|
logMetacat.debug("Attribute type: " + attributeType);
|
164
|
logMetacat.debug("Attribute scale: " + attributeScale);
|
165
|
logMetacat.debug("Attribute unit type: " + attributeUnitType);
|
166
|
logMetacat.debug("Attribute unit: " + attributeUnit);
|
167
|
logMetacat.debug("Attribute domain: " + attributeDomain);
|
168
|
|
169
|
// look up the characteristic or standard subclasses
|
170
|
Resource standard = this.lookupStandard(standardClass, attribute);
|
171
|
Resource characteristic = this.lookupCharacteristic(characteristicClass, attribute);
|
172
|
|
173
|
if (standard != null || characteristic != null) {
|
174
|
|
175
|
// instances
|
176
|
Individual m1 = m.createIndividual(ont.getURI() + "#measurement" + cnt, measurementClass);
|
177
|
Individual a1 = m.createIndividual(ont.getURI() + "#annotation" + cnt, annotationClass);
|
178
|
Individual t1 = m.createIndividual(ont.getURI() + "#target" + cnt, specificResourceClass);
|
179
|
String xpointer = "xpointer(/eml/dataSet/" + cnt + "/attributeList/" + attributeCount + ")";
|
180
|
Individual s1 = m.createIndividual(ont.getURI() + "#" + xpointer, fragmentSelectorClass);
|
181
|
s1.addLiteral(rdfValue, xpointer);
|
182
|
s1.addProperty(conformsToProperty, "http://www.w3.org/TR/xptr/");
|
183
|
|
184
|
// statements about the annotation
|
185
|
a1.addProperty(hasBodyProperty, m1);
|
186
|
a1.addProperty(hasTargetProperty, t1);
|
187
|
t1.addProperty(hasSourceProperty, meta1);
|
188
|
t1.addProperty(hasSelectorProperty, s1);
|
189
|
a1.addProperty(annotatedByProperty, p1);
|
190
|
|
191
|
// describe the measurement in terms of restrictions
|
192
|
if (standard != null) {
|
193
|
AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, usesStandard, standard);
|
194
|
m1.addOntClass(avfr);
|
195
|
}
|
196
|
if (characteristic != null) {
|
197
|
AllValuesFromRestriction avfr = m.createAllValuesFromRestriction(null, ofCharacteristic, characteristic);
|
198
|
m1.addOntClass(avfr);
|
199
|
}
|
200
|
cnt++;
|
201
|
}
|
202
|
|
203
|
}
|
204
|
}
|
205
|
|
206
|
StringWriter sw = new StringWriter();
|
207
|
// only write the base model
|
208
|
//m.write(sw, "RDF/XML-ABBREV");
|
209
|
m.write(sw, null);
|
210
|
|
211
|
return sw.toString();
|
212
|
|
213
|
}
|
214
|
|
215
|
private Resource lookupStandard(OntClass standardClass, Attribute attribute) {
|
216
|
// what's our unit?
|
217
|
String unit = attribute.getUnit().toLowerCase();
|
218
|
List<String> tokens = Arrays.asList(unit.split(" "));
|
219
|
|
220
|
boolean found = false;
|
221
|
ExtendedIterator iter = standardClass.listSubClasses(false);
|
222
|
if (randomize) {
|
223
|
List subclasses = iter.toList();
|
224
|
int size = subclasses.size();
|
225
|
Long index = new Long(Math.round(Math.floor((Math.random() * (size-1)))));
|
226
|
OntClass subclass = (OntClass) subclasses.get( index.intValue() );
|
227
|
return subclass;
|
228
|
}
|
229
|
while (iter.hasNext()) {
|
230
|
OntClass subclass = (OntClass) iter.next();
|
231
|
String subclassName = subclass.getLocalName().toLowerCase();
|
232
|
logMetacat.debug("subclass: " + subclassName);
|
233
|
if (tokens.contains(subclassName)) {
|
234
|
found = true;
|
235
|
}
|
236
|
if (subclass.hasLabel(unit, null)) {
|
237
|
found = true;
|
238
|
}
|
239
|
if (found) {
|
240
|
return subclass;
|
241
|
}
|
242
|
}
|
243
|
// try to look it up if we got this far
|
244
|
return this.lookupRemoteAnnotationClass(standardClass, unit);
|
245
|
}
|
246
|
|
247
|
private Resource lookupCharacteristic(OntClass characteristicClass, Attribute attribute) {
|
248
|
// what's our label?
|
249
|
String label = attribute.getLabel().toLowerCase();
|
250
|
List<String> tokens = Arrays.asList(label.split(" "));
|
251
|
|
252
|
boolean found = false;
|
253
|
// find something that matches
|
254
|
ExtendedIterator iter = characteristicClass.listSubClasses();
|
255
|
if (randomize) {
|
256
|
List subclasses = iter.toList();
|
257
|
int size = subclasses.size();
|
258
|
Long index = new Long(Math.round(Math.floor((Math.random() * (size-1)))));
|
259
|
OntClass subclass = (OntClass) subclasses.get( index.intValue() );
|
260
|
return subclass;
|
261
|
}
|
262
|
while (iter.hasNext()) {
|
263
|
OntClass subclass = (OntClass) iter.next();
|
264
|
String subclassName = subclass.getLocalName().toLowerCase();
|
265
|
logMetacat.debug("subclass: " + subclassName);
|
266
|
if (tokens.contains(subclassName)) {
|
267
|
found = true;
|
268
|
}
|
269
|
if (subclass.hasLabel(label, null)) {
|
270
|
found = true;
|
271
|
}
|
272
|
if (found) {
|
273
|
return subclass;
|
274
|
}
|
275
|
}
|
276
|
|
277
|
// try to look it up if we got this far
|
278
|
return this.lookupRemoteAnnotationClass(characteristicClass, attribute.getDefinition());
|
279
|
|
280
|
}
|
281
|
|
282
|
/**
|
283
|
* Look up possible concept from BioPortal annotation service.
|
284
|
* @see "http://data.bioontology.org/documentation"
|
285
|
* @param superClass
|
286
|
* @param text
|
287
|
* @return
|
288
|
*/
|
289
|
private Resource lookupRemoteAnnotationClass(OntClass superClass, String text) {
|
290
|
|
291
|
try {
|
292
|
|
293
|
String urlParameters = "apikey=" + API_KEY;
|
294
|
urlParameters += "&format=xml";
|
295
|
// urlParameters += "&ontologies=OBOE-SBC";
|
296
|
urlParameters += "&ontologies=SWEET";
|
297
|
urlParameters += "&text=" + URLEncoder.encode(text, "UTF-8");
|
298
|
|
299
|
String url = REST_URL + "/annotator?" + urlParameters ;
|
300
|
URL restURL = new URL(url);
|
301
|
InputStream is = ReplicationService.getURLStream(restURL);
|
302
|
Document doc = XMLUtilities.getXMLReaderAsDOMDocument(new InputStreamReader(is, "UTF-8"));
|
303
|
NodeList classNodeList = XMLUtilities.getNodeListWithXPath(doc, "//annotation/annotatedClass/id");
|
304
|
if (classNodeList != null && classNodeList.getLength() > 0) {
|
305
|
String classURI = classNodeList.item(0).getFirstChild().getNodeValue();
|
306
|
logMetacat.info("annotator suggested: " + classURI);
|
307
|
Resource subclass = superClass.getModel().getResource(classURI);
|
308
|
// TODO: check that it is a subclass of superClass?
|
309
|
return subclass;
|
310
|
}
|
311
|
} catch (Exception e) {
|
312
|
logMetacat.error("Could not lookup BioPortal annotation for text= " + text, e);
|
313
|
}
|
314
|
|
315
|
return null;
|
316
|
}
|
317
|
|
318
|
private DataPackage getDataPackage(Identifier pid) throws Exception {
|
319
|
// for using the MN API as the MN itself
|
320
|
MockHttpServletRequest request = new MockHttpServletRequest(null, null, null);
|
321
|
Session session = new Session();
|
322
|
Subject subject = MNodeService.getInstance(request).getCapabilities().getSubject(0);
|
323
|
session.setSubject(subject);
|
324
|
InputStream emlStream = MNodeService.getInstance(request).get(session, pid);
|
325
|
|
326
|
// parse the metadata
|
327
|
DataPackageParserInterface parser = new Eml200DataPackageParser();
|
328
|
parser.parse(emlStream);
|
329
|
DataPackage dataPackage = parser.getDataPackage();
|
330
|
return dataPackage;
|
331
|
}
|
332
|
|
333
|
private void summarize(List<Identifier> identifiers) throws SQLException {
|
334
|
|
335
|
DBConnection dbconn = null;
|
336
|
|
337
|
try {
|
338
|
dbconn = DBConnectionPool.getDBConnection("DatapackageSummarizer.summarize");
|
339
|
|
340
|
PreparedStatement dropStatement = dbconn.prepareStatement("DROP TABLE IF EXISTS entity_summary");
|
341
|
dropStatement.execute();
|
342
|
|
343
|
PreparedStatement createStatement = dbconn.prepareStatement(
|
344
|
"CREATE TABLE entity_summary (" +
|
345
|
"guid text, " +
|
346
|
"title text, " +
|
347
|
"entity text," +
|
348
|
"attributeName text," +
|
349
|
"attributeLabel text," +
|
350
|
"attributeDefinition text," +
|
351
|
"attributeType text," +
|
352
|
"attributeScale text," +
|
353
|
"attributeUnitType text," +
|
354
|
"attributeUnit text," +
|
355
|
"attributeDomain text" +
|
356
|
")");
|
357
|
createStatement.execute();
|
358
|
|
359
|
PreparedStatement insertStatement = dbconn.prepareStatement(
|
360
|
"INSERT INTO entity_summary " +
|
361
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
362
|
|
363
|
for (Identifier pid: identifiers) {
|
364
|
|
365
|
logMetacat.debug("Parsing pid: " + pid.getValue());
|
366
|
|
367
|
try {
|
368
|
|
369
|
// get the package
|
370
|
DataPackage dataPackage = this.getDataPackage(pid);
|
371
|
String title = dataPackage.getTitle();
|
372
|
logMetacat.debug("Title: " + title);
|
373
|
|
374
|
Entity[] entities = dataPackage.getEntityList();
|
375
|
if (entities != null) {
|
376
|
for (Entity entity: entities) {
|
377
|
String entityName = entity.getName();
|
378
|
logMetacat.debug("Entity name: " + entityName);
|
379
|
Attribute[] attributes = entity.getAttributeList().getAttributes();
|
380
|
for (Attribute attribute: attributes) {
|
381
|
String attributeName = attribute.getName();
|
382
|
String attributeLabel = attribute.getLabel();
|
383
|
String attributeDefinition = attribute.getDefinition();
|
384
|
String attributeType = attribute.getAttributeType();
|
385
|
String attributeScale = attribute.getMeasurementScale();
|
386
|
String attributeUnitType = attribute.getUnitType();
|
387
|
String attributeUnit = attribute.getUnit();
|
388
|
String attributeDomain = attribute.getDomain().getClass().getSimpleName();
|
389
|
|
390
|
logMetacat.debug("Attribute name: " + attributeName);
|
391
|
logMetacat.debug("Attribute label: " + attributeLabel);
|
392
|
logMetacat.debug("Attribute definition: " + attributeDefinition);
|
393
|
logMetacat.debug("Attribute type: " + attributeType);
|
394
|
logMetacat.debug("Attribute scale: " + attributeScale);
|
395
|
logMetacat.debug("Attribute unit type: " + attributeUnitType);
|
396
|
logMetacat.debug("Attribute unit: " + attributeUnit);
|
397
|
logMetacat.debug("Attribute domain: " + attributeDomain);
|
398
|
|
399
|
// set the values for this attribute
|
400
|
insertStatement.setString(1, pid.getValue());
|
401
|
insertStatement.setString(2, title);
|
402
|
insertStatement.setString(3, entityName);
|
403
|
insertStatement.setString(4, attributeName);
|
404
|
insertStatement.setString(5, attributeLabel);
|
405
|
insertStatement.setString(6, attributeDefinition);
|
406
|
insertStatement.setString(7, attributeType);
|
407
|
insertStatement.setString(8, attributeScale);
|
408
|
insertStatement.setString(9, attributeUnitType);
|
409
|
insertStatement.setString(10, attributeUnit);
|
410
|
insertStatement.setString(11, attributeDomain);
|
411
|
insertStatement.execute();
|
412
|
|
413
|
}
|
414
|
}
|
415
|
}
|
416
|
|
417
|
} catch (Exception e) {
|
418
|
logMetacat.warn("error parsing metadata for: " + pid.getValue(), e);
|
419
|
}
|
420
|
}
|
421
|
} catch (SQLException sqle) {
|
422
|
// just throw it
|
423
|
throw sqle;
|
424
|
} finally {
|
425
|
if (dbconn != null) {
|
426
|
DBConnectionPool.returnDBConnection(dbconn, 0);
|
427
|
dbconn.close();
|
428
|
}
|
429
|
}
|
430
|
}
|
431
|
|
432
|
public static void main(String[] args) throws Exception {
|
433
|
// set up the properties based on the test/deployed configuration of the workspace
|
434
|
SortedProperties testProperties = new SortedProperties("test/test.properties");
|
435
|
testProperties.load();
|
436
|
String metacatContextDir = testProperties.getProperty("metacat.contextDir");
|
437
|
PropertyService.getInstance(metacatContextDir + "/WEB-INF");
|
438
|
|
439
|
testGenerate();
|
440
|
// testSummary();
|
441
|
System.exit(0);
|
442
|
}
|
443
|
|
444
|
public static void testGenerate() throws Exception {
|
445
|
Identifier metadataPid = new Identifier();
|
446
|
metadataPid.setValue("doi:10.5072/FK2445ZN4");
|
447
|
DatapackageSummarizer ds = new DatapackageSummarizer();
|
448
|
String rdfString = ds.generateAnnotation(metadataPid);
|
449
|
logMetacat.info("RDF annotation: \n" + rdfString);
|
450
|
|
451
|
}
|
452
|
|
453
|
public static void testSummary() throws Exception {
|
454
|
|
455
|
// summarize the packages
|
456
|
DatapackageSummarizer ds = new DatapackageSummarizer();
|
457
|
List<Identifier> identifiers = new ArrayList<Identifier>();
|
458
|
Map<Integer, String> serverCodes = ReplicationService.getServerCodes();
|
459
|
|
460
|
// select the metadata ids we want to summarize
|
461
|
boolean includeReplicas = true;
|
462
|
Iterator<Integer> codeIter = Arrays.asList(new Integer[] {1}).iterator();
|
463
|
if (includeReplicas ) {
|
464
|
codeIter = serverCodes.keySet().iterator();
|
465
|
}
|
466
|
|
467
|
Vector<String> idList = new Vector<String>();
|
468
|
while (codeIter.hasNext()) {
|
469
|
int serverLocation = codeIter.next();
|
470
|
Vector<String> idList0 = DBUtil.getAllDocidsByType(DocumentImpl.EML2_0_0NAMESPACE, false, serverLocation);
|
471
|
Vector<String> idList1 = DBUtil.getAllDocidsByType(DocumentImpl.EML2_0_1NAMESPACE, false, serverLocation);
|
472
|
Vector<String> idList2 = DBUtil.getAllDocidsByType(DocumentImpl.EML2_1_0NAMESPACE, false, serverLocation);
|
473
|
Vector<String> idList3 = DBUtil.getAllDocidsByType(DocumentImpl.EML2_1_1NAMESPACE, false, serverLocation);
|
474
|
|
475
|
idList.addAll(idList0);
|
476
|
idList.addAll(idList1);
|
477
|
idList.addAll(idList2);
|
478
|
idList.addAll(idList3);
|
479
|
|
480
|
}
|
481
|
|
482
|
// go through all the identifiers now
|
483
|
for (String localId : idList) {
|
484
|
try {
|
485
|
String guid = IdentifierManager.getInstance().getGUID(
|
486
|
DocumentUtil.getDocIdFromAccessionNumber(localId),
|
487
|
DocumentUtil.getRevisionFromAccessionNumber(localId));
|
488
|
Identifier pid = new Identifier();
|
489
|
pid.setValue(guid);
|
490
|
identifiers.add(pid);
|
491
|
} catch (McdbDocNotFoundException nfe) {
|
492
|
// just skip it
|
493
|
continue;
|
494
|
}
|
495
|
}
|
496
|
ds.summarize(identifiers);
|
497
|
System.exit(0);
|
498
|
}
|
499
|
|
500
|
}
|