*
* @throws EMFUserError
*/
private void importParameters(boolean overwrite) throws EMFUserError {
logger.debug("IN");
SbiParameters exportedParameter = null;
try {
List exportedParams = importer.getAllExportedSbiObjects(sessionExpDB, "SbiParameters", null);
Iterator iterSbiParams = exportedParams.iterator();
while (iterSbiParams.hasNext()) {
exportedParameter = (SbiParameters) iterSbiParams.next();
Integer oldId = exportedParameter.getParId();
Integer existingParId = null;
Map paramIdAss = metaAss.getParameterIDAssociation();
Set paramIdAssSet = paramIdAss.keySet();
if (paramIdAssSet.contains(oldId) && !overwrite) {
metaLog.log("Exported parameter " + exportedParameter.getName() + " not inserted"
+ " because it has the same label of an existing parameter");
continue;
} else {
existingParId = (Integer) paramIdAss.get(oldId);
}
Integer newIdPar=null;
// parameter is already present and overwrite==true b(exstingParId)
if (existingParId != null) {
logger.info("The parameter with label:[" + exportedParameter.getLabel() + "] is just present. It will be updated.");
metaLog.log("The parameter with label = [" + exportedParameter.getLabel() + "] will be updated.");
SbiParameters existingParameter = ImportUtilities.modifyExistingSbiParameter(exportedParameter, sessionCurrDB, existingParId);
ImportUtilities.associateWithExistingEntities(existingParameter, exportedParameter, sessionCurrDB, importer, metaAss);
sessionCurrDB.update(existingParameter);
newIdPar=existingParId;
// delete the paruse associated to the previous!
// List exportedParuses = importer.getAllExportedSbiObjects(sessionCurrDB, "SbiParuse", null);
// Iterator iterSbiParuses = exportedParuses.iterator();
// while (iterSbiParuses.hasNext()) {
// SbiParuse paruse = (SbiParuse) iterSbiParuses.next();
// SbiParameters param = paruse.getSbiParameters();
// Delete the UseParameters Object
IParameterUseDAO iParameterUseDAO=DAOFactory.getParameterUseDAO();
// iParameterUseDAO.eraseParameterUseByParIdSameSession(newIdPar, sessionCurrDB, txCurrDB);
//deleteParameterUseByParId(newIdPar);
iParameterUseDAO.eraseParameterUseByParIdSameSession(newIdPar, sessionCurrDB);
// List exportedParuses = importer.getFilteredExportedSbiObjects(sessionExpDB, "SbiParuse", "sbiParameters", existingParId);
// Iterator iterSbiParuses = exportedParuses.iterator();
// while (iterSbiParuses.hasNext()) {
// SbiParuse paruse = (SbiParuse) iterSbiParuses.next();
// sessionCurrDB.delete(paruse);
// }
} else {
// parameter is new (new Id)
SbiParameters newPar = ImportUtilities.makeNewSbiParameter(exportedParameter);
ImportUtilities.associateWithExistingEntities(newPar, exportedParameter, sessionCurrDB, importer, metaAss);
sessionCurrDB.save(newPar);
metaLog.log("Inserted new parameter " + newPar.getName());
Integer newId = newPar.getParId();
metaAss.insertCoupleParameter(oldId, newId);
newIdPar=newId;
}
importParuse(oldId);
}