// import association between maps and features
List exportedMapFeatures = importer.getAllExportedSbiObjects(sessionExpDB, "SbiGeoMapFeatures", null);
Iterator iterMapFeatures = exportedMapFeatures.iterator();
while (iterMapFeatures.hasNext()) {
SbiGeoMapFeatures expMapFeature = (SbiGeoMapFeatures) iterMapFeatures.next();
Integer expMapId = new Integer(expMapFeature.getId().getMapId());
Integer expFeatureId = new Integer(expMapFeature.getId().getFeatureId());
Integer existingMapId = null;
Integer existingFeatureId = null;
// find associated map id
Map mapsIDAssociations = metaAss.getMapIDAssociation();
Set mapsIDAssociationsKeySet = mapsIDAssociations.keySet();
if (!mapsIDAssociationsKeySet.contains(expMapId)) {
metaLog.log("Association between exported map with id = " + expMapId + " and exported feature with id = " + expFeatureId +
" will not be imported: the map was not imported.");
continue;
} else {
existingMapId = (Integer) mapsIDAssociations.get(expMapId);
}
// find associated feature id
Map featuresIDAssociations = metaAss.getFeaturesIDAssociation();
Set featuresIDAssociationsKeySet = featuresIDAssociations.keySet();
if (!featuresIDAssociationsKeySet.contains(expFeatureId)) {
metaLog.log("Association between exported map with id = " + expMapId + " and exported feature with id = " + expFeatureId +
" will not be imported: the feature was not imported.");
continue;
} else {
existingFeatureId = (Integer) featuresIDAssociations.get(expFeatureId);
}
Map unique = new HashMap();
unique.put("mapId", existingMapId);
unique.put("featureId", existingFeatureId);
Object existObj = importer.checkExistence(unique, sessionCurrDB, new SbiGeoMapFeatures());
SbiGeoMapFeatures newMapFeature = null;
if (existObj != null) {
if (!overwrite) {
metaLog.log("Found an existing association between map " + existingMapId + " and feature " + existingFeatureId + ". " +
"It will be not overwritten.");
continue;
} else {
metaLog.log("Found an existing association between map " + existingMapId + " and feature " + existingFeatureId + ". " +
"It will be overwritten.");
newMapFeature = (SbiGeoMapFeatures) existObj;
}
} else {
newMapFeature = new SbiGeoMapFeatures();
SbiGeoMapFeaturesId hibMapFeatureId = new SbiGeoMapFeaturesId();
hibMapFeatureId.setMapId(existingMapId.intValue());
hibMapFeatureId.setFeatureId(existingFeatureId.intValue());
newMapFeature.setId(hibMapFeatureId);
}
newMapFeature.setSvgGroup(expMapFeature.getSvgGroup());
newMapFeature.setVisibleFlag(expMapFeature.getVisibleFlag());
sessionCurrDB.save(newMapFeature);
}
/*
// copy all exported map files