@VP.dropActionContribution JFREE.Axis ACTIONS.DropAction 1.0 \r
@VP.dropActionContribution JFREE.Series ACTIONS.DropAction 1.0 \r
\r
+CBC\r
+ VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+ VP.VisualsContribution.HasNodeType JFREE.Chart\r
+ VP.VisualsContribution.HasRule VP.PassThruSorterRule \r
+ VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+ VP.VisualsContribution.HasNodeType JFREE.Axis\r
+ VP.VisualsContribution.HasRule VP.PassThruSorterRule\r
+ \r
+ \r
ACTIONS = CAC.Actions : L0.Library\r
ACTIONS.DropAction : ACT.DropAction
\ No newline at end of file
@L0.singleProperty SYSDYN.HasEquation
SYSDYN.DelayExpression <T SYSDYN.Expression
- @L0.singleProperty SYSDYN.HasEquation
-
+ >-- SYSDYN.DelayExpression.expression --> L0.String <R SYSDYN.HasEquation
+ >-- SYSDYN.DelayExpression.order --> L0.Integer <R SYSDYN.HasEquation
+ >-- SYSDYN.DelayExpression.delayTime --> L0.String <R SYSDYN.HasEquation
+ >-- SYSDYN.DelayExpression.initialValue --> L0.String <R SYSDYN.HasEquation
+
SYSDYN.StockExpression <T SYSDYN.Expression
@L0.singleProperty SYSDYN.HasInitialEquation
SYSDYN.SysdynIssue <T ISSUE.TextualIssue\r
\r
// DEPENDENCIES\r
-SYSDYN.DependencyIssue <T SYSDYN.SysdynIssue\r
VALIDATIONS.Dependencies : L0.Library\r
-\r
-VALIDATIONS.Dependencies.DependencyConnectionsIssueSource <T ISSUE.DependencyIssueSource\r
- @L0.assert ISSUE.DependencyIssueSource.HasType SYSDYN.Variable\r
- @L0.assert ISSUE.DependencyIssueSource.HasValidator VALIDATIONS.Dependencies.dependencyValidator\r
- @L0.assert ISSUE.DependencyIssueSource.HasSynchronizer VALIDATIONS.Dependencies.dependencySynchronizer\r
- @L0.assert ISSUE.DependencyIssueSource.HasBaseFunction VALIDATIONS.Dependencies.dependencyBaseRealizationFunction\r
- \r
- \r
VALIDATIONS.Dependencies.dependencyValidator : L0X.Function\r
VALIDATIONS.Dependencies.dependencySynchronizer : L0X.Function\r
VALIDATIONS.Dependencies.dependencyBaseRealizationFunction : L0X.Function\r
\r
// EXPRESSIONS \r
-SYSDYN.ExpressionIssue <T SYSDYN.SysdynIssue\r
VALIDATIONS.Expressions : L0.Library\r
-\r
-VALIDATIONS.Expressions.ExpressionIssueSource <T ISSUE.DependencyIssueSource\r
- @L0.assert ISSUE.DependencyIssueSource.HasType SYSDYN.Variable\r
- @L0.assert ISSUE.DependencyIssueSource.HasValidator VALIDATIONS.Expressions.expressionValidator\r
- @L0.assert ISSUE.DependencyIssueSource.HasSynchronizer VALIDATIONS.Expressions.expressionSynchronizer\r
- @L0.assert ISSUE.DependencyIssueSource.HasBaseFunction VALIDATIONS.Expressions.expressionBaseRealizationFunction\r
- \r
VALIDATIONS.Expressions.expressionValidator : L0X.Function\r
VALIDATIONS.Expressions.expressionSynchronizer : L0X.Function\r
VALIDATIONS.Expressions.expressionBaseRealizationFunction : L0X.Function\r
-
\ No newline at end of file
+\r
+\r
+SYSDYN.Variable\r
+ @VALIDATIONS.constraint\r
+ VALIDATIONS.ExpressionConstraint\r
+ VALIDATIONS.Expressions.ExpressionIssueSource \r
+ VALIDATIONS.Expressions.expressionValidator \r
+ \r
+SYSDYN.Variable\r
+ @VALIDATIONS.constraint\r
+ VALIDATIONS.DependencyConstraint\r
+ VALIDATIONS.Dependencies.DependencyConnectionsIssueSource\r
+ VALIDATIONS.Dependencies.dependencyValidator \r
+ \r
+VALIDATIONS.ExpressionIssue\r
+ @VALIDATIONS.issue\r
+ ISSUE.Severity.Error\r
+ VALIDATIONS.Expressions.expressionIssueDescription : L0.Function\r
+ \r
+VALIDATIONS.MissingLinkIssue\r
+ @VALIDATIONS.issue\r
+ ISSUE.Severity.Warning\r
+ VALIDATIONS.Dependencies.missingLinkIssueDescription : L0.Function\r
+ \r
+VALIDATIONS.UnusedDependencyIssue\r
+ @VALIDATIONS.issue\r
+ ISSUE.Severity.Warning\r
+ VALIDATIONS.Dependencies.unusedDependencyIssueDescription : L0.Function \r
+ \r
+VALIDATIONS.NoSuchVariableIssue\r
+ @VALIDATIONS.issue\r
+ ISSUE.Severity.Error\r
+ VALIDATIONS.Dependencies.noSuchVariableIssueDescription : L0.Function \r
+ >-- VALIDATIONS.NoSuchVariableIssue.variableName --> L0.String <R L0.HasProperty : L0.FunctionalRelation\r
+\r
+// IssueSource template\r
+VALIDATIONS.constraint : L0.Template\r
+ @template %type %constraint %source %validator\r
+ %type\r
+ L0.HasConstraint %constraint : L0.Constraint\r
+ L0.Constraint.Validator %validator\r
+ %source <T ISSUE.DependencyIssueSource2\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate ISSUE.DependencyIssueSource2.HasType\r
+ L0.HasObject %type\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate ISSUE.DependencyIssueSource2.HasConstraint\r
+ L0.HasObject %constraint\r
+\r
+// Issue template\r
+VALIDATIONS.issue : L0.Template\r
+ @template %issue %severity %description\r
+ %issue <T ISSUE.DependencyIssueSource2.Issue\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate ISSUE.HasSeverity\r
+ L0.HasObject %severity\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate L0.HasDescription\r
+ L0.HasObject %description
\ No newline at end of file
public final Resource DefaultProfile;\r
public final Resource DefaultRealization;\r
public final Resource DelayExpression;\r
+ public final Resource DelayExpression_delayTime;\r
+ public final Resource DelayExpression_delayTime_Inverse;\r
+ public final Resource DelayExpression_expression;\r
+ public final Resource DelayExpression_expression_Inverse;\r
+ public final Resource DelayExpression_initialValue;\r
+ public final Resource DelayExpression_initialValue_Inverse;\r
+ public final Resource DelayExpression_order;\r
+ public final Resource DelayExpression_order_Inverse;\r
public final Resource Dependency;\r
public final Resource DependencyConnection;\r
- public final Resource DependencyIssue;\r
public final Resource DiagramToCompositeMapping;\r
public final Resource Enumeration;\r
public final Resource EnumerationIndex;\r
public final Resource Experiment;\r
public final Resource ExportModuleTree;\r
public final Resource Expression;\r
- public final Resource ExpressionIssue;\r
public final Resource Expressions;\r
public final Resource Expressions_Inverse;\r
public final Resource ExternalFiles;\r
public final Resource Validations_Dependencies_dependencyBaseRealizationFunction;\r
public final Resource Validations_Dependencies_dependencySynchronizer;\r
public final Resource Validations_Dependencies_dependencyValidator;\r
+ public final Resource Validations_Dependencies_missingLinkIssueDescription;\r
+ public final Resource Validations_Dependencies_noSuchVariableIssueDescription;\r
+ public final Resource Validations_Dependencies_unusedDependencyIssueDescription;\r
+ public final Resource Validations_DependencyConstraint;\r
+ public final Resource Validations_ExpressionConstraint;\r
+ public final Resource Validations_ExpressionIssue;\r
public final Resource Validations_Expressions;\r
public final Resource Validations_Expressions_ExpressionIssueSource;\r
public final Resource Validations_Expressions_expressionBaseRealizationFunction;\r
+ public final Resource Validations_Expressions_expressionIssueDescription;\r
public final Resource Validations_Expressions_expressionSynchronizer;\r
public final Resource Validations_Expressions_expressionValidator;\r
+ public final Resource Validations_MissingLinkIssue;\r
+ public final Resource Validations_NoSuchVariableIssue;\r
+ public final Resource Validations_NoSuchVariableIssue_variableName;\r
+ public final Resource Validations_NoSuchVariableIssue_variableName_Inverse;\r
+ public final Resource Validations_UnusedDependencyIssue;\r
+ public final Resource Validations_constraint;\r
+ public final Resource Validations_issue;\r
public final Resource Valve;\r
public final Resource ValveSymbol;\r
public final Resource Variable;\r
public static final String DefaultProfile = "http://www.simantics.org/Sysdyn-1.1/DefaultProfile";\r
public static final String DefaultRealization = "http://www.simantics.org/Sysdyn-1.1/DefaultRealization";\r
public static final String DelayExpression = "http://www.simantics.org/Sysdyn-1.1/DelayExpression";\r
+ public static final String DelayExpression_delayTime = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/delayTime";\r
+ public static final String DelayExpression_delayTime_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/delayTime/Inverse";\r
+ public static final String DelayExpression_expression = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/expression";\r
+ public static final String DelayExpression_expression_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/expression/Inverse";\r
+ public static final String DelayExpression_initialValue = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/initialValue";\r
+ public static final String DelayExpression_initialValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/initialValue/Inverse";\r
+ public static final String DelayExpression_order = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/order";\r
+ public static final String DelayExpression_order_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/order/Inverse";\r
public static final String Dependency = "http://www.simantics.org/Sysdyn-1.1/Dependency";\r
public static final String DependencyConnection = "http://www.simantics.org/Sysdyn-1.1/DependencyConnection";\r
- public static final String DependencyIssue = "http://www.simantics.org/Sysdyn-1.1/DependencyIssue";\r
public static final String DiagramToCompositeMapping = "http://www.simantics.org/Sysdyn-1.1/DiagramToCompositeMapping";\r
public static final String Enumeration = "http://www.simantics.org/Sysdyn-1.1/Enumeration";\r
public static final String EnumerationIndex = "http://www.simantics.org/Sysdyn-1.1/EnumerationIndex";\r
public static final String Experiment = "http://www.simantics.org/Sysdyn-1.1/Experiment";\r
public static final String ExportModuleTree = "http://www.simantics.org/Sysdyn-1.1/ExportModuleTree";\r
public static final String Expression = "http://www.simantics.org/Sysdyn-1.1/Expression";\r
- public static final String ExpressionIssue = "http://www.simantics.org/Sysdyn-1.1/ExpressionIssue";\r
public static final String Expressions = "http://www.simantics.org/Sysdyn-1.1/Expressions";\r
public static final String Expressions_Inverse = "http://www.simantics.org/Sysdyn-1.1/Expressions/Inverse";\r
public static final String ExternalFiles = "http://www.simantics.org/Sysdyn-1.1/ExternalFiles";\r
public static final String Validations_Dependencies_dependencyBaseRealizationFunction = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies/dependencyBaseRealizationFunction";\r
public static final String Validations_Dependencies_dependencySynchronizer = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies/dependencySynchronizer";\r
public static final String Validations_Dependencies_dependencyValidator = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies/dependencyValidator";\r
+ public static final String Validations_Dependencies_missingLinkIssueDescription = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies/missingLinkIssueDescription";\r
+ public static final String Validations_Dependencies_noSuchVariableIssueDescription = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies/noSuchVariableIssueDescription";\r
+ public static final String Validations_Dependencies_unusedDependencyIssueDescription = "http://www.simantics.org/Sysdyn-1.1/Validations/Dependencies/unusedDependencyIssueDescription";\r
+ public static final String Validations_DependencyConstraint = "http://www.simantics.org/Sysdyn-1.1/Validations/DependencyConstraint";\r
+ public static final String Validations_ExpressionConstraint = "http://www.simantics.org/Sysdyn-1.1/Validations/ExpressionConstraint";\r
+ public static final String Validations_ExpressionIssue = "http://www.simantics.org/Sysdyn-1.1/Validations/ExpressionIssue";\r
public static final String Validations_Expressions = "http://www.simantics.org/Sysdyn-1.1/Validations/Expressions";\r
public static final String Validations_Expressions_ExpressionIssueSource = "http://www.simantics.org/Sysdyn-1.1/Validations/Expressions/ExpressionIssueSource";\r
public static final String Validations_Expressions_expressionBaseRealizationFunction = "http://www.simantics.org/Sysdyn-1.1/Validations/Expressions/expressionBaseRealizationFunction";\r
+ public static final String Validations_Expressions_expressionIssueDescription = "http://www.simantics.org/Sysdyn-1.1/Validations/Expressions/expressionIssueDescription";\r
public static final String Validations_Expressions_expressionSynchronizer = "http://www.simantics.org/Sysdyn-1.1/Validations/Expressions/expressionSynchronizer";\r
public static final String Validations_Expressions_expressionValidator = "http://www.simantics.org/Sysdyn-1.1/Validations/Expressions/expressionValidator";\r
+ public static final String Validations_MissingLinkIssue = "http://www.simantics.org/Sysdyn-1.1/Validations/MissingLinkIssue";\r
+ public static final String Validations_NoSuchVariableIssue = "http://www.simantics.org/Sysdyn-1.1/Validations/NoSuchVariableIssue";\r
+ public static final String Validations_NoSuchVariableIssue_variableName = "http://www.simantics.org/Sysdyn-1.1/Validations/NoSuchVariableIssue/variableName";\r
+ public static final String Validations_NoSuchVariableIssue_variableName_Inverse = "http://www.simantics.org/Sysdyn-1.1/Validations/NoSuchVariableIssue/variableName/Inverse";\r
+ public static final String Validations_UnusedDependencyIssue = "http://www.simantics.org/Sysdyn-1.1/Validations/UnusedDependencyIssue";\r
+ public static final String Validations_constraint = "http://www.simantics.org/Sysdyn-1.1/Validations/constraint";\r
+ public static final String Validations_issue = "http://www.simantics.org/Sysdyn-1.1/Validations/issue";\r
public static final String Valve = "http://www.simantics.org/Sysdyn-1.1/Valve";\r
public static final String ValveSymbol = "http://www.simantics.org/Sysdyn-1.1/ValveSymbol";\r
public static final String Variable = "http://www.simantics.org/Sysdyn-1.1/Variable";\r
DefaultProfile = getResourceOrNull(graph, URIs.DefaultProfile);\r
DefaultRealization = getResourceOrNull(graph, URIs.DefaultRealization);\r
DelayExpression = getResourceOrNull(graph, URIs.DelayExpression);\r
+ DelayExpression_delayTime = getResourceOrNull(graph, URIs.DelayExpression_delayTime);\r
+ DelayExpression_delayTime_Inverse = getResourceOrNull(graph, URIs.DelayExpression_delayTime_Inverse);\r
+ DelayExpression_expression = getResourceOrNull(graph, URIs.DelayExpression_expression);\r
+ DelayExpression_expression_Inverse = getResourceOrNull(graph, URIs.DelayExpression_expression_Inverse);\r
+ DelayExpression_initialValue = getResourceOrNull(graph, URIs.DelayExpression_initialValue);\r
+ DelayExpression_initialValue_Inverse = getResourceOrNull(graph, URIs.DelayExpression_initialValue_Inverse);\r
+ DelayExpression_order = getResourceOrNull(graph, URIs.DelayExpression_order);\r
+ DelayExpression_order_Inverse = getResourceOrNull(graph, URIs.DelayExpression_order_Inverse);\r
Dependency = getResourceOrNull(graph, URIs.Dependency);\r
DependencyConnection = getResourceOrNull(graph, URIs.DependencyConnection);\r
- DependencyIssue = getResourceOrNull(graph, URIs.DependencyIssue);\r
DiagramToCompositeMapping = getResourceOrNull(graph, URIs.DiagramToCompositeMapping);\r
Enumeration = getResourceOrNull(graph, URIs.Enumeration);\r
EnumerationIndex = getResourceOrNull(graph, URIs.EnumerationIndex);\r
Experiment = getResourceOrNull(graph, URIs.Experiment);\r
ExportModuleTree = getResourceOrNull(graph, URIs.ExportModuleTree);\r
Expression = getResourceOrNull(graph, URIs.Expression);\r
- ExpressionIssue = getResourceOrNull(graph, URIs.ExpressionIssue);\r
Expressions = getResourceOrNull(graph, URIs.Expressions);\r
Expressions_Inverse = getResourceOrNull(graph, URIs.Expressions_Inverse);\r
ExternalFiles = getResourceOrNull(graph, URIs.ExternalFiles);\r
Validations_Dependencies_dependencyBaseRealizationFunction = getResourceOrNull(graph, URIs.Validations_Dependencies_dependencyBaseRealizationFunction);\r
Validations_Dependencies_dependencySynchronizer = getResourceOrNull(graph, URIs.Validations_Dependencies_dependencySynchronizer);\r
Validations_Dependencies_dependencyValidator = getResourceOrNull(graph, URIs.Validations_Dependencies_dependencyValidator);\r
+ Validations_Dependencies_missingLinkIssueDescription = getResourceOrNull(graph, URIs.Validations_Dependencies_missingLinkIssueDescription);\r
+ Validations_Dependencies_noSuchVariableIssueDescription = getResourceOrNull(graph, URIs.Validations_Dependencies_noSuchVariableIssueDescription);\r
+ Validations_Dependencies_unusedDependencyIssueDescription = getResourceOrNull(graph, URIs.Validations_Dependencies_unusedDependencyIssueDescription);\r
+ Validations_DependencyConstraint = getResourceOrNull(graph, URIs.Validations_DependencyConstraint);\r
+ Validations_ExpressionConstraint = getResourceOrNull(graph, URIs.Validations_ExpressionConstraint);\r
+ Validations_ExpressionIssue = getResourceOrNull(graph, URIs.Validations_ExpressionIssue);\r
Validations_Expressions = getResourceOrNull(graph, URIs.Validations_Expressions);\r
Validations_Expressions_ExpressionIssueSource = getResourceOrNull(graph, URIs.Validations_Expressions_ExpressionIssueSource);\r
Validations_Expressions_expressionBaseRealizationFunction = getResourceOrNull(graph, URIs.Validations_Expressions_expressionBaseRealizationFunction);\r
+ Validations_Expressions_expressionIssueDescription = getResourceOrNull(graph, URIs.Validations_Expressions_expressionIssueDescription);\r
Validations_Expressions_expressionSynchronizer = getResourceOrNull(graph, URIs.Validations_Expressions_expressionSynchronizer);\r
Validations_Expressions_expressionValidator = getResourceOrNull(graph, URIs.Validations_Expressions_expressionValidator);\r
+ Validations_MissingLinkIssue = getResourceOrNull(graph, URIs.Validations_MissingLinkIssue);\r
+ Validations_NoSuchVariableIssue = getResourceOrNull(graph, URIs.Validations_NoSuchVariableIssue);\r
+ Validations_NoSuchVariableIssue_variableName = getResourceOrNull(graph, URIs.Validations_NoSuchVariableIssue_variableName);\r
+ Validations_NoSuchVariableIssue_variableName_Inverse = getResourceOrNull(graph, URIs.Validations_NoSuchVariableIssue_variableName_Inverse);\r
+ Validations_UnusedDependencyIssue = getResourceOrNull(graph, URIs.Validations_UnusedDependencyIssue);\r
+ Validations_constraint = getResourceOrNull(graph, URIs.Validations_constraint);\r
+ Validations_issue = getResourceOrNull(graph, URIs.Validations_issue);\r
Valve = getResourceOrNull(graph, URIs.Valve);\r
ValveSymbol = getResourceOrNull(graph, URIs.ValveSymbol);\r
Variable = getResourceOrNull(graph, URIs.Variable);\r
relative="org.simantics.sysdyn.ui.trend.view">\r
</view>\r
<view\r
- id="org.simantics.issues.ui.issueview"\r
+ id="org.simantics.issues.ui.issueview2"\r
minimized="false"\r
relationship="stack"\r
relative="org.simantics.browsing.ui.graph.propertyView">\r
<extension point="org.simantics.scl.reflection.binding">\r
<namespace path="http://www.simantics.org/Sysdyn-0.0/Validations">\r
<namespace path="Dependencies">\r
+ <externalClass className="org.simantics.db.Resource"/>\r
+ <externalClass className="org.simantics.db.layer0.variable.Variable"/>\r
+ <externalClass className="org.simantics.db.ReadGraph"/>\r
+ <externalClass className="org.simantics.db.WriteGraph"/>\r
<class className="org.simantics.sysdyn.ui.validation.DependencyFunction"/>\r
</namespace>\r
<namespace path="Expressions">\r
+ <externalClass className="org.simantics.db.Resource"/>\r
+ <externalClass className="org.simantics.db.layer0.variable.Variable"/>\r
+ <externalClass className="org.simantics.db.ReadGraph"/>\r
+ <externalClass className="org.simantics.db.WriteGraph"/>\r
<class className="org.simantics.sysdyn.ui.validation.ExpressionIssueFunction"/>\r
</namespace>\r
</namespace>\r
import java.awt.geom.AffineTransform;\r
import java.awt.geom.Rectangle2D;\r
import java.util.Collections;\r
+import java.util.List;\r
import java.util.Set;\r
\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.common.request.PossibleTypedParent;\r
+import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.variable.Variable;\r
import org.simantics.diagram.profile.StyleBase;\r
import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;\r
-import org.simantics.issues.IssueOld.Severity;\r
import org.simantics.issues.common.ErrorIssues;\r
import org.simantics.issues.common.FatalIssues;\r
-import org.simantics.issues.common.IssueContexts;\r
import org.simantics.issues.common.WarningIssues;\r
+import org.simantics.issues.ontology.IssueResource;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.modeling.ModelingResources;\r
import org.simantics.scenegraph.INode;\r
import org.simantics.utils.datastructures.map.Tuple;\r
\r
/**\r
- * @author Tuukka Lehtonen\r
+ * Issue Decorations. Display an issue icon on \r
+ * a diagram element depending on the type of the issue\r
+ * .\r
+ * @author Teemu Lempinen\r
+ *\r
*/\r
public class IssueDecorationStyle extends StyleBase<IssueResult> {\r
\r
private static final String DECORATION_NODE_NAME = "issueDecorations";\r
\r
@Override\r
- public IssueResult calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource module, Variable configuration) throws DatabaseException {\r
+ public IssueResult calculateStyle(ReadGraph graph, Resource runtimeDiagram, Resource entry, Resource element, Variable configuration) throws DatabaseException {\r
Layer0 L0 = Layer0.getInstance(graph);\r
ModelingResources MOD = ModelingResources.getInstance(graph);\r
- Resource config = graph.getPossibleObject(module, MOD.ElementToComponent);\r
- if (config == null)\r
+ \r
+ // Find a component for the element \r
+ Resource component = graph.getPossibleObject(element, MOD.ElementToComponent);\r
+ if (component == null)\r
return null;\r
\r
- AffineTransform transform = DiagramGraphUtil.getAffineTransform(graph, module);\r
+ // Get the current transform of the element to be able to move the decoration with the element\r
+ AffineTransform transform = DiagramGraphUtil.getAffineTransform(graph, element);\r
\r
- Resource model = graph.syncRequest(new PossibleTypedParent(config, SimulationResource.getInstance(graph).Model));\r
+ // Find the model of the component\r
+ Resource model = graph.syncRequest(new PossibleTypedParent(component, SimulationResource.getInstance(graph).Model));\r
if (model == null)\r
return null;\r
\r
+ // Project\r
Resource project = graph.getPossibleObject(model, L0.PartOf);\r
if (project == null)\r
return null;\r
\r
+ IssueResult result = null;\r
+ \r
+ /*\r
+ * Search for issues. Start from fatal and move to\r
+ * less important issues. This way the most important \r
+ * issue will be displayed.\r
+ * \r
+ * The issue is returned immediately after it is found.\r
+ */\r
+ \r
Set<Variable> fatals = graph.syncRequest(new FatalIssues(project, true));\r
- Set<Resource> fatalContexts = graph.syncRequest(new IssueContexts(fatals));\r
- if (fatalContexts.contains(config))\r
- return new IssueResult(Severity.FATAL, transform);\r
-\r
+ result = getIssue(graph, IssueResult.Severity.FATAL, fatals, component, transform);\r
+ if(result != null) return result;\r
+ \r
Set<Variable> errors = graph.syncRequest(new ErrorIssues(project, true));\r
- Set<Resource> errorContexts = graph.syncRequest(new IssueContexts(errors));\r
- if (errorContexts.contains(config))\r
- return new IssueResult(Severity.ERROR, transform);\r
+ result = getIssue(graph, IssueResult.Severity.ERROR, errors, component, transform);\r
+ if(result != null) return result;\r
\r
Set<Variable> warnings = graph.syncRequest(new WarningIssues(project, true));\r
- Set<Resource> warningContexts = graph.syncRequest(new IssueContexts(warnings));\r
- if (warningContexts.contains(config))\r
- return new IssueResult(Severity.WARNING, transform);\r
+ result = getIssue(graph, IssueResult.Severity.WARNING, warnings, component, transform);\r
+ if(result != null) return result;\r
\r
+ // No issue was found\r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * See if a set of issue variables concern this component\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param severity IssueResult.Severity of the issue\r
+ * @param issues Collection of issues of type severity\r
+ * @param component The component that is evaluated for issues\r
+ * @param transform AffineTransform of the diagram element\r
+ * @return IssueResult containing the severity and transform of the issue or null if no issue concerned component\r
+ * @throws DatabaseException\r
+ */\r
+ private IssueResult getIssue(ReadGraph graph, IssueResult.Severity severity, Set<Variable> issues, Resource component, AffineTransform transform) throws DatabaseException {\r
+ IssueResource ISSUE = IssueResource.getInstance(graph);\r
+ Resource list, issueResource;\r
+ for(Variable issue : issues) {\r
+ issueResource = issue.getRepresents(graph);\r
+ list = graph.getPossibleObject(issueResource, ISSUE.DependencyIssueSource2_Issue_HasContexts);\r
+ List<Resource> contexts = ListUtils.toList(graph, list);\r
+ if(!contexts.isEmpty()) {\r
+ if(ListUtils.toList(graph, list).get(0).equals(component)) {\r
+ return new IssueResult(severity, transform);\r
+ }\r
+ }\r
+ }\r
return null;\r
}\r
\r
@Override\r
public void applyStyleForNode(EvaluationContext observer, INode node, IssueResult result) {\r
+ \r
+ // If result == null, remove possible issue decoration\r
if (result == null) {\r
ProfileVariables.denyChild(node, "", DECORATION_NODE_NAME);\r
return;\r
}\r
\r
+ // Create issue decoration node\r
SVGNode svgNode = ProfileVariables.claimChild(node, "", DECORATION_NODE_NAME, SVGNode.class, observer);\r
\r
+ // Move the decoration to the upper right corner of the element\r
Rectangle2D bounds = NodeUtil.getLocalBounds(node, Collections.<INode>singleton(svgNode));\r
-\r
double tx = bounds.getMaxX();\r
double ty = bounds.getY();\r
-\r
svgNode.setZIndex( Integer.MAX_VALUE );\r
svgNode.setTransform( AffineTransform.getTranslateInstance(tx-1, ty-1)); \r
svgNode.getTransform().scale(0.5, 0.5);\r
\r
\r
- Severity sev = result.getSeverity();\r
- if (Severity.FATAL.equals(sev))\r
+ // Apply the corresponding svg graphics to the node\r
+ IssueResult.Severity sev = result.getSeverity();\r
+ if (IssueResult.Severity.FATAL.equals(sev))\r
svgNode.setData(Activator.FATAL_SVG_TEXT);\r
- else if (Severity.ERROR.equals(sev))\r
+ else if (IssueResult.Severity.ERROR.equals(sev))\r
svgNode.setData(Activator.ERROR_SVG_TEXT);\r
- else if (Severity.WARNING.equals(sev))\r
+ else if (IssueResult.Severity.WARNING.equals(sev))\r
svgNode.setData(Activator.WARNING_SVG_TEXT);\r
}\r
\r
* element moves.\r
*/\r
class IssueResult extends Tuple {\r
+ \r
+ public enum Severity{FATAL, ERROR, WARNING};\r
+ \r
public IssueResult(Severity severity, AffineTransform transform) {\r
super(severity, transform);\r
}\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.validation;\r
\r
-import java.util.Collection;\r
-import java.util.HashSet;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
import java.util.Set;\r
\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.issues.common.Issue;\r
+import org.simantics.issues.common.StandardIssue;\r
import org.simantics.issues.ontology.IssueResource;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.scl.reflection.annotations.SCLValue;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
\r
+/**\r
+ * Evaluates issues related to Dependencies (arrows)\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class DependencyFunction {\r
\r
-\r
- private static String getMissingLinkLabel(String name, String dependency) throws DatabaseException {\r
- return "Missing link " + dependency + " in " + name;\r
- }\r
- \r
- private static String getNoSuchVariableLabel(String name, String dependency) throws DatabaseException {\r
- return name + " refers to variable " + dependency + " that does not exist";\r
- }\r
-\r
- private static String getUnusedDependencyLabel(String name, String dependency) throws DatabaseException {\r
- return "Unused dependency " + dependency + " in " + name;\r
- }\r
- \r
/**\r
+ * Evaluates dependency-related issues for a component. \r
* \r
- * One issue is enough. The first encounter of a new issue returns Boolean.FALSE.\r
+ * Issues include:\r
+ * Missing link\r
+ * No such variable\r
+ * Unused dependency\r
* \r
- * @param _graph\r
- * @param _resource\r
- * @param _existing\r
- * @return\r
+ * @param graph ReadGraph\r
+ * @param component Evaluated component (Variable) \r
+ * @return list of issues related to component\r
* @throws DatabaseException\r
*/\r
- @SCLValue(type = "a -> b -> c -> d")\r
- public static Object dependencyValidator(Object _graph, Object _resource, Object _existing) throws DatabaseException {\r
-\r
- ReadGraph graph = (ReadGraph)_graph;\r
- Resource variable = (Resource)_resource;\r
- Collection<Resource> existing = (Collection<Resource>)_existing;\r
- \r
- IssueResource ISSUE = IssueResource.getInstance(graph);\r
+ @SCLValue(type = "ReadGraph -> Resource -> [Issue]")\r
+ public static List<Issue> dependencyValidator(ReadGraph graph, Resource component) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Layer0 l0 = Layer0.getInstance(graph);\r
- \r
- if(!graph.isInstanceOf(variable, sr.IndependentVariable)) \r
- return Boolean.TRUE;\r
- \r
- if(!graph.hasStatement(variable) || !graph.hasStatement(variable, l0.PartOf))\r
- return Boolean.FALSE;\r
\r
- String name = graph.getRelatedValue(variable, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
+ if(!graph.isInstanceOf(component, sr.IndependentVariable)) \r
+ return Collections.emptyList();\r
\r
- Set<String> dependencies = ValidationUtils.getDependencies(graph, variable);\r
+ if(!graph.hasStatement(component) || !graph.hasStatement(component, l0.PartOf))\r
+ return Collections.emptyList();\r
\r
+ // Find all variables that are linked to component with arrows\r
+ Set<String> dependencies = ValidationUtils.getDependencies(graph, component);\r
Set<String> references = null;\r
+\r
+ // Find all references in equations of component\r
try {\r
- references = ValidationUtils.getReferences(graph, variable);\r
+ references = ValidationUtils.getReferences(graph, component);\r
} catch (SyntaxErrorException e) {\r
} catch (UnsupportedCharactersException e) {\r
} catch (UndefinedExpressionException e) {\r
}\r
- \r
- if(references != null && dependencies != null) {\r
- for(String reference : references) {\r
- if(!dependencies.contains(reference) && match(graph, existing, variable, getMissingLinkLabel(name, reference)) == null)\r
- return Boolean.FALSE;\r
- }\r
- }\r
\r
- if(dependencies != null) {\r
- for(String dependency : dependencies) {\r
- if(references == null || \r
- (!references.contains(dependency) && \r
- match(graph, existing, variable, getUnusedDependencyLabel(name, dependency)) == null))\r
- return Boolean.FALSE;\r
- }\r
- }\r
- \r
- Resource context;\r
- for(Resource exist : existing) {\r
- context = graph.getSingleObject(exist, ISSUE.HasIssueContext);\r
- if(!graph.hasStatement(context) || graph.hasStatement(context, l0.PartOf))\r
- return Boolean.FALSE;\r
- if(variable.equals(context) && graph.isInstanceOf(exist, sr.DependencyIssue)) {\r
- return Boolean.FALSE;\r
- }\r
- }\r
+ ArrayList<Issue> result = new ArrayList<Issue>();\r
\r
- return Boolean.TRUE;\r
- }\r
\r
- \r
- @SCLValue(type = "a -> b -> c -> d -> e -> f")\r
- public static Object dependencySynchronizer(Object _graph, Object _resource, Object _source, Object _model, Object _existing) throws DatabaseException {\r
-\r
- WriteGraph graph = (WriteGraph)_graph;\r
- Resource variable = (Resource)_resource;\r
- Resource model = (Resource)_model;\r
- Resource source = (Resource)_source;\r
- Collection<Resource> existing = (Collection<Resource>)_existing;\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- IssueResource ISSUE = IssueResource.getInstance(graph);\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- \r
- String name = graph.getRelatedValue(variable, L0.HasName, Bindings.STRING);\r
-\r
- Set<String> labels = new HashSet<String>();\r
- String label;\r
- \r
- Set<String> dependencies = ValidationUtils.getDependencies(graph, variable);\r
- Set<String> references = null;\r
- try {\r
- references = ValidationUtils.getReferences(graph, variable);\r
- } catch (SyntaxErrorException e) {\r
- } catch (UnsupportedCharactersException e) {\r
- } catch (UndefinedExpressionException e) {\r
- }\r
- \r
+ // Check that all references have corresponding arrows\r
if(references != null && dependencies != null) {\r
for(String reference : references) {\r
if(!dependencies.contains(reference)) {\r
- if(ValidationUtils.isReachable(graph, variable, reference)) {\r
- label = getMissingLinkLabel(name, reference);\r
- labels.add(label);\r
- if(match(graph, existing, variable, label) == null) {\r
- ValidationUtils.createIssue(graph, model, source, variable, label, ISSUE.Severity_Warning, sr.DependencyIssue);\r
- }\r
+ Resource variable = null;\r
+ if((variable = ValidationUtils.reach(graph, component, reference)) != null) {\r
+ result.add(new StandardIssue(sr.Validations_MissingLinkIssue, component, variable));\r
} else {\r
- label = getNoSuchVariableLabel(name, reference);\r
- labels.add(label);\r
- if(match(graph, existing, variable, label) == null) {\r
- ValidationUtils.createIssue(graph, model, source, variable, label, ISSUE.Severity_Error, sr.DependencyIssue);\r
- }\r
+ result.add(new NoSuchVariableIssue(sr.Validations_NoSuchVariableIssue, reference, component));\r
}\r
} \r
}\r
}\r
\r
+ // Check that all arrow dependencies are used in equations\r
if(dependencies != null) {\r
for(String dependency : dependencies) {\r
- label = getUnusedDependencyLabel(name, dependency);\r
if(references == null || !references.contains(dependency)) {\r
- labels.add(label);\r
- if(match(graph, existing, variable, label) == null) {\r
- ValidationUtils.createIssue(graph, model, source, variable, label, ISSUE.Severity_Warning, sr.DependencyIssue);\r
- }\r
+ Resource variable = ValidationUtils.reach(graph, component, dependency);\r
+ result.add(new StandardIssue(sr.Validations_UnusedDependencyIssue, component, variable));\r
}\r
}\r
}\r
\r
- Set<Resource> toBeRemoved = new HashSet<Resource>();\r
- Resource context;\r
- for(Resource exist : existing) {\r
- context = graph.getSingleObject(exist, ISSUE.HasIssueContext);\r
- if(!graph.hasStatement(context) || !graph.hasStatement(context, L0.PartOf))\r
- toBeRemoved.add(exist);\r
- if(graph.isInstanceOf(exist, sr.DependencyIssue) && variable.equals(context)) {\r
- String l = graph.getRelatedValue(exist, L0.HasLabel);\r
- if(!labels.contains(l))\r
- toBeRemoved.add(exist);\r
- }\r
- }\r
-\r
- for(Resource r : toBeRemoved) {\r
- ValidationUtils.removeIssue(graph, model, source, variable, r, existing);\r
- }\r
-\r
-\r
- return Boolean.TRUE;\r
-\r
+ return result;\r
}\r
\r
- @SCLValue(type = "a -> b -> c")\r
- public static Object dependencyBaseRealizationFunction(Object _graph, Object _model) throws DatabaseException {\r
- ReadGraph graph = (ReadGraph)_graph;\r
- Resource model = (Resource)_model;\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- if(graph.isInstanceOf(model, sr.SysdynModel))\r
- return graph.getSingleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
- else if (graph.isInheritedFrom(model, sr.Module))\r
- return graph.getSingleObject(model, StructuralResource2.getInstance(graph).IsDefinedBy);\r
- else return null;\r
\r
- }\r
\r
-\r
- private static Resource match(ReadGraph graph, Collection<Resource> existing, Resource variable, String description) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
+ /**\r
+ * Missing link description\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param converter\r
+ * @param issue Issue\r
+ * @return issue description\r
+ * @throws DatabaseException\r
+ */\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")\r
+ public static String missingLinkIssueDescription(ReadGraph graph, Resource converter, Variable issue) throws DatabaseException {\r
+ IssueResource ISSUE = IssueResource.getInstance(graph);\r
+ Resource issueResource = issue.getRepresents(graph);\r
+ Resource list = graph.getSingleObject(issueResource, ISSUE.DependencyIssueSource2_Issue_HasContexts);\r
+ List<Resource> contexts = ListUtils.toList(graph, list);\r
+ String result = "Missing a link to ";\r
+ if(contexts.size() > 0) {\r
+ Resource component = contexts.get(1);\r
+ String name = NameUtils.getSafeName(graph, component);\r
+ result = result + name;\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ /**\r
+ * Unused dependency description\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param converter\r
+ * @param issue Issue\r
+ * @return issue description\r
+ * @throws DatabaseException\r
+ */\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")\r
+ public static String unusedDependencyIssueDescription(ReadGraph graph, Resource converter, Variable issue) throws DatabaseException {\r
IssueResource ISSUE = IssueResource.getInstance(graph);\r
- for(Resource exist : existing) {\r
- Resource source = graph.getSingleObject(exist, ISSUE.HasIssueContext);\r
- String desc = graph.getRelatedValue(exist, L0.HasLabel);\r
-// if(source.equals(variable) && desc.startsWith(description.substring(0, description.lastIndexOf(" ")))) return exist;\r
- if(source.equals(variable) && desc.equals(description)) return exist;\r
+ Resource issueResource = issue.getRepresents(graph);\r
+ Resource list = graph.getSingleObject(issueResource, ISSUE.DependencyIssueSource2_Issue_HasContexts);\r
+ List<Resource> contexts = ListUtils.toList(graph, list);\r
+ String result = "Unused dependency: ";\r
+ if(contexts.size() > 0) {\r
+ Resource component = contexts.get(1);\r
+ String name = NameUtils.getSafeName(graph, component);\r
+ result = result + name;\r
}\r
- return null;\r
+ return result;\r
}\r
\r
+ /**\r
+ * No such variable description\r
+ * @param graph ReadGraph\r
+ * @param converter\r
+ * @param issue Issue\r
+ * @return issue description\r
+ * @throws DatabaseException\r
+ */\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")\r
+ public static String noSuchVariableIssueDescription(ReadGraph graph, Resource converter, Variable issue) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource issueResource = issue.getRepresents(graph);\r
+ String variable = graph.getPossibleRelatedValue(issueResource, sr.Validations_NoSuchVariableIssue_variableName, Bindings.STRING);\r
+ return "Refers to variable " + variable + " that does not exist";\r
+ }\r
}\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.validation;\r
\r
-import java.util.Collection;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
+import java.util.Collections;\r
+import java.util.List;\r
\r
-import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.issues.common.Issue;\r
+import org.simantics.issues.common.StandardIssue;\r
import org.simantics.issues.ontology.IssueResource;\r
-import org.simantics.layer0.Layer0;\r
import org.simantics.scl.reflection.annotations.SCLValue;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
\r
/**\r
*/\r
public class ExpressionIssueFunction {\r
\r
- private static String getSyntaxErrorLabel(String name) throws DatabaseException {\r
- return "Syntax error in " + name;\r
- }\r
- \r
- private static String getUnsupportedCharacterLabel(String name) throws DatabaseException {\r
- return "Unsupported character(s) in " + name;\r
- }\r
- \r
- private static String getUndefinedExpressionLabel(String name) throws DatabaseException {\r
- return "Undefined expression in " + name;\r
- }\r
+ private static String SYNTAX_ERROR = "Syntax error";\r
+ private static String UNSUPPORTED_CHARACTERS = "Unsupported characters";\r
+ private static String UNDEFINED_EXPRESSION = "Undefined expression";\r
\r
- @SCLValue(type = "a -> b -> c -> d")\r
- public static Object expressionValidator(Object _graph, Object _resource, Object _existing) throws DatabaseException {\r
- \r
- ReadGraph graph = (ReadGraph)_graph;\r
- Resource variable = (Resource)_resource;\r
- Collection<Resource> existing = (Collection<Resource>)_existing;\r
+ @SCLValue(type = "ReadGraph -> Resource -> [Issue]")\r
+ public static List<Issue> expressionValidator(ReadGraph graph, Resource component) throws DatabaseException {\r
\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
- IssueResource ISSUE = IssueResource.getInstance(graph);\r
- Layer0 l0 = Layer0.getInstance(graph);\r
\r
- if(!graph.isInstanceOf(variable, sr.IndependentVariable)) {\r
- return Boolean.TRUE;\r
+ if(!graph.isInstanceOf(component, sr.IndependentVariable)) {\r
+ return Collections.emptyList();\r
}\r
\r
- String name = graph.getRelatedValue(variable, l0.HasName, Bindings.STRING);\r
-System.out.println(name);\r
// Try if there are any errors while parsing the expressions\r
try {\r
- ValidationUtils.getReferences(graph, variable);\r
- } catch (SyntaxErrorException e) {\r
- if(match(graph, existing, variable, getSyntaxErrorLabel(name)) == null)\r
- return Boolean.FALSE;\r
- } catch (UnsupportedCharactersException e) {\r
- if(match(graph, existing, variable, getUnsupportedCharacterLabel(name)) == null)\r
- return Boolean.FALSE;\r
- } catch (UndefinedExpressionException e) {\r
- if(match(graph, existing, variable, getUndefinedExpressionLabel(name)) == null)\r
- return Boolean.FALSE;\r
- } \r
- \r
- Resource context;\r
- // There were no errors -> There should be no expression issues for this variable\r
- for(Resource exist : existing) {\r
- context = graph.getSingleObject(exist, ISSUE.HasIssueContext);\r
- if(!graph.hasStatement(context) || graph.hasStatement(context, l0.PartOf))\r
- return Boolean.FALSE;\r
- if(variable.equals(context) && graph.isInstanceOf(exist, sr.ExpressionIssue)) {\r
- return Boolean.FALSE;\r
- }\r
+ ValidationUtils.getReferences(graph, component);\r
+ } catch (Exception e) {\r
+ return Collections.<Issue>singletonList(new StandardIssue(sr.Validations_ExpressionIssue, component));\r
}\r
- \r
- \r
- return Boolean.TRUE;\r
+ return Collections.emptyList();\r
}\r
-\r
\r
- @SCLValue(type = "a -> b -> c -> d -> e -> f")\r
- public static Object expressionSynchronizer(Object _graph, Object _resource, Object _source, Object _model, Object _existing) throws DatabaseException {\r
- WriteGraph graph = (WriteGraph)_graph;\r
- Resource variable = (Resource)_resource;\r
- Resource model = (Resource)_model;\r
- Resource source = (Resource)_source;\r
- Collection<Resource> existing = (Collection<Resource>)_existing;\r
- Layer0 L0 = Layer0.getInstance(graph);\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> String")\r
+ public static String expressionIssueDescription(ReadGraph graph, Resource converter, Variable issue) throws DatabaseException {\r
IssueResource ISSUE = IssueResource.getInstance(graph);\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource issueResource = issue.getRepresents(graph);\r
+ Resource list = graph.getSingleObject(issueResource, ISSUE.DependencyIssueSource2_Issue_HasContexts);\r
+ List<Resource> contexts = ListUtils.toList(graph, list);\r
+ Resource component = contexts.get(0);\r
\r
- String name = graph.getRelatedValue(variable, L0.HasName, Bindings.STRING);\r
- String label = null; \r
- Resource issue = null;\r
+ // There should be an error\r
try {\r
- ValidationUtils.getReferences(graph, variable);\r
+ ValidationUtils.getReferences(graph, component);\r
} catch (SyntaxErrorException e) {\r
- label = getSyntaxErrorLabel(name);\r
- if(match(graph, existing, variable, label) == null)\r
- issue = ValidationUtils.createIssue(graph, model, source, variable, label, ISSUE.Severity_Error, sr.ExpressionIssue);\r
+ return SYNTAX_ERROR;\r
} catch (UnsupportedCharactersException e) {\r
- label = getUnsupportedCharacterLabel(name);\r
- if(match(graph, existing, variable, label) == null)\r
- issue = ValidationUtils.createIssue(graph, model, source, variable, label, ISSUE.Severity_Error, sr.ExpressionIssue);\r
+ return UNSUPPORTED_CHARACTERS;\r
} catch (UndefinedExpressionException e) {\r
- label = getUndefinedExpressionLabel(name);\r
- if(match(graph, existing, variable, label) == null)\r
- issue = ValidationUtils.createIssue(graph, model, source, variable, label, ISSUE.Severity_Error, sr.ExpressionIssue);\r
- }\r
- \r
- Resource context;\r
- Set<Resource> toBeRemoved = new HashSet<Resource>();\r
- for(Resource exist : existing) {\r
- context = graph.getSingleObject(exist, ISSUE.HasIssueContext);\r
- if(!graph.hasStatement(context) || !graph.hasStatement(context, L0.PartOf))\r
- toBeRemoved.add(exist);\r
- else if(!exist.equals(issue) && graph.isInstanceOf(exist, sr.ExpressionIssue) && variable.equals(context)) {\r
- String l = graph.getRelatedValue(exist, L0.HasLabel);\r
- if(!l.equals(label)) {\r
- toBeRemoved.add(exist);\r
- }\r
- }\r
- }\r
- \r
- for(Resource r : toBeRemoved) {\r
- ValidationUtils.removeIssue(graph, model, source, variable, r, existing);\r
- }\r
- \r
- return Boolean.TRUE;\r
- }\r
-\r
-\r
- @SCLValue(type = "a -> b -> c")\r
- public static Object expressionBaseRealizationFunction(Object _graph, Object _model) throws DatabaseException {\r
- ReadGraph graph = (ReadGraph)_graph;\r
- Resource model = (Resource)_model;\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- if(graph.isInstanceOf(model, sr.SysdynModel))\r
- return graph.getSingleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
- else if (graph.isInheritedFrom(model, sr.Module)) {\r
- return graph.getSingleObject(model, StructuralResource2.getInstance(graph).IsDefinedBy);\r
- } else return null;\r
- }\r
- \r
- \r
- private static Resource match(ReadGraph graph, Collection<Resource> existing, Resource variable, String description) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- IssueResource ISSUE = IssueResource.getInstance(graph);\r
- for(Resource exist : existing) {\r
- Resource source = graph.getSingleObject(exist, ISSUE.HasIssueContext);\r
- String desc = graph.getRelatedValue(exist, L0.HasLabel);\r
- if(source.equals(variable) && desc.equals(description)) return exist;\r
- }\r
- return null;\r
+ return UNDEFINED_EXPRESSION;\r
+ } \r
+ return "Erroneus error";\r
}\r
\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.validation;\r
+\r
+import java.text.DateFormat;\r
+import java.text.SimpleDateFormat;\r
+import java.util.Arrays;\r
+import java.util.Calendar;\r
+import java.util.UUID;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.issues.common.StandardIssue;\r
+import org.simantics.issues.ontology.IssueResource;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+/**\r
+ * Issue class for NoSuchVariableIssues. Extended from StandardIssue to allow\r
+ * a string parameter containing the name of the variable in an equation that\r
+ * does not correspond to any existing and reachable variable.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class NoSuchVariableIssue extends StandardIssue {\r
+\r
+ public String missingVariable;\r
+ \r
+ public NoSuchVariableIssue(Resource type, String missingVariable, Resource ... contexts) {\r
+ super(type, contexts);\r
+ this.missingVariable = missingVariable;\r
+ }\r
+ \r
+ /**\r
+ * Same as in StandardIssue. Added Validations_NoSuchVariableIssue_variableName.\r
+ */\r
+ @Override\r
+ public void write(WriteGraph graph, Resource model, Resource source) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ IssueResource IR = IssueResource.getInstance(graph);\r
+ Resource issue = graph.newResource();\r
+ graph.claim(issue, L0.InstanceOf, null, type);\r
+ graph.claimLiteral(issue, L0.HasName, UUID.randomUUID().toString(), Bindings.STRING);\r
+ graph.claim(issue, IR.DependencyIssueSource2_Issue_HasContexts, ListUtils.create(graph, L0.List, contexts));\r
+ DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");\r
+ String created = format.format(Calendar.getInstance().getTime());\r
+ graph.claimLiteral(issue, IR.HasCreationTime, created, Bindings.STRING);\r
+ graph.claim(source, IR.Manages, issue);\r
+ graph.claim(model, L0.ConsistsOf, issue);\r
+ \r
+ // Modification to standard issue:\r
+ graph.claimLiteral(issue, SysdynResource.getInstance(graph).Validations_NoSuchVariableIssue_variableName, this.missingVariable, Bindings.STRING);\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return Arrays.toString(contexts) + " + missing: " + missingVariable; \r
+ }\r
+\r
+}\r
package org.simantics.sysdyn.ui.validation;\r
\r
import java.io.StringReader;\r
-import java.text.DateFormat;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Calendar;\r
import java.util.Collection;\r
import java.util.HashSet;\r
import java.util.List;\r
-import java.util.UUID;\r
\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.common.utils.OrderedSetUtils;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.RemoverUtil;\r
-import org.simantics.issues.ontology.IssueResource;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
import org.simantics.sysdyn.expressionParser.ParseException;\r
import org.simantics.sysdyn.expressionParser.TokenMgrError;\r
\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
public class ValidationUtils {\r
\r
- public static void removeIssue(WriteGraph graph, Resource model, Resource source, Resource variable, Resource issue, Collection<Resource> existing) throws DatabaseException {\r
- graph.deny(issue, Layer0.getInstance(graph).PartOf);\r
- graph.deny(source, IssueResource.getInstance(graph).Manages, issue);\r
- RemoverUtil.remove(graph, issue);\r
- existing.remove(issue);\r
- }\r
- \r
- public static Resource createIssue(WriteGraph graph, Resource model, Resource source, Resource variable, String label) throws DatabaseException {\r
- return createIssue(graph, model, source, variable, label, IssueResource.getInstance(graph).Severity_Error);\r
- }\r
-\r
- \r
- public static Resource createIssue(WriteGraph graph, Resource model, Resource source, Resource variable, String label, Resource severity) throws DatabaseException {\r
- return createIssue(graph, model, source, variable, label, severity, SysdynResource.getInstance(graph).SysdynIssue);\r
- }\r
-\r
- \r
- public static Resource createIssue(WriteGraph graph, Resource model, Resource source, Resource variable, String label, Resource severity, Resource type) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- IssueResource ISSUE = IssueResource.getInstance(graph);\r
-\r
- Resource issue = graph.newResource();\r
- graph.claim(issue, L0.InstanceOf, null, type);\r
- graph.claim(issue, ISSUE.HasIssueContext, null, variable);\r
- graph.claim(issue, ISSUE.HasSeverity, severity);\r
- graph.claimLiteral(issue, L0.HasLabel, label, Bindings.STRING);\r
- graph.claimLiteral(issue, L0.HasName, UUID.randomUUID().toString(), Bindings.STRING);\r
- DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");\r
- String created = format.format(Calendar.getInstance().getTime());\r
- graph.claimLiteral(issue, ISSUE.HasCreationTime, created, Bindings.STRING);\r
- graph.claim(source, ISSUE.Manages, issue);\r
- graph.claim(model, L0.ConsistsOf, issue); \r
- return issue;\r
- }\r
- \r
+ /**\r
+ * Find all variables that are referred to in the expressions of variable r\r
+ * @param graph ReadGraph\r
+ * @param r Variable resource\r
+ * @return All names of the variables that are referred to in the expressions of r\r
+ * @throws DatabaseException\r
+ * @throws SyntaxErrorException\r
+ * @throws UnsupportedCharactersException\r
+ * @throws UndefinedExpressionException\r
+ */\r
public static HashSet<String> getReferences(ReadGraph graph, Resource r) throws DatabaseException, SyntaxErrorException, UnsupportedCharactersException, UndefinedExpressionException {\r
HashSet<String> references = new HashSet<String>();\r
ExpressionParser parser = new ExpressionParser(new StringReader(""));\r
return references;\r
}\r
\r
+ /**\r
+ * Get all expressions of a variable r\r
+ * @param graph ReadGraph\r
+ * @param r Variable with expressions\r
+ * @return List of expression (resources)\r
+ * @throws DatabaseException\r
+ */\r
private static List<Resource> getExpressions(ReadGraph graph, Resource r) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Resource hasExpressions = graph.getPossibleObject(r, sr.HasExpressions);\r
* @throws DatabaseException\r
*/\r
public static boolean isReachable(ReadGraph graph, Resource variable, String reference) throws DatabaseException {\r
+ if(reach(graph, variable, reference) != null)\r
+ return true;\r
+ else \r
+ return false;\r
+ }\r
+ \r
+ /**\r
+ * Find a resource starting from variable and using reference path\r
+ * \r
+ * @param graph ReadGraph\r
+ * @param variable starting point\r
+ * @param reference path to another variable\r
+ * @return found variable or null\r
+ * @throws DatabaseException\r
+ */\r
+ public static Resource reach(ReadGraph graph, Resource variable, String reference) throws DatabaseException {\r
Layer0 l0 = Layer0.getInstance(graph);\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Resource configuration = graph.getSingleObject(variable, l0.PartOf);\r
for(Resource var : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Variable))) {\r
varName = graph.getRelatedValue(var, l0.HasName, Bindings.STRING);\r
if(varName != null && reference.equals(varName))\r
- return true;\r
+ return var;\r
}\r
- return false;\r
+ return null;\r
}\r
+ \r
}\r