mdTemp = new Metadata(mdt);
if (defaultPagination.equalsIgnoreCase("arabic")) {
mdTemp.setValue(String.valueOf(currentPhysicalOrder));
} else if (defaultPagination.equalsIgnoreCase("roman")) {
RomanNumeral roman = new RomanNumeral();
roman.setValue(currentPhysicalOrder);
mdTemp.setValue(roman.getNumber());
} else {
mdTemp.setValue("uncounted");
}
dsPage.addMetadata(mdTemp);
log.addReferenceTo(dsPage, "logical_physical");
// image name
ContentFile cf = new ContentFile();
if (SystemUtils.IS_OS_WINDOWS) {
cf.setLocation("file:/" + inProzess.getImagesTifDirectory(false) + newImage);
} else {
cf.setLocation("file://" + inProzess.getImagesTifDirectory(false) + newImage);
}
dsPage.addContentFile(cf);
} catch (TypeNotAllowedAsChildException e) {
logger.error(e);
} catch (MetadataTypeNotAllowedException e) {
logger.error(e);
}
}
}
// case 3: empty page docs and unassinged images
else {
for (DocStruct page : pageElementsWithoutImages) {
if (!imagesWithoutPageElements.isEmpty()) {
// assign new image name to page
String newImageName = imagesWithoutPageElements.get(0);
imagesWithoutPageElements.remove(0);
ContentFile cf = new ContentFile();
if (SystemUtils.IS_OS_WINDOWS) {
cf.setLocation("file:/" + inProzess.getImagesTifDirectory(false) + newImageName);
} else {
cf.setLocation("file://" + inProzess.getImagesTifDirectory(false) + newImageName);
}
page.addContentFile(cf);
} else {
// remove page
physicaldocstruct.removeChild(page);
List<Reference> refs = new ArrayList<Reference>(page.getAllFromReferences());
for (ugh.dl.Reference ref : refs) {
ref.getSource().removeReferenceTo(page);
}
}
}
if (!imagesWithoutPageElements.isEmpty()) {
// create new page elements
int currentPhysicalOrder = physicaldocstruct.getAllChildren().size();
for (String newImage : imagesWithoutPageElements) {
DocStruct dsPage = this.mydocument.createDocStruct(newPage);
try {
// physical page no
physicaldocstruct.addChild(dsPage);
MetadataType mdt = this.myPrefs.getMetadataTypeByName("physPageNumber");
Metadata mdTemp = new Metadata(mdt);
mdTemp.setValue(String.valueOf(++currentPhysicalOrder));
dsPage.addMetadata(mdTemp);
// logical page no
mdt = this.myPrefs.getMetadataTypeByName("logicalPageNumber");
mdTemp = new Metadata(mdt);
if (defaultPagination.equalsIgnoreCase("arabic")) {
mdTemp.setValue(String.valueOf(currentPhysicalOrder));
} else if (defaultPagination.equalsIgnoreCase("roman")) {
RomanNumeral roman = new RomanNumeral();
roman.setValue(currentPhysicalOrder);
mdTemp.setValue(roman.getNumber());
} else {
mdTemp.setValue("uncounted");
}
dsPage.addMetadata(mdTemp);