<!doctype html><htmllang=enclass="js csstransforms3d"><head><metacharset=utf-8><metaname=viewportcontent="width=device-width,initial-scale=1"><metaname=generatorcontent="Hugo 0.80.0"><metaname=descriptioncontent="Strolch is a parameterized framework for use on servers and IoT"><metaname=authorcontent="Strolch"><linkrel=iconhref=/favicon.icotype=image/ico><title>Versioning - Strolch</title><linkhref=/css/nucleus.css?1626091328rel=stylesheet><linkhref=/css/fontawesome-all.min.css?1626091328rel=stylesheet><linkhref=/css/hybrid.css?1626091328rel=stylesheet><linkhref=/css/featherlight.min.css?1626091328rel=stylesheet><linkhref=/css/perfect-scrollbar.min.css?1626091328rel=stylesheet><linkhref=/css/auto-complete.css?1626091328rel=stylesheet><linkhref=/css/atom-one-dark-reasonable.css?1626091328rel=stylesheet><linkhref=/css/theme.css?1626091328rel=stylesheet><linkhref=/css/hugo-theme.css?1626091328rel=stylesheet><linkhref=/css/theme-green.css?1626091328rel=stylesheet><scriptsrc=/js/jquery-3.3.1.min.js?1626091328></script><style>:root#header+#content>#left>#rlblock_left{display:none!important}</style></head><bodydata-url=/documentation/versioning/><navid=sidebar><divid=header-wrapper><divid=header><aid=logohref=/><imgsrc=/logo.png></a></div><divclass=searchbox><labelfor=search-by><iclass="fas fa-search"></i></label><inputdata-search-inputid=search-bytype=searchplaceholder=Search...>
parent"><ahref=/documentation/>Documentation</a><ul><lidata-nav-id=/documentation/architecture/title=Architectureclass=dd-item><ahref=/documentation/architecture/>Architecture</a></li><lidata-nav-id=/documentation/model/title=Modelclass=dd-item><ahref=/documentation/model/>Model</a></li><lidata-nav-id=/documentation/do-and-donts/title="Do and Don't"class=dd-item><ahref=/documentation/do-and-donts/>Do and Don't</a></li><lidata-nav-id=/documentation/runtime-configuration/title="Runtime Configuration"class=dd-item><ahref=/documentation/runtime-configuration/>Runtime Configuration</a></li><lidata-nav-id=/documentation/realms/title=Realmsclass=dd-item><ahref=/documentation/realms/>Realms</a></li><lidata-nav-id=/documentation/components/title=Componentsclass=dd-item><ahref=/documentation/components/>Components</a></li><lidata-nav-id=/documentation/services-and-commands/title="Services and Commands"class=dd-item><ahref=/documentation/services-and-commands/>Services and Commands</a></li><lidata-nav-id=/documentation/searches/title=Searchesclass=dd-item><ahref=/documentation/searches/>Searches</a></li><lidata-nav-id=/documentation/queries/title=Queriesclass=dd-item><ahref=/documentation/queries/>Queries</a></li><lidata-nav-id=/documentation/transactions/title=Transactionsclass=dd-item><ahref=/documentation/transactions/>Transactions</a></li><lidata-nav-id=/documentation/policies/title=Policiesclass=dd-item><ahref=/documentation/policies/>Policies</a></li><lidata-nav-id=/documentation/observers/title=Observersclass=dd-item><ahref=/documentation/observers/>Observers</a></li><lidata-nav-id=/documentation/versioning/title=Versioningclass="dd-item active"><ahref=/documentation/versioning/>Versioning</a></li><lidata-nav-id=/documentation/reports/title=Reportsclass=dd-item><ahref=/documentation/reports/>Reports</a></li><lidata-nav-id=/documentation/priviles/title=Privilegesclass=dd-item><ahref=/documentation/priviles/>Privileges</a></li></ul></li><lidata-nav-id=/plc/title=PLCclass=dd-item><ahref=/plc/>PLC</a><ul><lidata-nav-id=/plc/architecture/title=Architectureclass=dd-item><ahref=/plc/architecture/>Architecture</a></li><lidata-nav-id=/plc/example-set-up/title="Example Set-Up"class=dd-item><ahref=/plc/example-set-up/>Example Set-Up</a></li></ul></li><lidata-nav-id=/tutorial/title=Tutorialclass=dd-item><ahref=/tutorial/>Tutorial</a><ul><lidata-nav-id=/tutorial/configuration/title=Configurationclass=dd-item><ahref=/tutorial/configuration/>Configuration</a></li><lidata-nav-id=/tutorial/model/title=Modelclass=dd-item><ahref=/tutorial/model/>Model</a></li><lidata-nav-id=/tutorial/crud-book/title="CRUD Book"class=dd-item><ahref=/tutorial/crud-book/>CRUD Book</a></li></ul></li><lidata-nav-id=/download/title=Downloadclass=dd-item><ahref=/download/>Download</a></li><lidata-nav-id=/development/title=Developmentclass=dd-item><ahref=/development/>Development</a></li></ul><sectionid=shortcuts><h3>More</h3><ul><li><aclass=paddinghref=https://strolch.li/tags><iclass="fas fa-tags"></i>Tags</a></li><li><aclass=paddinghref=https://github.com/strolch-li><iclass="fab fa-github"></i>GitHub project</a></li></ul></section><sectionid=footer><p>Built with <ahref=https://github.com/matcornic/hugo-theme-learn><iclass="fas fa-heart"></i></a>from <ahref=https://getgrav.org>Grav</a> and <ahref=https://gohugo.io/>Hugo</a></p></section></div></nav><sectionid=body><divid=overlay></div><divclass="padding highlightable"><div><divid=top-bar><divid=top-github-link><aclass=github-linktitle="Edit this page"href=https://github.com/Pi4J/pi4j.github.io/tree/main/contentdocumentation/versioning.mdtarget=blank><iclass="fas fa-code-branch"></i><spanid=top-github-link-text>Edit this page</span></a></div><divid=breadcrumbsitemscopeitemtype=http://data-vocabulary.org/Breadcrumb><spanid=sidebar-toggle-span><ahref=#id=sidebar-toggledata-sidebar-toggle><iclass="fas fa-bars"></i></a></span><spanid=toc-menu><iclass="fas fa-list-alt"></i></span><spanclass=li
versioning is baked into Strolch’s fabric. The feature is opt-in, as it is not
required in all projects, but it only needs enabling, for all modifications to
objects to be versioned, so that rollbacks can be done when needed.</p><p>The feature is enabled for each realm. In the <code>StrolchConfiguration.xml</code> file
enable it by adding the <code>enableVersioning</code> propery per realm:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-xmldata-lang=xml><spanstyle=color:#f92672><StrolchConfiguration></span>
</code></pre></div><p>Once versioning is enabled, versioning is handled automatically. The API for versioning is implemented on the ElementMaps.</p><p>Example: Revert to previous version of a Resource:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java>Resource res <spanstyle=color:#f92672>=</span> tx<spanstyle=color:#f92672>.</span><spanstyle=color:#a6e22e>getResourceBy</span><spanstyle=color:#f92672>(</span><spanstyle=color:#e6db74>"TestType"</span><spanstyle=color:#f92672>,</span><spanstyle=color:#e6db74>"MyTestResource"</span><spanstyle=color:#f92672>);</span>
</code></pre></div><p>Example: Retrieve all versions of a Resource:</p><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javadata-lang=java>List<spanstyle=color:#f92672><</span>Resource<spanstyle=color:#f92672>></span> versions <spanstyle=color:#f92672>=</span> resourceMap<spanstyle=color:#f92672>.</span><spanstyle=color:#a6e22e>getVersionsFor</span><spanstyle=color:#f92672>(</span>tx<spanstyle=color:#f92672>,</span><spanstyle=color:#e6db74>"TestType"</span><spanstyle=color:#f92672>,</span><spanstyle=color:#e6db74>"MyTestResource"</span><spanstyle=color:#f92672>);</span>
</code></pre></div><divclass="notices tip"><p>Note: When reverting to a previous version, it is important to remember, that
any references on an element to other elements will also be restored. As long as
the relationship is to the same element, then this is not an issue, but should
the relationship have changed, then it this must be handled and the user
performing a revert be allowed to decided which element to reference in the