Search in sources :

Example 6 with LogicalDiv

use of org.mycore.mets.model.struct.LogicalDiv in project mycore by MyCoRe-Org.

the class MCRSimpleModelXMLConverter method buildLogicalPages.

private static void buildLogicalPages(MCRMetsSimpleModel msm, Mets mets, Map<MCRMetsSection, String> sectionIdMap, Map<String, String> idToNewIDMap) {
    LogicalStructMap logicalStructMap = (LogicalStructMap) mets.getStructMap(LogicalStructMap.TYPE);
    MCRMetsSection rootSection = msm.getRootSection();
    String type = rootSection.getType();
    String label = rootSection.getLabel();
    String id = rootSection.getId();
    LogicalDiv logicalDiv = new LogicalDiv(id, type, label);
    sectionIdMap.put(rootSection, id);
    for (MCRMetsSection metsSection : rootSection.getMetsSectionList()) {
        buildLogicalSubDiv(metsSection, logicalDiv, sectionIdMap, idToNewIDMap);
    }
    logicalStructMap.setDivContainer(logicalDiv);
}
Also used : LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) MCRMetsSection(org.mycore.mets.model.simple.MCRMetsSection)

Example 7 with LogicalDiv

use of org.mycore.mets.model.struct.LogicalDiv in project mycore by MyCoRe-Org.

the class MCRMetsMods2IIIFConverter method processDivContainer.

protected void processDivContainer(List<MCRIIIFRange> complete, LogicalDiv divContainer) {
    MCRIIIFRange range = new MCRIIIFRange(divContainer.getId());
    if (divContainer.getParent() == null) {
        range.setViewingHint(MCRIIIFViewingHint.top);
    }
    complete.add(range);
    range.setLabel(divContainer.getLabel());
    this.logicalIdIdentifiersMap.get(divContainer.getId()).stream().map(refId -> refId).forEach(canvasRef -> range.canvases.add(canvasRef));
    divContainer.getChildren().stream().forEach(div -> {
        processDivContainer(complete, div);
        range.ranges.add(div.getId());
    });
    range.metadata = extractMedataFromLogicalDiv(mets, divContainer);
}
Also used : MCRIIIFRange(org.mycore.iiif.presentation.model.basic.MCRIIIFRange) PhysicalDiv(org.mycore.mets.model.struct.PhysicalDiv) MCRIIIFCanvas(org.mycore.iiif.presentation.model.basic.MCRIIIFCanvas) MCRIIIFImageUtil(org.mycore.iiif.image.MCRIIIFImageUtil) MCRIIIFImageImpl(org.mycore.iiif.image.impl.MCRIIIFImageImpl) MCRConstants(org.mycore.common.MCRConstants) MCRIIIFImageProvidingException(org.mycore.iiif.image.impl.MCRIIIFImageProvidingException) MCRIIIFImageProfile(org.mycore.iiif.image.model.MCRIIIFImageProfile) HashMap(java.util.HashMap) MCRIIIFSequence(org.mycore.iiif.presentation.model.basic.MCRIIIFSequence) MCRException(org.mycore.common.MCRException) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) MCRIIIFService(org.mycore.iiif.presentation.model.attributes.MCRIIIFService) FileGrp(org.mycore.mets.model.files.FileGrp) Map(java.util.Map) MCRDCMIType(org.mycore.iiif.presentation.model.attributes.MCRDCMIType) MCRIIIFResource(org.mycore.iiif.presentation.model.attributes.MCRIIIFResource) MCRAccessException(org.mycore.access.MCRAccessException) File(org.mycore.mets.model.files.File) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) MCRIIIFAnnotation(org.mycore.iiif.presentation.model.additional.MCRIIIFAnnotation) MCRIIIFViewingHint(org.mycore.iiif.presentation.model.attributes.MCRIIIFViewingHint) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MCRIIIFManifest(org.mycore.iiif.presentation.model.basic.MCRIIIFManifest) Mets(org.mycore.mets.model.Mets) Collectors(java.util.stream.Collectors) MCRIIIFRange(org.mycore.iiif.presentation.model.basic.MCRIIIFRange) LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) MDTYPE(org.mycore.mets.model.struct.MDTYPE) PhysicalSubDiv(org.mycore.mets.model.struct.PhysicalSubDiv) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) MCRIIIFImageNotFoundException(org.mycore.iiif.image.impl.MCRIIIFImageNotFoundException) MCRIIIFImageInformation(org.mycore.iiif.image.model.MCRIIIFImageInformation) LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) DmdSec(org.mycore.mets.model.sections.DmdSec) MdWrap(org.mycore.mets.model.struct.MdWrap) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) MCRIIIFMetadata(org.mycore.iiif.presentation.model.attributes.MCRIIIFMetadata)

Example 8 with LogicalDiv

use of org.mycore.mets.model.struct.LogicalDiv in project mycore by MyCoRe-Org.

the class MCRMETSDefaultGenerator method createMets.

private Mets createMets() throws IOException {
    Mets mets = new Mets();
    String owner = getOwner();
    // add dmdsec
    DmdSec dmdSec = new DmdSec("dmd_" + owner);
    // add amdsec
    AmdSec amdSec = new AmdSec("amd_" + owner);
    // file sec
    FileSec fileSec = new FileSec();
    for (MCRMetsFileUse fileUse : MCRMetsFileUse.values()) {
        FileGrp fileGrp = new FileGrp(fileUse.toString());
        fileSec.addFileGrp(fileGrp);
    }
    // physical structure
    PhysicalStructMap physicalStructMap = new PhysicalStructMap();
    PhysicalDiv physicalDiv = new PhysicalDiv("phys_" + owner, "physSequence");
    physicalStructMap.setDivContainer(physicalDiv);
    // logical structure
    MCRILogicalStructMapTypeProvider typeProvider = getTypeProvider();
    LogicalStructMap logicalStructMap = new LogicalStructMap();
    LogicalDiv logicalDiv = new LogicalDiv("log_" + owner, typeProvider.getType(MCRObjectID.getInstance(owner)), owner, amdSec.getId(), dmdSec.getId());
    logicalDiv.setDmdId(dmdSec.getId());
    logicalStructMap.setDivContainer(logicalDiv);
    // struct Link
    StructLink structLink = new StructLink();
    // create internal structure
    structureMets(getDerivatePath(), getIgnorePaths(), fileSec, physicalDiv, logicalDiv, structLink, 0);
    hrefIdMap.clear();
    // add to mets
    mets.addDmdSec(dmdSec);
    mets.addAmdSec(amdSec);
    mets.setFileSec(fileSec);
    mets.addStructMap(physicalStructMap);
    mets.addStructMap(logicalStructMap);
    mets.setStructLink(structLink);
    return mets;
}
Also used : AmdSec(org.mycore.mets.model.sections.AmdSec) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) FileGrp(org.mycore.mets.model.files.FileGrp) StructLink(org.mycore.mets.model.struct.StructLink) DmdSec(org.mycore.mets.model.sections.DmdSec) MCRMetsFileUse(org.mycore.mets.model.simple.MCRMetsFileUse) PhysicalDiv(org.mycore.mets.model.struct.PhysicalDiv) LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) FileSec(org.mycore.mets.model.files.FileSec)

Example 9 with LogicalDiv

use of org.mycore.mets.model.struct.LogicalDiv in project mycore by MyCoRe-Org.

the class MCRMETSDefaultGenerator method structureMets.

private void structureMets(MCRPath dir, Set<MCRPath> ignoreNodes, FileSec fileSec, PhysicalDiv physicalDiv, LogicalDiv logicalDiv, StructLink structLink, int logOrder) throws IOException {
    SortedMap<MCRPath, BasicFileAttributes> files = new TreeMap<>(), directories = new TreeMap<>();
    fillFileMap(ignoreNodes, files, directories, dir);
    for (Map.Entry<MCRPath, BasicFileAttributes> file : files.entrySet()) {
        createStructure(dir, fileSec, physicalDiv, logicalDiv, structLink, file);
    }
    for (Map.Entry<MCRPath, BasicFileAttributes> directory : directories.entrySet()) {
        String dirName = directory.getKey().getFileName().toString();
        if (isInExcludedRootFolder(directory.getKey())) {
            structureMets(directory.getKey(), ignoreNodes, fileSec, physicalDiv, logicalDiv, structLink, logOrder);
        } else {
            LogicalDiv section = new LogicalDiv("log_" + Integer.toString(++logOrder), "section", dirName);
            logicalDiv.add(section);
            structureMets(directory.getKey(), ignoreNodes, fileSec, physicalDiv, section, structLink, logOrder);
        }
    }
}
Also used : LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) MCRPath(org.mycore.datamodel.niofs.MCRPath) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) PhysicalStructMap(org.mycore.mets.model.struct.PhysicalStructMap) TreeMap(java.util.TreeMap) LogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap) SortedMap(java.util.SortedMap) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 10 with LogicalDiv

use of org.mycore.mets.model.struct.LogicalDiv in project mycore by MyCoRe-Org.

the class MCRMETSHierarchyGenerator method newLogicalStructMap.

/**
 * Creates the logical structure recursive.
 *
 * @param parentObject mycore object
 * @param parentLogicalDiv parent div
 */
protected void newLogicalStructMap(MCRObject parentObject, LogicalDiv parentLogicalDiv) {
    // run through all children
    List<MCRObject> children = getChildren(parentObject);
    children.forEach(childObject -> {
        // create new logical sub div
        String id = childObject.getId().toString();
        LogicalDiv logicalChildDiv = new LogicalDiv(id, getType(childObject), getLabel(childObject));
        // add to parent
        parentLogicalDiv.add(logicalChildDiv);
        // check if a derivate link exists and get the linked file
        updateStructLinkMapUsingDerivateLinks(logicalChildDiv, childObject);
        // do recursive call for children
        newLogicalStructMap(childObject, logicalChildDiv);
    });
}
Also used : LogicalDiv(org.mycore.mets.model.struct.LogicalDiv) MCRObject(org.mycore.datamodel.metadata.MCRObject)

Aggregations

LogicalDiv (org.mycore.mets.model.struct.LogicalDiv)15 LogicalStructMap (org.mycore.mets.model.struct.LogicalStructMap)12 PhysicalStructMap (org.mycore.mets.model.struct.PhysicalStructMap)8 FileGrp (org.mycore.mets.model.files.FileGrp)7 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 PhysicalDiv (org.mycore.mets.model.struct.PhysicalDiv)6 PhysicalSubDiv (org.mycore.mets.model.struct.PhysicalSubDiv)6 HashMap (java.util.HashMap)5 List (java.util.List)5 MCRException (org.mycore.common.MCRException)5 Mets (org.mycore.mets.model.Mets)5 File (org.mycore.mets.model.files.File)5 Collections (java.util.Collections)4 Objects (java.util.Objects)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 Document (org.jdom2.Document)4 DmdSec (org.mycore.mets.model.sections.DmdSec)4 Fptr (org.mycore.mets.model.struct.Fptr)4