Search in sources :

Example 6 with SmLink

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());
}
Also used : SmLink(org.mycore.mets.model.struct.SmLink) Attribute(org.jdom2.Attribute)

Example 7 with SmLink

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();
}
Also used : PhysicalDiv(org.mycore.mets.model.struct.PhysicalDiv) MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) StructLink(org.mycore.mets.model.struct.StructLink) LOCTYPE(org.mycore.mets.model.struct.LOCTYPE) Area(org.mycore.mets.model.struct.Area) MCRException(org.mycore.common.MCRException) Document(org.jdom2.Document) FileGrp(org.mycore.mets.model.files.FileGrp) Map(java.util.Map) MCRMetsFileUse(org.mycore.mets.model.simple.MCRMetsFileUse) File(org.mycore.mets.model.files.File) Hashtable(java.util.Hashtable) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) Mets(org.mycore.mets.model.Mets) UUID(java.util.UUID) Seq(org.mycore.mets.model.struct.Seq) LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) PhysicalSubDiv(org.mycore.mets.model.struct.PhysicalSubDiv) SmLink(org.mycore.mets.model.struct.SmLink) List(java.util.List) Fptr(org.mycore.mets.model.struct.Fptr) LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) FLocat(org.mycore.mets.model.files.FLocat) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection) MCRMetsSimpleModel(org.mycore.mets.model.simple.MCRMetsSimpleModel) SmLink(org.mycore.mets.model.struct.SmLink) Mets(org.mycore.mets.model.Mets) Hashtable(java.util.Hashtable) MCRMetsPage(org.mycore.mets.model.simple.MCRMetsPage) StructLink(org.mycore.mets.model.struct.StructLink) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection)

Aggregations

SmLink (org.mycore.mets.model.struct.SmLink)7 PhysicalDiv (org.mycore.mets.model.struct.PhysicalDiv)5 PhysicalSubDiv (org.mycore.mets.model.struct.PhysicalSubDiv)5 URISyntaxException (java.net.URISyntaxException)4 ArrayList (java.util.ArrayList)4 Mets (org.mycore.mets.model.Mets)4 File (org.mycore.mets.model.files.File)4 FileGrp (org.mycore.mets.model.files.FileGrp)4 Fptr (org.mycore.mets.model.struct.Fptr)4 LogicalDiv (org.mycore.mets.model.struct.LogicalDiv)4 LogicalStructMap (org.mycore.mets.model.struct.LogicalStructMap)4 PhysicalStructMap (org.mycore.mets.model.struct.PhysicalStructMap)4 StructLink (org.mycore.mets.model.struct.StructLink)4 IOException (java.io.IOException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 List (java.util.List)3 Map (java.util.Map)3 MCRMetsFileUse (org.mycore.mets.model.simple.MCRMetsFileUse)3 OutputStream (java.io.OutputStream)2 URLDecoder (java.net.URLDecoder)2