<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dev.simantics.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Antti+Villberg</id>
	<title>Developer Documents - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://dev.simantics.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Antti+Villberg"/>
	<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php/Special:Contributions/Antti_Villberg"/>
	<updated>2026-04-05T21:16:14Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Concept_Versioning&amp;diff=3066</id>
		<title>Concept Versioning</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Concept_Versioning&amp;diff=3066"/>
		<updated>2013-11-01T13:55:47Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: Created page with &amp;quot;= Basic concepts =  == Rationale ==  Many concepts stored in the Simantics database evolve through modelling projects. Each time a concept gets changed a new version of the conce...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Basic concepts =&lt;br /&gt;
&lt;br /&gt;
== Rationale ==&lt;br /&gt;
&lt;br /&gt;
Many concepts stored in the Simantics database evolve through modelling projects. Each time a concept gets changed a new version of the concepts gets created. The Simantics database provides many mechanisms for dealing with such changes&lt;br /&gt;
&lt;br /&gt;
* The semantic database stores complete &#039;&#039;modification history&#039;&#039; of any concept in the database.&lt;br /&gt;
* The shared team repository stores selected database snapshots, &#039;&#039;revisions&#039;&#039;.&lt;br /&gt;
* &#039;&#039;Concept versioning&#039;&#039; can be used to represent multiple versions of a &#039;&#039;logical&#039;&#039; concept. These versions can co-exist in the same database snapshot.&lt;br /&gt;
&lt;br /&gt;
The database client has only limited support for browsing the database modification history and remote revisions also need to be imported into the database for processing. With concept versions the user can apply the semantic modelling framework.&lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
&lt;br /&gt;
* Management of shared modelling concepts using export/import or shared repository&lt;br /&gt;
* Controlled transitioning between concept versions in model migration&lt;br /&gt;
* Full-featured inspection of old versions&lt;br /&gt;
* Version comparison analysis tools&lt;br /&gt;
&lt;br /&gt;
= Technical details =&lt;br /&gt;
&lt;br /&gt;
* A concept version can be attached to all resources with L0.HasName&lt;br /&gt;
* The version identifier is textual and is encoded into the resource name as &amp;lt;logical name&amp;gt;@&amp;lt;version identifier&amp;gt;&lt;br /&gt;
* Version identifiers have a complete ordering defined by &#039;&#039;alphanumeric sorting&#039;&#039;&lt;br /&gt;
* A version identifier in the concept hierarchy (L0.ConsistsOf) effectively creates a version of the complete sub-tree of the concept&lt;br /&gt;
* User interfaces may use hiding and grouping to visualize the different versions to the user&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
= Open Questions =&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=3065</id>
		<title>Simantics Developer Documentation</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=3065"/>
		<updated>2013-11-01T13:54:05Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Model Development */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
[[image:Simantics_logo_pile_01.png|right|border|400px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Simantics&#039;&#039;&#039; is a software platform for modelling and simulation. The system has client-server architecture with a semantic ontology-based modelling database and Eclipse framework -based client software with plug-in interface. The Simantics platform and many of its components are open source under [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License (EPL)].&lt;br /&gt;
&lt;br /&gt;
The philosophy of the Simantics platform is to offer an open, high level application platform on which different computational tools can be easily integrated to form a common environment for modelling and simulation. The platform includes several modelling tools, so-called editors, for e.g. 2D graph-like hierarchical model composition and semantic graph browsing.&lt;br /&gt;
&lt;br /&gt;
One of the biggest innovations in the Simantics platform is the semantic modelling approach itself and high-level ontology tools. The semantic database, i.e. triplestore, on the server side enables high performance data management and arbitrary mappings of data. This enables e.g. efficient mapping of simulation and measurement data to the model configuration and its visualisation.&lt;br /&gt;
&lt;br /&gt;
The Simantics development and maintenance process is built to be solid and scalable from the very beginning. The objective is to aim far to the future what comes to requirements for scalability, usability, and reliability.&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;Simantics Developer Documentation&#039;&#039; is targeted to programmers and software developers developing either the platform itself or additional plug-ins to be used with or on the platform. The [[userwiki:Main_Page|Simantics End User Documentation]] complements to documentation for the Simantics platform offering overview and detailed information about the platform from the user&#039;s point of view. The [https://www.simantics.org/simantics Simantics] website is the source of information for the Simantics project and related subjects[[Tutorials|.]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:white;&amp;quot;&amp;gt;Disclaimer Warning: This site may cause narcolepsia in some readers. Consult your doctor if sensitive to boredom.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;75%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
* [[Glossary]]&lt;br /&gt;
* [[Introduction to Simantics Architecture]]&lt;br /&gt;
* [[Roadmap]]&lt;br /&gt;
* [[Data View]]&lt;br /&gt;
* [[Component View]]&lt;br /&gt;
* [[Licensing|Licensing]]&lt;br /&gt;
* [[Useful Links]]&lt;br /&gt;
* [[Platform development process]]&lt;br /&gt;
&amp;lt;!--* [[Simantics Specifications|Specifications]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Documents ===&lt;br /&gt;
&lt;br /&gt;
* [[Quick Development Environment Setup|Quick Development Environment Setup Guide]]&lt;br /&gt;
* [[Development Environment Setup Guide|Old Development Environment Setup Guide]]&lt;br /&gt;
* [[Target Platform]]&lt;br /&gt;
* [[Development Practices]]&lt;br /&gt;
* [[Internalization]]&lt;br /&gt;
* [[Update Site]]&lt;br /&gt;
* [[Coding Convention]]&lt;br /&gt;
* [[Tools]]&lt;br /&gt;
* [[Testing]]&lt;br /&gt;
* [[FAQ]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Ontology Development ===&lt;br /&gt;
&lt;br /&gt;
* [[:Media:Layer0.pdf|Layer0.pdf]] ([[:File:Layer0.pdf|log]])&lt;br /&gt;
* [[Graph Compiler]]&lt;br /&gt;
* [[Transferable Graph]]&lt;br /&gt;
* [[Binary Container Format]]&lt;br /&gt;
* [[Graph File Format]]&lt;br /&gt;
* [[Version Migration]]&lt;br /&gt;
* [[Tutorial: Ontology Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Database Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Interface summary]]&lt;br /&gt;
* [[Tutorial: Quickstart]]&lt;br /&gt;
* [[Tutorial: Database Development]]&lt;br /&gt;
* [[Resource Adaptation]]&lt;br /&gt;
* [[Resource Serialization]]&lt;br /&gt;
* [[Inverse Relations]]&lt;br /&gt;
* [[Virtual Graphs]]&lt;br /&gt;
* [[Functions]]&lt;br /&gt;
* [[Procedural Values]]&lt;br /&gt;
* [[Variable]]&lt;br /&gt;
* [[Undo Mechanism]]&lt;br /&gt;
* [[Team Features]]&lt;br /&gt;
* [[Subgraph Extents]]&lt;br /&gt;
* [[Database Testing]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Data management &amp;amp; Experiment Control ===&lt;br /&gt;
&lt;br /&gt;
* [[Databoard Specification]]&lt;br /&gt;
* [[Databoard Developer Manual|Databoard Java Manual]]&lt;br /&gt;
* [[Experiment Control]]&lt;br /&gt;
* [[Dataflows]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== UI Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Org.simantics.browsing.ui_Manual|Browser Manual]]&lt;br /&gt;
* [[org.simantics.browsing.ui.feature|Browser Component]]&lt;br /&gt;
* [[Org.simantics.scenegraph.loader|Scene Graph Loader]]&lt;br /&gt;
* [[Org.simantics.message|Messages]]&lt;br /&gt;
* [[Org.simantics.views|Modelled Views]]&lt;br /&gt;
* [[Org.simantics.document|Documents]]&lt;br /&gt;
* [[Selection View]]&lt;br /&gt;
|}&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Simantics Constraint Language===&lt;br /&gt;
&lt;br /&gt;
* [[SCL Compiler]]&lt;br /&gt;
* [[SCL Tutorial]]&lt;br /&gt;
* [[SCL Types]]&lt;br /&gt;
&amp;lt;!--* [[SCL_Language|SCL Language]] --&amp;gt;&lt;br /&gt;
&amp;lt;!--* [https://www.simantics.org/wiki/index.php/Org.simantics.scl_Compiler SCL Compiler]--&amp;gt;&lt;br /&gt;
* [[Org.simantics.objmap_Manual|Object Map Manual]]&lt;br /&gt;
* [[SCL Registry]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Model Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Structural Ontology]]&lt;br /&gt;
* [[Users and Roles]]&lt;br /&gt;
* [[Models]]&lt;br /&gt;
* [[Concept Versioning]]&lt;br /&gt;
* [[Tutorial: Model Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Project Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Project Management Conceptual Model]]&lt;br /&gt;
* [[Project Development]]&lt;br /&gt;
* [[Tutorial: Project Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Diagram Development ===&lt;br /&gt;
&lt;br /&gt;
* [[2D Ontologies]]&lt;br /&gt;
* [[org.simantics.diagram|Diagram]]&lt;br /&gt;
* [[org.simantics.scenegraph|Scene graph]]&lt;br /&gt;
* [[Diagram connections]]&lt;br /&gt;
* [[Tutorial: Diagram Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Issue Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Issue subsystem general description]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
-----&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=3064</id>
		<title>Simantics Developer Documentation</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=3064"/>
		<updated>2013-11-01T13:53:58Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Model Development */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
[[image:Simantics_logo_pile_01.png|right|border|400px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Simantics&#039;&#039;&#039; is a software platform for modelling and simulation. The system has client-server architecture with a semantic ontology-based modelling database and Eclipse framework -based client software with plug-in interface. The Simantics platform and many of its components are open source under [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License (EPL)].&lt;br /&gt;
&lt;br /&gt;
The philosophy of the Simantics platform is to offer an open, high level application platform on which different computational tools can be easily integrated to form a common environment for modelling and simulation. The platform includes several modelling tools, so-called editors, for e.g. 2D graph-like hierarchical model composition and semantic graph browsing.&lt;br /&gt;
&lt;br /&gt;
One of the biggest innovations in the Simantics platform is the semantic modelling approach itself and high-level ontology tools. The semantic database, i.e. triplestore, on the server side enables high performance data management and arbitrary mappings of data. This enables e.g. efficient mapping of simulation and measurement data to the model configuration and its visualisation.&lt;br /&gt;
&lt;br /&gt;
The Simantics development and maintenance process is built to be solid and scalable from the very beginning. The objective is to aim far to the future what comes to requirements for scalability, usability, and reliability.&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;Simantics Developer Documentation&#039;&#039; is targeted to programmers and software developers developing either the platform itself or additional plug-ins to be used with or on the platform. The [[userwiki:Main_Page|Simantics End User Documentation]] complements to documentation for the Simantics platform offering overview and detailed information about the platform from the user&#039;s point of view. The [https://www.simantics.org/simantics Simantics] website is the source of information for the Simantics project and related subjects[[Tutorials|.]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:white;&amp;quot;&amp;gt;Disclaimer Warning: This site may cause narcolepsia in some readers. Consult your doctor if sensitive to boredom.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;75%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
* [[Glossary]]&lt;br /&gt;
* [[Introduction to Simantics Architecture]]&lt;br /&gt;
* [[Roadmap]]&lt;br /&gt;
* [[Data View]]&lt;br /&gt;
* [[Component View]]&lt;br /&gt;
* [[Licensing|Licensing]]&lt;br /&gt;
* [[Useful Links]]&lt;br /&gt;
* [[Platform development process]]&lt;br /&gt;
&amp;lt;!--* [[Simantics Specifications|Specifications]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Documents ===&lt;br /&gt;
&lt;br /&gt;
* [[Quick Development Environment Setup|Quick Development Environment Setup Guide]]&lt;br /&gt;
* [[Development Environment Setup Guide|Old Development Environment Setup Guide]]&lt;br /&gt;
* [[Target Platform]]&lt;br /&gt;
* [[Development Practices]]&lt;br /&gt;
* [[Internalization]]&lt;br /&gt;
* [[Update Site]]&lt;br /&gt;
* [[Coding Convention]]&lt;br /&gt;
* [[Tools]]&lt;br /&gt;
* [[Testing]]&lt;br /&gt;
* [[FAQ]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Ontology Development ===&lt;br /&gt;
&lt;br /&gt;
* [[:Media:Layer0.pdf|Layer0.pdf]] ([[:File:Layer0.pdf|log]])&lt;br /&gt;
* [[Graph Compiler]]&lt;br /&gt;
* [[Transferable Graph]]&lt;br /&gt;
* [[Binary Container Format]]&lt;br /&gt;
* [[Graph File Format]]&lt;br /&gt;
* [[Version Migration]]&lt;br /&gt;
* [[Tutorial: Ontology Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Database Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Interface summary]]&lt;br /&gt;
* [[Tutorial: Quickstart]]&lt;br /&gt;
* [[Tutorial: Database Development]]&lt;br /&gt;
* [[Resource Adaptation]]&lt;br /&gt;
* [[Resource Serialization]]&lt;br /&gt;
* [[Inverse Relations]]&lt;br /&gt;
* [[Virtual Graphs]]&lt;br /&gt;
* [[Functions]]&lt;br /&gt;
* [[Procedural Values]]&lt;br /&gt;
* [[Variable]]&lt;br /&gt;
* [[Undo Mechanism]]&lt;br /&gt;
* [[Team Features]]&lt;br /&gt;
* [[Subgraph Extents]]&lt;br /&gt;
* [[Database Testing]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Data management &amp;amp; Experiment Control ===&lt;br /&gt;
&lt;br /&gt;
* [[Databoard Specification]]&lt;br /&gt;
* [[Databoard Developer Manual|Databoard Java Manual]]&lt;br /&gt;
* [[Experiment Control]]&lt;br /&gt;
* [[Dataflows]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== UI Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Org.simantics.browsing.ui_Manual|Browser Manual]]&lt;br /&gt;
* [[org.simantics.browsing.ui.feature|Browser Component]]&lt;br /&gt;
* [[Org.simantics.scenegraph.loader|Scene Graph Loader]]&lt;br /&gt;
* [[Org.simantics.message|Messages]]&lt;br /&gt;
* [[Org.simantics.views|Modelled Views]]&lt;br /&gt;
* [[Org.simantics.document|Documents]]&lt;br /&gt;
* [[Selection View]]&lt;br /&gt;
|}&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Simantics Constraint Language===&lt;br /&gt;
&lt;br /&gt;
* [[SCL Compiler]]&lt;br /&gt;
* [[SCL Tutorial]]&lt;br /&gt;
* [[SCL Types]]&lt;br /&gt;
&amp;lt;!--* [[SCL_Language|SCL Language]] --&amp;gt;&lt;br /&gt;
&amp;lt;!--* [https://www.simantics.org/wiki/index.php/Org.simantics.scl_Compiler SCL Compiler]--&amp;gt;&lt;br /&gt;
* [[Org.simantics.objmap_Manual|Object Map Manual]]&lt;br /&gt;
* [[SCL Registry]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Model Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Structural Ontology]]&lt;br /&gt;
* [[Users and Roles]]&lt;br /&gt;
* [[Models]]&lt;br /&gt;
* [[ConceptVersioning]]&lt;br /&gt;
* [[Tutorial: Model Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Project Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Project Management Conceptual Model]]&lt;br /&gt;
* [[Project Development]]&lt;br /&gt;
* [[Tutorial: Project Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Diagram Development ===&lt;br /&gt;
&lt;br /&gt;
* [[2D Ontologies]]&lt;br /&gt;
* [[org.simantics.diagram|Diagram]]&lt;br /&gt;
* [[org.simantics.scenegraph|Scene graph]]&lt;br /&gt;
* [[Diagram connections]]&lt;br /&gt;
* [[Tutorial: Diagram Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Issue Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Issue subsystem general description]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
-----&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=3063</id>
		<title>Simantics Developer Documentation</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=3063"/>
		<updated>2013-11-01T12:49:08Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Model Development */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
[[image:Simantics_logo_pile_01.png|right|border|400px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Simantics&#039;&#039;&#039; is a software platform for modelling and simulation. The system has client-server architecture with a semantic ontology-based modelling database and Eclipse framework -based client software with plug-in interface. The Simantics platform and many of its components are open source under [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License (EPL)].&lt;br /&gt;
&lt;br /&gt;
The philosophy of the Simantics platform is to offer an open, high level application platform on which different computational tools can be easily integrated to form a common environment for modelling and simulation. The platform includes several modelling tools, so-called editors, for e.g. 2D graph-like hierarchical model composition and semantic graph browsing.&lt;br /&gt;
&lt;br /&gt;
One of the biggest innovations in the Simantics platform is the semantic modelling approach itself and high-level ontology tools. The semantic database, i.e. triplestore, on the server side enables high performance data management and arbitrary mappings of data. This enables e.g. efficient mapping of simulation and measurement data to the model configuration and its visualisation.&lt;br /&gt;
&lt;br /&gt;
The Simantics development and maintenance process is built to be solid and scalable from the very beginning. The objective is to aim far to the future what comes to requirements for scalability, usability, and reliability.&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;Simantics Developer Documentation&#039;&#039; is targeted to programmers and software developers developing either the platform itself or additional plug-ins to be used with or on the platform. The [[userwiki:Main_Page|Simantics End User Documentation]] complements to documentation for the Simantics platform offering overview and detailed information about the platform from the user&#039;s point of view. The [https://www.simantics.org/simantics Simantics] website is the source of information for the Simantics project and related subjects[[Tutorials|.]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:white;&amp;quot;&amp;gt;Disclaimer Warning: This site may cause narcolepsia in some readers. Consult your doctor if sensitive to boredom.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;75%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
* [[Glossary]]&lt;br /&gt;
* [[Introduction to Simantics Architecture]]&lt;br /&gt;
* [[Roadmap]]&lt;br /&gt;
* [[Data View]]&lt;br /&gt;
* [[Component View]]&lt;br /&gt;
* [[Licensing|Licensing]]&lt;br /&gt;
* [[Useful Links]]&lt;br /&gt;
* [[Platform development process]]&lt;br /&gt;
&amp;lt;!--* [[Simantics Specifications|Specifications]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Documents ===&lt;br /&gt;
&lt;br /&gt;
* [[Quick Development Environment Setup|Quick Development Environment Setup Guide]]&lt;br /&gt;
* [[Development Environment Setup Guide|Old Development Environment Setup Guide]]&lt;br /&gt;
* [[Target Platform]]&lt;br /&gt;
* [[Development Practices]]&lt;br /&gt;
* [[Internalization]]&lt;br /&gt;
* [[Update Site]]&lt;br /&gt;
* [[Coding Convention]]&lt;br /&gt;
* [[Tools]]&lt;br /&gt;
* [[Testing]]&lt;br /&gt;
* [[FAQ]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Ontology Development ===&lt;br /&gt;
&lt;br /&gt;
* [[:Media:Layer0.pdf|Layer0.pdf]] ([[:File:Layer0.pdf|log]])&lt;br /&gt;
* [[Graph Compiler]]&lt;br /&gt;
* [[Transferable Graph]]&lt;br /&gt;
* [[Binary Container Format]]&lt;br /&gt;
* [[Graph File Format]]&lt;br /&gt;
* [[Version Migration]]&lt;br /&gt;
* [[Tutorial: Ontology Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Database Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Interface summary]]&lt;br /&gt;
* [[Tutorial: Quickstart]]&lt;br /&gt;
* [[Tutorial: Database Development]]&lt;br /&gt;
* [[Resource Adaptation]]&lt;br /&gt;
* [[Resource Serialization]]&lt;br /&gt;
* [[Inverse Relations]]&lt;br /&gt;
* [[Virtual Graphs]]&lt;br /&gt;
* [[Functions]]&lt;br /&gt;
* [[Procedural Values]]&lt;br /&gt;
* [[Variable]]&lt;br /&gt;
* [[Undo Mechanism]]&lt;br /&gt;
* [[Team Features]]&lt;br /&gt;
* [[Subgraph Extents]]&lt;br /&gt;
* [[Database Testing]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Data management &amp;amp; Experiment Control ===&lt;br /&gt;
&lt;br /&gt;
* [[Databoard Specification]]&lt;br /&gt;
* [[Databoard Developer Manual|Databoard Java Manual]]&lt;br /&gt;
* [[Experiment Control]]&lt;br /&gt;
* [[Dataflows]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== UI Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Org.simantics.browsing.ui_Manual|Browser Manual]]&lt;br /&gt;
* [[org.simantics.browsing.ui.feature|Browser Component]]&lt;br /&gt;
* [[Org.simantics.scenegraph.loader|Scene Graph Loader]]&lt;br /&gt;
* [[Org.simantics.message|Messages]]&lt;br /&gt;
* [[Org.simantics.views|Modelled Views]]&lt;br /&gt;
* [[Org.simantics.document|Documents]]&lt;br /&gt;
* [[Selection View]]&lt;br /&gt;
|}&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Simantics Constraint Language===&lt;br /&gt;
&lt;br /&gt;
* [[SCL Compiler]]&lt;br /&gt;
* [[SCL Tutorial]]&lt;br /&gt;
* [[SCL Types]]&lt;br /&gt;
&amp;lt;!--* [[SCL_Language|SCL Language]] --&amp;gt;&lt;br /&gt;
&amp;lt;!--* [https://www.simantics.org/wiki/index.php/Org.simantics.scl_Compiler SCL Compiler]--&amp;gt;&lt;br /&gt;
* [[Org.simantics.objmap_Manual|Object Map Manual]]&lt;br /&gt;
* [[SCL Registry]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Model Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Structural Ontology]]&lt;br /&gt;
* [[Users and Roles]]&lt;br /&gt;
* [[Models]]&lt;br /&gt;
* [[Resource Versioning]]&lt;br /&gt;
* [[Tutorial: Model Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Project Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Project Management Conceptual Model]]&lt;br /&gt;
* [[Project Development]]&lt;br /&gt;
* [[Tutorial: Project Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Diagram Development ===&lt;br /&gt;
&lt;br /&gt;
* [[2D Ontologies]]&lt;br /&gt;
* [[org.simantics.diagram|Diagram]]&lt;br /&gt;
* [[org.simantics.scenegraph|Scene graph]]&lt;br /&gt;
* [[Diagram connections]]&lt;br /&gt;
* [[Tutorial: Diagram Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Issue Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Issue subsystem general description]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
-----&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Models&amp;diff=3031</id>
		<title>Models</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Models&amp;diff=3031"/>
		<updated>2013-06-14T07:23:13Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Questions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See old documentation: [[Models Deprecated]].&lt;br /&gt;
&lt;br /&gt;
= Basic concepts =&lt;br /&gt;
&lt;br /&gt;
== Entities ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Model&#039;&#039; is a structure that is created in purpose of analysing some existing or planned system. It is usually tied to a particular method of analysis such as dynamic or steady-state simulation or model-checking. What is inside the model depends strongly on the analysis method. Model is however always a unit that can be exported from the Simantics workspace and imported back to some other workspace.&lt;br /&gt;
&lt;br /&gt;
Model contains one or more &#039;&#039;configurations&#039;&#039;. Configuration is a description of the system being modelled. Usually (always?) one of the configurations is the root configuration describing the most aspects of the system and other configurations specify some deviations from it. A configuration can be parametrized. Multiple configurations are used to maintain many different but related designs (cases) of the system within the same model or to parametrize the configuration so that optimization, sensitivity analysis or similar method can be applied to the system.&lt;br /&gt;
&lt;br /&gt;
The main purpose of creating a model of a system is to apply some analysis to it. We call these analyses &#039;&#039;experiments&#039;&#039;. An experiment points to a certain configuration but may also contain an additional specification of how the analysis is executed such as simulation sequence, list of subscribed variables, simulation method used, etc.. &lt;br /&gt;
&lt;br /&gt;
Each individual execution of the experiment is a &#039;&#039;run&#039;&#039;. What a single run generates, depends on the analysis method and the experiment specification. Typical artifacts produced include:&lt;br /&gt;
* &#039;&#039;State&#039;&#039; is an assignment of values to the properties of the components in the configuration&lt;br /&gt;
* &#039;&#039;History&#039;&#039; is an assignment of time series to the properties&lt;br /&gt;
Additionally the run can be interactive so that the current state being simulated can be accessed and even modified during the simulation.&lt;br /&gt;
&lt;br /&gt;
States and histories can be also independent entities in the model that are not produced by experiment runs. They can be used as an input in the experiments.&lt;br /&gt;
&lt;br /&gt;
Multiple runs can be executed in parallel, some in remote machines. One of the runs (states, or histories?) is the &#039;&#039;active experiment&#039;&#039; whose state is visualized in the UI.&lt;br /&gt;
&lt;br /&gt;
Some analysis methods have a capability of storing a snapshot of the state of the analysis algorithm. We call these snapshots &#039;&#039;IC&#039;&#039;s. An experiment may specify IC to be used to initialize the analysis. IC and state are slightly overlapping concepts. The main difference between them is that IC contains a complete state of the analysis algorithm including the internal state not seen by users in a representation that is optimized for fast initialization of the algorithm. On the other hand a state contains only properties of components in the configuration, it is optimized for efficient browsing and may be partial (not assigning value to all possible properties).&lt;br /&gt;
&lt;br /&gt;
== Analogy ==&lt;br /&gt;
&lt;br /&gt;
Consider crash testing of cars. The configuration describes the car and possibly how the crash test dummy is positioned in it. There may be many different configurations with varying safety equipments and we may for example parametrize the size of the airbag in order to find the size that minimizes head injuries. The experiment describes which configuration is used and how the crash test is executed (for example crashing speed). It also describes the variables that are measured during the crash. A run is one crash test. Each run produces time series of all variables that were measured, maybe a high speed video of the crash and the final state of the car and the dummy after the crash.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
&lt;br /&gt;
We describe here the basic operations involving models and experiments. They are not necessarily the same operations that are presented to user in UI but building blocks with smaller granularity. In particularly, we consider starting an experiment an explicit operation while some this may be an automatic operation in UI. If the analysis is fast enough, even simulation results can be updated automatically when the user modifies the configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Running an experiment&#039;&#039; creates a new run starting the corresponding runtime entities. This involves:&lt;br /&gt;
* Start the actual analysis algorithm (if a remote server is used, this may include waiting that computational resource become available)&lt;br /&gt;
* Initialize the algorithm state. This can be done in many ways:&lt;br /&gt;
** Write the configuration in a form understood by the algorithm (for example Modelica code)&lt;br /&gt;
** Load previously stored IC and synchronize the algorithm state with the current configuration&lt;br /&gt;
** Initialize the algorithm in a &amp;quot;blank&amp;quot; state and synchronize the current configuration &lt;br /&gt;
* Run the analysis&lt;br /&gt;
** This phase may be interactive so that state of the algorithm can be monitored and mutated&lt;br /&gt;
** It may be possible to run synchronization operation during the analysis&lt;br /&gt;
* Make the results of the analysis available&lt;br /&gt;
If the analysis is fast running all these phases happen almost immediately after the experiment is started.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Synchronization&#039;&#039; is the operation of making the current state of an analysis algorithm compatible with a certain configuration (and parameters, if the configuration is parametrized).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Save/load IC&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Archive simulation results&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
* The line between configuration and experiment is not well defined (for example is the crashing speed in the analogy part of configuration or experiment). Experiments and configurations are probably often tied together. Also experiments (such as simulation sequences) are parametrizable. Would it be possible to consider experiments as part of the configuration?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO Q&amp;amp;A:&lt;br /&gt;
&lt;br /&gt;
;Q1. Miten selection view toimii?&lt;br /&gt;
:A1: Annetaan viewille pino variableja (konf-delta1-delta2-state), jotka näytetään combossa&lt;br /&gt;
:A1: Pinon päällä on aktiivisen experimentin variable ja muut variablet ovat sen konfigurointipuu&lt;br /&gt;
:A1: Propertyvariablella on aliproperty jokaista columnia varten (alipropertyn implementaatio vastaa luvusta ja kirjoituksesta stringinä)&lt;br /&gt;
:A2: Lisäksi jokainen propertyvariable määrittää yhden kategorian (joka voi olla hidden)&lt;br /&gt;
:A3: Propertyjen järjestäminen?&lt;br /&gt;
&lt;br /&gt;
;Q2. Mitä variableja Simantics tarjoaa?&lt;br /&gt;
:A2: Jokainen konfiguraatio tarjoaa variablen (miten polun alkuosa määräytyy)&lt;br /&gt;
:A2: Jokainen run tarjoaa variablen &lt;br /&gt;
:A2: Saako experimentin konfiguraatiosta variablen? Ei saa?&lt;br /&gt;
:A2: IC voi tarjota variablen (onko IC konfiguraatio?)&lt;br /&gt;
:A2: State voi tarjota variablen? (onko State konfiguraatio?)&lt;br /&gt;
:A2: Minkä variablen kautta historioita katsellaan? Run-variablen? Tuleeko konffiksen alle Runien lisäksi myös HistoricalRun?&lt;br /&gt;
&lt;br /&gt;
;Q3. Miten eri variablet implementoidaan?&lt;br /&gt;
:A3: Geneerinen toteutus, joka käy stackin läpi ja palauttaa ensimmäisen tuotetun arvon.&lt;br /&gt;
:A3: Solvervariable + graphvariable?&lt;br /&gt;
:A3: Millä perusteella valueAccessor ja domainChildren hakevat datansa? &lt;br /&gt;
&lt;br /&gt;
;Q4. Miten IC ja State näkyvät käyttäjälle?&lt;br /&gt;
:A4: Mallin alle voi tallentaa IC:itä aktiivisesta runista. IC:llä voi alustaa uuden runin. Onko IC konfiguraatio?&lt;br /&gt;
:A4: Mitä Statella voi tehdä?&lt;br /&gt;
:A4: Mikä on hierarkia käsitteiden IC, State, Configuration välillä?&lt;br /&gt;
&lt;br /&gt;
;Q5. Mikä on runin handle? &lt;br /&gt;
:A5: ExperimentManager?&lt;br /&gt;
:A5: Nykyään monessa paikassa riittää hankkia aktiivinen Run-resurssi&lt;br /&gt;
:A5: Voidaanko lähteä siitä, että jokainen run näkyy tietokannassa resurssina (mahd. virtuaali) ja Run-resurssilta voi kysyä tarvittavia rajapintoja adaptilla?&lt;br /&gt;
:A5: Vai variablessa (ei tarvitse resurssia)?&lt;br /&gt;
&lt;br /&gt;
;Q6. Miten useamman ajon Runin parametrisaatio näkyy runin variablessa?&lt;br /&gt;
:A6: Experimentin konfiguraatioon liittyvässä skriptissä on parametrien asettelulogiikka suorituksessa. Runin variable kuvaa nykyistä tilaa.&lt;br /&gt;
&lt;br /&gt;
;Q7. Miten solveri vastaanottaa konfiguraationsa?&lt;br /&gt;
:A7: Solvervariable?&lt;br /&gt;
:A7: Serialisoituvia komentoja?&lt;br /&gt;
&lt;br /&gt;
;Q8. Miten solveri palauttaa tuloksensa?&lt;br /&gt;
:A8: Laiska kysely clientin suunnasta?&lt;br /&gt;
:A8: Jos clientillä on state niin työnnetään tulokset stateen?&lt;br /&gt;
&lt;br /&gt;
;Q9. Miten määritellään osittainen / full synkronointi vrt. solverin alustus ja päivitys?&lt;br /&gt;
:A9: Case Balas nyt: kun run käynnistetään syntyy transientti state, joka pitää ensin synkronoida (full)&lt;br /&gt;
:A9: Jatkossa myös Balasissa voitaisiin säilöä stateja alustusta varten&lt;br /&gt;
:A9: Millä rajapinnalla solveri alustetaan staten tai ic:n perusteella?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Models&amp;diff=3030</id>
		<title>Models</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Models&amp;diff=3030"/>
		<updated>2013-06-14T07:22:37Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Questions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See old documentation: [[Models Deprecated]].&lt;br /&gt;
&lt;br /&gt;
= Basic concepts =&lt;br /&gt;
&lt;br /&gt;
== Entities ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Model&#039;&#039; is a structure that is created in purpose of analysing some existing or planned system. It is usually tied to a particular method of analysis such as dynamic or steady-state simulation or model-checking. What is inside the model depends strongly on the analysis method. Model is however always a unit that can be exported from the Simantics workspace and imported back to some other workspace.&lt;br /&gt;
&lt;br /&gt;
Model contains one or more &#039;&#039;configurations&#039;&#039;. Configuration is a description of the system being modelled. Usually (always?) one of the configurations is the root configuration describing the most aspects of the system and other configurations specify some deviations from it. A configuration can be parametrized. Multiple configurations are used to maintain many different but related designs (cases) of the system within the same model or to parametrize the configuration so that optimization, sensitivity analysis or similar method can be applied to the system.&lt;br /&gt;
&lt;br /&gt;
The main purpose of creating a model of a system is to apply some analysis to it. We call these analyses &#039;&#039;experiments&#039;&#039;. An experiment points to a certain configuration but may also contain an additional specification of how the analysis is executed such as simulation sequence, list of subscribed variables, simulation method used, etc.. &lt;br /&gt;
&lt;br /&gt;
Each individual execution of the experiment is a &#039;&#039;run&#039;&#039;. What a single run generates, depends on the analysis method and the experiment specification. Typical artifacts produced include:&lt;br /&gt;
* &#039;&#039;State&#039;&#039; is an assignment of values to the properties of the components in the configuration&lt;br /&gt;
* &#039;&#039;History&#039;&#039; is an assignment of time series to the properties&lt;br /&gt;
Additionally the run can be interactive so that the current state being simulated can be accessed and even modified during the simulation.&lt;br /&gt;
&lt;br /&gt;
States and histories can be also independent entities in the model that are not produced by experiment runs. They can be used as an input in the experiments.&lt;br /&gt;
&lt;br /&gt;
Multiple runs can be executed in parallel, some in remote machines. One of the runs (states, or histories?) is the &#039;&#039;active experiment&#039;&#039; whose state is visualized in the UI.&lt;br /&gt;
&lt;br /&gt;
Some analysis methods have a capability of storing a snapshot of the state of the analysis algorithm. We call these snapshots &#039;&#039;IC&#039;&#039;s. An experiment may specify IC to be used to initialize the analysis. IC and state are slightly overlapping concepts. The main difference between them is that IC contains a complete state of the analysis algorithm including the internal state not seen by users in a representation that is optimized for fast initialization of the algorithm. On the other hand a state contains only properties of components in the configuration, it is optimized for efficient browsing and may be partial (not assigning value to all possible properties).&lt;br /&gt;
&lt;br /&gt;
== Analogy ==&lt;br /&gt;
&lt;br /&gt;
Consider crash testing of cars. The configuration describes the car and possibly how the crash test dummy is positioned in it. There may be many different configurations with varying safety equipments and we may for example parametrize the size of the airbag in order to find the size that minimizes head injuries. The experiment describes which configuration is used and how the crash test is executed (for example crashing speed). It also describes the variables that are measured during the crash. A run is one crash test. Each run produces time series of all variables that were measured, maybe a high speed video of the crash and the final state of the car and the dummy after the crash.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
&lt;br /&gt;
We describe here the basic operations involving models and experiments. They are not necessarily the same operations that are presented to user in UI but building blocks with smaller granularity. In particularly, we consider starting an experiment an explicit operation while some this may be an automatic operation in UI. If the analysis is fast enough, even simulation results can be updated automatically when the user modifies the configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Running an experiment&#039;&#039; creates a new run starting the corresponding runtime entities. This involves:&lt;br /&gt;
* Start the actual analysis algorithm (if a remote server is used, this may include waiting that computational resource become available)&lt;br /&gt;
* Initialize the algorithm state. This can be done in many ways:&lt;br /&gt;
** Write the configuration in a form understood by the algorithm (for example Modelica code)&lt;br /&gt;
** Load previously stored IC and synchronize the algorithm state with the current configuration&lt;br /&gt;
** Initialize the algorithm in a &amp;quot;blank&amp;quot; state and synchronize the current configuration &lt;br /&gt;
* Run the analysis&lt;br /&gt;
** This phase may be interactive so that state of the algorithm can be monitored and mutated&lt;br /&gt;
** It may be possible to run synchronization operation during the analysis&lt;br /&gt;
* Make the results of the analysis available&lt;br /&gt;
If the analysis is fast running all these phases happen almost immediately after the experiment is started.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Synchronization&#039;&#039; is the operation of making the current state of an analysis algorithm compatible with a certain configuration (and parameters, if the configuration is parametrized).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Save/load IC&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Archive simulation results&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
* The line between configuration and experiment is not well defined (for example is the crashing speed in the analogy part of configuration or experiment). Experiments and configurations are probably often tied together. Also experiments (such as simulation sequences) are parametrizable. Would it be possible to consider experiments as part of the configuration?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO Q&amp;amp;A:&lt;br /&gt;
&lt;br /&gt;
;Q1. Miten selection view toimii?&lt;br /&gt;
:A1: Annetaan viewille pino variableja (konf-delta1-delta2-state), jotka näytetään combossa&lt;br /&gt;
:A1: Pinon päällä on aktiivisen experimentin variable ja muut variablet ovat sen konfigurointipuu&lt;br /&gt;
:A1: Propertyvariablella on aliproperty jokaista columnia varten (alipropertyn implementaatio vastaa luvusta ja kirjoituksesta stringinä)&lt;br /&gt;
:A2: Lisäksi jokainen propertyvariable määrittää yhden kategorian (joka voi olla hidden)&lt;br /&gt;
:A3: Propertyjen järjestäminen?&lt;br /&gt;
&lt;br /&gt;
;Q2. Mitä variableja Simantics tarjoaa?&lt;br /&gt;
:A2: Jokainen konfiguraatio tarjoaa variablen (miten polun alkuosa määräytyy)&lt;br /&gt;
:A2: Jokainen run tarjoaa variablen &lt;br /&gt;
:A2: Saako experimentin konfiguraatiosta variablen? Ei saa?&lt;br /&gt;
:A2: IC voi tarjota variablen (onko IC konfiguraatio?)&lt;br /&gt;
:A2: State voi tarjota variablen? (onko State konfiguraatio?)&lt;br /&gt;
:A2: Minkä variablen kautta historioita katsellaan? Run-variablen? Tuleeko konffiksen alle Runien lisäksi myös HistoricalRun?&lt;br /&gt;
&lt;br /&gt;
;Q3. Miten eri variablet implementoidaan?&lt;br /&gt;
:A3: Geneerinen toteutus, joka käy stackin läpi ja palauttaa ensimmäisen tuotetun arvon.&lt;br /&gt;
:A3: Solvervariable + graphvariable?&lt;br /&gt;
:A3: Millä perusteella valueAccessor ja domainChildren hakevat datansa? &lt;br /&gt;
&lt;br /&gt;
;Q4. Miten IC ja State näkyvät käyttäjälle?&lt;br /&gt;
:A4: Mallin alle voi tallentaa IC:itä aktiivisesta runista. IC:llä voi alustaa uuden runin. Onko IC konfiguraatio?&lt;br /&gt;
:A4: Mitä Statella voi tehdä?&lt;br /&gt;
:A4: Mikä on hierarkia käsitteiden IC, State, Configuration välillä?&lt;br /&gt;
&lt;br /&gt;
;Q5. Mikä on runin handle? &lt;br /&gt;
:A5: ExperimentManager?&lt;br /&gt;
:A5: Nykyään monessa paikassa riittää hankkia aktiivinen Run-resurssi&lt;br /&gt;
:A5: Voidaanko lähteä siitä, että jokainen run näkyy tietokannassa resurssina (mahd. virtuaali) ja Run-resurssilta voi kysyä tarvittavia rajapintoja adaptilla?&lt;br /&gt;
:A5: Vai variablessa (ei tarvitse resurssia)?&lt;br /&gt;
&lt;br /&gt;
;Q6. Miten useamman ajon Runin parametrisaatio näkyy runin variablessa?&lt;br /&gt;
:A6: Experimentin konfiguraatioon liittyvässä skriptissä on parametrien asettelulogiikka suorituksessa. Runin variable kuvaa nykyistä tilaa.&lt;br /&gt;
&lt;br /&gt;
;Q7. Miten solveri vastaanottaa konfiguraationsa?&lt;br /&gt;
:A7: Solvervariable?&lt;br /&gt;
:A7: Serialisoituvia komentoja?&lt;br /&gt;
&lt;br /&gt;
;Q8. Miten solveri palauttaa tuloksensa?&lt;br /&gt;
:A8: Laiska kysely clientin suunnasta?&lt;br /&gt;
:A8: Jos clientillä on state niin työnnetään tulokset stateen?&lt;br /&gt;
&lt;br /&gt;
;Q9: Miten määritellään osittainen / full synkronointi vrt. solverin alustus ja päivitys?&lt;br /&gt;
:A9: Case Balas nyt: kun run käynnistetään syntyy transientti state, joka pitää ensin synkronoida (full)&lt;br /&gt;
:A9: Jatkossa myös Balasissa voitaisiin säilöä stateja alustusta varten&lt;br /&gt;
:A9: Millä rajapinnalla solveri alustetaan staten tai ic:n perusteella?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Models&amp;diff=3028</id>
		<title>Models</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Models&amp;diff=3028"/>
		<updated>2013-06-14T07:15:01Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Questions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See old documentation: [[Models Deprecated]].&lt;br /&gt;
&lt;br /&gt;
= Basic concepts =&lt;br /&gt;
&lt;br /&gt;
== Entities ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Model&#039;&#039; is a structure that is created in purpose of analysing some existing or planned system. It is usually tied to a particular method of analysis such as dynamic or steady-state simulation or model-checking. What is inside the model depends strongly on the analysis method. Model is however always a unit that can be exported from the Simantics workspace and imported back to some other workspace.&lt;br /&gt;
&lt;br /&gt;
Model contains one or more &#039;&#039;configurations&#039;&#039;. Configuration is a description of the system being modelled. Usually (always?) one of the configurations is the root configuration describing the most aspects of the system and other configurations specify some deviations from it. A configuration can be parametrized. Multiple configurations are used to maintain many different but related designs (cases) of the system within the same model or to parametrize the configuration so that optimization, sensitivity analysis or similar method can be applied to the system.&lt;br /&gt;
&lt;br /&gt;
The main purpose of creating a model of a system is to apply some analysis to it. We call these analyses &#039;&#039;experiments&#039;&#039;. An experiment points to a certain configuration but may also contain an additional specification of how the analysis is executed such as simulation sequence, list of subscribed variables, simulation method used, etc.. &lt;br /&gt;
&lt;br /&gt;
Each individual execution of the experiment is a &#039;&#039;run&#039;&#039;. What a single run generates, depends on the analysis method and the experiment specification. Typical artifacts produced include:&lt;br /&gt;
* &#039;&#039;State&#039;&#039; is an assignment of values to the properties of the components in the configuration&lt;br /&gt;
* &#039;&#039;History&#039;&#039; is an assignment of time series to the properties&lt;br /&gt;
Additionally the run can be interactive so that the current state being simulated can be accessed and even modified during the simulation.&lt;br /&gt;
&lt;br /&gt;
States and histories can be also independent entities in the model that are not produced by experiment runs. They can be used as an input in the experiments.&lt;br /&gt;
&lt;br /&gt;
Multiple runs can be executed in parallel, some in remote machines. One of the runs (states, or histories?) is the &#039;&#039;active experiment&#039;&#039; whose state is visualized in the UI.&lt;br /&gt;
&lt;br /&gt;
Some analysis methods have a capability of storing a snapshot of the state of the analysis algorithm. We call these snapshots &#039;&#039;IC&#039;&#039;s. An experiment may specify IC to be used to initialize the analysis. IC and state are slightly overlapping concepts. The main difference between them is that IC contains a complete state of the analysis algorithm including the internal state not seen by users in a representation that is optimized for fast initialization of the algorithm. On the other hand a state contains only properties of components in the configuration, it is optimized for efficient browsing and may be partial (not assigning value to all possible properties).&lt;br /&gt;
&lt;br /&gt;
== Analogy ==&lt;br /&gt;
&lt;br /&gt;
Consider crash testing of cars. The configuration describes the car and possibly how the crash test dummy is positioned in it. There may be many different configurations with varying safety equipments and we may for example parametrize the size of the airbag in order to find the size that minimizes head injuries. The experiment describes which configuration is used and how the crash test is executed (for example crashing speed). It also describes the variables that are measured during the crash. A run is one crash test. Each run produces time series of all variables that were measured, maybe a high speed video of the crash and the final state of the car and the dummy after the crash.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
&lt;br /&gt;
We describe here the basic operations involving models and experiments. They are not necessarily the same operations that are presented to user in UI but building blocks with smaller granularity. In particularly, we consider starting an experiment an explicit operation while some this may be an automatic operation in UI. If the analysis is fast enough, even simulation results can be updated automatically when the user modifies the configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Running an experiment&#039;&#039; creates a new run starting the corresponding runtime entities. This involves:&lt;br /&gt;
* Start the actual analysis algorithm (if a remote server is used, this may include waiting that computational resource become available)&lt;br /&gt;
* Initialize the algorithm state. This can be done in many ways:&lt;br /&gt;
** Write the configuration in a form understood by the algorithm (for example Modelica code)&lt;br /&gt;
** Load previously stored IC and synchronize the algorithm state with the current configuration&lt;br /&gt;
** Initialize the algorithm in a &amp;quot;blank&amp;quot; state and synchronize the current configuration &lt;br /&gt;
* Run the analysis&lt;br /&gt;
** This phase may be interactive so that state of the algorithm can be monitored and mutated&lt;br /&gt;
** It may be possible to run synchronization operation during the analysis&lt;br /&gt;
* Make the results of the analysis available&lt;br /&gt;
If the analysis is fast running all these phases happen almost immediately after the experiment is started.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Synchronization&#039;&#039; is the operation of making the current state of an analysis algorithm compatible with a certain configuration (and parameters, if the configuration is parametrized).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Save/load IC&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Archive simulation results&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
* The line between configuration and experiment is not well defined (for example is the crashing speed in the analogy part of configuration or experiment). Experiments and configurations are probably often tied together. Also experiments (such as simulation sequences) are parametrizable. Would it be possible to consider experiments as part of the configuration?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO Q&amp;amp;A:&lt;br /&gt;
&lt;br /&gt;
Q1: Miten selection view toimii?&lt;br /&gt;
&lt;br /&gt;
A1: Annetaan viewille pino variableja (konf-delta1-delta2-state), jotka näytetään combossa&lt;br /&gt;
&lt;br /&gt;
A1: Pinon päällä on aktiivisen experimentin variable ja muut variablet ovat sen konfigurointipuu&lt;br /&gt;
&lt;br /&gt;
A1: Propertyvariablella on aliproperty jokaista columnia varten (alipropertyn implementaatio vastaa luvusta ja kirjoituksesta stringinä)&lt;br /&gt;
&lt;br /&gt;
A2: Lisäksi jokainen propertyvariable määrittää yhden kategorian (joka voi olla hidden)&lt;br /&gt;
&lt;br /&gt;
A3: Propertyjen järjestäminen?&lt;br /&gt;
&lt;br /&gt;
Q2: Mitä variableja Simantics tarjoaa?&lt;br /&gt;
&lt;br /&gt;
A2: Jokainen konfiguraatio tarjoaa variablen (miten polun alkuosa määräytyy)&lt;br /&gt;
&lt;br /&gt;
A2: Jokainen run tarjoaa variablen &lt;br /&gt;
&lt;br /&gt;
A2: Saako experimentin konfiguraatiosta variablen? Ei saa?&lt;br /&gt;
&lt;br /&gt;
A2: IC voi tarjota variablen (onko IC konfiguraatio?)&lt;br /&gt;
&lt;br /&gt;
A2: State voi tarjota variablen? (onko State konfiguraatio?)&lt;br /&gt;
&lt;br /&gt;
A2: Minkä variablen kautta historioita katsellaan? Run-variablen? Tuleeko konffiksen alle Runien lisäksi myös HistoricalRun?&lt;br /&gt;
&lt;br /&gt;
Q3: Miten eri variablet implementoidaan?&lt;br /&gt;
&lt;br /&gt;
A3: Geneerinen toteutus, joka käy stackin läpi ja palauttaa ensimmäisen tuotetun arvon.&lt;br /&gt;
&lt;br /&gt;
A3: Solvervariable + graphvariable?&lt;br /&gt;
&lt;br /&gt;
A3: Millä perusteella valueAccessor ja domainChildren hakevat datansa? &lt;br /&gt;
&lt;br /&gt;
Q4: Miten IC ja State näkyvät käyttäjälle?&lt;br /&gt;
&lt;br /&gt;
A4: Mallin alle voi tallentaa IC:itä aktiivisesta runista. IC:llä voi alustaa uuden runin. Onko IC konfiguraatio?&lt;br /&gt;
&lt;br /&gt;
A4: Mitä Statella voi tehdä?&lt;br /&gt;
&lt;br /&gt;
A4: Mikä on hierarkia käsitteiden IC, State, Configuration välillä?&lt;br /&gt;
&lt;br /&gt;
Q5: Mikä on runin handle? &lt;br /&gt;
&lt;br /&gt;
A5: ExperimentManager?&lt;br /&gt;
&lt;br /&gt;
A5: Nykyään monessa paikassa riittää hankkia aktiivinen Run-resurssi&lt;br /&gt;
&lt;br /&gt;
A5: Voidaanko lähteä siitä, että jokainen run näkyy tietokannassa resurssina (mahd. virtuaali) ja Run-resurssilta voi kysyä tarvittavia rajapintoja adaptilla?&lt;br /&gt;
&lt;br /&gt;
A5: Vai variablessa (ei tarvitse resurssia)?&lt;br /&gt;
&lt;br /&gt;
Q6: Miten useamman ajon Runin parametrisaatio näkyy runin variablessa?&lt;br /&gt;
&lt;br /&gt;
A6: Experimentin konfiguraatioon liittyvässä skriptissä on parametrien asettelulogiikka suorituksessa. Runin variable kuvaa nykyistä tilaa.&lt;br /&gt;
&lt;br /&gt;
Q7. Miten solveri vastaanottaa konfiguraationsa?&lt;br /&gt;
&lt;br /&gt;
A7: Solvervariable?&lt;br /&gt;
&lt;br /&gt;
A7: Serialisoituvia komentoja?&lt;br /&gt;
&lt;br /&gt;
Q8. Miten solveri palauttaa tuloksensa?&lt;br /&gt;
&lt;br /&gt;
A8: Laiska kysely clientin suunnasta?&lt;br /&gt;
&lt;br /&gt;
A8: Jos clientillä on state niin työnnetään tulokset stateen?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Models&amp;diff=3027</id>
		<title>Models</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Models&amp;diff=3027"/>
		<updated>2013-06-14T07:13:59Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See old documentation: [[Models Deprecated]].&lt;br /&gt;
&lt;br /&gt;
= Basic concepts =&lt;br /&gt;
&lt;br /&gt;
== Entities ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Model&#039;&#039; is a structure that is created in purpose of analysing some existing or planned system. It is usually tied to a particular method of analysis such as dynamic or steady-state simulation or model-checking. What is inside the model depends strongly on the analysis method. Model is however always a unit that can be exported from the Simantics workspace and imported back to some other workspace.&lt;br /&gt;
&lt;br /&gt;
Model contains one or more &#039;&#039;configurations&#039;&#039;. Configuration is a description of the system being modelled. Usually (always?) one of the configurations is the root configuration describing the most aspects of the system and other configurations specify some deviations from it. A configuration can be parametrized. Multiple configurations are used to maintain many different but related designs (cases) of the system within the same model or to parametrize the configuration so that optimization, sensitivity analysis or similar method can be applied to the system.&lt;br /&gt;
&lt;br /&gt;
The main purpose of creating a model of a system is to apply some analysis to it. We call these analyses &#039;&#039;experiments&#039;&#039;. An experiment points to a certain configuration but may also contain an additional specification of how the analysis is executed such as simulation sequence, list of subscribed variables, simulation method used, etc.. &lt;br /&gt;
&lt;br /&gt;
Each individual execution of the experiment is a &#039;&#039;run&#039;&#039;. What a single run generates, depends on the analysis method and the experiment specification. Typical artifacts produced include:&lt;br /&gt;
* &#039;&#039;State&#039;&#039; is an assignment of values to the properties of the components in the configuration&lt;br /&gt;
* &#039;&#039;History&#039;&#039; is an assignment of time series to the properties&lt;br /&gt;
Additionally the run can be interactive so that the current state being simulated can be accessed and even modified during the simulation.&lt;br /&gt;
&lt;br /&gt;
States and histories can be also independent entities in the model that are not produced by experiment runs. They can be used as an input in the experiments.&lt;br /&gt;
&lt;br /&gt;
Multiple runs can be executed in parallel, some in remote machines. One of the runs (states, or histories?) is the &#039;&#039;active experiment&#039;&#039; whose state is visualized in the UI.&lt;br /&gt;
&lt;br /&gt;
Some analysis methods have a capability of storing a snapshot of the state of the analysis algorithm. We call these snapshots &#039;&#039;IC&#039;&#039;s. An experiment may specify IC to be used to initialize the analysis. IC and state are slightly overlapping concepts. The main difference between them is that IC contains a complete state of the analysis algorithm including the internal state not seen by users in a representation that is optimized for fast initialization of the algorithm. On the other hand a state contains only properties of components in the configuration, it is optimized for efficient browsing and may be partial (not assigning value to all possible properties).&lt;br /&gt;
&lt;br /&gt;
== Analogy ==&lt;br /&gt;
&lt;br /&gt;
Consider crash testing of cars. The configuration describes the car and possibly how the crash test dummy is positioned in it. There may be many different configurations with varying safety equipments and we may for example parametrize the size of the airbag in order to find the size that minimizes head injuries. The experiment describes which configuration is used and how the crash test is executed (for example crashing speed). It also describes the variables that are measured during the crash. A run is one crash test. Each run produces time series of all variables that were measured, maybe a high speed video of the crash and the final state of the car and the dummy after the crash.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
&lt;br /&gt;
We describe here the basic operations involving models and experiments. They are not necessarily the same operations that are presented to user in UI but building blocks with smaller granularity. In particularly, we consider starting an experiment an explicit operation while some this may be an automatic operation in UI. If the analysis is fast enough, even simulation results can be updated automatically when the user modifies the configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Running an experiment&#039;&#039; creates a new run starting the corresponding runtime entities. This involves:&lt;br /&gt;
* Start the actual analysis algorithm (if a remote server is used, this may include waiting that computational resource become available)&lt;br /&gt;
* Initialize the algorithm state. This can be done in many ways:&lt;br /&gt;
** Write the configuration in a form understood by the algorithm (for example Modelica code)&lt;br /&gt;
** Load previously stored IC and synchronize the algorithm state with the current configuration&lt;br /&gt;
** Initialize the algorithm in a &amp;quot;blank&amp;quot; state and synchronize the current configuration &lt;br /&gt;
* Run the analysis&lt;br /&gt;
** This phase may be interactive so that state of the algorithm can be monitored and mutated&lt;br /&gt;
** It may be possible to run synchronization operation during the analysis&lt;br /&gt;
* Make the results of the analysis available&lt;br /&gt;
If the analysis is fast running all these phases happen almost immediately after the experiment is started.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Synchronization&#039;&#039; is the operation of making the current state of an analysis algorithm compatible with a certain configuration (and parameters, if the configuration is parametrized).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Save/load IC&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Archive simulation results&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
* The line between configuration and experiment is not well defined (for example is the crashing speed in the analogy part of configuration or experiment). Experiments and configurations are probably often tied together. Also experiments (such as simulation sequences) are parametrizable. Would it be possible to consider experiments as part of the configuration?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO Q&amp;amp;A:&lt;br /&gt;
&lt;br /&gt;
Q1: Miten selection view toimii?&lt;br /&gt;
&lt;br /&gt;
A1: Annetaan viewille pino variableja (konf-delta1-delta2-state), jotka näytetään combossa&lt;br /&gt;
&lt;br /&gt;
A1: Pinon päällä on aktiivisen experimentin variable ja muut variablet ovat sen konfigurointipuu&lt;br /&gt;
&lt;br /&gt;
A1: Propertyvariablella on aliproperty jokaista columnia varten&lt;br /&gt;
&lt;br /&gt;
A2: Lisäksi jokainen propertyvariable määrittää yhden kategorian (joka voi olla hidden)&lt;br /&gt;
&lt;br /&gt;
A3: Propertyjen järjestäminen?&lt;br /&gt;
&lt;br /&gt;
Q2: Mitä variableja Simantics tarjoaa?&lt;br /&gt;
&lt;br /&gt;
A2: Jokainen konfiguraatio tarjoaa variablen (miten polun alkuosa määräytyy)&lt;br /&gt;
&lt;br /&gt;
A2: Jokainen run tarjoaa variablen &lt;br /&gt;
&lt;br /&gt;
A2: Saako experimentin konfiguraatiosta variablen? Ei saa?&lt;br /&gt;
&lt;br /&gt;
A2: IC voi tarjota variablen (onko IC konfiguraatio?)&lt;br /&gt;
&lt;br /&gt;
A2: State voi tarjota variablen? (onko State konfiguraatio?)&lt;br /&gt;
&lt;br /&gt;
A2: Minkä variablen kautta historioita katsellaan? Run-variablen? Tuleeko konffiksen alle Runien lisäksi myös HistoricalRun?&lt;br /&gt;
&lt;br /&gt;
Q3: Miten eri variablet implementoidaan?&lt;br /&gt;
&lt;br /&gt;
A3: Geneerinen toteutus, joka käy stackin läpi ja palauttaa ensimmäisen tuotetun arvon.&lt;br /&gt;
&lt;br /&gt;
A3: Solvervariable + graphvariable?&lt;br /&gt;
&lt;br /&gt;
A3: Millä perusteella valueAccessor ja domainChildren hakevat datansa? &lt;br /&gt;
&lt;br /&gt;
Q4: Miten IC ja State näkyvät käyttäjälle?&lt;br /&gt;
&lt;br /&gt;
A4: Mallin alle voi tallentaa IC:itä aktiivisesta runista. IC:llä voi alustaa uuden runin. Onko IC konfiguraatio?&lt;br /&gt;
&lt;br /&gt;
A4: Mitä Statella voi tehdä?&lt;br /&gt;
&lt;br /&gt;
A4: Mikä on hierarkia käsitteiden IC, State, Configuration välillä?&lt;br /&gt;
&lt;br /&gt;
Q5: Mikä on runin handle? &lt;br /&gt;
&lt;br /&gt;
A5: ExperimentManager?&lt;br /&gt;
&lt;br /&gt;
A5: Nykyään monessa paikassa riittää hankkia aktiivinen Run-resurssi&lt;br /&gt;
&lt;br /&gt;
A5: Voidaanko lähteä siitä, että jokainen run näkyy tietokannassa resurssina (mahd. virtuaali) ja Run-resurssilta voi kysyä tarvittavia rajapintoja adaptilla?&lt;br /&gt;
&lt;br /&gt;
A5: Vai variablessa (ei tarvitse resurssia)?&lt;br /&gt;
&lt;br /&gt;
Q6: Miten useamman ajon Runin parametrisaatio näkyy runin variablessa?&lt;br /&gt;
&lt;br /&gt;
A6: Experimentin konfiguraatioon liittyvässä skriptissä on parametrien asettelulogiikka suorituksessa. Runin variable kuvaa nykyistä tilaa.&lt;br /&gt;
&lt;br /&gt;
Q7. Miten solveri vastaanottaa konfiguraationsa?&lt;br /&gt;
&lt;br /&gt;
A7: Solvervariable?&lt;br /&gt;
&lt;br /&gt;
A7: Serialisoituvia komentoja?&lt;br /&gt;
&lt;br /&gt;
Q8. Miten solveri palauttaa tuloksensa?&lt;br /&gt;
&lt;br /&gt;
A8: Laiska kysely clientin suunnasta?&lt;br /&gt;
&lt;br /&gt;
A8: Jos clientillä on state niin työnnetään tulokset stateen?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Models&amp;diff=3026</id>
		<title>Models</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Models&amp;diff=3026"/>
		<updated>2013-06-14T07:12:20Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See old documentation: [[Models Deprecated]].&lt;br /&gt;
&lt;br /&gt;
= Basic concepts =&lt;br /&gt;
&lt;br /&gt;
== Entities ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Model&#039;&#039; is a structure that is created in purpose of analysing some existing or planned system. It is usually tied to a particular method of analysis such as dynamic or steady-state simulation or model-checking. What is inside the model depends strongly on the analysis method. Model is however always a unit that can be exported from the Simantics workspace and imported back to some other workspace.&lt;br /&gt;
&lt;br /&gt;
Model contains one or more &#039;&#039;configurations&#039;&#039;. Configuration is a description of the system being modelled. Usually (always?) one of the configurations is the root configuration describing the most aspects of the system and other configurations specify some deviations from it. A configuration can be parametrized. Multiple configurations are used to maintain many different but related designs (cases) of the system within the same model or to parametrize the configuration so that optimization, sensitivity analysis or similar method can be applied to the system.&lt;br /&gt;
&lt;br /&gt;
The main purpose of creating a model of a system is to apply some analysis to it. We call these analyses &#039;&#039;experiments&#039;&#039;. An experiment points to a certain configuration but may also contain an additional specification of how the analysis is executed such as simulation sequence, list of subscribed variables, simulation method used, etc.. &lt;br /&gt;
&lt;br /&gt;
Each individual execution of the experiment is a &#039;&#039;run&#039;&#039;. What a single run generates, depends on the analysis method and the experiment specification. Typical artifacts produced include:&lt;br /&gt;
* &#039;&#039;State&#039;&#039; is an assignment of values to the properties of the components in the configuration&lt;br /&gt;
* &#039;&#039;History&#039;&#039; is an assignment of time series to the properties&lt;br /&gt;
Additionally the run can be interactive so that the current state being simulated can be accessed and even modified during the simulation.&lt;br /&gt;
&lt;br /&gt;
States and histories can be also independent entities in the model that are not produced by experiment runs. They can be used as an input in the experiments.&lt;br /&gt;
&lt;br /&gt;
Multiple runs can be executed in parallel, some in remote machines. One of the runs (states, or histories?) is the &#039;&#039;active experiment&#039;&#039; whose state is visualized in the UI.&lt;br /&gt;
&lt;br /&gt;
Some analysis methods have a capability of storing a snapshot of the state of the analysis algorithm. We call these snapshots &#039;&#039;IC&#039;&#039;s. An experiment may specify IC to be used to initialize the analysis. IC and state are slightly overlapping concepts. The main difference between them is that IC contains a complete state of the analysis algorithm including the internal state not seen by users in a representation that is optimized for fast initialization of the algorithm. On the other hand a state contains only properties of components in the configuration, it is optimized for efficient browsing and may be partial (not assigning value to all possible properties).&lt;br /&gt;
&lt;br /&gt;
== Analogy ==&lt;br /&gt;
&lt;br /&gt;
Consider crash testing of cars. The configuration describes the car and possibly how the crash test dummy is positioned in it. There may be many different configurations with varying safety equipments and we may for example parametrize the size of the airbag in order to find the size that minimizes head injuries. The experiment describes which configuration is used and how the crash test is executed (for example crashing speed). It also describes the variables that are measured during the crash. A run is one crash test. Each run produces time series of all variables that were measured, maybe a high speed video of the crash and the final state of the car and the dummy after the crash.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
&lt;br /&gt;
We describe here the basic operations involving models and experiments. They are not necessarily the same operations that are presented to user in UI but building blocks with smaller granularity. In particularly, we consider starting an experiment an explicit operation while some this may be an automatic operation in UI. If the analysis is fast enough, even simulation results can be updated automatically when the user modifies the configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Running an experiment&#039;&#039; creates a new run starting the corresponding runtime entities. This involves:&lt;br /&gt;
* Start the actual analysis algorithm (if a remote server is used, this may include waiting that computational resource become available)&lt;br /&gt;
* Initialize the algorithm state. This can be done in many ways:&lt;br /&gt;
** Write the configuration in a form understood by the algorithm (for example Modelica code)&lt;br /&gt;
** Load previously stored IC and synchronize the algorithm state with the current configuration&lt;br /&gt;
** Initialize the algorithm in a &amp;quot;blank&amp;quot; state and synchronize the current configuration &lt;br /&gt;
* Run the analysis&lt;br /&gt;
** This phase may be interactive so that state of the algorithm can be monitored and mutated&lt;br /&gt;
** It may be possible to run synchronization operation during the analysis&lt;br /&gt;
* Make the results of the analysis available&lt;br /&gt;
If the analysis is fast running all these phases happen almost immediately after the experiment is started.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Synchronization&#039;&#039; is the operation of making the current state of an analysis algorithm compatible with a certain configuration (and parameters, if the configuration is parametrized).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Save/load IC&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Archive simulation results&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Questions =&lt;br /&gt;
&lt;br /&gt;
* The line between configuration and experiment is not well defined (for example is the crashing speed in the analogy part of configuration or experiment). Experiments and configurations are probably often tied together. Also experiments (such as simulation sequences) are parametrizable. Would it be possible to consider experiments as part of the configuration?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
TODO Q&amp;amp;A:&lt;br /&gt;
&lt;br /&gt;
Q1: Miten selection view toimii?&lt;br /&gt;
&lt;br /&gt;
A1: Annetaan viewille pino variableja (konf-delta1-delta2-state), jotka näytetään combossa&lt;br /&gt;
A1: Pinon päällä on aktiivisen experimentin variable ja muut variablet ovat sen konfigurointipuu&lt;br /&gt;
A1: Propertyvariablella on aliproperty jokaista columnia varten&lt;br /&gt;
A2: Lisäksi jokainen propertyvariable määrittää yhden kategorian (joka voi olla hidden)&lt;br /&gt;
A3: Propertyjen järjestäminen?&lt;br /&gt;
&lt;br /&gt;
Q2: Mitä variableja Simantics tarjoaa?&lt;br /&gt;
&lt;br /&gt;
A2: Jokainen konfiguraatio tarjoaa variablen (miten polun alkuosa määräytyy)&lt;br /&gt;
A2: Jokainen run tarjoaa variablen &lt;br /&gt;
A2: Saako experimentin konfiguraatiosta variablen? Ei saa?&lt;br /&gt;
A2: IC voi tarjota variablen (onko IC konfiguraatio?)&lt;br /&gt;
A2: State voi tarjota variablen? (onko State konfiguraatio?)&lt;br /&gt;
A2: Minkä variablen kautta historioita katsellaan? Run-variablen? Tuleeko konffiksen alle Runien lisäksi myös HistoricalRun?&lt;br /&gt;
&lt;br /&gt;
Q3: Miten eri variablet implementoidaan?&lt;br /&gt;
&lt;br /&gt;
A3: Geneerinen toteutus, joka käy stackin läpi ja palauttaa ensimmäisen tuotetun arvon.&lt;br /&gt;
A3: Solvervariable + graphvariable?&lt;br /&gt;
A3: Millä perusteella valueAccessor ja domainChildren hakevat datansa? &lt;br /&gt;
&lt;br /&gt;
Q4: Miten IC ja State näkyvät käyttäjälle?&lt;br /&gt;
&lt;br /&gt;
A4: Mallin alle voi tallentaa IC:itä aktiivisesta runista. IC:llä voi alustaa uuden runin. Onko IC konfiguraatio?&lt;br /&gt;
A4: Mitä Statella voi tehdä?&lt;br /&gt;
A4: Mikä on hierarkia käsitteiden IC, State, Configuration välillä?&lt;br /&gt;
&lt;br /&gt;
Q5: Mikä on runin handle? &lt;br /&gt;
&lt;br /&gt;
A5: ExperimentManager?&lt;br /&gt;
A5: Nykyään monessa paikassa riittää hankkia aktiivinen Run-resurssi&lt;br /&gt;
A5: Voidaanko lähteä siitä, että jokainen run näkyy tietokannassa resurssina (mahd. virtuaali) ja Run-resurssilta voi kysyä tarvittavia rajapintoja adaptilla?&lt;br /&gt;
A5: Vai variablessa (ei tarvitse resurssia)?&lt;br /&gt;
&lt;br /&gt;
Q6: Miten useamman ajon Runin parametrisaatio näkyy runin variablessa?&lt;br /&gt;
&lt;br /&gt;
A6: Experimentin konfiguraatioon liittyvässä skriptissä on parametrien asettelulogiikka suorituksessa. Runin variable kuvaa nykyistä tilaa.&lt;br /&gt;
&lt;br /&gt;
Q7. Miten solveri vastaanottaa konfiguraationsa?&lt;br /&gt;
&lt;br /&gt;
A7: Solvervariable?&lt;br /&gt;
A7: Serialisoituvia komentoja?&lt;br /&gt;
&lt;br /&gt;
Q8. Miten solveri palauttaa tuloksensa?&lt;br /&gt;
&lt;br /&gt;
A8: Laiska kysely clientin suunnasta?&lt;br /&gt;
A8: Jos clientillä on state niin työnnetään tulokset stateen?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=FAQ&amp;diff=2937</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=FAQ&amp;diff=2937"/>
		<updated>2012-08-29T05:35:20Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: Created page with &amp;quot;== Working with the IDE ==  # Q: Product does not launch from IDE #: INFO: org.eclipse.core.runtime.CoreException: Plug-in org.simantics.workbench was unable to load class org.si...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Working with the IDE ==&lt;br /&gt;
&lt;br /&gt;
# Q: Product does not launch from IDE&lt;br /&gt;
#: INFO: org.eclipse.core.runtime.CoreException: Plug-in org.simantics.workbench was unable to load class org.simantics.workbench.internal.SimanticsWorkbenchApplication&lt;br /&gt;
#:  java.lang.UnsupportedClassVersionError: org/simantics/workbench/internal/SimanticsWorkbenchApplication : Unsupported major.minor version 51.0&lt;br /&gt;
#: A:  Product has been compiled with a different version of Java VM than the one being launched with&lt;br /&gt;
#: Resolutions: Check Windows-&amp;gt;Preferences-&amp;gt;Java-&amp;gt;Compiler-&amp;gt;Compiler compliance level&lt;br /&gt;
#: Resolutions: Check Windows-&amp;gt;Preferences-&amp;gt;Java-&amp;gt;Installed JREs&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=2936</id>
		<title>Simantics Developer Documentation</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Simantics_Developer_Documentation&amp;diff=2936"/>
		<updated>2012-08-29T05:22:17Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Miscellaneous Documents */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
[[image:Simantics_logo_pile_01.png|right|border|400px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Simantics&#039;&#039;&#039; is a software platform for modelling and simulation. The system has client-server architecture with a semantic ontology-based modelling database and Eclipse framework -based client software with plug-in interface. The Simantics platform and many of its components are open source under [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License (EPL)].&lt;br /&gt;
&lt;br /&gt;
The philosophy of the Simantics platform is to offer an open, high level application platform on which different computational tools can be easily integrated to form a common environment for modelling and simulation. The platform includes several modelling tools, so-called editors, for e.g. 2D graph-like hierarchical model composition and semantic graph browsing.&lt;br /&gt;
&lt;br /&gt;
One of the biggest innovations in the Simantics platform is the semantic modelling approach itself and high-level ontology tools. The semantic database, i.e. triplestore, on the server side enables high performance data management and arbitrary mappings of data. This enables e.g. efficient mapping of simulation and measurement data to the model configuration and its visualisation.&lt;br /&gt;
&lt;br /&gt;
The Simantics development and maintenance process is built to be solid and scalable from the very beginning. The objective is to aim far to the future what comes to requirements for scalability, usability, and reliability.&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;Simantics Developer Documentation&#039;&#039; is targeted to programmers and software developers developing either the platform itself or additional plug-ins to be used with or on the platform. The [[userwiki:Main_Page|Simantics End User Documentation]] complements to documentation for the Simantics platform offering overview and detailed information about the platform from the user&#039;s point of view. The [https://www.simantics.org/simantics Simantics] website is the source of information for the Simantics project and related subjects[[Tutorials|.]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:white;&amp;quot;&amp;gt;Disclaimer Warning: This site may cause narcolepsia in some readers. Consult your doctor if sensitive to boredom.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;75%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
* [[Glossary]]&lt;br /&gt;
* [[Introduction to Simantics Architecture]]&lt;br /&gt;
* [[Roadmap]]&lt;br /&gt;
* [[Data View]]&lt;br /&gt;
* [[Component View]]&lt;br /&gt;
* [[Licensing|Licensing]]&lt;br /&gt;
* [[Useful Links]]&lt;br /&gt;
* [[Platform development process]]&lt;br /&gt;
&amp;lt;!--* [[Simantics Specifications|Specifications]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Documents ===&lt;br /&gt;
&lt;br /&gt;
* [[Quick Development Environment Setup|Quick Development Environment Setup Guide]]&lt;br /&gt;
* [[Development Environment Setup Guide|Old Development Environment Setup Guide]]&lt;br /&gt;
* [[Target Platform]]&lt;br /&gt;
* [[Development Practices]]&lt;br /&gt;
* [[Internalization]]&lt;br /&gt;
* [[Update Site]]&lt;br /&gt;
* [[Coding Convention]]&lt;br /&gt;
* [[Tools]]&lt;br /&gt;
* [[Testing]]&lt;br /&gt;
* [[FAQ]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Ontology Development ===&lt;br /&gt;
&lt;br /&gt;
* [[:Media:Layer0.pdf|Layer0.pdf]] ([[:File:Layer0.pdf|log]])&lt;br /&gt;
* [[Graph Compiler]]&lt;br /&gt;
* [[Transferable Graph]]&lt;br /&gt;
* [[Binary Container Format]]&lt;br /&gt;
* [[Graph File Format]]&lt;br /&gt;
* [[Version Migration]]&lt;br /&gt;
* [[Tutorial: Ontology Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Database Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Interface summary]]&lt;br /&gt;
* [[Tutorial: Quickstart]]&lt;br /&gt;
* [[Tutorial: Database Development]]&lt;br /&gt;
* [[Resource Adaptation]]&lt;br /&gt;
* [[Resource Serialization]]&lt;br /&gt;
* [[Inverse Relations]]&lt;br /&gt;
* [[Virtual Graphs]]&lt;br /&gt;
* [[Functions]]&lt;br /&gt;
* [[Procedural Values]]&lt;br /&gt;
* [[Variable]]&lt;br /&gt;
* [[Undo Mechanism]]&lt;br /&gt;
* [[Team Features]]&lt;br /&gt;
* [[Subgraph Extents]]&lt;br /&gt;
* [[Database Testing]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Data management &amp;amp; Experiment Control ===&lt;br /&gt;
&lt;br /&gt;
* [[Databoard Specification]]&lt;br /&gt;
* [[Databoard Developer Manual|Databoard Java Manual]]&lt;br /&gt;
* [[Experiment Control]]&lt;br /&gt;
* [[Dataflows]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== UI Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Org.simantics.browsing.ui_Manual|Browser Manual]]&lt;br /&gt;
* [[org.simantics.browsing.ui.feature|Browser Component]]&lt;br /&gt;
* [[Org.simantics.scenegraph.loader|Scene Graph Loader]]&lt;br /&gt;
* [[Org.simantics.message|Messages]]&lt;br /&gt;
* [[Org.simantics.views|Modelled Views]]&lt;br /&gt;
* [[Org.simantics.document|Documents]]&lt;br /&gt;
* [[Selection View]]&lt;br /&gt;
|}&lt;br /&gt;
{|width=&amp;quot;100%&amp;quot;&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Simantics Constraint Language===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--* [[SCL_Language|SCL Language]] --&amp;gt;&lt;br /&gt;
&amp;lt;!--* [https://www.simantics.org/wiki/index.php/Org.simantics.scl_Compiler SCL Compiler]--&amp;gt;&lt;br /&gt;
* [[Org.simantics.objmap_Manual|Object Map Manual]]&lt;br /&gt;
* [[SCL Registry]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Model Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Structural Ontology]]&lt;br /&gt;
* [[Users and Roles]]&lt;br /&gt;
* [[Models]]&lt;br /&gt;
* [[Tutorial: Model Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Project Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Project Management Conceptual Model]]&lt;br /&gt;
* [[Project Development]]&lt;br /&gt;
* [[Tutorial: Project Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Diagram Development ===&lt;br /&gt;
&lt;br /&gt;
* [[2D Ontologies]]&lt;br /&gt;
* [[org.simantics.diagram|Diagram]]&lt;br /&gt;
* [[org.simantics.scenegraph|Scene graph]]&lt;br /&gt;
* [[Diagram connections]]&lt;br /&gt;
* [[Tutorial: Diagram Development]]&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;25%&amp;quot; valign=&amp;quot;top&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
=== Issue Development ===&lt;br /&gt;
&lt;br /&gt;
* [[Issue subsystem general description]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
-----&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2740</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2740"/>
		<updated>2012-03-30T05:58:15Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Standard graph based variable implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
* All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard properties =&lt;br /&gt;
&lt;br /&gt;
== Connections ==&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
== String editing operations ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
== Property properties ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
== Complex datatypes ==&lt;br /&gt;
&lt;br /&gt;
* Record&lt;br /&gt;
** All named fields are &#039;/name&#039;&lt;br /&gt;
** Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
* Union&lt;br /&gt;
** Union does not show in URI&lt;br /&gt;
* Array&lt;br /&gt;
** Elements are named after position e.g. &#039;/i-11&#039;&lt;br /&gt;
* Map&lt;br /&gt;
** Items are named after key &lt;br /&gt;
&lt;br /&gt;
= Standard graph based variable implementation =&lt;br /&gt;
&lt;br /&gt;
The standard child and property variables are&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable&lt;br /&gt;
&lt;br /&gt;
Their implementation is based on the following interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface VariableMap {&lt;br /&gt;
    Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException;&lt;br /&gt;
    // Must not modify collection in any way not possible with put-method.&lt;br /&gt;
    void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface ValueAccessor {&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context) throws DatabaseException;&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Implementations of the above interfaces can be bound to instances and types in the database via the following standard properties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
L0.Entity&lt;br /&gt;
  &amp;gt;-- L0.hasStandardResource ==&amp;gt; &amp;quot;Resource&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation&lt;br /&gt;
    L0.HasDescription &amp;quot;The backend resource for standard graph-based Variables.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainProperties ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain properties of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainChildren ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain children of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.valueAccessor ==&amp;gt; &amp;quot;ValueAccessor&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Returns an interface for accessing the value.&amp;quot;&lt;br /&gt;
  @L0.assert L0.hasStandardResource&lt;br /&gt;
    L0.Functions.hasStandardResource : L0.Function&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardChildDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardChildDomainChildren&lt;br /&gt;
&lt;br /&gt;
L0.Value&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardPropertyDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardPropertyDomainChildren&lt;br /&gt;
  @L0.assert L0.valueAccessor L0.Functions.standardValueAccessor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard implementation is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@SCLValue(type = &amp;quot;ValueAccessor&amp;quot;)&lt;br /&gt;
public static ValueAccessor standardValueAccessor = new ValueAccessor() {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
		try {&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) return propertyAccessor.getValue(graph, context);&lt;br /&gt;
			if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
				Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
				return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);&lt;br /&gt;
			}&lt;br /&gt;
			if(variable.adapterClass != null) {&lt;br /&gt;
				return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
			} else {&lt;br /&gt;
				return graph.getRelatedValue2(variable.parentResource, variable.property, variable);&lt;br /&gt;
			}&lt;br /&gt;
		} catch (NoSingleResultException e) {&lt;br /&gt;
			throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
		} catch (DoesNotContainValueException e) {&lt;br /&gt;
			throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
		} catch (DatabaseException e) {&lt;br /&gt;
			throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
		try {&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) return propertyAccessor.getValue(graph, context, binding);&lt;br /&gt;
			if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
				Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
				return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);&lt;br /&gt;
			}&lt;br /&gt;
			if(variable.adapterClass != null) {&lt;br /&gt;
				return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
			} else {&lt;br /&gt;
				return graph.getRelatedValue2(variable.parentResource, variable.property, variable, binding);&lt;br /&gt;
			}&lt;br /&gt;
		} catch (NoSingleResultException e) {&lt;br /&gt;
			throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
		} catch (DoesNotContainValueException e) {&lt;br /&gt;
			throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
		} catch (DatabaseException e) {&lt;br /&gt;
			throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
		ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
		if(propertyAccessor != null) {&lt;br /&gt;
			propertyAccessor.setValue(graph, context, value);&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
		Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
		if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
		try {&lt;br /&gt;
			modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));&lt;br /&gt;
		} catch (BindingConstructionException e) {&lt;br /&gt;
			throw new DatabaseException(e);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
		ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
		if(propertyAccessor != null) {&lt;br /&gt;
			propertyAccessor.setValue(graph, context, value, binding);&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
		Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
		if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
		modifier.apply(graph, context, value, binding);&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
@SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
public static VariableMap standardChildDomainProperties = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
	       	final StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
	       	return getPossiblePropertyFromContext(graph, variable, variable.resource, name);&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
    		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.resource, map);&lt;br /&gt;
	}&lt;br /&gt;
		&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
@SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
public static VariableMap standardPropertyDomainProperties = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) {&lt;br /&gt;
        		Variable result = getPossiblePropertyFromContext(graph, variable, literal, name);&lt;br /&gt;
        		if(result != null) return result;&lt;br /&gt;
        	}&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.property, name);&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
		StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.property, map);&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) collectPropertiesFromContext(graph, variable, literal, map);&lt;br /&gt;
	}&lt;br /&gt;
		&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
@SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
public static VariableMap standardChildDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
		Map&amp;lt;String, Resource&amp;gt; children = graph.syncRequest(new UnescapedChildMapOfResource(variable.resource));&lt;br /&gt;
		Resource child = children.get(name);&lt;br /&gt;
		if(child == null) return null;&lt;br /&gt;
		return graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
		for(Map.Entry&amp;lt;String, Resource&amp;gt; entry : graph.syncRequest(new UnescapedChildMapOfResource(variable.resource)).entrySet()) {&lt;br /&gt;
			String name = entry.getKey();&lt;br /&gt;
			Resource child = entry.getValue();&lt;br /&gt;
			Variable var = graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
			if(var != null) {&lt;br /&gt;
				map.put(name, var);&lt;br /&gt;
			} else {&lt;br /&gt;
				System.err.println(&amp;quot;No adapter for &amp;quot; + child + &amp;quot; in &amp;quot; + variable.getURI(graph));&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
		&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
@SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
public static VariableMap standardPropertyDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		Datatype dt = variable.getDatatype(graph);&lt;br /&gt;
    		if (dt instanceof ArrayType) {&lt;br /&gt;
    		    ChildReference ref = getPossibleIndexReference(name);&lt;br /&gt;
    		    if (ref != null)&lt;br /&gt;
    		        return new SubliteralPropertyVariable(variable, ref);&lt;br /&gt;
    		}&lt;br /&gt;
    		return null;&lt;br /&gt;
	}&lt;br /&gt;
	@Override&lt;br /&gt;
	public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
	}&lt;br /&gt;
		&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Informally ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
The graph.adaptContextual step is an extension point for defining custom variable implementations contributed using the adapter (adapters.xml) mechanism.&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model (Resource)&lt;br /&gt;
   call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain context (Variable)&lt;br /&gt;
   call Variables.getContext(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Obtain string representation for value of Variable v&lt;br /&gt;
   obtain value of v#HasDisplayValue&lt;br /&gt;
&lt;br /&gt;
to be continued...&lt;br /&gt;
&lt;br /&gt;
= Open issues =&lt;br /&gt;
&lt;br /&gt;
== Generic simulator support in Variable ==&lt;br /&gt;
&lt;br /&gt;
Current hypothesis is that we extends standard graph based implementation by a special interface, which serves the simulator (or other) data. The standard implementation then combines data from graph and simulator. The special interface is designed such that is supports custom synchronization and lazy operation and can also be directly utilized in remote simulators.&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
== Experiment modelling ==&lt;br /&gt;
&lt;br /&gt;
The modelling of experiment run contexts and the value types of properties in states is still underway.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2739</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2739"/>
		<updated>2012-03-30T05:54:21Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Frequent cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
* All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard properties =&lt;br /&gt;
&lt;br /&gt;
== Connections ==&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
== String editing operations ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
== Property properties ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
== Complex datatypes ==&lt;br /&gt;
&lt;br /&gt;
* Record&lt;br /&gt;
** All named fields are &#039;/name&#039;&lt;br /&gt;
** Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
* Union&lt;br /&gt;
** Union does not show in URI&lt;br /&gt;
* Array&lt;br /&gt;
** Elements are named after position e.g. &#039;/i-11&#039;&lt;br /&gt;
* Map&lt;br /&gt;
** Items are named after key &lt;br /&gt;
&lt;br /&gt;
= Standard graph based variable implementation =&lt;br /&gt;
&lt;br /&gt;
The standard child and property variables are&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable&lt;br /&gt;
&lt;br /&gt;
Their implementation is based on the following interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface VariableMap {&lt;br /&gt;
    Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException;&lt;br /&gt;
    // Must not modify collection in any way not possible with put-method.&lt;br /&gt;
    void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface ValueAccessor {&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context) throws DatabaseException;&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Implementations of the above interfaces can be bound to instances and types in the database via the following standard properties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
L0.Entity&lt;br /&gt;
  &amp;gt;-- L0.hasStandardResource ==&amp;gt; &amp;quot;Resource&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation&lt;br /&gt;
    L0.HasDescription &amp;quot;The backend resource for standard graph-based Variables.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainProperties ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain properties of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainChildren ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain children of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.valueAccessor ==&amp;gt; &amp;quot;ValueAccessor&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Returns an interface for accessing the value.&amp;quot;&lt;br /&gt;
  @L0.assert L0.hasStandardResource&lt;br /&gt;
    L0.Functions.hasStandardResource : L0.Function&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardChildDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardChildDomainChildren&lt;br /&gt;
&lt;br /&gt;
L0.Value&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardPropertyDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardPropertyDomainChildren&lt;br /&gt;
  @L0.assert L0.valueAccessor L0.Functions.standardValueAccessor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard implementation is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ValueAccessor&amp;quot;)&lt;br /&gt;
	public static ValueAccessor standardValueAccessor = new ValueAccessor() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			try {&lt;br /&gt;
				&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
&lt;br /&gt;
			try {&lt;br /&gt;
&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context, binding);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			try {&lt;br /&gt;
				modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));&lt;br /&gt;
			} catch (BindingConstructionException e) {&lt;br /&gt;
				throw new DatabaseException(e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value, binding);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			modifier.apply(graph, context, value, binding);&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainProperties = new VariableMap() {&lt;br /&gt;
    	&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	final StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.resource, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
    		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.resource, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainProperties = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) {&lt;br /&gt;
        		Variable result = getPossiblePropertyFromContext(graph, variable, literal, name);&lt;br /&gt;
        		if(result != null) return result;&lt;br /&gt;
        	}&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.property, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.property, map);&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) collectPropertiesFromContext(graph, variable, literal, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			Map&amp;lt;String, Resource&amp;gt; children = graph.syncRequest(new UnescapedChildMapOfResource(variable.resource));&lt;br /&gt;
			Resource child = children.get(name);&lt;br /&gt;
			if(child == null) return null;&lt;br /&gt;
			return graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			for(Map.Entry&amp;lt;String, Resource&amp;gt; entry : graph.syncRequest(new UnescapedChildMapOfResource(variable.resource)).entrySet()) {&lt;br /&gt;
				String name = entry.getKey();&lt;br /&gt;
				Resource child = entry.getValue();&lt;br /&gt;
				Variable var = graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
				if(var != null) {&lt;br /&gt;
					map.put(name, var);&lt;br /&gt;
				} else {&lt;br /&gt;
					System.err.println(&amp;quot;No adapter for &amp;quot; + child + &amp;quot; in &amp;quot; + variable.getURI(graph));&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		Datatype dt = variable.getDatatype(graph);&lt;br /&gt;
    		if (dt instanceof ArrayType) {&lt;br /&gt;
    		    ChildReference ref = getPossibleIndexReference(name);&lt;br /&gt;
    		    if (ref != null)&lt;br /&gt;
    		        return new SubliteralPropertyVariable(variable, ref);&lt;br /&gt;
    		}&lt;br /&gt;
    		return null;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Informally ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
The graph.adaptContextual step is an extension point for defining custom variable implementations contributed using the adapter (adapters.xml) mechanism.&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model (Resource)&lt;br /&gt;
   call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain context (Variable)&lt;br /&gt;
   call Variables.getContext(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Obtain string representation for value of Variable v&lt;br /&gt;
   obtain value of v#HasDisplayValue&lt;br /&gt;
&lt;br /&gt;
to be continued...&lt;br /&gt;
&lt;br /&gt;
= Open issues =&lt;br /&gt;
&lt;br /&gt;
== Generic simulator support in Variable ==&lt;br /&gt;
&lt;br /&gt;
Current hypothesis is that we extends standard graph based implementation by a special interface, which serves the simulator (or other) data. The standard implementation then combines data from graph and simulator. The special interface is designed such that is supports custom synchronization and lazy operation and can also be directly utilized in remote simulators.&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
== Experiment modelling ==&lt;br /&gt;
&lt;br /&gt;
The modelling of experiment run contexts and the value types of properties in states is still underway.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2738</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2738"/>
		<updated>2012-03-30T05:54:00Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Frequent cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
* All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard properties =&lt;br /&gt;
&lt;br /&gt;
== Connections ==&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
== String editing operations ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
== Property properties ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
== Complex datatypes ==&lt;br /&gt;
&lt;br /&gt;
* Record&lt;br /&gt;
** All named fields are &#039;/name&#039;&lt;br /&gt;
** Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
* Union&lt;br /&gt;
** Union does not show in URI&lt;br /&gt;
* Array&lt;br /&gt;
** Elements are named after position e.g. &#039;/i-11&#039;&lt;br /&gt;
* Map&lt;br /&gt;
** Items are named after key &lt;br /&gt;
&lt;br /&gt;
= Standard graph based variable implementation =&lt;br /&gt;
&lt;br /&gt;
The standard child and property variables are&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable&lt;br /&gt;
&lt;br /&gt;
Their implementation is based on the following interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface VariableMap {&lt;br /&gt;
    Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException;&lt;br /&gt;
    // Must not modify collection in any way not possible with put-method.&lt;br /&gt;
    void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface ValueAccessor {&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context) throws DatabaseException;&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Implementations of the above interfaces can be bound to instances and types in the database via the following standard properties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
L0.Entity&lt;br /&gt;
  &amp;gt;-- L0.hasStandardResource ==&amp;gt; &amp;quot;Resource&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation&lt;br /&gt;
    L0.HasDescription &amp;quot;The backend resource for standard graph-based Variables.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainProperties ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain properties of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainChildren ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain children of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.valueAccessor ==&amp;gt; &amp;quot;ValueAccessor&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Returns an interface for accessing the value.&amp;quot;&lt;br /&gt;
  @L0.assert L0.hasStandardResource&lt;br /&gt;
    L0.Functions.hasStandardResource : L0.Function&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardChildDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardChildDomainChildren&lt;br /&gt;
&lt;br /&gt;
L0.Value&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardPropertyDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardPropertyDomainChildren&lt;br /&gt;
  @L0.assert L0.valueAccessor L0.Functions.standardValueAccessor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard implementation is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ValueAccessor&amp;quot;)&lt;br /&gt;
	public static ValueAccessor standardValueAccessor = new ValueAccessor() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			try {&lt;br /&gt;
				&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
&lt;br /&gt;
			try {&lt;br /&gt;
&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context, binding);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			try {&lt;br /&gt;
				modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));&lt;br /&gt;
			} catch (BindingConstructionException e) {&lt;br /&gt;
				throw new DatabaseException(e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value, binding);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			modifier.apply(graph, context, value, binding);&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainProperties = new VariableMap() {&lt;br /&gt;
    	&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	final StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.resource, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
    		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.resource, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainProperties = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) {&lt;br /&gt;
        		Variable result = getPossiblePropertyFromContext(graph, variable, literal, name);&lt;br /&gt;
        		if(result != null) return result;&lt;br /&gt;
        	}&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.property, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.property, map);&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) collectPropertiesFromContext(graph, variable, literal, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			Map&amp;lt;String, Resource&amp;gt; children = graph.syncRequest(new UnescapedChildMapOfResource(variable.resource));&lt;br /&gt;
			Resource child = children.get(name);&lt;br /&gt;
			if(child == null) return null;&lt;br /&gt;
			return graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			for(Map.Entry&amp;lt;String, Resource&amp;gt; entry : graph.syncRequest(new UnescapedChildMapOfResource(variable.resource)).entrySet()) {&lt;br /&gt;
				String name = entry.getKey();&lt;br /&gt;
				Resource child = entry.getValue();&lt;br /&gt;
				Variable var = graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
				if(var != null) {&lt;br /&gt;
					map.put(name, var);&lt;br /&gt;
				} else {&lt;br /&gt;
					System.err.println(&amp;quot;No adapter for &amp;quot; + child + &amp;quot; in &amp;quot; + variable.getURI(graph));&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		Datatype dt = variable.getDatatype(graph);&lt;br /&gt;
    		if (dt instanceof ArrayType) {&lt;br /&gt;
    		    ChildReference ref = getPossibleIndexReference(name);&lt;br /&gt;
    		    if (ref != null)&lt;br /&gt;
    		        return new SubliteralPropertyVariable(variable, ref);&lt;br /&gt;
    		}&lt;br /&gt;
    		return null;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Informally ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
The graph.adaptContextual step is an extension point for defining custom variable implementations contributed using the adapter (adapters.xml) mechanism.&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model (Resource)&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain context (Variable)&lt;br /&gt;
   Procedure: call Variables.getContext(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Obtain string representation for value of Variable v&lt;br /&gt;
   -obtain value of v#HasDisplayValue&lt;br /&gt;
&lt;br /&gt;
to be continued...&lt;br /&gt;
&lt;br /&gt;
= Open issues =&lt;br /&gt;
&lt;br /&gt;
== Generic simulator support in Variable ==&lt;br /&gt;
&lt;br /&gt;
Current hypothesis is that we extends standard graph based implementation by a special interface, which serves the simulator (or other) data. The standard implementation then combines data from graph and simulator. The special interface is designed such that is supports custom synchronization and lazy operation and can also be directly utilized in remote simulators.&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
== Experiment modelling ==&lt;br /&gt;
&lt;br /&gt;
The modelling of experiment run contexts and the value types of properties in states is still underway.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2737</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2737"/>
		<updated>2012-03-30T05:51:20Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Open issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
* All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard properties =&lt;br /&gt;
&lt;br /&gt;
== Connections ==&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
== String editing operations ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
== Property properties ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
== Complex datatypes ==&lt;br /&gt;
&lt;br /&gt;
* Record&lt;br /&gt;
** All named fields are &#039;/name&#039;&lt;br /&gt;
** Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
* Union&lt;br /&gt;
** Union does not show in URI&lt;br /&gt;
* Array&lt;br /&gt;
** Elements are named after position e.g. &#039;/i-11&#039;&lt;br /&gt;
* Map&lt;br /&gt;
** Items are named after key &lt;br /&gt;
&lt;br /&gt;
= Standard graph based variable implementation =&lt;br /&gt;
&lt;br /&gt;
The standard child and property variables are&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable&lt;br /&gt;
&lt;br /&gt;
Their implementation is based on the following interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface VariableMap {&lt;br /&gt;
    Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException;&lt;br /&gt;
    // Must not modify collection in any way not possible with put-method.&lt;br /&gt;
    void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface ValueAccessor {&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context) throws DatabaseException;&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Implementations of the above interfaces can be bound to instances and types in the database via the following standard properties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
L0.Entity&lt;br /&gt;
  &amp;gt;-- L0.hasStandardResource ==&amp;gt; &amp;quot;Resource&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation&lt;br /&gt;
    L0.HasDescription &amp;quot;The backend resource for standard graph-based Variables.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainProperties ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain properties of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainChildren ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain children of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.valueAccessor ==&amp;gt; &amp;quot;ValueAccessor&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Returns an interface for accessing the value.&amp;quot;&lt;br /&gt;
  @L0.assert L0.hasStandardResource&lt;br /&gt;
    L0.Functions.hasStandardResource : L0.Function&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardChildDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardChildDomainChildren&lt;br /&gt;
&lt;br /&gt;
L0.Value&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardPropertyDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardPropertyDomainChildren&lt;br /&gt;
  @L0.assert L0.valueAccessor L0.Functions.standardValueAccessor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard implementation is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ValueAccessor&amp;quot;)&lt;br /&gt;
	public static ValueAccessor standardValueAccessor = new ValueAccessor() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			try {&lt;br /&gt;
				&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
&lt;br /&gt;
			try {&lt;br /&gt;
&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context, binding);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			try {&lt;br /&gt;
				modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));&lt;br /&gt;
			} catch (BindingConstructionException e) {&lt;br /&gt;
				throw new DatabaseException(e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value, binding);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			modifier.apply(graph, context, value, binding);&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainProperties = new VariableMap() {&lt;br /&gt;
    	&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	final StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.resource, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
    		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.resource, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainProperties = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) {&lt;br /&gt;
        		Variable result = getPossiblePropertyFromContext(graph, variable, literal, name);&lt;br /&gt;
        		if(result != null) return result;&lt;br /&gt;
        	}&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.property, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.property, map);&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) collectPropertiesFromContext(graph, variable, literal, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			Map&amp;lt;String, Resource&amp;gt; children = graph.syncRequest(new UnescapedChildMapOfResource(variable.resource));&lt;br /&gt;
			Resource child = children.get(name);&lt;br /&gt;
			if(child == null) return null;&lt;br /&gt;
			return graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			for(Map.Entry&amp;lt;String, Resource&amp;gt; entry : graph.syncRequest(new UnescapedChildMapOfResource(variable.resource)).entrySet()) {&lt;br /&gt;
				String name = entry.getKey();&lt;br /&gt;
				Resource child = entry.getValue();&lt;br /&gt;
				Variable var = graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
				if(var != null) {&lt;br /&gt;
					map.put(name, var);&lt;br /&gt;
				} else {&lt;br /&gt;
					System.err.println(&amp;quot;No adapter for &amp;quot; + child + &amp;quot; in &amp;quot; + variable.getURI(graph));&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		Datatype dt = variable.getDatatype(graph);&lt;br /&gt;
    		if (dt instanceof ArrayType) {&lt;br /&gt;
    		    ChildReference ref = getPossibleIndexReference(name);&lt;br /&gt;
    		    if (ref != null)&lt;br /&gt;
    		        return new SubliteralPropertyVariable(variable, ref);&lt;br /&gt;
    		}&lt;br /&gt;
    		return null;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Informally ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
The graph.adaptContextual step is an extension point for defining custom variable implementations contributed using the adapter (adapters.xml) mechanism.&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Open issues =&lt;br /&gt;
&lt;br /&gt;
== Generic simulator support in Variable ==&lt;br /&gt;
&lt;br /&gt;
Current hypothesis is that we extends standard graph based implementation by a special interface, which serves the simulator (or other) data. The standard implementation then combines data from graph and simulator. The special interface is designed such that is supports custom synchronization and lazy operation and can also be directly utilized in remote simulators.&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
== Experiment modelling ==&lt;br /&gt;
&lt;br /&gt;
The modelling of experiment run contexts and the value types of properties in states is still underway.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2736</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2736"/>
		<updated>2012-03-30T05:48:43Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
* All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard properties =&lt;br /&gt;
&lt;br /&gt;
== Connections ==&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
== String editing operations ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
== Property properties ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
== Complex datatypes ==&lt;br /&gt;
&lt;br /&gt;
* Record&lt;br /&gt;
** All named fields are &#039;/name&#039;&lt;br /&gt;
** Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
* Union&lt;br /&gt;
** Union does not show in URI&lt;br /&gt;
* Array&lt;br /&gt;
** Elements are named after position e.g. &#039;/i-11&#039;&lt;br /&gt;
* Map&lt;br /&gt;
** Items are named after key &lt;br /&gt;
&lt;br /&gt;
= Standard graph based variable implementation =&lt;br /&gt;
&lt;br /&gt;
The standard child and property variables are&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable&lt;br /&gt;
&lt;br /&gt;
Their implementation is based on the following interfaces&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface VariableMap {&lt;br /&gt;
    Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException;&lt;br /&gt;
    // Must not modify collection in any way not possible with put-method.&lt;br /&gt;
    void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
package org.simantics.db.layer0.variable;&lt;br /&gt;
&lt;br /&gt;
public interface ValueAccessor {&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context) throws DatabaseException;&lt;br /&gt;
    Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException;&lt;br /&gt;
    void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Implementations of the above interfaces can be bound to instances and types in the database via the following standard properties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
L0.Entity&lt;br /&gt;
  &amp;gt;-- L0.hasStandardResource ==&amp;gt; &amp;quot;Resource&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation&lt;br /&gt;
    L0.HasDescription &amp;quot;The backend resource for standard graph-based Variables.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainProperties ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain properties of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.domainChildren ==&amp;gt; &amp;quot;VariableMap&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Retruns a map of all domain children of the entity.&amp;quot;&lt;br /&gt;
  &amp;gt;-- L0.valueAccessor ==&amp;gt; &amp;quot;ValueAccessor&amp;quot; &amp;lt;R L0.HasProperty : L0.FunctionalRelation &lt;br /&gt;
    L0.HasDescription &amp;quot;Returns an interface for accessing the value.&amp;quot;&lt;br /&gt;
  @L0.assert L0.hasStandardResource&lt;br /&gt;
    L0.Functions.hasStandardResource : L0.Function&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardChildDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardChildDomainChildren&lt;br /&gt;
&lt;br /&gt;
L0.Value&lt;br /&gt;
  @L0.assert L0.domainProperties L0.Functions.standardPropertyDomainProperties&lt;br /&gt;
  @L0.assert L0.domainChildren L0.Functions.standardPropertyDomainChildren&lt;br /&gt;
  @L0.assert L0.valueAccessor L0.Functions.standardValueAccessor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard implementation is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ValueAccessor&amp;quot;)&lt;br /&gt;
	public static ValueAccessor standardValueAccessor = new ValueAccessor() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			try {&lt;br /&gt;
				&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph), e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Object getValue(ReadGraph graph, Variable context, Binding binding) throws DatabaseException {&lt;br /&gt;
			&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
&lt;br /&gt;
			try {&lt;br /&gt;
&lt;br /&gt;
				ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
				if(propertyAccessor != null) return propertyAccessor.getValue(graph, context, binding);&lt;br /&gt;
				&lt;br /&gt;
				if(graph.sync(new IsEnumeratedValue(variable.getRepresents(graph)))) {&lt;br /&gt;
					Layer0 L0 = Layer0.getInstance(graph);&lt;br /&gt;
					return graph.getRelatedValue2(variable.getRepresents(graph), L0.HasLabel, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				if(variable.adapterClass != null) {&lt;br /&gt;
					return graph.adaptRelated(variable.parentResource, variable.property, variable.adapterClass);&lt;br /&gt;
				} else {&lt;br /&gt;
					return graph.getRelatedValue2(variable.parentResource, variable.property, variable, binding);&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
			} catch (NoSingleResultException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DoesNotContainValueException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			} catch (DatabaseException e) {&lt;br /&gt;
				throw new MissingVariableValueException(variable.getPossibleURI(graph));&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			try {&lt;br /&gt;
				modifier.apply(graph, context, value, Bindings.getBinding(value.getClass()));&lt;br /&gt;
			} catch (BindingConstructionException e) {&lt;br /&gt;
				throw new DatabaseException(e);&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void setValue(WriteGraph graph, Variable context, Object value, Binding binding) throws DatabaseException {&lt;br /&gt;
&lt;br /&gt;
	    	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
			&lt;br /&gt;
			ValueAccessor propertyAccessor = getPossiblePropertyValueAccessor(graph, variable);&lt;br /&gt;
			if(propertyAccessor != null) {&lt;br /&gt;
				propertyAccessor.setValue(graph, context, value, binding);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			Function4&amp;lt;WriteGraph, Variable, Object, Object, String&amp;gt; modifier = context.getPossiblePropertyValue(graph, Variables.INPUT_MODIFIER);&lt;br /&gt;
			if(modifier == null) modifier = VariableUtils.defaultInputModifier; &lt;br /&gt;
			modifier.apply(graph, context, value, binding);&lt;br /&gt;
			&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainProperties = new VariableMap() {&lt;br /&gt;
    	&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	final StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.resource, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
    		StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.resource, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainProperties = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) {&lt;br /&gt;
        		Variable result = getPossiblePropertyFromContext(graph, variable, literal, name);&lt;br /&gt;
        		if(result != null) return result;&lt;br /&gt;
        	}&lt;br /&gt;
        	return getPossiblePropertyFromContext(graph, variable, variable.property, name);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		collectPropertiesFromContext(graph, variable, variable.property, map);&lt;br /&gt;
        	Resource literal = graph.getPossibleObject(variable.parentResource, variable.property);&lt;br /&gt;
        	if(literal != null) collectPropertiesFromContext(graph, variable, literal, map);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardChildDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			Map&amp;lt;String, Resource&amp;gt; children = graph.syncRequest(new UnescapedChildMapOfResource(variable.resource));&lt;br /&gt;
			Resource child = children.get(name);&lt;br /&gt;
			if(child == null) return null;&lt;br /&gt;
			return graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
			StandardGraphChildVariable variable = (StandardGraphChildVariable)context;&lt;br /&gt;
			for(Map.Entry&amp;lt;String, Resource&amp;gt; entry : graph.syncRequest(new UnescapedChildMapOfResource(variable.resource)).entrySet()) {&lt;br /&gt;
				String name = entry.getKey();&lt;br /&gt;
				Resource child = entry.getValue();&lt;br /&gt;
				Variable var = graph.getPossibleContextualAdapter(child, variable, Variable.class, Variable.class);&lt;br /&gt;
				if(var != null) {&lt;br /&gt;
					map.put(name, var);&lt;br /&gt;
				} else {&lt;br /&gt;
					System.err.println(&amp;quot;No adapter for &amp;quot; + child + &amp;quot; in &amp;quot; + variable.getURI(graph));&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;VariableMap&amp;quot;)&lt;br /&gt;
	public static VariableMap standardPropertyDomainChildren = new VariableMap() {&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {&lt;br /&gt;
        	StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;&lt;br /&gt;
    		Datatype dt = variable.getDatatype(graph);&lt;br /&gt;
    		if (dt instanceof ArrayType) {&lt;br /&gt;
    		    ChildReference ref = getPossibleIndexReference(name);&lt;br /&gt;
    		    if (ref != null)&lt;br /&gt;
    		        return new SubliteralPropertyVariable(variable, ref);&lt;br /&gt;
    		}&lt;br /&gt;
    		return null;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		@Override&lt;br /&gt;
		public void getVariables(ReadGraph graph, Variable context, Map&amp;lt;String, Variable&amp;gt; map) throws DatabaseException {&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Informally ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
The graph.adaptContextual step is an extension point for defining custom variable implementations contributed using the adapter (adapters.xml) mechanism.&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Open issues =&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
== Experiment modelling ==&lt;br /&gt;
&lt;br /&gt;
The modelling of experiment run contexts and the value types of properties in states is still underway.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2735</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2735"/>
		<updated>2012-03-30T05:28:37Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* General assertions in the Variable model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
* All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2734</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2734"/>
		<updated>2012-03-30T05:27:40Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
= General assertions in the Variable model =&lt;br /&gt;
&lt;br /&gt;
* All variables except the &#039;&#039;&#039;root&#039;&#039;&#039; have a parent&lt;br /&gt;
* Let p be the parent of v. Then v#URI equals p#URI + &#039;/&#039;|&#039;#&#039; + escape(v#HasName)&lt;br /&gt;
* Iff v1#URI equals v2#URI, then v1 and v2 are equal in Java Object.equals sense&lt;br /&gt;
** Other identifications can be established by property values&lt;br /&gt;
* A variable v2 equaling variable v can always be obtained by calling Variables.getVariable(v#URI)&lt;br /&gt;
** The obtained variable &#039;&#039;&#039;need not be the same object&#039;&#039;&#039; but &#039;&#039;&#039;can be&#039;&#039;&#039;&lt;br /&gt;
** Variables.getVariable can return also variables, which are not reachable by browsing (&#039;&#039;&#039;TODO&#039;&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
* §1 All property variables have a value&lt;br /&gt;
** No child variable has a value&lt;br /&gt;
** The value of a property variable may be &#039;&#039;&#039;null&#039;&#039;&#039;&lt;br /&gt;
** The value of &#039;&#039;&#039;DATATYPE&#039;&#039;&#039; property can be null for property variables i.e. property values can be arbitrary Java objects&lt;br /&gt;
&lt;br /&gt;
* §2 Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
** Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
* §2 Variable.getChild returns all the variables returned from Variable.browseChildren &lt;br /&gt;
** Variable.getChild can return variables not returned by Variable.browseChildren&lt;br /&gt;
* §5 A variable can be part of at most one &#039;&#039;&#039;model&#039;&#039;&#039;&lt;br /&gt;
* §4 A variable can be part of at most one &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2733</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2733"/>
		<updated>2012-03-30T05:11:21Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
** Survives export/import&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
* The &#039;&#039;&#039;Type&#039;&#039;&#039; property of a context variable is inheried from L0.RVIContext&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
* The &#039;&#039;&#039;configuration&#039;&#039;&#039; context can be used to browse the structure and configuration values of the model&lt;br /&gt;
* &#039;&#039;Experiment run&#039;&#039;&#039; contexts are used to monitor values from simulations or history&lt;br /&gt;
&lt;br /&gt;
The variable interface is bound to Simantics database &#039;&#039;&#039;transactions&#039;&#039;&#039;, but is not in any other way bound to the semantic data model, which allows variable implementations to represent arbitrary data models somehow related to Simantics models. All variable-based requests can be listened using standard Simantics database listening.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2732</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2732"/>
		<updated>2012-03-30T04:58:39Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* RVI represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2731</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2731"/>
		<updated>2012-03-30T04:57:56Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) the value of a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
Other properties and the structure of the variable space is configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Examples:  &lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/Configuration/DiagramN/PI_X#PI_MASS_FLOW&lt;br /&gt;
** http://www.acme.org/Projects/MyProject/MyModel/ExperimentConfiguration/RunName/DiagramN/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
* A literal RVI (Variable.getRVI(), RVI.resolve())&lt;br /&gt;
** Does not need to depend on the names visible in the URI&lt;br /&gt;
** Is based on e.g. resource ids&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2730</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2730"/>
		<updated>2012-03-30T04:51:10Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain its own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;parent&#039;&#039;&#039; variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) a value for a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
More properties are configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
*Examples:  &lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/Configuration/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2729</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2729"/>
		<updated>2012-03-30T04:50:59Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a tree-structured view into the Simantics data model. Each variable is either a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; and can further contain its own children and properties. The difference between a child and a property is that a property contains a &#039;&#039;&#039;value&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The variable space browsing methods are used to obtain&lt;br /&gt;
&lt;br /&gt;
* all children&lt;br /&gt;
* children by name&lt;br /&gt;
* all properties&lt;br /&gt;
* properties by name&lt;br /&gt;
* variable by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
* parent variable&lt;br /&gt;
&lt;br /&gt;
Other services are&lt;br /&gt;
&lt;br /&gt;
* accessing (get/set) a value for a property variable&lt;br /&gt;
* querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties is required for all variables. These properties have also dedicated interface methods.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
More properties are configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
*Examples:  &lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/Configuration/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2728</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2728"/>
		<updated>2012-03-30T04:39:38Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a view into the Simantics data model with the following services&lt;br /&gt;
&lt;br /&gt;
* Browsing the variable space&lt;br /&gt;
** children (variables)&lt;br /&gt;
*** all&lt;br /&gt;
*** by name&lt;br /&gt;
** properties (variables) by&lt;br /&gt;
*** all&lt;br /&gt;
*** by name&lt;br /&gt;
** by &#039;&#039;&#039;path&#039;&#039;&#039;&lt;br /&gt;
** the &#039;&#039;&#039;parent&#039;&#039;&#039;&lt;br /&gt;
*Accessing (get/set) a value for a property variable&lt;br /&gt;
*Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
More properties are configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
*Examples:  &lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/Configuration/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2727</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2727"/>
		<updated>2012-03-30T04:35:33Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Intro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model configuration and states&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* &#039;&#039;&#039;Manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* Representation of &#039;&#039;&#039;tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a view into the Simantics data model with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Accessing (get/set) a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
More properties are configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
*Examples:  &lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/Configuration/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2726</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2726"/>
		<updated>2012-03-29T12:38:59Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a view into the Simantics data model with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Accessing (get/set) a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
More properties are configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
*Examples:  &lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/Configuration/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
The following general rules about variables apply:&lt;br /&gt;
&lt;br /&gt;
* Variable.getProperty returns all the variables returned from Variable.browseProperties &lt;br /&gt;
* Variable.getProperty can return variables not returned by Variable.browseProperties&lt;br /&gt;
** E.g. procedural variables &lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2725</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2725"/>
		<updated>2012-03-29T12:36:20Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Variable&#039;&#039;&#039; is a view into the Simantics data model with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Accessing (get/set) a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, which is a resource representing the variable &#039;&#039;&#039;TODO&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
More properties are configured in the semantic graph or contributed by custom variable implementations.&lt;br /&gt;
&lt;br /&gt;
Variables can be located using an &#039;&#039;&#039;URI&#039;&#039;&#039;, which&lt;br /&gt;
&lt;br /&gt;
* Is an &#039;&#039;&#039;identifier&#039;&#039;&#039; (two variables with the same URI are the same in the sense of Java Object.equals)&lt;br /&gt;
* Is a random access identifier (by Variables.getVariable())&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;root variable&#039;&#039;&#039; (Variables.getRootVariable) into the variable such that&lt;br /&gt;
** &#039;&#039;&#039;var/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query from var&lt;br /&gt;
** &#039;&#039;&#039;var#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query from var&lt;br /&gt;
** the escape function is bidirectional (URIStringUtils.escape and URIStringUtils.unescape)&lt;br /&gt;
*Examples:  &lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/Configuration/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
**http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#DATATYPE&lt;br /&gt;
&lt;br /&gt;
A common way of identifying a variable is by supplying a &#039;&#039;&#039;base variable&#039;&#039;&#039; and a &#039;&#039;&#039;Relative Variable Identifier (RVI)&#039;&#039;&#039;. RVI&lt;br /&gt;
&lt;br /&gt;
* Represents the path from &#039;&#039;&#039;base variable&#039;&#039;&#039; into another variable&lt;br /&gt;
* In textual RVI notation (Variable.browse())&lt;br /&gt;
** &#039;&#039;&#039;.&#039;&#039;&#039; represents a getParent() query&lt;br /&gt;
** &#039;&#039;&#039;/xx&#039;&#039;&#039; represents a getChild(unescaped(xx)) query&lt;br /&gt;
** &#039;&#039;&#039;#yy&#039;&#039;&#039; represents a getProperty(unescaped(yy)) query&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;model&#039;&#039;&#039; variable represents the root of a Simantics model&lt;br /&gt;
* Model variables correspond directly to instances of SIMU.Model in the database&lt;br /&gt;
** Variable and resource URIs are the same&lt;br /&gt;
* For all variables under a model, the model variable can be obtained using Variables.getModel()&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;context&#039;&#039;&#039; variable under a model provides a view into a &#039;&#039;&#039;state&#039;&#039;&#039; of the model&lt;br /&gt;
&lt;br /&gt;
* A RVI obtained from e.g. model configuration can be used to access similarly identified data from different model states&lt;br /&gt;
** E.g. /DiagramX/ComponentY#PropertyZ can have different values in different contexts&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2724</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2724"/>
		<updated>2012-03-29T11:45:32Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Intro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface provides an uniform access model to data in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
* add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
* add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
* deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
* Connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
* The value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2722</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2722"/>
		<updated>2012-03-29T11:10:14Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Tab implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (org.simantics.browsing.ui.platform.PropertyPageView) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and browsing rules are defined by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;MOD.ModelingBrowseContext.VariablePropertyRule&#039;&#039;&#039; returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariablePropertyCategoryRule&#039;&#039;&#039; returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariablePropertyLabelRule&#039;&#039;&#039; collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* &#039;&#039;&#039;SEL.CategoryNodeLabelRule&#039;&#039;&#039; returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* &#039;&#039;&#039;SEL.StandardPropertySorterRule&#039;&#039;&#039; sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariablePropertyModifierRule&#039;&#039;&#039; returns org.simantics.browsing.ui.content.Labeler.Modifier by&lt;br /&gt;
** finding the column property (by var#HasDisplayColumn)&lt;br /&gt;
** trying to obtain a custom modifier (var#HasCustomModifier)&lt;br /&gt;
** trying to obtain an enumeration modifier by listing (var#HasEnumerationValues) and returning &#039;&#039;&#039;org.simantics.browsing.ui.graph.impl.EnumerationVariableModifier3&#039;&#039;&#039;&lt;br /&gt;
** &#039;&#039;&#039;returning org.simantics.browsing.ui.model.modifiers.VariableModifier2&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariableDecorationRule&#039;&#039;&#039; offsets the property name column of properties by one&lt;br /&gt;
* &#039;&#039;&#039;SEL.CategoryDecorationRule&#039;&#039;&#039; displays categories as bold&lt;br /&gt;
&lt;br /&gt;
The standard implementation can be customised by e.g.&lt;br /&gt;
&lt;br /&gt;
* Introducing more columns&lt;br /&gt;
* Applying property filtering (RequiresProperty)&lt;br /&gt;
* Adding decorations&lt;br /&gt;
&lt;br /&gt;
Some other notable points&lt;br /&gt;
&lt;br /&gt;
* Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
* Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
* The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
&lt;br /&gt;
== Future developments ==&lt;br /&gt;
&lt;br /&gt;
Some generic Variable properties should be used in rules. These properties include&lt;br /&gt;
&lt;br /&gt;
* #classifications&lt;br /&gt;
* #valid&lt;br /&gt;
* #validator&lt;br /&gt;
* #expression &lt;br /&gt;
* #required&lt;br /&gt;
* #default&lt;br /&gt;
* #readOnly &lt;br /&gt;
&lt;br /&gt;
The Variable model includes a generic model for connections, which should also be supported in the standard properties&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2721</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2721"/>
		<updated>2012-03-29T11:09:31Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Tab implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (org.simantics.browsing.ui.platform.PropertyPageView) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and browsing rules are defined by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;MOD.ModelingBrowseContext.VariablePropertyRule&#039;&#039;&#039; returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariablePropertyCategoryRule&#039;&#039;&#039; returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariablePropertyLabelRule&#039;&#039;&#039; collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* &#039;&#039;&#039;SEL.CategoryNodeLabelRule&#039;&#039;&#039; returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* &#039;&#039;&#039;SEL.StandardPropertySorterRule&#039;&#039;&#039; sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariablePropertyModifierRule&#039;&#039;&#039; returns org.simantics.browsing.ui.content.Labeler.Modifier by&lt;br /&gt;
** finding the column property (by var#HasDisplayColumn)&lt;br /&gt;
** trying to obtain a custom modifier (var#HasCustomModifier)&lt;br /&gt;
** trying to obtain an enumeration modifier by listing (var#HasEnumerationValues) and returning org.simantics.browsing.ui.graph.impl.EnumerationVariableModifier3&lt;br /&gt;
** returning org.simantics.browsing.ui.model.modifiers.VariableModifier2&lt;br /&gt;
* &#039;&#039;&#039;SEL.VariableDecorationRule&#039;&#039;&#039; offsets the property name column of properties by one&lt;br /&gt;
* &#039;&#039;&#039;SEL.CategoryDecorationRule&#039;&#039;&#039; displays categories as bold&lt;br /&gt;
&lt;br /&gt;
The standard implementation can be customised by e.g.&lt;br /&gt;
&lt;br /&gt;
* Introducing more columns&lt;br /&gt;
* Applying property filtering (RequiresProperty)&lt;br /&gt;
* Adding decorations&lt;br /&gt;
&lt;br /&gt;
Some other notable points&lt;br /&gt;
&lt;br /&gt;
* Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
* Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
* The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
&lt;br /&gt;
== Future developments ==&lt;br /&gt;
&lt;br /&gt;
Some generic Variable properties should be used in rules. These properties include&lt;br /&gt;
&lt;br /&gt;
* #classifications&lt;br /&gt;
* #valid&lt;br /&gt;
* #validator&lt;br /&gt;
* #expression &lt;br /&gt;
* #required&lt;br /&gt;
* #default&lt;br /&gt;
* #readOnly &lt;br /&gt;
&lt;br /&gt;
The Variable model includes a generic model for connections, which should also be supported in the standard properties&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2720</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2720"/>
		<updated>2012-03-29T11:07:35Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (org.simantics.browsing.ui.platform.PropertyPageView) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* MOD.ModelingBrowseContext.VariablePropertyRule returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* SEL.VariablePropertyCategoryRule returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* SEL.VariablePropertyLabelRule collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* SEL.CategoryNodeLabelRule returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* SEL.StandardPropertySorterRule sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
* SEL.VariablePropertyModifierRule returns org.simantics.browsing.ui.content.Labeler.Modifier by&lt;br /&gt;
** finding the column property (by var#HasDisplayColumn)&lt;br /&gt;
** trying to obtain a custom modifier (var#HasCustomModifier)&lt;br /&gt;
** trying to obtain an enumeration modifier by listing (var#HasEnumerationValues) and returning org.simantics.browsing.ui.graph.impl.EnumerationVariableModifier3&lt;br /&gt;
** returning org.simantics.browsing.ui.model.modifiers.VariableModifier2&lt;br /&gt;
* SEL.VariableDecorationRule offsets the property name column of properties by one&lt;br /&gt;
* SEL.CategoryDecorationRule displays categories as bold&lt;br /&gt;
&lt;br /&gt;
The standard implementation can be customised by e.g.&lt;br /&gt;
&lt;br /&gt;
* Introducing more columns&lt;br /&gt;
* Applying property filtering (RequiresProperty)&lt;br /&gt;
* Adding decorations&lt;br /&gt;
&lt;br /&gt;
Some other notable points&lt;br /&gt;
&lt;br /&gt;
* Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
* Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
* The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
&lt;br /&gt;
== Future developments ==&lt;br /&gt;
&lt;br /&gt;
Some generic Variable properties should be used in rules. These properties include&lt;br /&gt;
&lt;br /&gt;
* #classifications&lt;br /&gt;
* #valid&lt;br /&gt;
* #validator&lt;br /&gt;
* #expression &lt;br /&gt;
* #required&lt;br /&gt;
* #default&lt;br /&gt;
* #readOnly &lt;br /&gt;
&lt;br /&gt;
The Variable model includes a generic model for connections, which should also be supported in the standard properties&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2719</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2719"/>
		<updated>2012-03-29T11:07:16Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* MOD.ModelingBrowseContext.VariablePropertyRule returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* SEL.VariablePropertyCategoryRule returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* SEL.VariablePropertyLabelRule collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* SEL.CategoryNodeLabelRule returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* SEL.StandardPropertySorterRule sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
* SEL.VariablePropertyModifierRule returns org.simantics.browsing.ui.content.Labeler.Modifier by&lt;br /&gt;
** finding the column property (by var#HasDisplayColumn)&lt;br /&gt;
** trying to obtain a custom modifier (var#HasCustomModifier)&lt;br /&gt;
** trying to obtain an enumeration modifier by listing (var#HasEnumerationValues) and returning org.simantics.browsing.ui.graph.impl.EnumerationVariableModifier3&lt;br /&gt;
** returning org.simantics.browsing.ui.model.modifiers.VariableModifier2&lt;br /&gt;
* SEL.VariableDecorationRule offsets the property name column of properties by one&lt;br /&gt;
* SEL.CategoryDecorationRule displays categories as bold&lt;br /&gt;
&lt;br /&gt;
The standard implementation can be customised by e.g.&lt;br /&gt;
&lt;br /&gt;
* Introducing more columns&lt;br /&gt;
* Applying property filtering (RequiresProperty)&lt;br /&gt;
* Adding decorations&lt;br /&gt;
&lt;br /&gt;
Some other notable points&lt;br /&gt;
&lt;br /&gt;
* Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
* Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
* The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
&lt;br /&gt;
== Future developments ==&lt;br /&gt;
&lt;br /&gt;
Some generic Variable properties should be used in rules. These properties include&lt;br /&gt;
&lt;br /&gt;
* #classifications&lt;br /&gt;
* #valid&lt;br /&gt;
* #validator&lt;br /&gt;
* #expression &lt;br /&gt;
* #required&lt;br /&gt;
* #default&lt;br /&gt;
* #readOnly &lt;br /&gt;
&lt;br /&gt;
The Variable model includes a generic model for connections, which should also be supported in the standard properties&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2718</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2718"/>
		<updated>2012-03-29T11:04:53Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* MOD.ModelingBrowseContext.VariablePropertyRule returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* SEL.VariablePropertyCategoryRule returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* SEL.VariablePropertyLabelRule collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* SEL.CategoryNodeLabelRule returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* SEL.StandardPropertySorterRule sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
* SEL.VariablePropertyModifierRule returns org.simantics.browsing.ui.content.Labeler.Modifier by&lt;br /&gt;
** finding the column property (by var#HasDisplayColumn)&lt;br /&gt;
** trying to obtain a custom modifier (var#HasCustomModifier)&lt;br /&gt;
** trying to obtain an enumeration modifier by listing (var#HasEnumerationValues) and returning org.simantics.browsing.ui.graph.impl.EnumerationVariableModifier3&lt;br /&gt;
** returning org.simantics.browsing.ui.model.modifiers.VariableModifier2&lt;br /&gt;
* SEL.VariableDecorationRule offsets the property name column of properties by one&lt;br /&gt;
* SEL.CategoryDecorationRule displays categories as bold&lt;br /&gt;
&lt;br /&gt;
The standard implementation can be customised by e.g.&lt;br /&gt;
&lt;br /&gt;
* Introducing more columns&lt;br /&gt;
* Applying property filtering (RequiresProperty)&lt;br /&gt;
* Adding decorations&lt;br /&gt;
&lt;br /&gt;
Some other notable points&lt;br /&gt;
&lt;br /&gt;
* Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
* Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
* The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
&lt;br /&gt;
== Future developments ==&lt;br /&gt;
&lt;br /&gt;
Some generic Variable properties should be used in rules. These properties include&lt;br /&gt;
&lt;br /&gt;
* #&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2717</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2717"/>
		<updated>2012-03-29T11:03:32Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Tab implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* MOD.ModelingBrowseContext.VariablePropertyRule returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* SEL.VariablePropertyCategoryRule returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* SEL.VariablePropertyLabelRule collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* SEL.CategoryNodeLabelRule returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* SEL.StandardPropertySorterRule sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
* SEL.VariablePropertyModifierRule returns org.simantics.browsing.ui.content.Labeler.Modifier by&lt;br /&gt;
** finding the column property (by var#HasDisplayColumn)&lt;br /&gt;
** trying to obtain a custom modifier (var#HasCustomModifier)&lt;br /&gt;
** trying to obtain an enumeration modifier by listing (var#HasEnumerationValues) and returning org.simantics.browsing.ui.graph.impl.EnumerationVariableModifier3&lt;br /&gt;
** returning org.simantics.browsing.ui.model.modifiers.VariableModifier2&lt;br /&gt;
* SEL.VariableDecorationRule offsets the property name column of properties by one&lt;br /&gt;
* SEL.CategoryDecorationRule displays categories as bold&lt;br /&gt;
&lt;br /&gt;
The standard implementation can be customised by e.g.&lt;br /&gt;
&lt;br /&gt;
* Introducing more columns&lt;br /&gt;
* Applying property filtering (RequiresProperty)&lt;br /&gt;
* Adding decorations&lt;br /&gt;
&lt;br /&gt;
Some other notable points&lt;br /&gt;
&lt;br /&gt;
* Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
* Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
* The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2716</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2716"/>
		<updated>2012-03-29T10:55:47Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Tab implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* MOD.ModelingBrowseContext.VariablePropertyRule returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* SEL.VariablePropertyCategoryRule returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
* SEL.VariablePropertyLabelRule collects a String-&amp;gt;String map by searching properties var where&lt;br /&gt;
** key is the value of (var#HasDisplayColumn)&lt;br /&gt;
** value is the (Bindings.STRING) value of var&lt;br /&gt;
* SEL.CategoryNodeLabelRule returns the map &amp;quot;HasDisplayProperty&amp;quot; -&amp;gt; ((CategoryNode)content).getName()&lt;br /&gt;
* SEL.StandardPropertySorterRule sorts properties and categories by sorting name where sorting name is&lt;br /&gt;
** (p#SortingName) or if absent (p#HasDisplayProperty) for a variable p&lt;br /&gt;
** ((CategoryNode)content).getSortingName() for categories&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2715</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2715"/>
		<updated>2012-03-29T10:46:19Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Tab implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* MOD.ModelingBrowseContext.VariablePropertyRule returns all properties (Variable.browseProperties) such that&lt;br /&gt;
** All results contain all properties defined by VariablePropertyRule.RequireProperty&lt;br /&gt;
* SEL.VariablePropertyCategoryRule returns a set of categories collected from all suitable properties (as above)&lt;br /&gt;
** categories are identified by&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategoryName&lt;br /&gt;
*** var#HasStandardPropertyInfo#CategorySortingName&lt;br /&gt;
** hidden categories are not shown&lt;br /&gt;
*** see var#HasStandardPropertyInfo#IsHidden&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2714</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2714"/>
		<updated>2012-03-29T10:33:54Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Tab implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View.&lt;br /&gt;
&lt;br /&gt;
Generic configurations for modelled tabs can be found in the ontology http://www.simantics.org/SelectionViewUI-1.0.&lt;br /&gt;
&lt;br /&gt;
The standard modelled property tab is http://www.simantics.org/SelectionViewUI-1.0/StandardProperties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.StandardPropertiesBase &amp;lt;T VIEW.Explorer&lt;br /&gt;
  @L0.assert VIEW.Control.layoutData&lt;br /&gt;
    _ : VIEW.GridLayout.GridData&lt;br /&gt;
      VIEW.GridLayout.GridData.horizontalGrab true&lt;br /&gt;
      VIEW.GridLayout.GridData.verticalGrab true&lt;br /&gt;
  @L0.assert VIEW.Control.style &lt;br /&gt;
    _ : VIEW.Control.Style&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.Multi&lt;br /&gt;
      VIEW.Control.Style.HasConstant VIEW.Control.Style.Constant.FullSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.columns &lt;br /&gt;
    _ : VIEW.Explorer.ColumnList&lt;br /&gt;
      @L0.list&lt;br /&gt;
        SEL.PropertyColumn&lt;br /&gt;
        SEL.ValueColumn&lt;br /&gt;
        SEL.UnitColumn&lt;br /&gt;
  @L0.assert VIEW.Explorer.input MOD.Functions.singleVariableSelection&lt;br /&gt;
  @L0.assert VIEW.Explorer.browseContext&lt;br /&gt;
    _ : VIEW.ResourceURI&lt;br /&gt;
      VIEW.ResourceURI.HasResource SEL.StandardPropertiesBase.BrowseContext : SEL.StandardProperties.BrowseContextStandardChildren&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties : SEL.StandardPropertiesBase&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextStandardChildren &amp;lt;T SEL.StandardProperties.BrowseContextWithoutChildren&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
        MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasChildContribution &lt;br /&gt;
    _ : VP.ChildContribution&lt;br /&gt;
      VP.ChildContribution.HasParentNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.ChildContribution.HasChildNodeType SEL.CategoryNode&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
&lt;br /&gt;
SEL.StandardProperties.BrowseContextWithoutChildren &amp;lt;T VP.BrowseContext&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType MOD.ModelingBrowseContext.Variable&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
  @L0.assert VP.BrowseContext.HasVisualsContribution&lt;br /&gt;
    _ : VP.VisualsContribution&lt;br /&gt;
      VP.VisualsContribution.HasNodeType SEL.CategoryNode&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where input is obtained from modelled view runtime state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    @SCLValue(type = &amp;quot;ReadGraph -&amp;gt; Resource -&amp;gt; Variable -&amp;gt; Variable&amp;quot;)&lt;br /&gt;
    public static Variable singleVariableSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {&lt;br /&gt;
    	return ScenegraphLoaderUtils.getVariableSelection(graph, context);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rules of the standard browse context are as follows:&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
      VP.ChildContribution.HasRule _ : MOD.ModelingBrowseContext.VariablePropertyRule&lt;br /&gt;
      MOD.ModelingBrowseContext.VariablePropertyRule.RequireProperty &amp;quot;HasStandardPropertyInfo&amp;quot;&lt;br /&gt;
      VP.ChildContribution.HasRule _ : SEL.VariablePropertyCategoryRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyLabelRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryNodeLabelRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.StandardPropertySorterRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariablePropertyModifierRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.VariableDecorationRule&lt;br /&gt;
      VP.VisualsContribution.HasRule SEL.CategoryDecorationRule&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2713</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2713"/>
		<updated>2012-03-29T10:05:25Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
SEL.TypedVariableTabContribution &amp;lt;T SEL.VariableTabContribution&lt;br /&gt;
  &amp;gt;-- SEL.TypedVariableTabContribution.HasType &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View. Generic modelled selection view tabs include&lt;br /&gt;
&lt;br /&gt;
=== StandardProperties (http://www.simantics.org/SelectionView-0.0/StandardProperties) ===&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2712</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2712"/>
		<updated>2012-03-29T09:53:55Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SEL.VariableTabContribution &amp;lt;T SEL.TabContribution&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasTest &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasView &amp;lt;R L0.DependsOn&lt;br /&gt;
  &amp;gt;-- SEL.VariableTabContribution.HasPriority &amp;lt;R L0.DependsOn&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(SEL.VariableTabContribution.HasView refers to a Modelled View configuration for describing the contents of the tab.)&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View. Generic modelled selection view tabs include&lt;br /&gt;
&lt;br /&gt;
=== StandardProperties (http://www.simantics.org/SelectionView-0.0/StandardProperties) ===&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2711</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2711"/>
		<updated>2012-03-29T09:50:37Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
The implementation of modelled selection processor does the following procedure:&lt;br /&gt;
&lt;br /&gt;
Try to get a model resource from the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
private Resource getModel(ReadGraph graph, Object selection) throws DatabaseException {&lt;br /&gt;
		&lt;br /&gt;
		Variable variable = ISelectionUtils.filterSingleSelection(selection, Variable.class);&lt;br /&gt;
		if(variable != null) {&lt;br /&gt;
			return Variables.getModel(graph, variable);&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		return ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MODEL, Resource.class);		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapt (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Seek all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and apply them (org.simantics.db.common.utils.Functions#exec) as long as needed to obtain a closure of inputs.&lt;br /&gt;
&lt;br /&gt;
Feed all inputs to the found TabContributions to obtain a set of tabs.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View. Generic modelled selection view tabs include&lt;br /&gt;
&lt;br /&gt;
=== StandardProperties (http://www.simantics.org/SelectionView-0.0/StandardProperties) ===&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2710</id>
		<title>Selection View</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Selection_View&amp;diff=2710"/>
		<updated>2012-03-29T09:45:02Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Selection View is a standard Simantics view, which shows tabbed configuration views about the current workbench selection.&lt;br /&gt;
&lt;br /&gt;
== Selection View (&#039;&#039;&#039;org.simantics.browsing.ui.platform.PropertyPageView&#039;&#039;&#039;) ==&lt;br /&gt;
&lt;br /&gt;
The Selection View is contributed in &#039;&#039;&#039;org.simantics.browsing.ui.platform/plugin.xml&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View displays content for the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Selection View listens the &#039;&#039;&#039;active workbench part&#039;&#039;&#039; and tries to obtain &#039;&#039;&#039;org.simantics.ui.workbench.IPropertyPage&#039;&#039;&#039; via &#039;&#039;&#039;IAdaptable.getAdapter&#039;&#039;&#039; for displaying selections from the part. &lt;br /&gt;
&lt;br /&gt;
Most Simantics workbench part implementations adapt into the standard property page implementation described next.&lt;br /&gt;
&lt;br /&gt;
== Standard property page (org.simantics.selectionview.StandardPropertyPage) ==&lt;br /&gt;
&lt;br /&gt;
The standard property page displays a tab folder (&#039;&#039;&#039;org.simantics.selectionview.StandardProperties&#039;&#039;&#039;), which contains n tabs contributed by a set of &#039;&#039;&#039;selection processors&#039;&#039;&#039; (&#039;&#039;&#039;org.simantics.selectionview.SelectionProcessor&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
== Selection processing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface SelectionProcessor&amp;lt;S, B&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * @param selection the incoming selection to process&lt;br /&gt;
     * @param backend for providing back-end access to the processor&lt;br /&gt;
     * @return an ordered set of&lt;br /&gt;
     *         &amp;lt;code&amp;gt;org.simantics.browsing.ui.swt.ComparableTabContributor&amp;lt;/code&amp;gt;&lt;br /&gt;
     *         instances representing the property tabs to be contributed to the&lt;br /&gt;
     *         selection view. The processor must not return &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;,&lt;br /&gt;
     *         return an empty collection instead.&lt;br /&gt;
     */&lt;br /&gt;
    Collection&amp;lt;?&amp;gt; process(S selection, B backend);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selection is the &#039;&#039;&#039;workbench selection&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Backend is ReadGraph in most cases (could be something else if custom property pages are used).&lt;br /&gt;
&lt;br /&gt;
Selection processors are contributed by&lt;br /&gt;
&lt;br /&gt;
* Extending StandardPropertyPage and overriding method getSelectionProcessor&lt;br /&gt;
* Constructing StandardPropertyPage with a set of &#039;&#039;&#039;browse contexts&#039;&#039;&#039; for which selection processors can be contributed via extension point &#039;&#039;&#039;org.simantics.browsing.ui.common.selectionProcessorBinding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The obtained set of ComparableTabContributors are sorted and used to create tabs for the tabbed folder.&lt;br /&gt;
&lt;br /&gt;
A modelled implementation of the SelectionProcessor interface is described next.&lt;br /&gt;
&lt;br /&gt;
== Modelled Selection Processor (org.simantics.selectionview.StandardSelectionProcessor) == &lt;br /&gt;
&lt;br /&gt;
StandardSelectionProcessor seeks all instances of http://www.simantics.org/SelectionView-0.0/TabContribution from model dependencies and adapts (ReadGraph.adapt) them to org.simantics.selectionview.TabContribution.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface TabContribution&amp;lt;T&amp;gt; {&lt;br /&gt;
&lt;br /&gt;
	void contribute(ReadGraph graph, T selection, Collection&amp;lt;ComparableTabContributor&amp;gt; result) throws DatabaseException;	&lt;br /&gt;
	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
StandardSelectionProcessor seeks all instances of http://www.simantics.org/SelectionView-0.0/SelectionTransformation (which are also L0.Function) and applies them (org.simantics.db.common.utils.Functions#exec) to obtain a set of inputs, which are then fed to all TabContributions.&lt;br /&gt;
&lt;br /&gt;
== Tab implementation ==&lt;br /&gt;
&lt;br /&gt;
The standard way of implementing a tab is a Simantics Modelled View. Generic modelled selection view tabs include&lt;br /&gt;
&lt;br /&gt;
=== StandardProperties (http://www.simantics.org/SelectionView-0.0/StandardProperties) ===&lt;br /&gt;
&lt;br /&gt;
* StandardProperties is an Explorer view which expects a single Variable as an input.&lt;br /&gt;
* The view has the columns &#039;Property&#039;, &#039;Value&#039; and &#039;Unit&#039;&lt;br /&gt;
* Tree children for variable v are all properties of v which have a property called HasStandardPropertyInfo&lt;br /&gt;
* Column labels for child c are obtained by collecting all properties of c that have a property called DISPLAY_COLUMN&lt;br /&gt;
** The (String) value of DISPLAY_COLUMN property if the column identifier&lt;br /&gt;
** Modifier uses the property &#039;HasInputValidator&#039; for getting a validator&lt;br /&gt;
** Modifier writes with Bindings.STRING into the label property.&lt;br /&gt;
** The labels may apply transformations such as unit conversion or formatting i.e. they can not be used for obtaining raw property data.&lt;br /&gt;
* The HasStandardPropertyInfo property defines the following attributes of the displayed property&lt;br /&gt;
** Category (Name, SortingName, Visibility)&lt;br /&gt;
* Required, Default?&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2703</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2703"/>
		<updated>2012-03-13T09:19:38Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Property properties =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property should contain a valid value&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value is a default value&lt;br /&gt;
* &#039;&#039;&#039;readOnly&#039;&#039;&#039; is a Boolean-valued property, which indicates that the property value can not be written&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2702</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2702"/>
		<updated>2012-03-13T09:06:27Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Selection View =&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2701</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2701"/>
		<updated>2012-03-13T09:04:19Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* String editing operations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property. If the property can be computed using an expression, this property is always available and returns &#039;&#039;&#039;null&#039;&#039;&#039; if an expression has not been defined.&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2700</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2700"/>
		<updated>2012-03-13T09:03:08Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* String editing operations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;valid&#039;&#039;&#039; is a Boolean-valued property, which indicates whether the property contains a valid value.&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2699</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2699"/>
		<updated>2012-03-13T08:58:32Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* String editing operations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
&lt;br /&gt;
  enum Severity {&lt;br /&gt;
    Error, Warning&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  String getDescription();&lt;br /&gt;
  int getBegin();&lt;br /&gt;
  int getEnd();&lt;br /&gt;
  Severity getSeverity();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2698</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2698"/>
		<updated>2012-03-13T08:57:39Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: /* String editing operations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.utils.strings.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface StringInputProblem {&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public interface StringInputValidator {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;StringInputProblem&amp;gt; validate(String input);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2697</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2697"/>
		<updated>2012-03-13T08:53:33Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= String editing operations =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;HasDisplayValue&#039;&#039;&#039; is a String-valued property, which is a formatted and unit-converted representation of the property value.&lt;br /&gt;
* &#039;&#039;&#039;expression&#039;&#039;&#039; is a String-valued property, which is an SCL-formula used to compute the value of the property&lt;br /&gt;
* &#039;&#039;&#039;validator&#039;&#039;&#039; is a &#039;&#039;&#039;org.simantics.db.layer0.variable.StringInputValidator&#039;&#039;&#039;-valued property. The validator is used for checking values to be written into a property.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2696</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2696"/>
		<updated>2012-03-13T08:39:51Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection point properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection point property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities (equals/hashCode) based on flattened connections.&lt;br /&gt;
&lt;br /&gt;
The value of connection point properties can be &#039;&#039;&#039;null&#039;&#039;&#039;. This means that the connection point is not connected.&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
	<entry>
		<id>https://dev.simantics.org/index.php?title=Variable&amp;diff=2695</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://dev.simantics.org/index.php?title=Variable&amp;diff=2695"/>
		<updated>2012-03-13T08:38:09Z</updated>

		<summary type="html">&lt;p&gt;Antti Villberg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Intro =&lt;br /&gt;
&lt;br /&gt;
The Variable interface is an interface, which provides an uniform access models to models in Simantics. It includes&lt;br /&gt;
&lt;br /&gt;
* Tree-structured address space for accessing model &#039;&#039;&#039;structure&#039;&#039;&#039; and &#039;&#039;&#039;properties&#039;&#039;&#039;&lt;br /&gt;
* Uniform access to model &#039;&#039;&#039;configuration&#039;&#039;&#039; and &#039;&#039;&#039;state&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Key use cases include&lt;br /&gt;
&lt;br /&gt;
* Browsing of the &#039;&#039;&#039;model structure&#039;&#039;&#039; (see [[Model Browser]])&lt;br /&gt;
* Browsing and &#039;&#039;&#039;manipulation of objects&#039;&#039;&#039; (see [[Selection View]])&lt;br /&gt;
* &#039;&#039;&#039;Tabular data&#039;&#039;&#039; (see [[Spreadsheets]])&lt;br /&gt;
&lt;br /&gt;
Main functional requirements include representation of &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Structural models&#039;&#039;&#039; with &#039;&#039;&#039;procedural&#039;&#039;&#039; features (see [[Structural]])&lt;br /&gt;
* &#039;&#039;&#039;Runtime&#039;&#039;&#039; data of solvers (see [[Experiments]])&lt;br /&gt;
* &#039;&#039;&#039;Historical&#039;&#039;&#039; data from experiments&lt;br /&gt;
* &#039;&#039;&#039;Ontological&#039;&#039;&#039; data&lt;br /&gt;
&lt;br /&gt;
= Solution =&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; is an interface with the following services&lt;br /&gt;
&lt;br /&gt;
**Querying children (variable) by name&lt;br /&gt;
**Querying properties (variables) by name&lt;br /&gt;
**Querying a value for a property variable&lt;br /&gt;
**Querying adapter interfaces&lt;br /&gt;
&lt;br /&gt;
A set of built-in properties include&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;URI&#039;&#039;&#039;, which is an unique string identifier and locator of the variable in the tree structure&lt;br /&gt;
* &#039;&#039;&#039;Parent&#039;&#039;&#039;, which is the tree parent of the variable&lt;br /&gt;
* &#039;&#039;&#039;HasName&#039;&#039;&#039;, which is a local identifier for the variable within its parent. Names are also used to create URIs.&lt;br /&gt;
* &#039;&#039;&#039;HasLabel&#039;&#039;&#039;, which is a short textual representation of the variable&lt;br /&gt;
* &#039;&#039;&#039;hasStandardResource&#039;&#039;&#039;, which returns the context resource in a &#039;&#039;&#039;standard graph-based child variable&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Represents&#039;&#039;&#039;, TODO&lt;br /&gt;
* &#039;&#039;&#039;Type&#039;&#039;&#039;, which returns a single type resource classifying the variable&lt;br /&gt;
* &#039;&#039;&#039;Role&#039;&#039;&#039;, which tells whether the variable is a &#039;&#039;&#039;child&#039;&#039;&#039; or a &#039;&#039;&#039;property&#039;&#039;&#039; (TODO: could be deprecated)&lt;br /&gt;
* &#039;&#039;&#039;DATATYPE&#039;&#039;&#039;, which returns the data type of a property variable. (TODO: should be HasDatatype)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; is a container for all data related to some user task e.g. simulation model.&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;context&#039;&#039;&#039;&#039;&#039; is an entity under a &#039;&#039;&#039;&#039;&#039;model&#039;&#039;&#039;&#039;&#039; which spans a set of &#039;&#039;&#039;&#039;&#039;variables&#039;&#039;&#039;&#039;&#039; specified by &#039;&#039;&#039;&#039;&#039;paths&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is an &#039;&#039;identifier&#039;&#039; which can be used to retrieve a variable from given &#039;&#039;&#039;context&#039;&#039;&#039;&lt;br /&gt;
*A path &#039;&#039;&#039;&#039;&#039;separator&#039;&#039;&#039;&#039;&#039; which identifies traversal of parents based on &#039;&#039;&#039;&#039;&#039;role&#039;&#039;&#039;&#039;&#039;. Specified separators are &#039;.&#039;, &#039;/&#039;, &#039;#&#039;&lt;br /&gt;
&lt;br /&gt;
The specified roles are defined as&lt;br /&gt;
*Parent variable is denoted by the &#039;.&#039; separator&lt;br /&gt;
*Children are denoted by the &#039;/&#039; separator.&lt;br /&gt;
*Properties are denoted by the &#039;#&#039; separator. All properties contain a value.&lt;br /&gt;
&lt;br /&gt;
Procedural children and variables are used with large data sets. E.g. query-based views can be exposed. Procedural properties also enable efficient slicing of arrays e.g. URI#Array_Property/0-99&lt;br /&gt;
&lt;br /&gt;
A model typically contains a number of contexts which are browsed using the Variable interface. Typical contexts are//&lt;br /&gt;
&lt;br /&gt;
*The base context, which can be used to browse the structure and configuration values of the model&lt;br /&gt;
*Configuration value contexts with e.g. set point values for some variables&lt;br /&gt;
*Experiment contexts with structure and values retrieved from simulator using Databoard Accessor interface&lt;br /&gt;
&lt;br /&gt;
Generic tools such as Model Browser, Selection View, Diagram, Chart, Spreadsheet, OperationUI use the the path identifiers to refer to their data. Once a desired Variable has been obtained its value can be accessed using direct database requests or Databoard Accessor.&lt;br /&gt;
&lt;br /&gt;
The variable system processes two kinds of textual identifiers&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;URI&#039;&#039;&#039;&#039;&#039; is a complete reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**Examples:  &lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/BaseRealization/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName/Diagram/PI_X#PI_MASS_FLOW#Unit&lt;br /&gt;
**Models and contexts are identified by URIs&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1&lt;br /&gt;
***http://www.asd.org/Projects/AprosProject/AprosModel1/ExperimentConfiguration/RunName&lt;br /&gt;
&lt;br /&gt;
*A &#039;&#039;&#039;&#039;&#039;path&#039;&#039;&#039;&#039;&#039; is a relative reference to a &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039; based on another &#039;&#039;&#039;&#039;&#039;variable&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
**A path can contain a number of leading parent steps denoted by &#039;.&#039;&lt;br /&gt;
**Examples:&lt;br /&gt;
***/Diagram/PI_X#PI_MASS_FLOW&lt;br /&gt;
***./Diagram2/PI_X#PI_MASS_FLOW#HasDatatype&lt;br /&gt;
&lt;br /&gt;
Path identifiers can also be serialized into graph representation, which is name-independent and survives export/import. In e.g. structural this is an ordered set of path separators and configuration resources.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Refactoring =&lt;br /&gt;
&lt;br /&gt;
- add Collection&amp;lt;Variable&amp;gt; browseProperties(ReadGraph graph, String classification) throws DatabaseException;&lt;br /&gt;
- add standard property &#039;&#039;&#039;classifications&#039;&#039;&#039;, which returns a set of strings&lt;br /&gt;
- deprecate browseChildren, browseProperties =&amp;gt; add get&lt;br /&gt;
&lt;br /&gt;
= Connection modelling =&lt;br /&gt;
&lt;br /&gt;
- connection properties are classified with &#039;&#039;&#039;http://www.simantics.org/Structural-1.0/ConnectionRelation&#039;&#039;&#039;&lt;br /&gt;
- the value of a connection property is an object of class &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public interface Connection {&lt;br /&gt;
&lt;br /&gt;
  Collection&amp;lt;Variable&amp;gt; getConnectionPoints(ReadGraph graph) throws DatabaseException;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is assumed that instances of &#039;&#039;&#039;org.simantics.structural2.variables.Connection&#039;&#039;&#039; have proper identities based on equals/hashCode.&lt;br /&gt;
&lt;br /&gt;
= Assumptions =&lt;br /&gt;
&lt;br /&gt;
* §1 Everything after &#039;#&#039; has a value&lt;br /&gt;
* §2 For all realization resources a variable can be obtained by graph.adapt(r, Variable.class)&lt;br /&gt;
* §3 For all realization resources the variable URI equals graph.getURI(r)&lt;br /&gt;
* §4 A variable can be part of at most one Context&lt;br /&gt;
* §5 A variable can be part of at most one Model&lt;br /&gt;
* $6 All values can be accessed using either Variable.getValue or Variable.getInterface(Accessor.class)&lt;br /&gt;
* $7 All properties retrieved using Variable.browseProperties shall be available using Variable.getProperty&lt;br /&gt;
&lt;br /&gt;
= Standard modelling in Layer0 =&lt;br /&gt;
&lt;br /&gt;
[[File:Realizations.png]]&lt;br /&gt;
&lt;br /&gt;
== Child modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard child modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* childResource : where (res, L0.ConsistsOf, childResource)&lt;br /&gt;
* childVariable = graph.adaptContextual(childResource, this, Variable.class, Variable.class)&lt;br /&gt;
&lt;br /&gt;
== Property modelling ==&lt;br /&gt;
&lt;br /&gt;
Standard property modelling assumes a context resource res.&lt;br /&gt;
&lt;br /&gt;
* (predicate, object) : where (res, predicate, object) and (predicate &amp;lt;R L0.HasProperty)&lt;br /&gt;
* childProperty = graph.adaptContextual(object, ModelledVariablePropertyDescriptor(this, predicate), Variable.class)&lt;br /&gt;
&lt;br /&gt;
For property variables there are two context resources available, the associated value and the predicate. Properties are found from the value context first and then from the predicate context.&lt;br /&gt;
&lt;br /&gt;
== Layer0 properties ==&lt;br /&gt;
&lt;br /&gt;
=== For all variables ===&lt;br /&gt;
&lt;br /&gt;
* NAME: String&lt;br /&gt;
&lt;br /&gt;
The name of the resource. The URI uses an escaped version of this name. For graph-based variables this is L0.HasName&lt;br /&gt;
&lt;br /&gt;
* LABEL: String&lt;br /&gt;
&lt;br /&gt;
The standard textual representation for the variable. For graph-based variables this is L0.HasLabel&lt;br /&gt;
&lt;br /&gt;
* TYPE: Resource&lt;br /&gt;
&lt;br /&gt;
A single type related to the variable.&lt;br /&gt;
&lt;br /&gt;
* URI: String&lt;br /&gt;
&lt;br /&gt;
The variable URI, see Implementations&lt;br /&gt;
&lt;br /&gt;
* SERIALIZED: String&lt;br /&gt;
&lt;br /&gt;
An immutable string identified for this part&lt;br /&gt;
&lt;br /&gt;
* PARENT: Variable&lt;br /&gt;
&lt;br /&gt;
The parent variable&lt;br /&gt;
&lt;br /&gt;
* ROLE: Role&lt;br /&gt;
&lt;br /&gt;
Is Role.Property if URI contains &#039;#&#039;, else is Role.Child. If role is Role.Property, then the variable has a value.&lt;br /&gt;
&lt;br /&gt;
* CONTEXT : Variable&lt;br /&gt;
&lt;br /&gt;
The context variable of this variable. The URI of the context variable is a prefix of the URI of this variable.&lt;br /&gt;
&lt;br /&gt;
* CHILD_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of children.&lt;br /&gt;
&lt;br /&gt;
* PROPERTY_COUNT: Integer&lt;br /&gt;
&lt;br /&gt;
The amount of properties.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Child ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The configuration resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
=== For variables, where Role is Role.Property ===&lt;br /&gt;
&lt;br /&gt;
* REPRESENTS: Resource&lt;br /&gt;
&lt;br /&gt;
The literal resource related to this variable.&lt;br /&gt;
&lt;br /&gt;
* EXPRESSION: String&lt;br /&gt;
&lt;br /&gt;
The expression for determining the value of the property. Null if there is no expression.&lt;br /&gt;
&lt;br /&gt;
* PREDICATE: Variable&lt;br /&gt;
&lt;br /&gt;
The variable representing the predicate.&lt;br /&gt;
&lt;br /&gt;
* DATATYPE: Datatype&lt;br /&gt;
&lt;br /&gt;
The data type of the property.&lt;br /&gt;
&lt;br /&gt;
* INPUT_VALIDATOR: String -&amp;gt; String&lt;br /&gt;
&lt;br /&gt;
A function which performs validation for potential inputs to setValue.&lt;br /&gt;
&lt;br /&gt;
== Modelling ==&lt;br /&gt;
&lt;br /&gt;
* L0.ConsistsOf determines modelled variable children&lt;br /&gt;
* L0.HasProperty determines the predicates used for producing variable properties&lt;br /&gt;
&lt;br /&gt;
* L0.Entity defined the adapter org.simantics.db.layer0.variable.StandardGraphChildVariableAdapter&lt;br /&gt;
* L0.Value defines the adapter org.simantics.db.layer0.variable.StandardModelledPropertyVariable&lt;br /&gt;
* L0X.ResourcePropertyRelation defines the adapter org.simantics.db.layer0.variable.ResourcePropertyVariableAdapter&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphChildVariable implements a child variable based on a parent variable and on a context resource.&lt;br /&gt;
* org.simantics.db.layer0.variable.StandardGraphPropertyVariable implements a child variable based on a parent variable and on a (subject, predicate &amp;lt;R L0.HasProperty) resource pair.&lt;br /&gt;
&lt;br /&gt;
* org.simantics.db.layer0.variable.VariableSpaceManipulator: for modifying the variable space&lt;br /&gt;
* org.simantics.db.layer0.variable.InputValidator: for validating user input&lt;br /&gt;
* org.simantics.db.layer0.variable.Formatter: for representing values&lt;br /&gt;
* org.simantics.databoard.units.IUnitConverter: for representing values according to user needs&lt;br /&gt;
&lt;br /&gt;
= Frequent cases =&lt;br /&gt;
&lt;br /&gt;
1. Given variable v, obtain model&lt;br /&gt;
   Procedure: call Variables.getModel(graph, v)&lt;br /&gt;
2. Given variable v, obtain realization&lt;br /&gt;
   Procedure: call Variables.getRealization(graph, v)&lt;br /&gt;
3. Given Variable URI, obtain Variable&lt;br /&gt;
   Procedure: call Variables.getVariable(graph, uri)&lt;br /&gt;
4. Given Variable URI, obtain textual RVI&lt;br /&gt;
   Procedure: call Variables.getRVI(graph, v)&lt;br /&gt;
 &lt;br /&gt;
5. Given a configuration resource r and context variable obtain variable&lt;br /&gt;
   Procedure: call Variable.browse(graph, r)&lt;br /&gt;
6. Given two variables v1 and v2, obtain RVI of second based on first&lt;br /&gt;
   call Variables.getRVI(graph, v1, v2)&lt;br /&gt;
7. Given Realization URI and RVI, obtain Variable&lt;br /&gt;
   call Variables.getVariable(graph, uri, rvi)&lt;br /&gt;
&lt;br /&gt;
8. Obtain string representation for value of Variable v&lt;br /&gt;
   -Obtain value val (Object) by v.getValue()&lt;br /&gt;
   -Obtain converter c by v.getInterface(IUnitConverter.class)&lt;br /&gt;
   -Obtain converted value cval (Object) by c.convert(val)&lt;br /&gt;
   -Obtain formatter f by v.getInterface(Formatter.class)&lt;br /&gt;
   -Obtain String representation by f.format(cval)&lt;br /&gt;
&lt;br /&gt;
= Varible space modelling =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
==== Record ====&lt;br /&gt;
&lt;br /&gt;
* All named fields are &#039;/name&#039;&lt;br /&gt;
* Tuples are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Union ====&lt;br /&gt;
&lt;br /&gt;
* Union does not show in URI&lt;br /&gt;
&lt;br /&gt;
==== Array ====&lt;br /&gt;
&lt;br /&gt;
* Elements are named after position e.g. &#039;/11&#039;&lt;br /&gt;
&lt;br /&gt;
==== Map ====&lt;br /&gt;
&lt;br /&gt;
* Items are named after key &lt;br /&gt;
&lt;br /&gt;
Take for example http://www.asd.org/Project/AprosModel1/BaseRealization/a/TA_1#TA11_POINT_ELEV&lt;br /&gt;
&lt;br /&gt;
=== Property sets ===&lt;br /&gt;
&lt;br /&gt;
Two alternatives&lt;br /&gt;
&lt;br /&gt;
==== Set is also a value ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET#Set1/Flowrate&lt;br /&gt;
&lt;br /&gt;
Set1 is now a Databoard record.&lt;br /&gt;
&lt;br /&gt;
==== Only items are values ====&lt;br /&gt;
&lt;br /&gt;
http://www.asd.org/Project/BalasModel1/BaseRealization/Valve1/FSET/Set1#Flowrate&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Modelling of related concepts =&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
== Formatting ==&lt;br /&gt;
&lt;br /&gt;
= Standard variables =&lt;br /&gt;
&lt;br /&gt;
== Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Inferred configuration values from structural ===&lt;br /&gt;
&lt;br /&gt;
=== Expressions ===&lt;br /&gt;
&lt;br /&gt;
== Variable syntax in SCL ==&lt;br /&gt;
&lt;br /&gt;
* Implement variable interface methods as normal functions&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;browse entrypoint &amp;quot;./Out#sdf&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
* Use . and #-for browsing&lt;br /&gt;
** How to browse parent? Explicit function&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;(parent entrypoint).Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Special operator for parents (binds stronger than . or #):&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;!entrypoint.Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
* Resolve entrypoints in the context&lt;br /&gt;
** Example: &amp;lt;code&amp;gt;Out#sdf&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local variable definitions may shadow context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Experiment modelling =&lt;br /&gt;
&lt;br /&gt;
Each running or stored historical experiment in Simantics is modelled as a realization under the Model. Realizations have URIs as defined by ReadGraph.getURI. Some realizations are entirely backed by the semantic graph and some are backed by an Accessor provided by a running simulator or a time series stored as a file in the semantic graph. The structure of the Variable tree under the realization is generated from the semantic model configuration and can be implemented in different ways ranging from persistent graph to lazily produced transient virtual graph. The realizations are browsed using Variable interface methods and variable values can be obtained using Variable methods or by obtaining Databoard Accessor using Variable.getInterface. Each variable serves an instantaneous value and each variable can also contain a property which serves a time series associated to the variable such as in historical data or sampled history of a running experiment.&lt;br /&gt;
&lt;br /&gt;
= Validation scenario =&lt;br /&gt;
&lt;br /&gt;
The standard model is validated in a headless structural-based setup with&lt;br /&gt;
&lt;br /&gt;
*Structural configuration with joined diagrams and reusable component types&lt;br /&gt;
*Procedural children provided by simulator&lt;br /&gt;
*Accessor-backed simulator&lt;br /&gt;
&lt;br /&gt;
[[Category: Database Development]]&lt;/div&gt;</summary>
		<author><name>Antti Villberg</name></author>
	</entry>
</feed>