private void insertSnapshot(SbiObjects obj, SbiObjects exportedObj) throws EMFUserError {
logger.debug("IN");
List exportedSnapshotsList = null;
List currentSnapshotsList = null;
SbiSnapshots expSbiSnapshots = null;
try {
Query hibQuery = sessionExpDB.createQuery(" from SbiSnapshots ot where ot.sbiObject.biobjId = " + exportedObj.getBiobjId());
exportedSnapshotsList = hibQuery.list();
if (exportedSnapshotsList.isEmpty()) {
logger.debug("Exported document with label = [" + exportedObj.getLabel() + "] has no snapshots");
return;
}
hibQuery = sessionCurrDB
.createQuery(" from SbiSnapshots ot where ot.sbiObject.biobjId = " + obj.getBiobjId());
currentSnapshotsList = hibQuery.list();
Iterator exportedSnapshotsListIt = exportedSnapshotsList.iterator();
while (exportedSnapshotsListIt.hasNext()) {
expSbiSnapshots = (SbiSnapshots) exportedSnapshotsListIt.next();
if (isAlreadyExisting(expSbiSnapshots, currentSnapshotsList)) {
logger.info("Exported snaphost with name = [" + expSbiSnapshots.getName() + "] and creation date = [" + expSbiSnapshots.getCreationDate() + "] (of document with name = [" + exportedObj.getName() + "] and label = [" + exportedObj.getLabel() + "]) is already existing, most likely it is the same snapshot, so it will not be inserted.");
metaLog.log("Exported snaphost with name = [" + expSbiSnapshots.getName() + "] and creation date = [" + expSbiSnapshots.getCreationDate() + "] (of document with name = [" + exportedObj.getName() + "] and label = [" + exportedObj.getLabel() + "]) is already existing, most likely it is the same snapshot, so it will not be inserted.");
continue;
} else {
SbiSnapshots newSnapshots = ImportUtilities.makeNewSbiSnapshots(expSbiSnapshots);
newSnapshots.setSbiObject(obj);
SbiBinContents binary = insertBinaryContent(expSbiSnapshots.getSbiBinContents());
newSnapshots.setSbiBinContents(binary);
sessionCurrDB.save(newSnapshots);
}
}
} catch (Exception e) {
if (expSbiSnapshots != null) {