RequestContainer reqCont = getRequestContainer();
SessionContainer sessCont = reqCont.getSessionContainer();
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);
if (((String)serviceRequest.getAttribute("SUBMESSAGEDET")).equalsIgnoreCase(MOD_SAVEBACK))
{
serviceResponse.setAttribute("loopback", "true");
return;
}
return;
} else {
/* The activity UPDATE consists in:
* - update of a map (SBI_GEO_MAPS),
* - update of the relations (SBI_GEO_MAP_FEATURES) through the method 'loadUpdateMapFeatures', eventually if
* there are new features those will be inserted.
* (all objects had taken from the template file)
*/
//if content is null is because the user has modified the detail of map but not the content file (not upload)
if (content == null){
content = DAOFactory.getBinContentDAO().getBinContent(new Integer(mapNew.getBinId()));
}
List lstOldFeatures = DAOFactory.getSbiGeoMapFeaturesDAO().loadFeaturesByMapId(new Integer(mapNew.getMapId()));
//update map
daoGeoMaps.modifyMap(mapNew, content);
//update features
List lstNewFeatures = loadUpdateMapFeatures(mapNew,profile);
logger.debug("Loaded " +lstNewFeatures.size()+ " features form svg file." );
// If in the new file svg there aren't more some feature, the user can choose if erase theme relations or not.
List lstFeaturesDel = new ArrayList();