strolch/li.strolch.website/www.strolch.li/documentation-versioning.html

149 lines
6.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="google-site-verification" content="CPhbjooaiTdROm7Vs4E7kuHZvBfkeLUtonGgcVUbTL8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="ico/favicon.ico">
<title>Strolch: Versioning</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/custom.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script><![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Strolch</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Overview</a></li>
<li><a href="api.html">API</a></li>
<li class="active"><a href="documentation.html">Documentation</a></li>
<li><a href="tutorial.html">Tutorial</a></li>
<li><a href="downloads.html">Downloads</a></li>
<li><a href="development.html">Development</a></li>
<li><a href="blog.html">Blog</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="page-header">
<h1 class="page-title">Documentation: Versioning</h1>
<p class="lead page-description">This page discusses the Strolch Versioning</p>
</div>
<div class="content">
<p>One of Strolch's features that sets it apart from other frameworks, is that 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>
<pre>
&lt;StrolchConfiguration&gt;
&lt;env id="dev"&gt;
...
&lt;Component&gt;
&lt;name&gt;RealmHandler&lt;/name&gt;
&lt;api&gt;li.strolch.agent.api.RealmHandler&lt;/api&gt;
&lt;impl&gt;li.strolch.agent.impl.DefaultRealmHandler&lt;/impl&gt;
&lt;depends&gt;PrivilegeHandler&lt;/depends&gt;
&lt;Properties&gt;
&lt;realms&gt;defaultRealm, otherRealm&lt;/realms&gt;
&lt;enableVersioning&gt;true&lt;/enableVersioning&gt;
&lt;dataStoreMode&gt;TRANSIENT&lt;/dataStoreMode&gt;
&lt;dataStoreFile&gt;StrolchModel.xml&lt;/dataStoreFile&gt;
&lt;enableVersioning.otherRealm&gt;true&lt;/enableVersioning.otherRealm&gt;
&lt;dataStoreMode.otherRealm&gt;TRANSIENT&lt;/dataStoreMode.otherRealm&gt;
&lt;dataStoreFile.otherRealm&gt;StrolchModel.xml&lt;/dataStoreFile.otherRealm&gt;
&lt;/Properties&gt;
&lt;/Component&gt;
&lt;/env&gt;
...
&lt;/StrolchConfiguration&gt;</pre>
<br />
<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>
<pre>
Resource res = tx.getResourceBy("TestType", "MyTestResource");
ResourceMap resourceMap = tx.getResourceMap();
Resource previousVersion = resourceMap.revertToVersion(tx, res);
// or
Resource previousVersion = resourceMap.revertToVersion(tx, "TestType", "MyTestResource", 1);</pre>
<p>Example: Retrieve all versions of a Resource:</p>
<pre>
List&lt;Resource&gt; versions = resourceMap.getVersionsFor(tx, "TestType", "MyTestResource");</pre>
<br />
<p><b>Note:</b> 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 reverted version.</p>
<!-- content here -->
</div>
<!-- /.content -->
<div id="footer">
<div class="container">
<p class="text-muted">&copy; Strolch / <a href="mailto:eitch@eitchnet.ch">Robert von Burg</a> / Hosting by
<a href="http://www.eitchnet.ch">eitchnet.ch</a></p>
</div>
</div>
</div>
<!-- /.container -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual xsd as needed -->
<script src="js/bootstrap.min.js"></script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://piwik.eitchnet.ch/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', 2]);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.defer = true;
g.async = true;
g.src = u + 'piwik.js';
s.parentNode.insertBefore(g, s);
})();
</script>
<noscript><p><img src="http://piwik.eitchnet.ch/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>