yuxc
2025-01-15 2bea732496b4f5051233ed94e206160992351596
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
package com.vci.server.framework.delegate;
 
import java.util.List;
 
import org.apache.commons.lang3.StringUtils;
 
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.common.VCIError;
import com.vci.corba.framework.data.OperateInfo;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.server.base.delegate.BaseDelegate;
import com.vci.server.framework.funcmng.operate.Operate;
import com.vci.server.framework.funcmng.operate.OperateService;
 
/**
 * 操作类型服务端
 * 
 * @author xf
 * 
 *         2012-5-16
 */
public class OperateDelegate extends BaseDelegate {
 
    private OperateService service;
 
    public OperateDelegate(UserEntityInfo userEntityInfo) {
        super(userEntityInfo);
        service = new OperateService(userEntity);
    }
    
    public OperateDelegate() {
        service = new OperateService();
    }
    
 
    /**
     * 保存操作类型
     * 
     * @param operateInfo
     * @return
     * @throws VCIError
     *             创建操作类型失败
     */
    public String saveOperate(OperateInfo operateInfo) throws VCIError {
        String res = "";
        if (StringUtils.isBlank(operateInfo.id)) {
            String id = ObjectUtility.getNewObjectID36();
            operateInfo.id = id;
        }
        try {
            res = service.saveOperate(transformIdlToPo(operateInfo));
        } catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("110100", new String[0]);
        }
        return res;
    }
    
    /**
     * 修改操作类型
     * 
     * @param operateInfo
     * @return
     * @throws VCIError
     *             创建操作类型失败
     */
    public String updateOperate(OperateInfo operateInfo) throws VCIError {
        String res = "";
        try {
            res = service.updateOperate(transformIdlToPo(operateInfo));
        } catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("110100", new String[0]);
        }
        return res;
    }
    
    /**
     * 删除操作类型
     * 
     * @param operateInfo
     * @return
     * @throws VCIError
     *             创建操作类型失败
     */
    public boolean deleteOperate(String id) throws VCIError {
        boolean res = true;
        try {
            res = service.deleteOperate(id);
        } catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("110100", new String[0]);
        }
        return res;
    }
 
    /**
     * 显示操作类型树
     * 
     * @return
     * @throws VCIError
     *             显示操作类型树失败
     */
    public OperateInfo[] getOperateTreeList(String moduleId) throws VCIError {
        List<Operate> ls = null;
        try {
            if(moduleId.equals("")){
                ls = service.getOperateTreeList();
            }else{
                ls = service.getOtherOperateListByModule(moduleId);
            }
            OperateInfo[] o = new OperateInfo[ls.size()];
            for (int i = 0; i < ls.size(); i++) {
                o[i] = transformPoToIdl(ls.get(i));
            }
            return o;
        } catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("110105", new String[0]);
        }
 
    }
    
    /**
     * 检查操作是否被模块引用
     * @param operateId
     * @return 0表示没有任何引用,1表示被模块引用,2表示已经存在权限信息
     * @throws VCIError
     */
    public int checkOperateIsReferenced(String operateId) throws VCIError {
        try{
            return service.checkOperateIsReferenced(operateId);
        }catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("0", new String[0]);
        }
    }
 
    /**
     * 通过标识获取操作
     * @param identify
     * @return
     * @throws VCIError
     */
    public OperateInfo getOperateByIdentify(String identify) throws VCIError {
        try{
            Operate operate = service.getOperateByIdentify(identify);
            return transformPoToIdl(operate);
        }catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("0", new String[0]);
        }
    }
    /**
     * <p>Description:通过名称获取操作</p>
     * 
     * @author wangxl
     * @time 2012-5-30
     * @param name
     * @return
     * @throws VCIError
     */
    public OperateInfo fetchOperateTypeByName(String name) throws VCIError {
        try{
            Operate operate = service.fetchOperateTypeByName(name);
            return transformPoToIdl(operate);
        }catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("0", new String[0]);
        }
    }
    public OperateInfo getOperatetById(String id) throws VCIError {
        try{
            Operate operate = service.getOperatetById(id);
            return transformPoToIdl(operate);
        }catch (Exception e) {
            e.printStackTrace();
            throw new VCIError("0", new String[0]);
        }
    }
    
    /**
     * idl对象和po转换
     * 
     * @param o
     * @return
     */
    private Operate transformIdlToPo(OperateInfo o) {
        Operate po = new Operate();
        po.setId(o.id);
        po.setName(o.name);
        po.setIdentify(o.identify);
        po.setAlias(o.alias);
        po.setDesc(o.desc);
        po.setSequence((int)o.seq);
        return po;
    }
 
    /**
     * po对象和idl转换
     * 
     * @param o
     * @return
     */
    private OperateInfo transformPoToIdl(Operate o) {
        OperateInfo po = new OperateInfo();
        po.id = o.getId() == null ? "" : o.getId();
        po.name = o.getName() == null ? "" : o.getName();
        po.identify = o.getIdentify() == null ? "" : o.getIdentify();
        po.alias = o.getAlias() == null ? "" : o.getAlias();
        po.desc = o.getDesc() == null ? "" : o.getDesc();
        po.seq = o.getSequence();
        return po;
    }
    /**
     * 
     * 获取所有操作类型数量
     * add by caill start 2015.12.11
     * */
    public int getAllOperitionsNum() throws VCIError {
        int res = 0;
        try{
            res = service.getAllOperitionsNum();
        }catch (Exception e) {
            e.printStackTrace();
            throw new VCIError();
        }
        return res;
    }
    /**
     * 
     * 获取所有操作类型数量
     * add by caill start 2015.12.11
     * */
    public String[][] getAllOperitions(int size) throws VCIError {
        String[][] res = new String[size][6];
        try{
            res = service.getAllOperitions(size);
        }catch (Exception e) {
            e.printStackTrace();
            throw new VCIError();
        }
        return res;
    }
}