use of org.mycore.mets.model.struct.Seq in project mycore by MyCoRe-Org.
the class MCRMETSHierarchyGenerator method copyFptr.
private Optional<Fptr> copyFptr(FileGrp oldGrp, FileGrp newGrp, Fptr oldFptr) {
Fptr newFptr = new Fptr();
for (Seq oldSeq : oldFptr.getSeqList()) {
Seq newSeq = new Seq();
for (Area oldArea : oldSeq.getAreaList()) {
if (oldArea.getBetype() == null) {
continue;
}
String oldFileID = oldArea.getFileId();
File oldFile = oldGrp.getFileById(oldFileID);
String href = oldFile.getFLocat().getHref();
File newFile = newGrp.getFileByHref(href);
Area newArea = new Area();
newArea.setBegin(oldArea.getBegin());
newArea.setEnd(oldArea.getEnd());
newArea.setFileId(newFile.getId());
newArea.setBetype("IDREF");
newSeq.getAreaList().add(newArea);
}
if (!newSeq.getAreaList().isEmpty()) {
newFptr.getSeqList().add(newSeq);
}
}
return newFptr.getSeqList().isEmpty() ? Optional.empty() : Optional.of(newFptr);
}
use of org.mycore.mets.model.struct.Seq in project mycore by MyCoRe-Org.
the class MCRSimpleModelXMLConverter method buildLogicalSubDiv.
private static void buildLogicalSubDiv(MCRMetsSection metsSection, LogicalDiv parent, Map<MCRMetsSection, String> sectionIdMap, Map<String, String> idToNewIDMap) {
String id = metsSection.getId();
LogicalDiv logicalSubDiv = new LogicalDiv(id, metsSection.getType(), metsSection.getLabel());
if (metsSection.getAltoLinks().size() > 0) {
Fptr fptr = new Fptr();
List<Seq> seqList = fptr.getSeqList();
Seq seq = new Seq();
seqList.add(seq);
metsSection.getAltoLinks().forEach(al -> {
Area area = new Area();
seq.getAreaList().add(area);
area.setBetype("IDREF");
area.setBegin(al.getBegin());
area.setEnd(al.getEnd());
String oldID = al.getFile().getId();
if (!idToNewIDMap.containsKey(oldID)) {
throw new MCRException("Could not get new id for: " + oldID);
}
area.setFileId(idToNewIDMap.get(oldID));
});
logicalSubDiv.getFptrList().add(fptr);
}
sectionIdMap.put(metsSection, id);
parent.add(logicalSubDiv);
int count = 1;
for (MCRMetsSection section : metsSection.getMetsSectionList()) {
buildLogicalSubDiv(section, logicalSubDiv, sectionIdMap, idToNewIDMap);
}
}
Aggregations