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

在实际项目中,一个项目会存在多个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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值