}
private List loadUpdateMapFeatures(GeoMap mapNew,IEngUserProfile profile) throws EMFUserError, Exception {
try {
// through the content of a map, gets and opens the svg file and inserts a feature for every tag <g>
GeoFeature feature = null;
List lstHashFeatures = DAOFactory.getSbiGeoMapsDAO().getFeaturesFromSVG(content);
List lstFeatures = new ArrayList();
int mapId;
int featureId;
for (int i=0; i < lstHashFeatures.size(); i++){
HashMap hFeature = (HashMap)lstHashFeatures.get(i);
//checks if a feature with the same name yet exists in db
//NB: the field "id" of hashmap [hFeature] contains the name of the feature)
feature = DAOFactory.getSbiGeoFeaturesDAO().loadFeatureByName((String)hFeature.get("id"));
if (feature == null || feature.getFeatureId() == 0) {
feature = new GeoFeature();
feature.setName((String)hFeature.get("id"));
feature.setDescr((String)hFeature.get("descr"));
feature.setType((String)hFeature.get("type"));
ISbiGeoFeaturesDAO dao=DAOFactory.getSbiGeoFeaturesDAO();
dao.setUserProfile(profile);
dao.insertFeature(feature);
}
lstFeatures.add(feature.getName());
// for every map/feature inserts a row in join table (SBI_GEO_MAP_FEATURES)
//gets map_id
mapId = mapNew.getMapId();
if (mapId == -1 )
mapId = ((GeoMap)DAOFactory.getSbiGeoMapsDAO().loadMapByName(mapNew.getName())).getMapId();
//gets feature id
if (feature.getFeatureId() == 0)
feature = DAOFactory.getSbiGeoFeaturesDAO().loadFeatureByName((String)hFeature.get("id"));
featureId = feature.getFeatureId();
//gets relation
GeoMapFeature mapFeature = DAOFactory.getSbiGeoMapFeaturesDAO().loadMapFeatures(new Integer(mapId), new Integer(featureId));
if (mapFeature == null){
mapFeature = new GeoMapFeature();
mapFeature.setMapId(mapId);