private void insertSubObject(SbiObjects obj, SbiObjects exportedObj) throws EMFUserError {
logger.debug("IN");
List exportedSubObjList = null;
List currentSubObjList = null;
SbiSubObjects expSubObject = null;
try {
Query hibQuery = sessionExpDB
.createQuery(" from SbiSubObjects ot where ot.sbiObject.biobjId = " + exportedObj.getBiobjId());
exportedSubObjList = hibQuery.list();
if (exportedSubObjList.isEmpty()) {
logger.debug("Exported document with label=[" + exportedObj.getLabel() + "] has no subobjects");
return;
}
hibQuery = sessionCurrDB
.createQuery(" from SbiSubObjects ot where ot.sbiObject.biobjId = " + obj.getBiobjId());
currentSubObjList = hibQuery.list();
Iterator exportedSubObjListIt = exportedSubObjList.iterator();
Map idAssociation = metaAss.getObjSubObjectIDAssociation();
while (exportedSubObjListIt.hasNext()) {
expSubObject = (SbiSubObjects) exportedSubObjListIt.next();
SbiSubObjects current = isAlreadyExisting(expSubObject, currentSubObjList) ;
if (current != null) {
logger.info("Exported subobject with name = [" + expSubObject.getName() + "] and owner = [" + expSubObject.getOwner() + "] and visibility = [" + expSubObject.getIsPublic() + "] and creation date = [" + expSubObject.getCreationDate() + "] (of document with name = [" + exportedObj.getName() + "] and label = [" + exportedObj.getLabel() + "]) is already existing, so it will not be inserted.");
metaLog.log("Exported subobject with name = [" + expSubObject.getName() + "] and owner = [" + expSubObject.getOwner() + "] and visibility = [" + expSubObject.getIsPublic() + "] and creation date = [" + expSubObject.getCreationDate() + "] (of document with name = [" + exportedObj.getName() + "] and label = [" + exportedObj.getLabel() + "]) is already existing, most likely it is the same subobject, so it will not be inserted.");
// if already present don't modify the subObject so don't map the ID!
//idAssociation.put(expSubObject.getSubObjId(), current.getSubObjId());
continue;
} else {
SbiSubObjects newSubObj = ImportUtilities.makeNewSbiSubObjects(expSubObject);
newSubObj.setSbiObject(obj);
SbiBinContents binary = insertBinaryContent(expSubObject.getSbiBinContents());
newSubObj.setSbiBinContents(binary);
sessionCurrDB.save(newSubObj);
idAssociation.put(expSubObject.getSubObjId(), newSubObj.getSubObjId());
}
}
} catch (Exception e) {
if (expSubObject != null) {
logger.error("Error while importing exported subobject with name [" + expSubObject.getName() + "] " +