use of org.mycore.mets.model.struct.SmLink in project mycore by MyCoRe-Org.
the class MCRMetsSave method getDefaultSmLink.
/**
* Build the default smLink. The PhysicalSubDiv is simply linked to the root chapter of the mets document.
*
* @param mets the mets document
* @param div the PhysicalSubDiv which should be linked
* @return the default smLink
*/
private static SmLink getDefaultSmLink(Document mets, PhysicalSubDiv div) {
XPathExpression<Attribute> attributeXpath;
attributeXpath = XPathFactory.instance().compile("mets:mets/mets:structMap[@TYPE='LOGICAL']/mets:div/@ID", Filters.attribute(), null, MCRConstants.METS_NAMESPACE);
Attribute idAttribute = attributeXpath.evaluateFirst(mets);
String rootID = idAttribute.getValue();
return new SmLink(rootID, div.getId());
}
use of org.mycore.mets.model.struct.SmLink in project mycore by MyCoRe-Org.
the class MCRSimpleModelXMLConverter method toXML.
/**
* Converts MetsSimpleModel to XML
* @param msm the MetsSimpleModel which should be converted
* @return xml
*/
public static Document toXML(MCRMetsSimpleModel msm) {
Mets mets = new Mets();
Hashtable<MCRMetsPage, String> pageIdMap = new Hashtable<>();
Map<String, String> idToNewIDMap = new Hashtable<>();
buildPhysicalPages(msm, mets, pageIdMap, idToNewIDMap);
Hashtable<MCRMetsSection, String> sectionIdMap = new Hashtable<>();
buildLogicalPages(msm, mets, sectionIdMap, idToNewIDMap);
StructLink structLink = mets.getStructLink();
msm.getSectionPageLinkList().stream().map((metsLink) -> {
MCRMetsSection section = metsLink.getFrom();
MCRMetsPage page = metsLink.getTo();
String fromId = sectionIdMap.get(section);
String toId = pageIdMap.get(page);
return new SmLink(fromId, toId);
}).forEach(structLink::addSmLink);
return mets.asDocument();
}
Aggregations