*
* @throws EMFUserError
*/
private void importBIObjects(boolean overwrite) throws EMFUserError {
logger.debug("IN");
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