dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
package com.vci.client.framework.delegate;
 
import java.util.ArrayList;
 
import com.vci.client.ClientSession;
import com.vci.client.common.objects.UserEntityObject;
import com.vci.client.common.objects.UserObject;
import com.vci.client.framework.rightConfig.object.FuncOperationObject;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.ui.exception.VCIException;
import com.vci.corba.common.VCIError;
import com.vci.corba.framework.data.FuncOperationInfo;
import com.vci.corba.framework.data.FunctionInfo;
import com.vci.corba.framework.data.OperateInfo;
import com.vci.corba.framework.data.UserInfo;
 
/**
* <p>Title: 功能模块</p>
* <p>Description: 功能模块客户端方法调用</p>
* <p>Copyright: Copyright {c} 2011</p>
* <p>Company: VCI</p>
* @author ligang
* @time 2011-6-16
* @version 1.0
*/
public class FunctionClientDelegate extends ClientBaseDelegate {
    public FunctionClientDelegate(UserEntityObject userEntityObject) {
        super(userEntityObject);
    }
    
    public FunctionClientDelegate() {
    }
    
    /**
     * 保存模块
     * @param object
     * @return
     * @throws VCIException
     */
    public String saveModule(FunctionObject object) throws VCIException{
        String res = "";
        try{
            res = ClientSession.getFrameworkService().saveModule(changeFunObjectToInfo(object),userEntityInfo);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        return res;
    }
    
    /**
     * 判断第一级数据有没有重名的
     * add by caill
     * */
    public boolean firstLevel(String plName) throws VCIException{
        
        try{
            return ClientSession.getFrameworkService().firstLevel(plName);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        
    }
    /**
     * 覆盖重名的第一级数据
     * add by caill
     * */
    public String changeFirstLevel(FunctionObject functionObject,String plName) throws VCIException{
        
        String fParentId="";
            try {
                fParentId= ClientSession.getFrameworkService().changeFirstLevel(changeFunObjectToInfo(functionObject), plName);
            } catch (VCIError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        
        return fParentId;
    }    
    /**
     * 判断第二级数据有没有重名的
     * add by caill
     * */
    public boolean secondLevel(String plName,String fParentId) throws VCIException{
        
        try{
            return ClientSession.getFrameworkService().secondLevel(plName,fParentId);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        
    }
    /**
     * 覆盖重名的第二级数据
     * add by caill
     * */
    public String changeSecondLevel(FunctionObject functionObject,String plName,String fParentId) throws VCIException{
        
        String sParentId="";
            try {
                sParentId= ClientSession.getFrameworkService().changeSecondLevel(changeFunObjectToInfo(functionObject), plName,fParentId);
            } catch (VCIError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        
        return sParentId;        
    }    
    /**
     * 判断第三级数据有没有重名的
     * add by caill
     * */
    /*public boolean thirdLevel(String plName,String sParentId) throws VCIException{
        
        try{
            return ClientSession.getFrameworkService().thirdLevel(plName,sParentId);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        
    }*/
    /**
     * 覆盖重名的第三级数据
     * add by caill
     * */
/*    public String changeThirdLevel(FunctionObject functionObject,String plName,String sParentId) throws VCIException{
        
        String tParentId="";
            try {
                tParentId= ClientSession.getFrameworkService().changeThirdLevel(changeFunObjectToInfo(functionObject), plName,sParentId);
            } catch (VCIError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        
        return tParentId;
    }    */
    /**
     * 导入模块对象
     * add by caill
     * */
    public boolean importModules(FunctionObject[] funObject,int count) throws VCIException{
            boolean b=false;
            int len = funObject.length;
            ArrayList<FunctionInfo> funInfoList = new ArrayList<FunctionInfo>();
            for(int i = count ; i<len ; i++){
                if(funObject[i].getParentId()!=null){
                    FunctionObject object = funObject[i];
                    FunctionInfo funInfo = changeFunObjectToInfo(object);
                    funInfoList.add(funInfo);
                }
            }
            FunctionInfo[] funInfos = new FunctionInfo[funInfoList.size()];
            for(int j=0;j<funInfoList.size();j++){
                funInfos[j] = funInfoList.get(j);
            }
            
                try {
                    b = ClientSession.getFrameworkService().importModules(funInfos,userEntityInfo);
                } catch (VCIError e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            
            return b;
    }
    
    /**
     * 
     * 查询"功能模块管理"整个树结构并导出sql
     * add by caill start 2015.12.8
     * */
    public String[][] getAllDatas(int size) throws VCIException{
        String[][] res = new String[size][23];
        try{
            res = ClientSession.getFrameworkService().getAllDatas(size);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        return res;
    }
    /**
     * 
     * 获得所有操作类型的数量
     * add by caill start 2015.12.11
     * */
    public int getAllModelManagementNum() throws VCIException{
        long res = 0;
        try{
            res = ClientSession.getFrameworkService().getAllModelManagementNum();
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        return (int)res;
    }
    // add by caill end
    /**
     * 
     * 查询"功能模块管理"整个树结构并导出
     * add by caill start
     * */
    public String[][] checkLevel() throws VCIException{
        String[][] res = new String[3000][23];
        try{
            res = ClientSession.getFrameworkService().checkLevel();
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        return res;
    }
    // add by caill end
    /**
     * 根据名称查询操作
     * add by caill start
     * */
    public OperateInfo fetchOperateTypeByName(String name) throws VCIException{
        try{
            return ClientSession.getFrameworkService().fetchOperateTypeByName(name);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        
    }
    /**
     * 修改模块
     * @param object
     * @return
     * @throws VCIException
     */
    public String updateModule(FunctionObject object) throws VCIException{
        String res = "";
        try{
            res = ClientSession.getFrameworkService().updateModule(changeFunObjectToInfo(object),userEntityInfo);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        return res;
    }
    
    /**
     * 删除模块
     * @param rmDataObject
     * @return
     * @throws VCIException
     */
    public String deleteModule(String puid) throws VCIException{
        String res = "";
        try{
            res = ClientSession.getFrameworkService().deleteModule(puid,userEntityInfo);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code), e.messages);
        }
        return res;
    }
    
    /**
     * 获取自动生成的编号
     * @return
     * @throws VCIException
     */
//    public int getAutoModuleNo() throws VCIException {
//        int res = 0;
//        try{
//            res = ClientSession.getFrameworkService().getAutoModuleNo();
//        }catch (VCIError e) {
//            e.printStackTrace();
//            throw new VCIException(String.valueOf(e.code), e.messages);
//        }
//        return res;
//    }
    /**
     * 通过模块ID获取子级列表
     * @param parentId
     * @param isAll 是否包括无效的模块,true则包括
     * @return
     * @throws VCIException
     */
    public FunctionObject[] getModuleListByParentId(String parentId,boolean isAll) throws VCIException {
        FunctionObject[] funcObjs = null;
        try{
            FunctionInfo[] funcInfos = ClientSession.getFrameworkService().getModuleListByParentId(parentId, isAll);
            funcObjs = new FunctionObject[funcInfos.length];
            for(int i = 0;i < funcInfos.length; i++){
                funcObjs[i] = changeFunInfoToObject(funcInfos[i]);
            }
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return funcObjs;
    }
    
    /**
     * 获取父下所有子模块
     * @param parentId
     * @param isAll
     * @return
     * @throws VCIException
     */
    public FunctionObject[] getChildrenFunctionsByParentId(String parentId, boolean isAll) throws VCIException {
        FunctionObject[] funcObjs = null;
        try{
            FunctionInfo[] funcInfos = ClientSession.getFrameworkService().getChildrenFunctionsByParentId(parentId, isAll);
            funcObjs = new FunctionObject[funcInfos.length];
            for(int i = 0;i < funcInfos.length; i++){
                funcObjs[i] = changeFunInfoToObject(funcInfos[i]);
            }
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return funcObjs;
    }
    
    /**
     * BS框架的模块信息
     * @param parentId
     * @param isAll
     * @return
     * @throws VCIException
     */
    public FunctionObject[] getModuleListByParentIdForBS(String parentId,boolean isAll) throws VCIException {
        FunctionObject[] funcObjs = null;
        try{
            FunctionInfo[] funcInfos = ClientSession.getFrameworkService().getModuleListByParentIdForBS(parentId, isAll);
            funcObjs = new FunctionObject[funcInfos.length];
            for(int i = 0;i < funcInfos.length; i++){
                funcObjs[i] = changeFunInfoToObject(funcInfos[i]);
            }
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return funcObjs;
    }
    /**
     * CS框架的模块信息
     * @param parentId
     * @param isAll
     * @return
     * @throws VCIException
     */
    public FunctionObject[] getModuleListByParentIdForCS(String parentId,boolean isAll) throws VCIException {
        FunctionObject[] funcObjs = null;
        try{
            FunctionInfo[] funcInfos = ClientSession.getFrameworkService().getModuleListByParentIdForCS(parentId, isAll);
            funcObjs = new FunctionObject[funcInfos.length];
            for(int i = 0;i < funcInfos.length; i++){
                funcObjs[i] = changeFunInfoToObject(funcInfos[i]);
            }
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return funcObjs;
    }
    
    /**
     * 获取用户有权限的子级模块列表
     * @param parentId 模块ID
     * @param userName 用户名
     * @return
     * @throws VCIException
     */
    public FunctionObject[] getModuleListByRoleRight(String parentId,String userName) throws VCIException {
        FunctionObject[] funcObjs = null;
        try{
            FunctionInfo[] funcInfos = ClientSession.getFrameworkService().getModuleListByRoleRight(parentId, userName);
            funcObjs = new FunctionObject[funcInfos.length];
            for(int i = 0;i < funcInfos.length; i++){
                funcObjs[i] = changeFunInfoToObject(funcInfos[i]);
            }
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return funcObjs;
    }
    /**
     * BS框架获取用户有权限的子级模块列表
     * @param parentId 模块ID
     * @param userName 用户名
     * @return
     * @throws VCIException
     */
    public FunctionObject[] getModuleListByRoleRightForBS(String parentId,String userName) throws VCIException {
        FunctionObject[] funcObjs = null;
        try{
            FunctionInfo[] funcInfos = ClientSession.getFrameworkService().getModuleListByRoleRightForBS(parentId, userName);
            funcObjs = new FunctionObject[funcInfos.length];
            for(int i = 0;i < funcInfos.length; i++){
                funcObjs[i] = changeFunInfoToObject(funcInfos[i]);
            }
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return funcObjs;
    }
    
    /**
     * 
     * <p>根据模块名称查询出当前模块对象的信息</p>
     * 
     * @author 李刚
     * @time 2013-2-4
     * @param moduleName
     * @return
     * @throws VCIException
     */
    public FunctionObject getModuleByName(String moduleName)throws VCIException{
        FunctionObject obj = null;
        try {
            FunctionInfo info  = ClientSession.getFrameworkService().getModuleByName(moduleName);
            obj = changeFunInfoToObject(info);
        }catch (VCIError e) {
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        
        return obj;
        
    }
    
    /**
     * 通过模块ID检查该模块子级对象是模块还是操作
     * @param moduleId
     * @return 0表示没有模块也没有操作,1表示有模块,2表示有操作
     * @throws VCIException
     */
    public int checkChildObject(String moduleId) throws VCIException {
        long res = 0;
        try{
            res = ClientSession.getFrameworkService().checkChildObject(moduleId);
        }catch (VCIError e) {
            e.printStackTrace();
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return (int)res;
    }
    /**
     * 
     * <p>根据模块CLASS信息查询出当前模块对象的信息</p>
     * 
     * @author llb
     * @time 2013-2-4
     * @param classPath
     * @return
     * @throws VCIException
     */
    public FunctionObject getModuleByClass(String classPath)throws VCIException{
        FunctionObject obj = null;
        try {
            FunctionInfo info  = ClientSession.getFrameworkService().getModuleByClass(classPath);
            obj = changeFunInfoToObject(info);
        }catch (VCIError e) {
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        
        return obj;
        
    }
    
    /**
     * 
     * <p>根据模块funcOid信息查询出模块对象的信息</p>
     * 
     * @author xchao
     * @time 2014-6-6
     * @param funcOid
     * @return
     * @throws VCIException
     */
    public FunctionObject getFunctionObjectById(String funcOid)throws VCIException{
        FunctionObject obj = null;
        try {
            FunctionInfo info  = ClientSession.getFrameworkService().getFunctionObjectById(funcOid);
            obj = changeFunInfoToObject(info);
        }catch (VCIError e) {
            throw new VCIException(String.valueOf(e.code),e.messages);
        }
        return obj;
    }
    
    /**
     * <p>Description: plfunction表对象和cobra对象的转换</p>
     *
     *@author xf
     *@time 2012-5-16
     *@return FunctionObject
     * @param info
     * @return
     */
    public FunctionObject changeFunInfoToObject(FunctionInfo info) {
        FunctionObject object = new FunctionObject();
        object.setId(info.id);
        //object.setLayer(info.layer);
        object.setName(info.name);
        object.setParentId(info.parentId);
        object.setResourceC(info.resourceC);
        object.setSuffixC(info.suffixC);
        object.setResourceB(info.resourceB);
        object.setSuffixB(info.suffixB);
        object.setDesc(info.desc);
        //object.setModuleNo(info.moduleNo);
        object.setSequence(info.seq);
        object.setImage(info.image);
        object.setIsValid(info.isValid);
        object.setAliasName(info.aliasName);
        object.setResourceDotNet(info.resourceDotNet);
        object.setResourceMobile(info.resourceMobile);
        return object ;
    }
    
    /**
     * <p>Description: plfunction中cobra对象和前端对象的转换</p>
     *
     *@author xf
     *@time 2012-5-15
     *@return FunctionObject
     * @param info
     * @return
     */
    public FunctionInfo changeFunObjectToInfo(FunctionObject object) {
        FunctionInfo info = new FunctionInfo();
        info.id = object.getId() == null ? "" : object.getId();
        //info.layer = object.getLayer();
        info.name = object.getName() == null ? "" : object.getName();
        info.parentId = object.getParentId() == null ? "" : object.getParentId();
        info.resourceC = object.getResourceC() == null ? "" : object.getResourceC();
        info.suffixC = object.getSuffixC() == null ? "" : object.getSuffixC();
        info.resourceB = object.getResourceB() == null ? "" : object.getResourceB();
        info.suffixB = object.getSuffixB() == null ? "" : object.getSuffixB();
        info.desc = object.getDesc() == null ? "" : object.getDesc();
        info.seq = object.getSequence();
        //info.moduleNo = object.getModuleNo();
        info.image = object.getImage() == null ? "" : object.getImage();
        info.isValid = object.getIsValid();
        info.aliasName = object.getAliasName() == null ? "" : object.getAliasName();
        info.resourceDotNet = object.getResourceDotNet() == null ? "" : object.getResourceDotNet();
        info.resourceMobile = object.getResourceMobile() == null ? "" : object.getResourceMobile();
        return info;
    }
 
}