wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package com.vci.client.uif.actions.client;
 
import java.util.Map;
 
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.uif.engine.client.TransferBusinessObjectDialog;
import com.vci.client.uif.engine.common.DefaultTableNode;
import com.vci.corba.omd.lcm.TransitionVO;
import com.vci.mw.ClientContextVariable;
 
/**
 * 跃迁操作
 * 参数信息:
 *     oid(跃迁对象的oid)
 *     btmname(跃迁对象的类型)
 *     name(跃迁对象的名称、用于显示信息)
 * @author VCI-STGK006
 *
 */
public class TransferAction extends AbstractBusionessOperationAction {
 
    /**
     * 方法类
     */
    protected UIFUtils operation = 
            new UIFUtils();
    
    public TransferAction(){
        super();
    }
    
    @Override
    public String getKey() {
        return TRANSFER;
    }
    
    @Override
    public boolean checkHasRight(){
        // 按BO进行数据权限检查
        setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B);
        return super.checkHasRight();
    }
 
    @Override
    public boolean doPost() {
        //获得业务对象数据
        Object[] objs = getDataModel().getSelectObjects();
        if(objs == null || objs.length < 1){
            return false;
        }
         Map<String, String> buttonmap = this.getButtonParams();
        //modify 2014.03.09 start
        DefaultTableNode dtn = (DefaultTableNode) objs[0];
        ClientBusinessObject cbo = null;
        try {
            //判断主对象类型
            if(dtn.getMaterObject() instanceof ClientBusinessObject){
                //如果是业务类型
                cbo = (ClientBusinessObject) dtn.getMaterObject();
                if(cbo == null){
                    UIFUtils.showMessage(ClientContextVariable.getFrame(), 
                            "uifmodel.plm.uif.actions.notexistmsg", 
                            this.getParameterValue(ValueType.RuntimeData, "t_oid.name", 0));
                    return false;
                }
            } else if (dtn.getMaterObject() instanceof ClientLinkObject){
                //如果是link类型
                String oid = this.getParameterValue(ValueType.RuntimeData, "t_oid", 0);
                String btmName = this.getParameterValue(ValueType.RuntimeData, "t_btwname", 0);
                //如果操作所需参数不存在则直接停止操作
                if(oid == null || oid.equals("") ||btmName == null || btmName.equals("")){
                    UIFUtils.showMessage(ClientContextVariable.getFrame(),
                            "uifmodel.plm.uif.actions.syserror.parmerror.bo");
                    return false;
                }
                //需要重新下载cbo对象
                cbo = operation
                        .reloadClientBusinessObject(ClientContextVariable.getFrame(), oid, btmName);
                System.out.println("** TS:" + cbo.getBusinessObject().ts);
                //对象不存在或者已经被删除
                if(cbo.getBusinessObject().oid == null || cbo.getBusinessObject().oid.equals("")){
                    UIFUtils.showMessage(ClientContextVariable.getFrame(), 
                            "uifmodel.plm.uif.actions.notexistmsg", 
                            this.getParameterValue(ValueType.RuntimeData, "t_oid.name", 0));
                    return false;
                }                
            }
            
            TransitionVO vo = new TransitionVO();
//            String boLcStatus = cbo.getLcStatus();
//            if(boLcStatus == null || boLcStatus==""){
//                UIFUtils.showMessage(ClientContextVariable.getFrame(),
//                        "uifmodel.plm.uif.actions.syserror.parmerror.nostate");
//                return false;
//            }
//            LifeCyle curLC = null;
//            try {
//                curLC = LifeCycleStart.getService().getLifeCycle(cbo.getBusinessObject().lctId);
//            } catch (Exception e) {
//                e.getMessage();
//            }
//            if(curLC == null){
//                //TODO:提示出来
//                UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.parmerror.noconfigure");
//                return false;
//            }
            //如果配置了button参数,按参数执行
            if(buttonmap.get("connect") != null ){
                vo.connect = buttonmap.get("connect");
//                for (int l = 0; l < curLC.routes.length; ++l) {
//                    TransitionVO route = curLC.routes[l];
//                    if (route.source.equals(boLcStatus)){
//                        if(buttonmap.get("connect").equals(route.connect)){
//                            vo = route;
//                            break;    
//                        }
//                    }
//                }
//                if(vo == null){
//                    UIFUtils.showMessage(ClientContextVariable.getFrame(),
//                            "uifmodel.plm.uif.actions.syserror.parmerror.nodo", 
//                            buttonmap.get("connect"));
//                    return false;
//                
//                }
            }else if(buttonmap.get("destination") != null ){
                vo.destination = buttonmap.get("destination");
//                for (int l = 0; l < curLC.routes.length; ++l) {
//                    TransitionVO route = curLC.routes[l];
//                    if (route.source.equals(boLcStatus)){
//                        if(buttonmap.get("destination").equals(route.destination)){
//                            vo = route;
//                            break;    
//                        }
//                    }
//                }
//                if(vo == null){
//                    UIFUtils.showMessage(ClientContextVariable.getFrame(),
//                            "uifmodel.plm.uif.actions.syserror.parmerror.notostate", 
//                            buttonmap.get("destination"));
//                    return false;
//                }
            }else{
                //如果button没有参数,打开跃迁选择窗口
                TransferBusinessObjectDialog dialog = 
                        new TransferBusinessObjectDialog(ClientContextVariable.getFrame(), cbo);
                if(!dialog.isOk()){
                    return false;
                }
                //获得选择的TransitionVO信息,期中存储了跃迁时需要执行的事件transitionVOEvents
                vo = dialog.getTransitionVO();                
            }
            //跃迁
            boolean result = operation.transferBusinessObject(
                             ClientContextVariable.getFrame(), cbo, vo);
            return result;
        } catch (Exception e){
            UIFUtils.showErrorMessage(
                    ClientContextVariable.getFrame(),
                    "uifmodel.plm.uif.actions.transfererror", e);
            return false;
        }
        //modify 2014.03.09 end
    }
}