state.setProperty(MigrationStateKeys.MODEL_FILE, modelFile);
state.setProperty(MigrationStateKeys.SESSION, session);
state.setProperty(MigrationStateKeys.PROGRESS_MONITOR, monitor);
-
- if (includeDependencies) {
- try {
- ModelDependenciesBean libraryDependenciesBean = ModelDependenciesBean.fromMigrationState(state);
- if (libraryDependenciesBean != null) {
- for (ModelDependency dependency : libraryDependenciesBean.dependencies) {
- Resource existing = session.sync(new PossibleResource(dependency.uri));
- boolean isExternalEntity = existing != null && session.syncRequest(new IsExternalEntity(existing));
- if (existing == null || isExternalEntity) {
- MigrationUtils.importSharedOntology(session, dependency.tg, false);
- }
- }
- }
- } catch (AdaptException e) {
- Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not read model dependencies bean.", e));
- }
+ try {
+ if (includeDependencies) {
+ try {
+ ModelDependenciesBean libraryDependenciesBean = ModelDependenciesBean.fromMigrationState(state);
+ if (libraryDependenciesBean != null) {
+ for (ModelDependency dependency : libraryDependenciesBean.dependencies) {
+ Resource existing = session.sync(new PossibleResource(dependency.uri));
+ boolean isExternalEntity = existing != null && session.syncRequest(new IsExternalEntity(existing));
+ if (existing == null || isExternalEntity) {
+ MigrationUtils.importSharedOntology(session, dependency.tg, false);
+ }
+ }
+ }
+ } catch (AdaptException e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not read model dependencies bean.", e));
+ }
+ }
+
+ MigrationUtils.importMigrated(monitor, session, modelFile, state, new DefaultPasteImportAdvisor(target), target);
+
+ Collection<Resource> resultRoots = state.getProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES);
+ ImportResult result = state.getProperty(MigrationStateKeys.IMPORT_RESULT);
+ return new MigratedImportResult(resultRoots, result);
+ } finally {
+ state.dispose();
}
-
- MigrationUtils.importMigrated(monitor, session, modelFile, state, new DefaultPasteImportAdvisor(target), target);
-
- Collection<Resource> resultRoots = state.getProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES);
- ImportResult result = state.getProperty(MigrationStateKeys.IMPORT_RESULT);
- return new MigratedImportResult(resultRoots, result);
}
};