In this article we are going to use 3 EDIT2 callbacks registered for NP-Container, Presence Container, and a list.


  container a-NPcontainer {        // edit2 cb

    leaf b { type string; default "bee (default)"; }
    leaf c { type string; default "cee (default)"; }
    leaf x { type string; }
  }

  container d-Pcontainer {        // edit2 cb

    presence "Not created by default";
    leaf e { type string; default "ee (default)";  }
    leaf f { type string; default "eff (default)"; }
    leaf x { type string; }
  }

  list g-list {                   // edit2 cb

    key h;
    leaf h { type string; }
    leaf i { type string; default "aye (default)"; }
    leaf x { type string; }
  }

 

Now, let us go through all the possible operations that can be applied on this data model and how they should be handles by EDIT2 callbacks.

 



Create/Update containers/lists and their children

Create a new NP container


   # a-NPcontainer b boo c coo x doo


When you create a new NP Container the parent operation (operation on a container) will be "merge".

As a result the operation should be handled differently.  The edit is not really on this node; need to get each child_undo record to get the real edited nodes and the edited operations.

The following "merge list" (list of children records) illustrates what values should be expected:


    Merge list for parent a-NPcontainer:
        b: editop=merge newval=boo curval=bee (default)
        c: editop=merge newval=coo curval=cee (default)
        x: editop=create newval=xoo curval=(NULL)


Create a new Presence container or list


  # d-Pcontainer e eee f foo x xoo


For Presence containers operation will be "create" since there is no any default values to merge with.

As a result the create edit on the Presence container can be handled the same way as EDIT1 callbacks.

The following "list" (list of curval/newval records) illustrates what values should be expected:


    editop=create
    newval d-Pcontainer:
        e='eee'
        f='foo'
        x='xoo'
    curval (NULL)


Create a new list


# g-list first
# i inode x xoo

 

Similarly, for Lists operation also will be "create" since there is no any default values to merge with.

As a result the create edit on Lists can be handled the same way as EDIT1 callbacks.

The following "list" (list of curval/newval records) illustrates what values should be expected:


   editop=create
    newval g-list:
        h='first'
        i='inode'
        x='xoo'
    curval (NULL):

Update any container/list


When you update any existent container or list the parent operation (operation on a container or list) will be "merge".

As a result the operation should be handled differently.  The edit is not really on this node; need to get each child_undo record to get the real edited nodes and the edited operations.

The following "merge list" (list of children records) illustrates what values should be expected:


   # a-NPcontainer  b boo2 c coo1 x xoo1

    Merge list for parent a-NPcontainer:
        b: editop=merge newval=boo2 curval=boo
        c: editop=merge newval=coo1 curval=coo
        x: editop=merge newval=xoo1 curval=xoo


Delete/Remove containers/lists children


Remove children within NP-Containers


   >a-NPcontainer# no b no c no d

When you remove some nodes within NP-Container (default nodes as well as not default) the parent operation (operation on a container or list) will be "merge".

As a result the operation should be handled differently.  The edit is not really on this node; need to get each child_undo record to get the real edited nodes and the edited operations.

The following "merge list" (list of children records) illustrates what values should be expected:


    Merge list for parent a-NPcontainer:
        b: editop=merge newval=bee (default) curval=boo2
        c: editop=merge newval=cee (default) curval=coo1
        x: editop=remove newval= curval=xoo1               <----- not-default


Remove children within Presence containers


  >d-Pcontainer# no e no f no x


When you remove some nodes within P-Container (default nodes as well as not default) the parent operation (operation on a container or list) will be "merge".

As a result the operation should be handled differently.  The edit is not really on this node; need to get each child_undo record to get the real edited nodes and the edited operations.

The following "merge list" (list of children records) illustrates what values should be expected:


    Merge list for parent d-Pcontainer:
        e: editop=merge newval=ee (default) curval=eee1
        f: editop=merge newval=eff (default) curval=foo1
        x: editop=remove newval= curval=xoo1               <----- not-default


Remove children within lists


  >g-list# no i no x


When you remove some nodes within lists (default nodes as well as not default) the parent operation (operation on a container or list) will be "merge".

As a result the operation should be handled differently.  The edit is not really on this node; need to get each child_undo record to get the real edited nodes and the edited operations.

The following "merge list" (list of children records) illustrates what values should be expected:


    Merge list for parent g-list:
        i: editop=merge newval=aye (default) curval=inode
        x: editop=remove newval= curval=xoo               <----- not-default



Delete/Remove containers/lists


Delete NP container with children that are set to non-default

  # no a-NPcontainer


When you remove NP-container itself the parent operation (operation on a container) will be "delete".


As a result the delete edit on NP-containers can be handled the same way as EDIT1 callbacks.

The following "list" (list of curval/newval records) illustrates what values should be expected:


    editop=delete
    newval a-NPcontainer:
    curval a-NPcontainer:
        b='bee (default)'
        c='cee (default)'

Delete Presence container with children that are set to non-default


# no d-Pcontainer


When you remove P-container or list itself the parent operation (operation on a container or list) will be "delete".

As a result the delete edit can be handled the same way as EDIT1 callbacks.

The following "list" (list of curval/newval records) illustrates what values should be expected:


    editop=delete
    newval d-Pcontainer:
    curval d-Pcontainer:
        e='eee'
        f='foo'
        x='xoo'