{"id":7,"date":"2014-06-16T20:51:26","date_gmt":"2014-06-17T02:51:26","guid":{"rendered":"http:\/\/wolfcreekconsulting.com\/blog\/?p=7"},"modified":"2015-01-17T12:34:13","modified_gmt":"2015-01-17T19:34:13","slug":"smartplant-foundation-schema-graph-and-view-definitions","status":"publish","type":"post","link":"https:\/\/wolfcreekconsulting.com\/blog\/smartplant-foundation-schema-graph-and-view-definitions\/","title":{"rendered":"SPF Reporting &#8211; Creating SPF Schema Graph and View Definitions"},"content":{"rendered":"<p>I don&#8217;t use the Schema Editor for schema changes to SPF; I hand-code the updates in XMLSpy. This is pretty straightforward when modelling the more common objects like Classes, Interfaces and Properties. But Graph and View definitions are a little trickier.<\/p>\n<p>I deconstructed some existing Graph and View definitions in order to create some new ones manually;\u00a0this blog shows what I learned. In this explanation I gloss over the usual stuff like relationships between the objects; it&#8217;s the syntax of the definition strings that I go into detail on. This is based on SPF 4.3.3.<\/p>\n<p><!--more--><\/p>\n<p>To make a new Graph or View (or any Schema object), I just find one similar to the one I want to create, do an Export Data on it, expand all the relationships it has, copy the whole set of XML elements out to my text editor, wrap it in a &lt;Container&gt;&#8230;&lt;\/Container&gt; root element, then start changing each element to be what my new one needs. When done I load it with the Schema Import Wizard and test it.<\/p>\n<h1>DirectedGraphDefs<\/h1>\n<p>Think of a DirectedGraphDef as a set of related objects from a starting object. For example, starting from a transmittal object, a Graph that identifies all the files to be extracted to a ZIP file might identify the files found at the relationship path: Transmittal &gt; Document Revision &gt; Latest Document Version &gt; Files, and also the files at: Transmittal &gt; Files (those attached directly to the transmittal). A Graph might start from one object, or it might start from a collection or set of multiple objects. The Graph does not identify any specific properties of the objects it identifies; it merely gathers the objects up,\u00a0and assigns names to them, so they can be referenced from other paths in the Graph, or ultimately\u00a0from a ViewDef.<\/p>\n<p>Start by defining the basic properties of the DirectedGraphDef like Name, Description, etc. Next define a relationship from this DirectedGraphDef to the InterfaceDef for the object it will &#8220;start&#8221; from. Use the Export Data XML of an existing example to see how to set this up and what type of relationship to create.<\/p>\n<p>Now comes the fun part. \ud83d\ude42<\/p>\n<p>The property <strong>GraphDefn<\/strong> is the main property for a GraphDef. A typical value looks like this: (newlines added for readability at the commas, normally it is one continuous string)<\/p>\n<pre>+ITag\/+ITag\/,\r\nTagDocument_12\/DocumentVersions\/+ITag,\r\nSPFFileComposition_21\/Files\/DocumentVersions<\/pre>\n<p>It has the following syntax:<\/p>\n<ul>\n<li>It is a comma-delimited list of strings<\/li>\n<li>Each string has 3 components separated by forward slashes.<\/li>\n<\/ul>\n<p>The components that are separated by slashes are, in order (these names are made up by me, so may not agree with what Intergraph&#8217;s Schema Editor calls them):<\/p>\n<ul>\n<li>Unique ID (which is a RelDef or EdgeDef path)<\/li>\n<li>Name<\/li>\n<li>(optional) Start From Name<\/li>\n<\/ul>\n<p>So each string between commas looks like this:<\/p>\n<ul>\n<li>Unique ID\/Name\/Start From Name<\/li>\n<\/ul>\n<p><strong>Unique ID<\/strong> is either a relationship path in the form RelDef_12, or EDG_EdgeDef to refer to an EdgeDef already defined in your SPF schema. Where it ends, the objects at that end will be the &#8220;selected objects&#8221;.<\/p>\n<p><strong>Name<\/strong> is an English name given to the objects selected by the Unique ID path.<\/p>\n<p><strong>Start From Name<\/strong> is optional, if not specified then you still need the leading \/ slash character. It refers to a previously-defined Name value in a prior string in this Graph. If specified, it means the Unique ID &#8220;relationship hop&#8221; path will <em>start from<\/em> that set of objects, not the original Interface for the Graph.<\/p>\n<p>So in this example:<\/p>\n<ol>\n<li>+ITag\/<strong>+ITag<\/strong>\/,<\/li>\n<li>TagDocument_12\/<em>DocumentVersions<\/em>\/<strong>+ITag<\/strong>,<\/li>\n<li>SPFFileComposition_21\/Files\/<em>DocumentVersions<\/em><\/li>\n<\/ol>\n<ul>\n<li>The bold <strong>+ITag<\/strong> on line 2 refers to the objects selected by the path on line 1 (which is the starting interface) \u2013 this is the typical ending for most strings that are &#8220;one hop&#8221; from the starting object. Hence the &#8220;TagDocument_12&#8221; relationship expansion starts from <strong>+ITag<\/strong>.<\/li>\n<li>The italics <em>DocumentVersions<\/em> on line 3 refers to the objects selected on line 2, meaning the path continues from there. Hence the &#8220;SPFFileComposition_21&#8221; relationship expansion starts from the objects at the end of the &#8220;TagDocument_12&#8221; expansion (which were named &#8220;DocumentVersions&#8221;)<\/li>\n<li>The first line has no \u201cStart From Name\u201d so it starts from the InterfaceDef related to the GraphDef. This could be a single object that has that interface, or it could be a collection of objects that have that interface. This depends how the Graph used.<\/li>\n<\/ul>\n<h1>ViewDefs<\/h1>\n<p>If Graphs gather up and assign names to the objects related to a given starting object, then ViewDefs identify the properties to be extracted from those objects, for use in a report, for example; and assigns names and categories to those properties for ease of reference.<\/p>\n<p>ViewDefs can be used directly by users when they select File \u2013 New \u2013 Report. The initial list displayed is a list of ViewDefs they have access to through an access group (below).<\/p>\n<p>Like a DirectedGraphDef , ViewDefs require a relationship to a starting interface. They also require a relationship to a Group to allow access to use them, like a Method.<\/p>\n<p>ViewDefs\u00a0also need a DirectedGraphDef. This is not a relationship, rather the name of the DirectedGraphDef is stored in a property value. Certain values in the property string ViewPropsDefn (discussed below)refer to the &#8220;Name&#8221; components in the Graph&#8217;s string.<\/p>\n<p>The property <strong>ViewPropsDefn<\/strong> is the main definition of the ViewDef. A typical value looks like this: (newlines added for readability, normally it is one big string)<\/p>\n<pre>+ITag\/IObject\/Name\/Name\/Identification\/1,\r\n+ITag\/IObject\/Description\/Description\/Identification\/2,\r\nDocumentVersions\/ISPFDocumentVersion\/SPFIssueDate\/Issue Date\/Identification\/3,\r\nFiles\/ISPFBusinessFile\/SPFLocalFileName\/Local File Name\/Vault Info\/4<\/pre>\n<p>It has the following syntax:<\/p>\n<ul>\n<li>It is a comma-delimited list of strings<\/li>\n<li>Each string has 6 components separated by forward slashes.<\/li>\n<\/ul>\n<p>Components of each string are:<\/p>\n<ul>\n<li>Graph Edge Name<\/li>\n<li>Interface<\/li>\n<li>Property<\/li>\n<li>Name<\/li>\n<li>Category<\/li>\n<li>Number<\/li>\n<\/ul>\n<p>So each string between commas looks like this:<\/p>\n<ul>\n<li>Graph Edge Name\/Interface\/Property\/Name\/Category\/Number<\/li>\n<\/ul>\n<p><strong>Graph Edge Name<\/strong> refers to the Name component (middle part between two \/slashes\/) of one of the GraphDef strings. This selects the objects to read property values from.<\/p>\n<p><strong>Interface<\/strong> is the name of the interface on those objects to get read property values from.<\/p>\n<p><strong>Property<\/strong> is the name of the property to read values from on the selected objects.<\/p>\n<p><strong>Name<\/strong> is the display name given to those properties.<\/p>\n<p><strong>Category<\/strong> is a heading under which this Name will be grouped.<\/p>\n<p><strong>Number<\/strong> is a sequential number, must go up by 1 for each string. The highest vaule must also be put in the property LastLocalID.<\/p>\n<p>So in this example ViewDef (assuming it has a relationship back to the example graphDef above):<\/p>\n<ol>\n<li>+ITag\/IObject\/Name\/Name\/Identification\/1,<\/li>\n<li>+ITag\/IObject\/Description\/Description\/Identification\/2,<\/li>\n<li>DocumentVersions\/ISPFDocumentVersion\/SPFIssueDate\/Issue Date\/Identification\/3,<\/li>\n<li>Files\/ISPFBusinessFile\/SPFLocalFileName\/Local File Name\/Vault Info\/4<\/li>\n<\/ol>\n<ul>\n<li>Line 1 grabs the objects selected by the ITag interface, looks at their IObject interface and gets the Name property. It gives it the display name of \u201cName\u201d, and puts it under a category of Identification.<\/li>\n<li>Line 3 grabs the objects from Line 2 of the GraphDef (you will see it was named \u2026\/DocumentVersions\/\u2026), and gets the SPFIssueDate property from their ISPFDocumentVersion interfaces. It gives these values the display name \u201cIssue Date\u201d and puts it under the Identification category.<\/li>\n<li>Line 4 grabs the objects selected by Line 3 of the GraphDef (named \/Files\/), gets their SPFLocalFileName property from the ISPFBusinessFile interface, and gives it the display name \u201cLocal File name\u201d under the \u201cVault Info\u201d category.<\/li>\n<\/ul>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>Those are the key tricky bits I found to Graph and View definitions in SPF. Now you can create a report that uses the View Definition.<\/p>\n<p>Next I plan to blog on how to create an HTML transmittal report (ie. cover page) using XSLT using Graph and View defs like those above.<\/p>\n<p>Please comment if you found this post useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t use the Schema Editor for schema changes to SPF; I hand-code the updates in XMLSpy. This is pretty straightforward when modelling the more common objects like Classes, Interfaces and Properties. But Graph and View definitions are a little trickier. I deconstructed some existing Graph and View definitions in order to create some new [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,5],"tags":[3,4],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-schema","category-smartplant-foundation-spf","tag-directedgraphdef","tag-viewdef"],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":14,"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/posts\/7\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolfcreekconsulting.com\/blog\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}