]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fixed a bug that caused unit validation warnings for stocks inside modules: Provide...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 13 Jun 2013 13:06:17 +0000 (13:06 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 13 Jun 2013 13:06:17 +0000 (13:06 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27539 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/ComponentReferenceFull.java

index 732509d9631a26e99907b3e1c3ae5184702f33b3..f594c5ec9c57fce784a0767015fc69b57964ca97 100644 (file)
@@ -21,7 +21,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
 import org.simantics.db.exception.ServiceException;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.db.layer0.request.PossibleModel;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.manager.SysdynModel;\r
 import org.simantics.sysdyn.representation.Configuration;\r
@@ -125,18 +125,19 @@ public class UnitUtils {
     \r
     public static String getTimeUnit(ReadGraph graph, SysdynModel model) {\r
         try {\r
-            Resource modelResource = graph.getPossibleObject(model.getConfigurationResource(), SimulationResource.getInstance(graph).IsConfigurationOf);\r
+            Resource modelResource = graph.syncRequest(new PossibleModel(model.getConfigurationResource()));\r
             if(modelResource != null) {\r
                 String timeUnit = graph.getPossibleRelatedValue(modelResource, SysdynResource.getInstance(graph).SysdynModel_timeUnit);\r
                 if(timeUnit == null)\r
                     timeUnit = "month";\r
                 return timeUnit;\r
             }\r
-                \r
         } catch (ManyObjectsForFunctionalRelationException e) {\r
             e.printStackTrace();\r
         } catch (ServiceException e) {\r
             e.printStackTrace();\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
         }\r
         \r
         return null;\r
index 0f8ec7041b08329694e2a36da28a33d2522b5d9e..f539928289428659932e263700174cfc294367ea 100644 (file)
@@ -56,7 +56,7 @@ public class ComponentReferenceFull extends UnitCheckingNode {
         }\r
         \r
         if(units != null) {\r
-            if(!units.containsKey(node))\r
+            if(!units.containsKey(node) || units.get(node) == null)\r
                 throw new UnitCheckingException("No units defined for " + node);\r
             else {\r
                 return parseUnits(units.get(node));\r