Programming model of the Enterprise ChangeSets

The onion.net Enterprise ChangeSets represent an independent environment for longer-lasting data manipulation. It is an important part of the editorial workflow, where several editors perform a maintenance order of any complexity over any period. The concept is similar to that of the database transaction, but supplements it however with long life and input by any number of processes (or users). No conflict status can be created or saved in Enterprise ChangeSets. They can always be intercombined and can be safely published or discarded. The data consistency is subject to the same laws here which the live data stock also follows.

Enterprise ChangeSets are a core function of the onion.net Information Server and are controlled via the Client API. The following example is intended to illustrate the programming model:

using System;
using Onion.Client;

class Program
{
  private static void Main(string[] args)
  {
    using (var session = new OnionSession("ipc://onion.net/onion/server", "admin", "admin"))
    {
      IChangeSet cs = session.Repository.ChangeSets.Create("Neues ChangeSet");
      cs.Enter();

      try
      {
        RenameChildren(session.Repository.Root);

        // we leave the changes uncommitted to view them in the editor
        // cs.Commit();
      }
      catch (Exception)
      {
        cs.Discard();
       
        throw;
      }
    }
  }

  private static void RenameChildren(IDataObject item)
  {
    foreach (IDataObject child in item.Children)
    {
      child.Name += " renamed";

      RenameChildren(child);
    }
  }
}

The goal of this program is to recursively rename all data objects in the data stock. This operation is not to be performed directly on the productive data however. In the case of an error (e.g. due to lack of rights or a conflict), the ChangeSet is discarded via the method “IChangeSet.Discard”. The command “IChangeSet.Commit” is commented-out in the example to illustrate this. This allows us to look at the status in the onion.net Editor.

Calling the method “IChangeSet.Enter” is crucial. This call defines the read and write context of the connection to the ChangeSet. From this point onwards, each data modification will be automatically recorded in a ChangeSet and simulated for further read access. As a user of the onion.net Editor or the Client API, you work as in the production data stock.

In the onion.net Editor, all changes can be looked at in the ChangeSet overview. The objects highlighted in blue in the structure tree refer to a change.

For information: All connected systems can be adapted to an Enterprise ChangeSet and thus test its function with a future data stock. The onion.net Render Engine also offers the possibility of including several ChangeSets at the same time for a rendering!