SessionContainer permSess = sessCont.getPermanentContainer();
IEngUserProfile profile = (IEngUserProfile)permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
ISbiGeoMapsDAO daoGeoMaps=DAOFactory.getSbiGeoMapsDAO();
daoGeoMaps.setUserProfile(profile);
GeoMap mapNew = recoverMapDetails(serviceRequest);
EMFErrorHandler errorHandler = getErrorHandler();
// if there are some validation errors into the errorHandler does not write into DB
Collection errors = errorHandler.getErrors();
if (errors != null && errors.size() > 0) {
Iterator iterator = errors.iterator();
while (iterator.hasNext()) {
Object error = iterator.next();
if (error instanceof EMFValidationError) {
serviceResponse.setAttribute("mapObj", mapNew);
serviceResponse.setAttribute("modality", mod);
return;
}
}
}
if (mod.equalsIgnoreCase(SpagoBIConstants.DETAIL_INS)) {
//if a map with the same name not exists on db ok else error
if (daoGeoMaps.loadMapByName(mapNew.getName()) != null){
HashMap params = new HashMap();
params.put(AdmintoolsConstants.PAGE, ListMapsModule.MODULE_PAGE);
EMFUserError error = new EMFUserError(EMFErrorSeverity.ERROR, 5005, new Vector(), params );
getErrorHandler().addError(error);
return;
}
/* The activity INSERT consists in:
* - insert a map (SBI_GEO_MAPS),
* - insert of the features (SBI_GEO_FEATURES) through the method 'loadUpdateMapFeatures'
* - insert of the relations (SBI_GEO_MAP_FEATURES) through the method 'loadUpdateMapFeatures'
* (all objects are had taken from the template file)
*/
//DAOFactory.getSbiGeoMapsDAO().insertMap(mapNew);
daoGeoMaps.insertMap(mapNew, content);
loadUpdateMapFeatures(mapNew,profile);
GeoMap tmpMap = daoGeoMaps.loadMapByName(mapNew.getName());
mapNew.setMapId(tmpMap.getMapId());
mapNew.setBinId(tmpMap.getBinId());
serviceResponse.setAttribute("mapObj", mapNew);
serviceResponse.setAttribute("modality", SpagoBIConstants.DETAIL_MOD);
getTabDetails(serviceRequest, serviceResponse);