*
* @throws EMFUserError
*/
private void importKpiInstance(boolean overwrite) throws EMFUserError {
logger.debug("IN");
SbiKpiInstance exportedKpiInst = null;
try {
List exportedKpisInsts = importer.getAllExportedSbiObjects(sessionExpDB, "SbiKpiInstance", null);
Iterator iterSbiKpisInsts = exportedKpisInsts.iterator();
while (iterSbiKpisInsts.hasNext()) {
exportedKpiInst = (SbiKpiInstance) iterSbiKpisInsts.next();
Integer oldId = exportedKpiInst.getIdKpiInstance();
Integer existingKpiInstId = null;
Map kpiInstIdAss = metaAss.getKpiInstanceIDAssociation();
Set kpiInstIdAssSet = kpiInstIdAss.keySet();
if (kpiInstIdAssSet.contains(oldId) && !overwrite) {
metaLog.log("Exported kpi instance with id" + exportedKpiInst.getIdKpiInstance() + " not inserted"
+ " because it has the same relations of an existing kpi instance");
continue;
} else {
existingKpiInstId = (Integer) kpiInstIdAss.get(oldId);
}
if (existingKpiInstId != null) {
logger.info("The kpi instance with id:[" + exportedKpiInst.getIdKpiInstance() + "] is just present. It will be updated.");
metaLog.log("The kpi instance with id = [" + exportedKpiInst.getIdKpiInstance() + "] will be updated.");
SbiKpiInstance existingKpiInst = ImportUtilities.modifyExistingSbiKpiInstance(exportedKpiInst, sessionCurrDB, existingKpiInstId, metaAss);
sessionCurrDB.update(existingKpiInst);
} else {
SbiKpiInstance newKpiInst = ImportUtilities.makeNewSbiKpiInstance(exportedKpiInst, sessionCurrDB, metaAss);
sessionCurrDB.save(newKpiInst);
metaLog.log("Inserted new kpi instance with id " + newKpiInst.getIdKpiInstance());
Integer newId = newKpiInst.getIdKpiInstance();
metaAss.insertCoupleKpiInstance(oldId, newId);
}
}
} catch (Exception e) {
if (exportedKpiInst != null) {