SbiObjects exportedObj = null;
try {
List exportedBIObjs = importer.getAllExportedSbiObjects(sessionExpDB, "SbiObjects", "label");
Iterator iterSbiObjs = exportedBIObjs.iterator();
LuceneIndexer indexer = new LuceneIndexer();
while (iterSbiObjs.hasNext()) {
exportedObj = (SbiObjects) iterSbiObjs.next();
Integer expId = exportedObj.getBiobjId();
Integer existingObjId = null;
Map objIdAss = metaAss.getBIobjIDAssociation();
Set objIdAssSet = objIdAss.keySet();
if (objIdAssSet.contains(expId) && !overwrite) {
metaLog.log("Exported biobject "+exportedObj.getName()+" not inserted" +
" because it has the same label of an existing biobject");
continue;
} else {
existingObjId = (Integer) objIdAss.get(expId);
}
SbiObjects obj = null;
if (existingObjId != null) {
logger.info("The document with label:[" + exportedObj.getLabel() + "] is just present. It will be updated.");
metaLog.log("The document with label = [" + exportedObj.getLabel() + "] will be updated.");
obj = ImportUtilities.modifyExistingSbiObject(exportedObj, sessionCurrDB, existingObjId);
ImportUtilities.associateWithExistingEntities(obj, exportedObj, sessionCurrDB, importer, metaAss);
sessionCurrDB.update(obj);
} else {
obj = ImportUtilities.makeNewSbiObject(exportedObj);
ImportUtilities.associateWithExistingEntities(obj, exportedObj, sessionCurrDB, importer, metaAss);
// insert document
Integer newId = (Integer) sessionCurrDB.save(obj);
metaLog.log("Inserted new biobject " + obj.getName());
metaAss.insertCoupleBIObj(expId, newId);
}
// manage object template
insertObjectTemplate(obj, exportedObj.getBiobjId());
// manage sub_object here
insertSubObject(obj, exportedObj);
// manage snapshot here
insertSnapshot(obj, exportedObj);
// insert object into folders tree
importFunctObject(exportedObj.getBiobjId());
// puts parameters into object
importBIObjPar(exportedObj.getBiobjId());
// puts dependencies into object
importObjParUse(exportedObj.getBiobjId());
commit();
//updates lucene index
BIObjectDAOHibImpl daoObj = (BIObjectDAOHibImpl)DAOFactory.getBIObjectDAO();
BIObject biObj = daoObj.toBIObject(obj);
indexer.addBiobjToIndex(biObj);
// TODO controllare che fa questo e se serve!!!
//updateSubObject(obj, exportedObj.getBiobjId());
}
} catch (Exception e) {