*
* @throws EMFUserError
*/
private void importEngines() throws EMFUserError {
logger.debug("IN");
SbiEngines engine = null;
try {
List exportedEngines = importer.getAllExportedSbiObjects(sessionExpDB, "SbiEngines", null);
Iterator iterSbiEngines = exportedEngines.iterator();
while (iterSbiEngines.hasNext()) {
engine = (SbiEngines) iterSbiEngines.next();
Integer oldId = engine.getEngineId();
Map engIdAss = metaAss.getEngineIDAssociation();
Set engIdAssSet = engIdAss.keySet();
if (engIdAssSet.contains(oldId)) {
metaLog.log("Exported engine " + engine.getName() + " not inserted"
+ " because it has been associated to an existing engine or it has the same label "
+ " of an existing engine");
continue;
}
SbiEngines newEng = ImportUtilities.makeNewSbiEngine(engine);
SbiDomains engineTypeDomain = engine.getEngineType();
Map uniqueEngineType = new HashMap();
uniqueEngineType.put("valuecd", engineTypeDomain.getValueCd());
uniqueEngineType.put("domaincd", "ENGINE_TYPE");
SbiDomains existEngineTypeDomain = (SbiDomains) importer.checkExistence(uniqueEngineType,
sessionCurrDB, new SbiDomains());
if (existEngineTypeDomain != null) {
newEng.setEngineType(existEngineTypeDomain);
}
SbiDomains biobjectTypeDomain = engine.getBiobjType();
Map uniqueBiobjectType = new HashMap();
uniqueBiobjectType.put("valuecd", biobjectTypeDomain.getValueCd());
uniqueBiobjectType.put("domaincd", "BIOBJ_TYPE");
SbiDomains existBiobjectTypeDomain = (SbiDomains) importer.checkExistence(uniqueBiobjectType,
sessionCurrDB, new SbiDomains());
if (existBiobjectTypeDomain != null) {
newEng.setBiobjType(existBiobjectTypeDomain);
}
// check datasource link
SbiDataSource expDs = engine.getDataSource();
if (expDs != null) {
Integer dsId = (Integer) metaAss.getDataSourceIDAssociation().get(new Integer(expDs.getDsId()));
SbiDataSource localDS = (SbiDataSource) sessionCurrDB.load(SbiDataSource.class, dsId);
newEng.setDataSource(localDS);
}
sessionCurrDB.save(newEng);
metaLog.log("Inserted new engine " + engine.getName());
Integer newId = newEng.getEngineId();
metaAss.insertCoupleEngine(oldId, newId);
}
} catch (Exception e) {
if (engine != null) {
logger.error("Error while importing exported engine with label [" + engine.getLabel() + "].", e);