Revision 8783
Added by ben leinfelder over 10 years ago
test/edu/ucsb/nceas/metacat/annotation/OrePackageTest.java | ||
---|---|---|
34 | 34 |
import org.dataone.service.types.v1.ObjectFormatIdentifier; |
35 | 35 |
import org.dataone.service.types.v1.Session; |
36 | 36 |
import org.dataone.service.types.v1.SystemMetadata; |
37 |
import org.dspace.foresite.OREFactory; |
|
37 | 38 |
import org.dspace.foresite.Predicate; |
38 | 39 |
import org.dspace.foresite.ResourceMap; |
39 | 40 |
import org.dspace.foresite.Triple; |
... | ... | |
72 | 73 |
*/ |
73 | 74 |
public static Test suite() { |
74 | 75 |
TestSuite suite = new TestSuite(); |
75 |
suite.addTest(new DatapackageSummarizerTest("testGenerateAnnotation"));
|
|
76 |
suite.addTest(new OrePackageTest("testGenerateAnnotation"));
|
|
76 | 77 |
return suite; |
77 | 78 |
} |
78 | 79 |
|
... | ... | |
87 | 88 |
Identifier metadataPid = new Identifier(); |
88 | 89 |
metadataPid.setValue("testOre.eml." + System.currentTimeMillis()); |
89 | 90 |
Session session = getTestSession(); |
90 |
try { |
|
91 |
InputStream object = new ByteArrayInputStream(this.getTestDocFromFile(ANNOTATION_TEST_DOC).getBytes("UTF-8")); |
|
92 |
SystemMetadata sysmeta = createSystemMetadata(metadataPid, session.getSubject(), object); |
|
93 |
ObjectFormatIdentifier formatId = new ObjectFormatIdentifier(); |
|
94 |
formatId.setValue("eml://ecoinformatics.org/eml-2.0.0"); |
|
95 |
sysmeta.setFormatId(formatId); |
|
96 |
Identifier pid = MNodeService.getInstance(request).create(session, metadataPid, object, sysmeta); |
|
97 |
assertEquals(metadataPid.getValue(), pid.getValue()); |
|
98 |
} catch (Exception e) { |
|
99 |
e.printStackTrace(); |
|
100 |
fail("Could not add metadata test file: " + e.getMessage()); |
|
101 |
} |
|
91 |
// try {
|
|
92 |
// InputStream object = new ByteArrayInputStream(this.getTestDocFromFile(ANNOTATION_TEST_DOC).getBytes("UTF-8"));
|
|
93 |
// SystemMetadata sysmeta = createSystemMetadata(metadataPid, session.getSubject(), object);
|
|
94 |
// ObjectFormatIdentifier formatId = new ObjectFormatIdentifier();
|
|
95 |
// formatId.setValue("eml://ecoinformatics.org/eml-2.0.0");
|
|
96 |
// sysmeta.setFormatId(formatId);
|
|
97 |
// Identifier pid = MNodeService.getInstance(request).create(session, metadataPid, object, sysmeta);
|
|
98 |
// assertEquals(metadataPid.getValue(), pid.getValue());
|
|
99 |
// } catch (Exception e) {
|
|
100 |
// e.printStackTrace();
|
|
101 |
// fail("Could not add metadata test file: " + e.getMessage());
|
|
102 |
// }
|
|
102 | 103 |
|
103 | 104 |
// generate the ORE for the EML metadata + data |
104 | 105 |
Map<Identifier, List<Identifier>> resources = new HashMap<Identifier, List<Identifier>>(); |
... | ... | |
112 | 113 |
ResourceMap resourceMap = ResourceMapFactory.getInstance().createResourceMap(resourceMapPid , resources); |
113 | 114 |
|
114 | 115 |
// augment the ORE package with triples describing the derivation |
115 |
Triple triple = new TripleJena(); |
|
116 |
triple.initialise(new URI(dataIdentifier.getValue())); |
|
117 | 116 |
Predicate predicate = new Predicate(new URI("http://www.w3.org/ns/prov#wasDerivedFrom")); |
118 |
triple.relate(predicate , new URI("https://cn.dataone.or/cn/v1/resolve/data.1.1")); |
|
117 |
Triple triple = |
|
118 |
OREFactory.createTriple( |
|
119 |
new URI("https://cn.dataone.org/cn/v1/resolve/" + dataIdentifier.getValue()), |
|
120 |
predicate, |
|
121 |
new URI("https://cn.dataone.org/cn/v1/resolve/data.1.1")); |
|
122 |
System.out.println("Triple: " + " " + triple.getPredicate().getURI() + " " + triple.getObjectURI()); |
|
119 | 123 |
resourceMap.addTriple(triple); |
120 | 124 |
|
121 | 125 |
// get the RDF content |
Also available in: Unified diff
correct glaring erros -- still needs to be honed, but at least it runs without NPE and Jena/foresite errors