*
* @throws EMFUserError
*/
private void importResources(boolean overwrite) throws EMFUserError {
logger.debug("IN");
SbiResources exportedResource = null;
try {
List exportedResources = importer.getAllExportedSbiObjects(sessionExpDB, "SbiResources", null);
Iterator iterSbiResource = exportedResources.iterator();
while (iterSbiResource.hasNext()) {
exportedResource = (SbiResources) iterSbiResource.next();
Integer oldId = exportedResource.getResourceId();
Integer existingResourceId = null;
Map resourcesIdAss = metaAss.getResourcesIDAssociation();
Set resourcesIdAssSet = resourcesIdAss.keySet();
if (resourcesIdAssSet.contains(oldId) && !overwrite) {
metaLog.log("Exported resources" + exportedResource.getResourceName() + " not inserted"
+ " because it has the same name of an existing resource");
continue;
} else {
existingResourceId = (Integer) resourcesIdAss.get(oldId);
}
if (existingResourceId != null) {
logger.info("The resource with id:[" + exportedResource.getResourceId() + "] is just present. It will be updated.");
metaLog.log("The resource with name = [" + exportedResource.getResourceName() + "] will be updated.");
SbiResources existingResources = ImportUtilities.modifyExistingSbiResources(exportedResource, sessionCurrDB, existingResourceId, metaAss,importer);
sessionCurrDB.update(existingResources);
} else {
SbiResources newResource = ImportUtilities.makeNewSbiResources(exportedResource, sessionCurrDB, metaAss, importer);
sessionCurrDB.save(newResource);
metaLog.log("Inserted new resource " + newResource.getResourceName());
Integer newId = newResource.getResourceId();
metaAss.insertCoupleResources(oldId, newId);
}
}
} catch (Exception e) {
if (exportedResource != null) {