]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
c8df2821029a3a3ef17122f868105eecf3b5c47f
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.adapter;\r
2 \r
3 import java.util.ArrayList;\r
4 import java.util.Collection;\r
5 \r
6 import org.simantics.db.ReadGraph;\r
7 import org.simantics.db.WriteGraph;\r
8 import org.simantics.db.exception.DatabaseException;\r
9 import org.simantics.db.layer0.variable.Variable;\r
10 import org.simantics.modelica.data.DataSet;\r
11 import org.simantics.sysdyn.manager.SysdynDataSet;\r
12 import org.simantics.sysdyn.manager.SysdynResult;\r
13 \r
14 public class ActiveDatasetsIndexVariable extends IndexVariable< ArrayList<DataSet>> {\r
15 \r
16         public ActiveDatasetsIndexVariable(ReadGraph graph, Variable parent, String indexes)\r
17                         throws DatabaseException {\r
18                 super(graph, parent, indexes);\r
19         }\r
20 \r
21         @Override\r
22         public  ArrayList<DataSet> getValue() {\r
23                 ArrayList<DataSet> datasets = new ArrayList<DataSet>();\r
24                 \r
25                 if(experiment == null)\r
26                     return datasets;\r
27                 \r
28                 Collection<SysdynResult> results = experiment.getActiveResults();\r
29                 ArrayList<String> variableNamesWithIndexes = getVariableNamesWithIndexNumbers();\r
30                 ArrayList<String> variableNames = getVariableNames();\r
31 \r
32                 for(int i = 0; i < variableNamesWithIndexes.size(); i++) {\r
33                     for(SysdynResult result : results) {\r
34                         SysdynDataSet ds = result.getDataSet(variableNamesWithIndexes.get(i));\r
35                         if(ds != null) {\r
36                             ds.name = variableNames.get(i);\r
37                             datasets.add(ds);\r
38                         }\r
39                     }\r
40                 }\r
41                 return datasets;\r
42         }\r
43 \r
44         @Override\r
45         public void setIndexedValue(WriteGraph graph, Object value)\r
46                         throws DatabaseException {\r
47                 \r
48         }\r
49 \r
50 }\r