Search in sources :

Example 6 with MCRMetsSimpleModel

use of org.mycore.mets.model.simple.MCRMetsSimpleModel in project mycore by MyCoRe-Org.

the class MCRMetsTestUtil method buildMetsSimpleModel.

public static MCRMetsSimpleModel buildMetsSimpleModel() {
    MCRMetsSimpleModel metsSimpleModel = new MCRMetsSimpleModel();
    builSimpleModelSections(metsSimpleModel);
    buildSimpleModelPages(metsSimpleModel);
    buildSimpleModelLinkList(metsSimpleModel);
    return metsSimpleModel;
}
Also used : MCRMetsSimpleModel(org.mycore.mets.model.simple.MCRMetsSimpleModel)

Example 7 with MCRMetsSimpleModel

use of org.mycore.mets.model.simple.MCRMetsSimpleModel 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

MCRMetsSimpleModel (org.mycore.mets.model.simple.MCRMetsSimpleModel)7 MCRMetsSection (org.mycore.mets.model.simple.MCRMetsSection)4 Hashtable (java.util.Hashtable)3 Document (org.jdom2.Document)3 MCRMetsPage (org.mycore.mets.model.simple.MCRMetsPage)3 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 List (java.util.List)2 Map (java.util.Map)2 XMLOutputter (org.jdom2.output.XMLOutputter)2 MCRException (org.mycore.common.MCRException)2 MCRPath (org.mycore.datamodel.niofs.MCRPath)2 Mets (org.mycore.mets.model.Mets)2 MCRMetsFile (org.mycore.mets.model.simple.MCRMetsFile)2 MCRMetsFileUse (org.mycore.mets.model.simple.MCRMetsFileUse)2 MCRMetsLink (org.mycore.mets.model.simple.MCRMetsLink)2 GsonBuilder (com.google.gson.GsonBuilder)1 InputStream (java.io.InputStream)1 UUID (java.util.UUID)1 Collectors.toList (java.util.stream.Collectors.toList)1