RequestContainer reqCont = getRequestContainer();
SessionContainer sessCont = reqCont.getSessionContainer();
SessionContainer permSess = sessCont.getPermanentContainer();
IEngUserProfile profile = (IEngUserProfile)permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
ISbiGeoMapFeaturesDAO dao=DAOFactory.getSbiGeoMapFeaturesDAO();
dao.setUserProfile(profile);
String mapId = (String) request.getAttribute("MAP_ID");
String featureId = (String)request.getAttribute("FEATURE_ID");
GeoMap map = DAOFactory.getSbiGeoMapsDAO().loadMapByID(new Integer(mapId));
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) {
response.setAttribute("mapObj", map);
response.setAttribute("modality", SpagoBIConstants.DETAIL_MOD);
return;
}
}
}
//inserts the relation
GeoMapFeature mapFeature = dao.loadMapFeatures(new Integer(mapId), new Integer(featureId));
if (mapFeature == null){
mapFeature = new GeoMapFeature();
mapFeature.setMapId(new Integer(mapId).intValue());
mapFeature.setFeatureId(new Integer(featureId).intValue());
mapFeature.setSvgGroup(null);
mapFeature.setVisibleFlag(null);
dao.insertMapFeatures(mapFeature);
}
//create a List of features
List lstAllFeatures = dao.loadFeatureNamesByMapId(new Integer(map.getMapId()));
List lstMapFeatures = new ArrayList();
for (int i=0; i < lstAllFeatures.size(); i ++){
GeoFeature aFeature = DAOFactory.getSbiGeoFeaturesDAO().loadFeatureByName((String)lstAllFeatures.get(i));
lstMapFeatures.add(aFeature);