*
* @throws EMFUserError
*/
private void importObjMetacontent(boolean overwrite) throws EMFUserError {
logger.debug("IN");
SbiObjMetacontents exportedMetacontent = null;
try {
List exportedMetacontents = importer.getAllExportedSbiObjects(sessionExpDB, "SbiObjMetacontents", null);
Iterator iterMetacontents = exportedMetacontents.iterator();
while (iterMetacontents.hasNext()) {
exportedMetacontent = (SbiObjMetacontents) iterMetacontents.next();
Integer oldId = exportedMetacontent.getObjMetacontentId();
Integer existingMetacontentsId = null;
Map metaContentIdAss = metaAss.getObjMetacontentsIDAssociation();
Set metaContentIdAssSet = metaContentIdAss.keySet();
if (metaContentIdAssSet.contains(oldId) && !overwrite) {
metaLog.log("Exported metaContent with original id" + exportedMetacontent.getObjMetacontentId() + " not inserted"
+ " because there isalready one asociation to the same object "+exportedMetacontent.getSbiObjects().getLabel()+" " +
" and to the same metadata with id "+exportedMetacontent.getObjmetaId());
continue;
}
// if the content is associated to a subobject wich has not been inserted ignore it
Map subObjectIdAssociation = metaAss.getObjSubObjectIDAssociation();
if(exportedMetacontent.getSbiSubObjects()!=null &&
!subObjectIdAssociation.keySet().contains(exportedMetacontent.getSbiSubObjects().getSubObjId())){
metaLog.log("Exported metaContent with original id" + exportedMetacontent.getObjMetacontentId() + " not inserted" +
" becuase referring to a subobjects that will not be updated bcause already present" );
continue;
}
else {
existingMetacontentsId = (Integer) metaContentIdAss.get(oldId);
}
if (existingMetacontentsId != null) {
logger.info("The Metacontent with id:[" + exportedMetacontent.getObjMetacontentId() + "] is already present. It will be updated.");
metaLog.log("The Metacontent with original id = " + exportedMetacontent.getObjMetacontentId() + "and associated to the object with label" + exportedMetacontent.getSbiObjects().getLabel() +" will be updated.");
SbiObjMetacontents existingObjMetacontents = ImportUtilities.modifyExistingSbiObjMetacontents(exportedMetacontent, sessionCurrDB, existingMetacontentsId, metaAss,importer);
sessionCurrDB.update(existingObjMetacontents);
} else {
SbiObjMetacontents newMetacontents = ImportUtilities.makeNewSbiObjMetacontent(exportedMetacontent, sessionCurrDB, metaAss, importer);
sessionCurrDB.save(newMetacontents);
String subObject = newMetacontents.getSbiSubObjects() != null ? newMetacontents.getSbiSubObjects().getName() : null;
if( subObject != null){
metaLog.log("Inserted new Metacontents associated to subobject "+subObject +" of object " +
newMetacontents.getSbiObjects().getLabel());
}
else {
metaLog.log("Inserted new Metacontents associated to object " +
newMetacontents.getSbiObjects().getLabel());
}
Integer newId = newMetacontents.getObjMetacontentId();
metaAss.insertCoupleObjMetacontentsIDAssociation(oldId, newId);
}
}
} catch (Exception e) {
if (exportedMetacontent != null) {