ADF 生产环境中SavePoint的创建与清除

来源:互联网 发布:js缩略图点击放大 编辑:程序博客网 时间:2024/04/29 13:38

在实际项目中,一个项目会存在多个savepoint,而且同一个功能不同的用户操作都会产生savepoint,如果权限一样,不同的功能,不同的用户产生的savepoint后只能看到或清除自己操作产生的savepoint是必须要考虑的问题,解决的关键在于创建的时候savepoint设置name必须保证唯一即可,清除功能同理。代码如下:


public class EmpMain {    public EmpMain() {        cc = ControllerContext.getInstance();        sp = cc.getSavePointManager();    }    private SavePointManager sp;    private ControllerContext cc;    public void setSp(SavePointManager sp) {        this.sp = sp;    }    public SavePointManager getSp() {        return sp;    }    public void setCc(ControllerContext cc) {        this.cc = cc;    }    public ControllerContext getCc() {        return cc;    }    public void createSavePoint(ActionEvent actionEvent) {        Object user = ADFContext.getCurrent().getSessionScope().get("user");        SavePointAttributes s = new SavePointAttributes("Employee", "Employee's Save Point", null);        s.setName((String) user);        String saveId = sp.createSavePoint(s);        JSFUtils.setExpressionValue("#{pageFlowScope.savePointId}", saveId);    }    public List getPoint() {        List options;        options = new ArrayList();        List<String> saves = sp.listSavePointIds();        SelectItem option;        Object user = ADFContext.getCurrent().getSessionScope().get("user");        for (int i = 0; i < saves.size(); i++) {            SavePointAttributes att = sp.getSavePointAttributes( saves.get(i));            System.out.println(att);            if (att != null && att.getName() != null) {                if (att.getName().equals(user.toString())) {                    option = new SelectItem(saves.get(i), saves.get(i) + "_" + att.getName());                    options.add(option);                }            }        }        return options;    }    public void clearSavepoints(ActionEvent actionEvent) {        Object user = ADFContext.getCurrent().getSessionScope().get("user");        List<String> saves = sp.listSavePointIds();        String pointid = null;        for (int i = 0; i < saves.size(); i++) {            pointid = saves.get(i);            SavePointAttributes att = sp.getSavePointAttributes(pointid);            if (att != null && att.getName() != null) {                if (att.getName().equals(user.toString())) {                    sp.removeSavePoint(pointid);                }            }        }    }


0 0
原创粉丝点击