2 Replies Latest reply on Jan 18, 2013 3:37 PM by ChewCheeLim

    CheckOut(), CheckIn(), UndoCheckOut()


      Hi There, I want to make sure my following assumption is correct.


      At AFDatabase level, you can not do a db checkout. U only can checkout at AF element.


      AFElelement.CheckOut() --> only applies for the AFElement only. if the AFElement has child elements. none of them are 'CheckOut' unless checkout is called explicitly. Correct?


      Even without a checkout() being invoked, If I changed multiple AFElements (could be child, or could be other branch)  I still can apply AFDatabase.checkIn() method to commit all changes to DB.  Am I right on this one?


      If I decided to roll back, once I call AFDatabase.UndoCheckOut() .. all changes (mutiple afelements, including child, or other elements not at the same branch)  that I made for the DB will be rollback.




      Should I explicitly invoke CheckOut() as a good practice? (even though AF SDK help indicated that without a .CheckOut() being invoked, I still can call CheckIn() method at the end of my processing..)




      Many Thanks!



        • Re: CheckOut(), CheckIn(), UndoCheckOut()

          1.  Correct, You cannot checkout the entire database, only per object


          2.  Element.CheckOut will apply to children only if they are compositionally referenced.  In case of composition references, all elements in a composition are checked in/out together as one.  Note that we do not generally recommend using composition, especially large compositions, because it has performance costs.


          3.  Yes, you can use Database.CheckIn to checkin multiple changes.  You should generally use the method that takes the "AFCheckOutMode" - and pass either "ObjectsCheckedOutThisSession" or "ObjectsCheckedOutThisThread" so that you don't run into conflicts with other applications running under the same user identity (or in the same process if it is a multi-threaded process).  You can also send a specific list of objects to checkin using PISystem.CheckIn(IList<AFTransactable>)


          4. Yes, AFDatabase.UndoCheckout unchecks out everying the current user has checked out.  You can also undo them one by one.  AFDatabase.FindCheckedOutItems will give you the list of all items checked out.


          5.  Explictly invoking CheckOut is not required, but is sometimes useful..


             a. If you want to ensure, prior to starting a series of changes, that you have access to all the elements you need.  Once checked out, you will have a lock on the element which will prevent others from checking out.


             b. It is possible to add elements to another element without checking out the parent element.  However, in some cases, you may want the parent locked to prevent multiple applications from making simultaneous additions.  In this case, checking out the parent specifically will allow for the exclusive access.  It should be noted that for elements with large collections of children, this will slow down performance.