public final Resource GameExperiment_stepLength_Inverse;\r
public final Resource HasEquationOrEmpty;\r
public final Resource HasEquationOrEmpty_Inverse;\r
- public final Resource HasHead;\r
public final Resource HasHeadTerminal;\r
- public final Resource HasHead_Inverse;\r
public final Resource HasRangeEnd;\r
public final Resource HasRangeEnd_Inverse;\r
public final Resource HasRangeStart;\r
public final Resource HasRangeStart_Inverse;\r
public final Resource HasRangeStep;\r
public final Resource HasRangeStep_Inverse;\r
- public final Resource HasTail;\r
public final Resource HasTailTerminal;\r
- public final Resource HasTail_Inverse;\r
public final Resource HasUnit;\r
public final Resource HasUnit_Inverse;\r
public final Resource HistoryDataset;\r
public final Resource WithLookupExpression_maxY;\r
public final Resource WithLookupExpression_minX;\r
public final Resource WithLookupExpression_minY;\r
+ public final Resource from1$6to1$7;\r
+ public final Resource from1$6to1$7_Ontologies;\r
+ public final Resource from1$6to1$7_Spreadsheets;\r
+ public final Resource from1$6to1$7_SysdynChanges;\r
\r
public static class URIs {\r
public static final String AdditionalSymbols = "http://www.simantics.org/Sysdyn-1.1/AdditionalSymbols";\r
public static final String GameExperiment_stepLength_Inverse = "http://www.simantics.org/Sysdyn-1.1/GameExperiment/stepLength/Inverse";\r
public static final String HasEquationOrEmpty = "http://www.simantics.org/Sysdyn-1.1/HasEquationOrEmpty";\r
public static final String HasEquationOrEmpty_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasEquationOrEmpty/Inverse";\r
- public static final String HasHead = "http://www.simantics.org/Sysdyn-1.1/HasHead";\r
public static final String HasHeadTerminal = "http://www.simantics.org/Sysdyn-1.1/HasHeadTerminal";\r
- public static final String HasHead_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasHead/Inverse";\r
public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.1/HasRangeEnd";\r
public static final String HasRangeEnd_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasRangeEnd/Inverse";\r
public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.1/HasRangeStart";\r
public static final String HasRangeStart_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasRangeStart/Inverse";\r
public static final String HasRangeStep = "http://www.simantics.org/Sysdyn-1.1/HasRangeStep";\r
public static final String HasRangeStep_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasRangeStep/Inverse";\r
- public static final String HasTail = "http://www.simantics.org/Sysdyn-1.1/HasTail";\r
public static final String HasTailTerminal = "http://www.simantics.org/Sysdyn-1.1/HasTailTerminal";\r
- public static final String HasTail_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasTail/Inverse";\r
public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.1/HasUnit";\r
public static final String HasUnit_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasUnit/Inverse";\r
public static final String HistoryDataset = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset";\r
public static final String WithLookupExpression_maxY = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/maxY";\r
public static final String WithLookupExpression_minX = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/minX";\r
public static final String WithLookupExpression_minY = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/minY";\r
+ public static final String from1$6to1$7 = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7";\r
+ public static final String from1$6to1$7_Ontologies = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/Ontologies";\r
+ public static final String from1$6to1$7_Spreadsheets = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/Spreadsheets";\r
+ public static final String from1$6to1$7_SysdynChanges = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/SysdynChanges";\r
}\r
\r
public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
GameExperiment_stepLength_Inverse = getResourceOrNull(graph, URIs.GameExperiment_stepLength_Inverse);\r
HasEquationOrEmpty = getResourceOrNull(graph, URIs.HasEquationOrEmpty);\r
HasEquationOrEmpty_Inverse = getResourceOrNull(graph, URIs.HasEquationOrEmpty_Inverse);\r
- HasHead = getResourceOrNull(graph, URIs.HasHead);\r
HasHeadTerminal = getResourceOrNull(graph, URIs.HasHeadTerminal);\r
- HasHead_Inverse = getResourceOrNull(graph, URIs.HasHead_Inverse);\r
HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd);\r
HasRangeEnd_Inverse = getResourceOrNull(graph, URIs.HasRangeEnd_Inverse);\r
HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart);\r
HasRangeStart_Inverse = getResourceOrNull(graph, URIs.HasRangeStart_Inverse);\r
HasRangeStep = getResourceOrNull(graph, URIs.HasRangeStep);\r
HasRangeStep_Inverse = getResourceOrNull(graph, URIs.HasRangeStep_Inverse);\r
- HasTail = getResourceOrNull(graph, URIs.HasTail);\r
HasTailTerminal = getResourceOrNull(graph, URIs.HasTailTerminal);\r
- HasTail_Inverse = getResourceOrNull(graph, URIs.HasTail_Inverse);\r
HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
HasUnit_Inverse = getResourceOrNull(graph, URIs.HasUnit_Inverse);\r
HistoryDataset = getResourceOrNull(graph, URIs.HistoryDataset);\r
WithLookupExpression_maxY = getResourceOrNull(graph, URIs.WithLookupExpression_maxY);\r
WithLookupExpression_minX = getResourceOrNull(graph, URIs.WithLookupExpression_minX);\r
WithLookupExpression_minY = getResourceOrNull(graph, URIs.WithLookupExpression_minY);\r
+ from1$6to1$7 = getResourceOrNull(graph, URIs.from1$6to1$7);\r
+ from1$6to1$7_Ontologies = getResourceOrNull(graph, URIs.from1$6to1$7_Ontologies);\r
+ from1$6to1$7_Spreadsheets = getResourceOrNull(graph, URIs.from1$6to1$7_Spreadsheets);\r
+ from1$6to1$7_SysdynChanges = getResourceOrNull(graph, URIs.from1$6to1$7_SysdynChanges);\r
}\r
\r
public static SysdynResource getInstance(ReadGraph graph) {\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.eclipse.core.commands.ExecutionEvent;\r
import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.core.runtime.Status;\r
import org.eclipse.core.runtime.SubMonitor;\r
+import org.eclipse.core.runtime.jobs.Job;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.MessageBox;\r
import org.eclipse.swt.widgets.Shell;\r
import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.DatabaseJob;\r
import org.simantics.Simantics;\r
import org.simantics.databoard.binding.Binding;\r
import org.simantics.databoard.container.DataContainer;\r
import org.simantics.db.Session;\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.request.WriteResultRequest;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\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.MigrationStep;\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.graph.representation.TransferableGraph1;\r
*/\r
public class ImportModelHandler extends AbstractHandler {\r
\r
- public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
-\r
- @Override\r
- public Object execute(ExecutionEvent event) throws ExecutionException {\r
-\r
- final Resource project = SimanticsUI.getProject().get();\r
- if(project == null) return null;\r
-\r
- // Get imported transferable graph file using FileDialog\r
- final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
- FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
- fd.setText("Import Model");\r
-\r
- String path = Activator.getDefault().getPreferenceStore().getString(IMPORTMODELTPATH);\r
- if(path.isEmpty() || !(new File(path).exists()))\r
- path = Platform.getLocation().toOSString();\r
- fd.setFilterPath(path);\r
- String[] filterExt = {"*.tg"};\r
- fd.setFilterExtensions(filterExt);\r
- String selected = fd.open();\r
- if(selected == null) return null;\r
-\r
- Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(selected)).getParent());\r
-\r
-\r
-\r
- HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
- handlers.put("sysdynModel:1", new FormatHandler<Object>() {\r
- @Override\r
- public Binding getBinding() {\r
- return TransferableGraph1.BINDING;\r
- }\r
-\r
- @Override\r
- public Object process(DataContainer container) throws DataFormatException {\r
- DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(project);\r
- try {\r
- DefaultPasteHandler.defaultExecute((TransferableGraph1)container.content.getValue(), project, ia);\r
- return ia.getRoot();\r
-\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- return null;\r
- }\r
- }\r
- });\r
- \r
- Object result = null;\r
- try {\r
- File file = new File(selected);\r
- if(!file.isFile()) {\r
- displayErrorMessage(shell, "File " + selected + " not found");\r
- return null;\r
- } else { \r
- result = DataContainers.readFile(file, handlers);\r
- }\r
- } catch(DataFormatException e) {\r
- e.printStackTrace();\r
- } catch(IOException e) {\r
- e.printStackTrace();\r
- } catch(Exception e) {\r
- if(e instanceof RuntimeException)\r
- throw (RuntimeException)e;\r
- else\r
- throw new RuntimeException(e);\r
- }\r
- \r
- if(result == null || !(result instanceof Resource)) {\r
- displayErrorMessage(shell, "Model could not be imported.");\r
- } else {\r
- try {\r
- final Resource ModelRoot = (Resource) result;\r
- SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
- \r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- if(!graph.isInstanceOf(ModelRoot, SysdynResource.getInstance(graph).SysdynModel)) {\r
- // Imported model was not a SysdynModel, display error message.\r
- Resource instanceOf = graph.getPossibleObject(ModelRoot, Layer0.getInstance(graph).InstanceOf);\r
- String type = "...";\r
- if(instanceOf != null)\r
- type = NameUtils.getSafeName(graph, instanceOf);\r
- else {\r
- Resource inheritedFrom = graph.getPossibleObject(ModelRoot, Layer0.getInstance(graph).Inherits);\r
- if(inheritedFrom != null)\r
- type = NameUtils.getSafeName(graph, inheritedFrom);\r
- }\r
- final String ft = type; \r
- graph.deny(ModelRoot, Layer0.getInstance(graph).PartOf);\r
-\r
- shell.getDisplay().asyncExec(new Runnable() {\r
-\r
- @Override\r
- public void run() {\r
- displayErrorMessage(shell, "The imported file is not of type: System Dynamics Model (" + ft +")");\r
- }\r
- });\r
-\r
- } else {\r
- fixHasTailAndHasHead(graph, ModelRoot);\r
- addDependencies(graph, ModelRoot);\r
- removeIssueSourcesFromModules(graph, ModelRoot);\r
- addEnumerationIssueSource(graph, ModelRoot);\r
- \r
- activateModel(graph, ModelRoot);\r
- }\r
- }\r
-\r
- });\r
- \r
- \r
- Collection<Resource> confs = SimanticsUI.getSession().syncRequest(new Read<Collection<Resource>>() {\r
+ public static String IMPORTMODELTPATH = "IMPORT_MODEL_PATH";\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+ // Get imported transferable graph file using FileDialog\r
+ final Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+ fd.setText("Import Model");\r
+\r
+ String path = Activator.getDefault().getPreferenceStore().getString(IMPORTMODELTPATH);\r
+ if(path.isEmpty() || !(new File(path).exists()))\r
+ path = Platform.getLocation().toOSString();\r
+ fd.setFilterPath(path);\r
+ String[] filterExt = {"*.tg"};\r
+ fd.setFilterExtensions(filterExt);\r
+ final String selected = fd.open();\r
+ if(selected == null) return null;\r
+\r
+ Job job = new DatabaseJob("Import model") {\r
+\r
+ @Override\r
+ protected IStatus run(IProgressMonitor monitor) {\r
+ IStatus status = importFile(selected, shell, monitor);\r
+ return status;\r
+ }\r
+ };\r
+ job.setUser(true);\r
+ job.schedule();\r
+\r
+ return null;\r
+\r
+ }\r
+\r
+ private IStatus importFile(String path, final Shell shell, final IProgressMonitor monitor) {\r
+ final Resource project = SimanticsUI.getProject().get();\r
+ if(project == null) return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model: project not found", null);\r
+\r
+ monitor.beginTask("Import model", 7);\r
+ \r
+ Activator.getDefault().getPreferenceStore().setValue(IMPORTMODELTPATH, (new File(path)).getParent());\r
+\r
+\r
+\r
+ HashMap<String, FormatHandler<Object>> handlers = new HashMap<String, FormatHandler<Object>>();\r
+ handlers.put("sysdynModel:1", new FormatHandler<Object>() {\r
+ @Override\r
+ public Binding getBinding() {\r
+ return TransferableGraph1.BINDING;\r
+ }\r
+\r
+ @Override\r
+ public Object process(DataContainer container) throws DataFormatException {\r
+ DefaultPasteImportAdvisor ia = new DefaultPasteImportAdvisor(project);\r
+\r
+ try {\r
+ monitor.subTask("Migrate");\r
+ Session session = Simantics.getSession();\r
+ TransferableGraph1 tg = (TransferableGraph1)container.content.getValue();\r
+\r
+ MigrationStep step = MigrationUtils.getStep(session, SysdynResource.URIs.from1$6to1$7);\r
+ MigrationState state = MigrationUtils.newState();\r
+ state.setProperty(MigrationStateKeys.CURRENT_TG, tg);\r
+ step.applyTo(session, state);\r
+ tg = state.getProperty(MigrationStateKeys.CURRENT_TG);\r
+\r
+ monitor.worked(1);\r
+ monitor.subTask("Import");\r
+ DefaultPasteHandler.defaultExecute(tg, project, ia);\r
+ monitor.worked(1);\r
+ return ia.getRoot();\r
+\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed", e);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed", e);\r
+ }\r
+ }\r
+ });\r
+\r
+ Object result = null;\r
+ try {\r
+ File file = new File(path);\r
+ if(!file.isFile()) {\r
+// displayErrorMessage(shell, "File " + path + " not found");\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: File " + path + " not found", null);\r
+ } else { \r
+ result = DataContainers.readFile(file, handlers);\r
+ }\r
+ } catch(DataFormatException e) {\r
+ e.printStackTrace();\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", e); \r
+ } catch(IOException e) {\r
+ e.printStackTrace();\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", e); \r
+ } catch(Exception e) {\r
+ if(e instanceof RuntimeException) {\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", e); \r
+// throw (RuntimeException)e;\r
+ } else {\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", e); \r
+// throw new RuntimeException(e);\r
+ }\r
+ }\r
+\r
+ if(result == null || !(result instanceof Resource)) {\r
+// displayErrorMessage(shell, "Model could not be imported.");\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", null);\r
+ } else {\r
+ try {\r
+ final Resource ModelRoot = (Resource) result;\r
+ IStatus status = SimanticsUI.getSession().syncRequest(new WriteResultRequest<IStatus>() {\r
+\r
+ @Override\r
+ public IStatus perform(WriteGraph graph) throws DatabaseException {\r
+ if(!graph.isInstanceOf(ModelRoot, SysdynResource.getInstance(graph).SysdynModel)) {\r
+ // Imported model was not a SysdynModel, display error message.\r
+ Resource instanceOf = graph.getPossibleObject(ModelRoot, Layer0.getInstance(graph).InstanceOf);\r
+ String type = "...";\r
+ if(instanceOf != null)\r
+ type = NameUtils.getSafeName(graph, instanceOf);\r
+ else {\r
+ Resource inheritedFrom = graph.getPossibleObject(ModelRoot, Layer0.getInstance(graph).Inherits);\r
+ if(inheritedFrom != null)\r
+ type = NameUtils.getSafeName(graph, inheritedFrom);\r
+ }\r
+ final String ft = type; \r
+ graph.deny(ModelRoot, Layer0.getInstance(graph).PartOf);\r
+\r
+// shell.getDisplay().asyncExec(new Runnable() {\r
+//\r
+// @Override\r
+// public void run() {\r
+// displayErrorMessage(shell, "The imported file is not of type: System Dynamics Model (" + ft +")");\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The imported file is not of type: System Dynamics Model (" + ft +")", null);\r
+// }\r
+// });\r
+\r
+ } else {\r
+ monitor.subTask("Add required dependencies");\r
+ addDependencies(graph, ModelRoot);\r
+ monitor.worked(1);\r
+ monitor.subTask("Remove unnecessary issue sources");\r
+ removeIssueSourcesFromModules(graph, ModelRoot);\r
+ monitor.worked(1);\r
+ monitor.subTask("Add enumeration issue source");\r
+ addEnumerationIssueSource(graph, ModelRoot);\r
+ monitor.worked(1);\r
+ monitor.subTask("Activate model");\r
+ activateModel(graph, ModelRoot);\r
+ monitor.worked(1);\r
+ }\r
+ return null;\r
+\r
+ }\r
+\r
+ });\r
+\r
+ if(status != null)\r
+ return status;\r
+\r
+ monitor.subTask("Validate model");\r
+ Collection<Resource> confs = SimanticsUI.getSession().syncRequest(new Read<Collection<Resource>>() {\r
\r
@Override\r
public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
return findAllConfigurations(graph, ModelRoot);\r
}\r
\r
- });\r
-\r
-\r
- // Batch validate all issue sources after import\r
- try {\r
- for(Resource conf : confs) {\r
- /*\r
- * This section is copied from BatchValidations.runAll. runAll did\r
- * not find module types to validate.\r
- */\r
-// BatchValidations.runAll(null, mod);\r
-\r
- final Session session = Simantics.getSession();\r
- final Collection<BatchIssueSource> validations = session.sync( new AllBatchIssueSources(ModelRoot) );\r
- SubMonitor progress = SubMonitor.convert(null, "Validate Model", 100);\r
- Collection<Resource> contexts = Collections.singletonList(conf);\r
- for(BatchIssueSource bis : validations) {\r
- Map<Resource, Set<Issue>> is = BatchValidations.validate(progress.newChild(90, SubMonitor.SUPPRESS_NONE), bis, contexts);\r
- BatchValidations.store(progress.newChild(10, SubMonitor.SUPPRESS_NONE), bis.getResource(), is);\r
- }\r
- }\r
- } catch(Throwable t) {\r
- t.printStackTrace();\r
- } \r
-\r
-\r
- \r
- } catch (DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- return null;\r
-\r
- }\r
- \r
- protected void removeIssueSourcesFromModules(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
+ });\r
+\r
+\r
+ // Batch validate all issue sources after import\r
+ try {\r
+ for(Resource conf : confs) {\r
+ /*\r
+ * This section is copied from BatchValidations.runAll. runAll did\r
+ * not find module types to validate.\r
+ */\r
+// BatchValidations.runAll(null, mod);\r
+\r
+ final Session session = Simantics.getSession();\r
+ final Collection<BatchIssueSource> validations = session.sync( new AllBatchIssueSources(ModelRoot) );\r
+ SubMonitor progress = SubMonitor.convert(monitor, "Validate Model", 100);\r
+ Collection<Resource> contexts = Collections.singletonList(conf);\r
+ for(BatchIssueSource bis : validations) {\r
+ Map<Resource, Set<Issue>> is = BatchValidations.validate(progress.newChild(90, SubMonitor.SUPPRESS_NONE), bis, contexts);\r
+ BatchValidations.store(progress.newChild(10, SubMonitor.SUPPRESS_NONE), bis.getResource(), is);\r
+ }\r
+ }\r
+ } catch(Throwable t) {\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", t);\r
+ } \r
+\r
+ monitor.worked(1);\r
+\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", e);\r
+ }\r
+\r
+ return Status.OK_STATUS;\r
+ }\r
+ }\r
+\r
+ protected void removeIssueSourcesFromModules(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
Layer0 L0 = Layer0.getInstance(graph);\r
IssueResource ISSUE = IssueResource.getInstance(graph);\r
- \r
+\r
for(Resource m : findAllModelsAndModules(graph, modelRoot)) {\r
if(m.equals(modelRoot))\r
continue;\r
- \r
+\r
// Module may contain issue sources due to legacy reasons. Remove these. \r
for(Resource issueSource : graph.syncRequest(new ObjectsWithType(m, L0.ConsistsOf, ISSUE.IssueSource))) {\r
// Issues are created to virtual graphs, so they should not need to be removed. Just in case they are created, remove them first\r
for(Resource issue : graph.getObjects(issueSource, ISSUE.IssueSource_Manages)) {\r
RemoverUtil.remove(graph, issue);\r
}\r
- \r
+\r
// finally remove the issue source\r
RemoverUtil.remove(graph, issueSource);\r
}\r
}\r
- \r
+\r
}\r
\r
protected void activateModel(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
}\r
\r
protected void addDependencies(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
-\r
- ArrayList<String> links = new ArrayList<String>();\r
- for(Resource link : graph.getObjects(modelRoot, L0.IsLinkedTo))\r
- links.add(graph.getURI(link));\r
- \r
- \r
- if(!links.contains("http://www.simantics.org/Documentation-1.0")) {\r
- Resource documentation = graph.getPossibleResource("http://www.simantics.org/Documentation-1.0");\r
- if(documentation != null)\r
- graph.claim(modelRoot, L0.IsLinkedTo, documentation);\r
- }\r
- \r
- if(!links.contains("http://www.simantics.org/SelectionView-1.1")) {\r
- Resource selectionView = graph.getPossibleResource("http://www.simantics.org/SelectionView-1.1");\r
- if(selectionView != null)\r
- graph.claim(modelRoot, L0.IsLinkedTo, selectionView);\r
- }\r
- }\r
-\r
- protected void addEnumerationIssueSource(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- Layer0X L0X = Layer0X.getInstance(graph); \r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- Collection<Resource> enumerationIssueSources = graph.syncRequest(new ObjectsWithType(modelRoot, L0.ConsistsOf, sr.Validations_Enumerations_EnumerationIssueSource));\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+\r
+ ArrayList<String> links = new ArrayList<String>();\r
+ for(Resource link : graph.getObjects(modelRoot, L0.IsLinkedTo))\r
+ links.add(graph.getURI(link));\r
+\r
+\r
+ if(!links.contains("http://www.simantics.org/Documentation-1.1")) {\r
+ Resource documentation = graph.getPossibleResource("http://www.simantics.org/Documentation-1.1");\r
+ if(documentation != null)\r
+ graph.claim(modelRoot, L0.IsLinkedTo, documentation);\r
+ }\r
+\r
+ if(!links.contains("http://www.simantics.org/SelectionView-1.2")) {\r
+ Resource selectionView = graph.getPossibleResource("http://www.simantics.org/SelectionView-1.2");\r
+ if(selectionView != null)\r
+ graph.claim(modelRoot, L0.IsLinkedTo, selectionView);\r
+ }\r
+\r
+ if(!links.contains("http://www.simantics.org/DocumentWorkbench-1.0")) {\r
+ Resource documentWb = graph.getPossibleResource("http://www.simantics.org/DocumentWorkbench-1.0");\r
+ if(documentWb != null)\r
+ graph.claim(modelRoot, L0.IsLinkedTo, documentWb);\r
+ }\r
+ }\r
+\r
+ protected void addEnumerationIssueSource(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ Layer0X L0X = Layer0X.getInstance(graph); \r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Collection<Resource> enumerationIssueSources = graph.syncRequest(new ObjectsWithType(modelRoot, L0.ConsistsOf, sr.Validations_Enumerations_EnumerationIssueSource));\r
if(enumerationIssueSources.isEmpty()) {\r
GraphUtils.create2(graph,\r
sr.Validations_Enumerations_EnumerationIssueSource,\r
); \r
} }\r
\r
- protected void fixHasTailAndHasHead(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- for(Resource configuration : findAllConfigurations(graph, modelRoot)) {\r
- Collection<Resource> connections = graph.syncRequest(new ObjectsWithType(configuration, L0.ConsistsOf, sr.Dependency));\r
- connections.addAll(graph.syncRequest(new ObjectsWithType(configuration, L0.ConsistsOf, sr.Flow)));\r
-\r
- for(Resource connection : connections) {\r
- Resource head = graph.getPossibleObject(connection, sr.HasHead);\r
- Resource tail = graph.getPossibleObject(connection, sr.HasTail);\r
-\r
- if(head != null && tail != null) {\r
- graph.deny(connection, sr.HasHead, head);\r
- graph.deny(connection, sr.HasTail, tail);\r
-\r
- graph.claim(connection, sr.Variable_HasHead, head);\r
- graph.claim(connection, sr.Variable_HasTail, tail);\r
- }\r
- }\r
- }\r
- }\r
- \r
- private Collection<Resource> findAllConfigurations(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- StructuralResource2 SR2 = StructuralResource2.getInstance(graph);\r
- Collection<Resource> modulesAndModels = findAllModelsAndModules(graph, modelRoot);\r
- Collection<Resource> configurations = new ArrayList<Resource>();\r
-\r
- for(Resource r : modulesAndModels) {\r
- if(graph.isInheritedFrom(r, sr.Module)) {\r
- configurations.add(graph.getPossibleObject(r, SR2.IsDefinedBy));\r
- } else if(graph.isInstanceOf(r, sr.SysdynModel)) {\r
- configurations.add(graph.getPossibleObject(modelRoot, SimulationResource.getInstance(graph).HasConfiguration));\r
- }\r
- }\r
- \r
- return configurations;\r
- }\r
- \r
- private Collection<Resource> findAllModelsAndModules(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- Collection<Resource> modelsAndModules = new ArrayList<Resource>();\r
- modelsAndModules.add(modelRoot);\r
-\r
- for(Resource r : graph.getObjects(modelRoot, L0.ConsistsOf)) {\r
- if(graph.isInheritedFrom(r, sr.Module)) {\r
- modelsAndModules.add(r);\r
- }\r
- }\r
- \r
- return modelsAndModules;\r
- }\r
- \r
- private void displayErrorMessage(Shell shell, String message) {\r
- MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
- mb.setText("Error");\r
- mb.setMessage("The imported file is not of type: Model");\r
- mb.open();\r
- }\r
+ private Collection<Resource> findAllConfigurations(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 SR2 = StructuralResource2.getInstance(graph);\r
+ Collection<Resource> modulesAndModels = findAllModelsAndModules(graph, modelRoot);\r
+ Collection<Resource> configurations = new ArrayList<Resource>();\r
+\r
+ for(Resource r : modulesAndModels) {\r
+ if(graph.isInheritedFrom(r, sr.Module)) {\r
+ configurations.add(graph.getPossibleObject(r, SR2.IsDefinedBy));\r
+ } else if(graph.isInstanceOf(r, sr.SysdynModel)) {\r
+ configurations.add(graph.getPossibleObject(modelRoot, SimulationResource.getInstance(graph).HasConfiguration));\r
+ }\r
+ }\r
+\r
+ return configurations;\r
+ }\r
+\r
+ private Collection<Resource> findAllModelsAndModules(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Collection<Resource> modelsAndModules = new ArrayList<Resource>();\r
+ modelsAndModules.add(modelRoot);\r
+\r
+ for(Resource r : graph.getObjects(modelRoot, L0.ConsistsOf)) {\r
+ if(graph.isInheritedFrom(r, sr.Module)) {\r
+ modelsAndModules.add(r);\r
+ }\r
+ }\r
+\r
+ return modelsAndModules;\r
+ }\r
+\r
+// private void displayErrorMessage(Shell shell, String message) {\r
+// MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
+// mb.setText("Error");\r
+// mb.setMessage("The imported file is not of type: Model");\r
+// mb.open();\r
+// }\r
}\r