Search in sources :

Example 1 with AreaType

use of eu.transkribus.core.model.beans.mets.AreaType in project TranskribusCore by Transkribus.

the class FEPLocalDocReader method parsePhysicalStructure.

static List<HashMap<String, File>> parsePhysicalStructure(File inputDir, Mets mets) throws IOException {
    StructMapType physSm = findStructMap(mets, PHYSICAL_STRUCT_MAP_LABEL);
    DivType rootDiv = physSm.getDiv();
    // sort divs by order:
    Collections.sort(rootDiv.getDiv(), new Comparator<DivType>() {

        @Override
        public int compare(DivType o1, DivType o2) {
            return o1.getORDER().compareTo(o2.getORDER());
        }
    });
    List<HashMap<String, File>> fepFileGrps = new ArrayList<>();
    // parse them bloody divs:
    for (DivType div : rootDiv.getDiv()) {
        if (div.getFptr().size() != 1)
            throw new IOException("Error parsing physical structure: nr of fptr elements is not 1 in div: " + div.getFptr().size() + ", id: " + div.getID());
        ParType par = div.getFptr().get(0).getPar();
        if (par == null)
            throw new IOException("Error parsing physical structure: could not parse par element in fptr of div: " + div.getID());
        HashMap<String, File> files = new HashMap<>();
        for (Serializable o : par.getAreaOrSeq()) {
            if (o instanceof AreaType) {
                AreaType area = (AreaType) o;
                FileType fileType = (FileType) area.getFILEID();
                Pair<FileGrp, File> filePair = findFile(inputDir, mets, fileType.getID());
                logger.debug("found file with id: " + fileType.getID() + ", path: " + filePair.getRight().getAbsolutePath());
                files.put(filePair.getLeft().getID(), filePair.getRight());
            }
        }
        fepFileGrps.add(files);
    }
    return fepFileGrps;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FileGrp(eu.transkribus.core.model.beans.mets.MetsType.FileSec.FileGrp) IOException(java.io.IOException) AreaType(eu.transkribus.core.model.beans.mets.AreaType) DivType(eu.transkribus.core.model.beans.mets.DivType) FileType(eu.transkribus.core.model.beans.mets.FileType) StructMapType(eu.transkribus.core.model.beans.mets.StructMapType) ParType(eu.transkribus.core.model.beans.mets.ParType) File(java.io.File)

Example 2 with AreaType

use of eu.transkribus.core.model.beans.mets.AreaType in project TranskribusCore by Transkribus.

the class TrpMetsBuilder method buildFptr.

private static Fptr buildFptr(FileType img) {
    Fptr ptr = new Fptr();
    AreaType area = new AreaType();
    area.setFILEID(img);
    ptr.setArea(area);
    return ptr;
}
Also used : Fptr(eu.transkribus.core.model.beans.mets.DivType.Fptr) AreaType(eu.transkribus.core.model.beans.mets.AreaType)

Aggregations

AreaType (eu.transkribus.core.model.beans.mets.AreaType)2 DivType (eu.transkribus.core.model.beans.mets.DivType)1 Fptr (eu.transkribus.core.model.beans.mets.DivType.Fptr)1 FileType (eu.transkribus.core.model.beans.mets.FileType)1 FileGrp (eu.transkribus.core.model.beans.mets.MetsType.FileSec.FileGrp)1 ParType (eu.transkribus.core.model.beans.mets.ParType)1 StructMapType (eu.transkribus.core.model.beans.mets.StructMapType)1 File (java.io.File)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1