From: lempinen Date: Thu, 13 Jun 2013 13:06:17 +0000 (+0000) Subject: Fixed a bug that caused unit validation warnings for stocks inside modules: Provide... X-Git-Tag: 1.8.1~292 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=7a7cc90a702336df69e7336ffc8ae65494d1a384;p=simantics%2Fsysdyn.git Fixed a bug that caused unit validation warnings for stocks inside modules: Provide time unit data into modules (fixes #4341) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27539 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java index 732509d9..f594c5ec 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java @@ -21,7 +21,7 @@ import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.ServiceException; -import org.simantics.simulation.ontology.SimulationResource; +import org.simantics.db.layer0.request.PossibleModel; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.manager.SysdynModel; import org.simantics.sysdyn.representation.Configuration; @@ -125,18 +125,19 @@ public class UnitUtils { public static String getTimeUnit(ReadGraph graph, SysdynModel model) { try { - Resource modelResource = graph.getPossibleObject(model.getConfigurationResource(), SimulationResource.getInstance(graph).IsConfigurationOf); + Resource modelResource = graph.syncRequest(new PossibleModel(model.getConfigurationResource())); if(modelResource != null) { String timeUnit = graph.getPossibleRelatedValue(modelResource, SysdynResource.getInstance(graph).SysdynModel_timeUnit); if(timeUnit == null) timeUnit = "month"; return timeUnit; } - } catch (ManyObjectsForFunctionalRelationException e) { e.printStackTrace(); } catch (ServiceException e) { e.printStackTrace(); + } catch (DatabaseException e) { + e.printStackTrace(); } return null; diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/ComponentReferenceFull.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/ComponentReferenceFull.java index 0f8ec704..f5399282 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/ComponentReferenceFull.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/unitParser/nodes/ComponentReferenceFull.java @@ -56,7 +56,7 @@ public class ComponentReferenceFull extends UnitCheckingNode { } if(units != null) { - if(!units.containsKey(node)) + if(!units.containsKey(node) || units.get(node) == null) throw new UnitCheckingException("No units defined for " + node); else { return parseUnits(units.get(node));