use of org.mycore.datamodel.metadata.MCRObject in project mycore by MyCoRe-Org.
the class MCRRSSFeedImporter method sendNotificationMail.
private void sendNotificationMail(List<MCRObject> importedObjects) throws Exception {
Element xml = new Element(STATUS_FLAG).setAttribute("source", this.sourceSystemID);
for (MCRObject obj : importedObjects) {
xml.addContent(obj.createXML().detachRootElement());
}
HashMap<String, String> parameters = new HashMap<>();
parameters.put(PROPERTY_MAIL_ADDRESS, MCRConfiguration.instance().getString(PROPERTY_MAIL_ADDRESS));
MCRMailer.sendMail(new Document(xml), xsl2BuildNotificationMail, parameters);
}
use of org.mycore.datamodel.metadata.MCRObject in project mycore by MyCoRe-Org.
the class MCRRSSFeedImporter method buildMCRObject.
private MCRObject buildMCRObject(Element publicationXML, String projectID) {
MCRObject obj = new MCRObject(new Document(publicationXML));
MCRMODSWrapper wrapper = new MCRMODSWrapper(obj);
wrapper.setServiceFlag("status", STATUS_FLAG);
MCRObjectID oid = MCRObjectID.getNextFreeId(projectID, "mods");
obj.setId(oid);
return obj;
}
use of org.mycore.datamodel.metadata.MCRObject in project mycore by MyCoRe-Org.
the class MCRMODSLinkedMetadataTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
seriesID = MCRObjectID.getInstance("junit_mods_00000001");
bookID = MCRObjectID.getInstance("junit_mods_00000002");
MCRSessionMgr.getCurrentSession().setUserInformation(MCRSystemUserInformation.getSuperUserInstance());
MCRObject series = new MCRObject(getResourceAsURL(seriesID + ".xml").toURI());
MCRObject book = new MCRObject(getResourceAsURL(bookID + ".xml").toURI());
MCRMetadataManager.create(series);
MCRMetadataManager.create(book);
}
use of org.mycore.datamodel.metadata.MCRObject in project mycore by MyCoRe-Org.
the class MCRMODSLinkedMetadataTest method testUpdate.
@Test
public void testUpdate() throws IOException, URISyntaxException, MCRPersistenceException, MCRActiveLinkException, JDOMException, SAXException, MCRAccessException {
MCRObject seriesNew = new MCRObject(getResourceAsURL(seriesID + "-updated.xml").toURI());
MCRMetadataManager.update(seriesNew);
Document bookNew = MCRXMLMetadataManager.instance().retrieveXML(bookID);
XPathBuilder<Element> builder = new XPathBuilder<>("/mycoreobject/metadata/def.modsContainer/modsContainer/mods:mods/mods:relatedItem/mods:titleInfo/mods:title", Filters.element());
builder.setNamespace(MCRConstants.MODS_NAMESPACE);
XPathExpression<Element> seriesTitlePath = builder.compileWith(XPathFactory.instance());
Element titleElement = seriesTitlePath.evaluateFirst(bookNew);
Assert.assertNotNull("No title element in related item: " + new XMLOutputter(Format.getPrettyFormat()).outputString(bookNew), titleElement);
Assert.assertEquals("Title update from series was not promoted to book of series.", "Updated series title", titleElement.getText());
}
use of org.mycore.datamodel.metadata.MCRObject in project mycore by MyCoRe-Org.
the class MCRMODSWrapperTest method testWrapMODSDocument.
/**
* Test method for {@link org.mycore.mods.MCRMODSWrapper#wrapMODSDocument(org.jdom2.Element, java.lang.String)}.
*/
@Test
public void testWrapMODSDocument() throws SAXParseException, URISyntaxException, JDOMException, IOException {
Document modsDoc = loadMODSDocument();
MCRObject mcrObj = MCRMODSWrapper.wrapMODSDocument(modsDoc.getRootElement(), "JUnit");
assertTrue("Generated MCRObject is not valid.", mcrObj.isValid());
Document mcrObjXml = mcrObj.createXML();
// check load from XML throws no exception
MCRObject mcrObj2 = new MCRObject(mcrObjXml);
mcrObjXml = mcrObj2.createXML();
XPathExpression<Element> xpathCheck = XPathFactory.instance().compile("//mods:mods", Filters.element(), null, MCRConstants.MODS_NAMESPACE);
assertEquals("Did not find mods data", 1, xpathCheck.evaluate(mcrObjXml).size());
}
Aggregations