CentraSite Documentation : CentraSite Developer's Guide : Application Framework : Revision Management : Usage Sample for Revision Management
Usage Sample for Revision Management
package com.softwareag.centrasite.appl.framework.persistence.tests;
 
import java.util.ArrayList;
import java.util.Collection;
 
import com.softwareag.centrasite.appl.framework.SessionContext;
import com.softwareag.centrasite.appl.framework.beans.RevisionBean;
import com.softwareag.centrasite.appl.framework.beans.standard.Service;
import com.softwareag.centrasite.appl.framework.persistence.BeanPool;
import
com.softwareag.centrasite.appl.framework.persistence.revision.RevisionManager;
 
public class Revisioning {
private static String checkpointName = "MyLabel";
 
public void revisioning() throws Exception {
SessionContext sessionContext = initSessionContext();
BeanPool beanPool = sessionContext.getCurrentBeanPool();
 
RevisionManager revManager = sessionContext.getRevisionManager();
 
//enable the feature if needed
if (!revManager.isRevisioningEnabled()) {
revManager.enableRevisioning();
}
 
// create new checkpoint
Service bean = beanPool.read(Service.class, "uddikey");
revManager.setCheckpoint(bean, checkpointName);
 
// get all checkpoints including the current state object
Collection<RevisionBean> checkpoints = revManager.getRevisionBeans(bean);
 
// restore to the only checkpoint
Collection<RevisionBean> restoreObjs = new ArrayList<RevisionBean>();
for (RevisionBean rev : checkpoints) {
if (rev.isRevision()) {
restoreObjs.add(rev);
break;
}
}
 
revManager.restoreBeans(restoreObjs);
 
// delete checkpoints based on label
revManager.deleteBeans(checkpointName);
}
 
private SessionContext initSessionContext() {
//initialize CSAF
return null;
}
 
}
Copyright © 2005-2015 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback