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();
for (int i=0; i<lstOldFeatures.size(); i++){
if (!(lstNewFeatures.contains(((GeoFeature)lstOldFeatures.get(i)).getName())))
lstFeaturesDel.add(((GeoFeature)lstOldFeatures.get(i)).getName());
}
if (lstFeaturesDel.size() > 0){
serviceResponse.setAttribute("lstFeaturesOld",lstFeaturesDel);
serviceResponse.setAttribute("SUBMESSAGEDET", ((String)serviceRequest.getAttribute("SUBMESSAGEDET")));
getTabDetails(serviceRequest, serviceResponse);
serviceResponse.setAttribute("modality", mod);
serviceResponse.setAttribute("mapObj", mapNew);
return;
}
}
if (serviceRequest.getAttribute("SUBMESSAGEDET") != null &&
((String)serviceRequest.getAttribute("SUBMESSAGEDET")).equalsIgnoreCase(MOD_SAVE)) {
getTabDetails(serviceRequest, serviceResponse);
serviceResponse.setAttribute("modality", mod);
serviceResponse.setAttribute("mapObj", mapNew);
return;
}
else if (serviceRequest.getAttribute("SUBMESSAGEDET") != null &&
((String)serviceRequest.getAttribute("SUBMESSAGEDET")).equalsIgnoreCase(MOD_SAVEBACK)){
serviceResponse.setAttribute("loopback", "true");
return;
}
} catch (EMFUserError e){
logger.error("Error while saving catalogue map: " + e.getMessage());
HashMap params = new HashMap();
params.put(AdmintoolsConstants.PAGE, ListMapsModule.MODULE_PAGE);
throw new EMFUserError(EMFErrorSeverity.ERROR, e.getDescription(), new Vector(), params);
}
catch (Exception ex) {
TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.MAJOR, "Cannot fill response container" + ex.getLocalizedMessage());
throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
}
}