{"id":166,"date":"2015-12-11T13:22:14","date_gmt":"2015-12-11T13:22:14","guid":{"rendered":"http:\/\/o-calcpro.com\/wiki\/?p=166"},"modified":"2016-01-20T18:41:41","modified_gmt":"2016-01-20T18:41:41","slug":"using-the-working-data-store-wds","status":"publish","type":"post","link":"http:\/\/o-calcpro.com\/wiki\/2015\/12\/11\/using-the-working-data-store-wds\/","title":{"rendered":"Using the Working Data Store (WDS)"},"content":{"rendered":"<p>When creating a plugin, report, or script in\u00a0O-Calc Pro it is helpful to be able to store information such as state, history, or keys identifying external data sources directly in the PPLX elements. O-Calc Pro provides a mechanism for this in the form of the Working Data Store (WDS).<\/p>\n<p>The WDS is a free form dictionary that lives on every element within your model and allows you as a developer to store any data you wish for later retrieval or manipulation. The WDS is not visible to your users and is strictly used for adding data to a model to allow you to implement functionality.<\/p>\n<p>A value can be embedded into an element (any class derived from PPLElement) by using the method public void <strong>&#8220;WriteWorkingDataStore(String pKey, String pValue)&#8221;<\/strong>\u00a0and similarly can retrieve that value in the future using <strong>&#8220;public String ReadWorkingDataStore(String pKey)&#8221;<\/strong>.<\/p>\n<p>Here is a very simple example that adds two values to an element and all of its children as a test&#8230;<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">private<\/span> <span style=\"color: #6666cc;font-weight: bold\">void<\/span> SetWorkingStore<span style=\"color: #008000\">&#040;<\/span>PPLElement pElem<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">pElem<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">WriteWorkingDataStore<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Alpha&quot;<\/span>, <span style=\"color: #666666\">&quot;This is the alpha data&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">pElem<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">WriteWorkingDataStore<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Beta&quot;<\/span>, <span style=\"color: #666666\">&quot;This is the beta data&quot;<\/span><span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">foreach<\/span> <span style=\"color: #008000\">&#040;<\/span>PPLElement elem <span style=\"color: #0600FF;font-weight: bold\">in<\/span> pElem<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Children<\/span><span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">SetWorkingStore<span style=\"color: #008000\">&#040;<\/span>elem<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>After doing that we can save and then reload the structure and then verify that, in fact, the data was stored and is still available.<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">C#<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"csharp\" style=\"font-family:monospace\"><li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">private<\/span> <span style=\"color: #6666cc;font-weight: bold\">bool<\/span> TestWorkingStore<span style=\"color: #008000\">&#040;<\/span>PPLElement pElem<span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span>pElem<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ReadWorkingDataStore<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Alpha&quot;<\/span><span style=\"color: #008000\">&#041;<\/span> <span style=\"color: #008000\">!=<\/span> <span style=\"color: #666666\">&quot;This is the alpha data&quot;<\/span><span style=\"color: #008000\">&#041;<\/span> <span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #0600FF;font-weight: bold\">false<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span>pElem<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">ReadWorkingDataStore<\/span><span style=\"color: #008000\">&#040;<\/span><span style=\"color: #666666\">&quot;Beta&quot;<\/span><span style=\"color: #008000\">&#041;<\/span> <span style=\"color: #008000\">!=<\/span> <span style=\"color: #666666\">&quot;This is the beta data&quot;<\/span><span style=\"color: #008000\">&#041;<\/span> <span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #0600FF;font-weight: bold\">false<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">foreach<\/span> <span style=\"color: #008000\">&#040;<\/span>PPLElement elem <span style=\"color: #0600FF;font-weight: bold\">in<\/span> pElem<span style=\"color: #008000\">.<\/span><span style=\"color: #0000FF\">Children<\/span><span style=\"color: #008000\">&#041;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#123;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">if<\/span> <span style=\"color: #008000\">&#040;<\/span><span style=\"color: #008000\">!<\/span>TestWorkingStore<span style=\"color: #008000\">&#040;<\/span>elem<span style=\"color: #008000\">&#041;<\/span><span style=\"color: #008000\">&#041;<\/span> <span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #0600FF;font-weight: bold\">false<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0600FF;font-weight: bold\">return<\/span> <span style=\"color: #0600FF;font-weight: bold\">true<\/span><span style=\"color: #008000\">;<\/span><\/div><\/li>\n<li><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #008000\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Obviously this is a very simple example but in an actual plugin or report there are many times where storing additional data tightly bound to elements in the analysis model are useful to save state, or to bind that element to other data or processes within an organization.<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=http%3A%2F%2Fo-calcpro.com%2Fwiki%2Fwp-json%2Fwp%2Fv2%2Fposts%2F166&#038;t=Using%20the%20Working%20Data%20Store%20%28WDS%29&#038;s=100&#038;p&#091;url&#093;=http%3A%2F%2Fo-calcpro.com%2Fwiki%2Fwp-json%2Fwp%2Fv2%2Fposts%2F166&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=Using%20the%20Working%20Data%20Store%20%28WDS%29\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/o-calcpro.com\/wiki\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?url=http%3A%2F%2Fo-calcpro.com%2Fwiki%2Fwp-json%2Fwp%2Fv2%2Fposts%2F166&#038;text=O-Calc%20Pro%20Information\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/o-calcpro.com\/wiki\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=http%3A%2F%2Fo-calcpro.com%2Fwiki%2Fwp-json%2Fwp%2Fv2%2Fposts%2F166&#038;title=Using%20the%20Working%20Data%20Store%20%28WDS%29\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/o-calcpro.com\/wiki\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Using%20the%20Working%20Data%20Store%20%28WDS%29&#038;body=O-Calc%20Pro%20Information:%20http%3A%2F%2Fo-calcpro.com%2Fwiki%2Fwp-json%2Fwp%2Fv2%2Fposts%2F166\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px\"><img decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/o-calcpro.com\/wiki\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>When creating a plugin, report, or script in\u00a0O-Calc Pro it is helpful to be able to store information such as state, history, or keys identifying external data sources directly in the PPLX elements. O-Calc Pro provides a mechanism for this in the form of the Working Data Store (WDS). The WDS is a free form ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"http:\/\/o-calcpro.com\/wiki\/2015\/12\/11\/using-the-working-data-store-wds\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,6,3],"tags":[],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-plugin-development","category-report-development","category-scripting"],"_links":{"self":[{"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":4,"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"predecessor-version":[{"id":287,"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/posts\/166\/revisions\/287"}],"wp:attachment":[{"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/o-calcpro.com\/wiki\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}