L0.NamespaceMigrationStep.Prefix.from %from\r
L0.NamespaceMigrationStep.Prefix.to %to\r
\r
-MIGRATION = SYSDYN."from1.6to1.7" : L0.MigrationSequence\r
+MIGRATION = SYSDYN.Migration : L0.Library\r
+ \r
+MIGRATION.fromModel1 : L0.Migration\r
+ L0.Migration.format "sysdynModel"\r
+ L0.Migration.from 1\r
+ L0.Migration.step FROM16TO17\r
+ L0.Migration.priority 1.0\r
+ \r
+MIGRATION.fromModule1 : L0.Migration\r
+ L0.Migration.format "sysdynModule"\r
+ L0.Migration.from 1\r
+ L0.Migration.step FROM16TO17\r
+ L0.Migration.priority 1.0\r
+\r
+MIGRATION.fromFunctionLibrary1 : L0.Migration\r
+ L0.Migration.format "sysdynFunctionLibrary"\r
+ L0.Migration.from 1\r
+ L0.Migration.step FROM16TO17\r
+ L0.Migration.priority 1.0 \r
+ \r
+FROM16TO17 = MIGRATION."from1.6to1.7" : L0.MigrationSequence\r
@L0.list\r
- MIGRATION.Ontologies\r
- MIGRATION.Spreadsheets\r
- MIGRATION.SysdynChanges\r
- MIGRATION.OrderedSetsToLists\r
+ FROM16TO17.Ontologies\r
+ FROM16TO17.Spreadsheets\r
+ FROM16TO17.SysdynChanges\r
+ FROM16TO17.OrderedSetsToLists\r
\r
-MIGRATION.Ontologies : L0.NamespaceMigrationStep\r
+FROM16TO17.Ontologies : L0.NamespaceMigrationStep\r
@L0.list\r
_\r
@move "http://www.simantics.org/Layer0-" "1.0" "1.1"\r
_\r
@move"http://www.simantics.org/SelectionView-" "1.1" "1.2"\r
\r
-MIGRATION.Spreadsheets : L0.NamespaceMigrationStep\r
+FROM16TO17.Spreadsheets : L0.NamespaceMigrationStep\r
@L0.list\r
_\r
@move "http://www.simantics.org/Spreadsheet-1.2/" "HasContent" "Cell/content"\r
_\r
@move "http://www.simantics.org/Spreadsheet-1.2/" "ColumnWidthsOf" "Headers/columnWidths/Inverse" \r
\r
-MIGRATION.SysdynChanges : L0.NamespaceMigrationStep\r
+FROM16TO17.SysdynChanges : L0.NamespaceMigrationStep\r
@L0.list\r
_\r
@move "http://www.simantics.org/Sysdyn-1.1/" "HasTail" "Variable/HasTail"\r
@move "http://www.simantics.org/Sysdyn-1.1/" "SharedModuleOntolofgy" "SharedModuleOntology"\r
\r
\r
-MIGRATION.OrderedSetsToLists : L0.OrderedSetToListMigrationStep\r
+FROM16TO17.OrderedSetsToLists : L0.OrderedSetToListMigrationStep\r
@L0.list\r
_ : L0.OrderedSetToListMigrationStep.Change\r
L0.OrderedSetToListMigrationStep.entityType "http://www.simantics.org/Sysdyn-1.1/Variable"\r
*\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
+ * Semantum Oy - Bug #4192\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.utils.imports;\r
\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
+import org.simantics.db.layer0.migration.MigrationState;\r
+import org.simantics.db.layer0.migration.MigrationStateKeys;\r
+import org.simantics.db.layer0.migration.MigrationUtils;\r
import org.simantics.db.layer0.util.RemoverUtil;\r
import org.simantics.db.request.Read;\r
import org.simantics.issues.common.AllBatchIssueSources;\r
\r
Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
\r
+ MigrationState state = MigrationUtils.newState();\r
+ state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
+ state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
\r
-\r
- HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
- handlers.put("sysdynModel:1", new SysdynImportFormatHandler(project, SysdynResource.URIs.from1$6to1$7, monitor));\r
-\r
- Object result = ImportUtils.readFile(path, handlers);\r
+ Resource result = null;\r
+ try {\r
+ result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(project), project);\r
+ } catch (Exception e1) {\r
+ e1.printStackTrace();\r
+ }\r
\r
if(result == null || !(result instanceof Resource)) {\r
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: File could not be read.", null);\r
} else {\r
try {\r
- final Resource ModelRoot = (Resource) result;\r
+ final Resource ModelRoot = result;\r
IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
\r
@Override\r
\r
Activator.getDefault().getPreferenceStore().setValue(IMPORTMODULETPATH, (new File(path)).getParent());\r
\r
- // Handler for importing modules\r
- HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
- handlers.put("sysdynModule:1", new SysdynImportFormatHandler(model, SysdynResource.URIs.from1$6to1$7, monitor));\r
+ MigrationState state = MigrationUtils.newState();\r
+ state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
+ state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
\r
- // Read module file\r
- Object result = ImportUtils.readFile(path, handlers);\r
+ Resource result = null;\r
+ try {\r
+ result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(model), model);\r
+ } catch (Exception e1) {\r
+ e1.printStackTrace();\r
+ }\r
\r
\r
- if(result == null || !(result instanceof Resource)) {\r
+ if(result == null) {\r
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import module failed: Module could not be imported.", null);\r
} else {\r
- final Resource ModuleRoot = (Resource) result;\r
+ final Resource ModuleRoot = result;\r
// Check that the imported file actually was a module. Display error message otherwise.\r
try {\r
subTask(monitor, "Validate model");\r
\r
// Ensure that shared functions ontology exists\r
ensureSharedOntologies();\r
+ \r
+ MigrationState state = MigrationUtils.newState();\r
+ state.setProperty(MigrationStateKeys.BASE_URI, SysdynResource.URIs.Migration);\r
+ state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, Boolean.FALSE);\r
\r
- // Handler for importing function libraries\r
- HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
- handlers.put("sysdynFunctionLibrary:1", new SysdynImportFormatHandler(functionLibrary, SysdynResource.URIs.from1$6to1$7, monitor, new SysdynFunctionLibraryImportAdvisor(functionLibrary)));\r
-\r
- // Read function library file\r
- Object result = ImportUtils.readFile(path, handlers);\r
+ Resource result = null;\r
+ try {\r
+ result = MigrationUtils.importMigrated(monitor, SimanticsUI.getSession(), new File(path), state, new DefaultPasteImportAdvisor(functionLibrary), functionLibrary);\r
+ } catch (Exception e1) {\r
+ e1.printStackTrace();\r
+ }\r
\r
- if(result == null || !(result instanceof Resource)) {\r
+ if(result == null) {\r
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import Function library failed: Function library not be imported.", null);\r
} else {\r
final Resource FunctionLibraryRoot = (Resource) result;\r