use of eu.transkribus.core.model.beans.mets.ParType 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;
}
Aggregations