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
package com.vci.client.auth2.utils;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.vci.client.portal.utility.UITools;
import com.vci.corba.common.VCIError;
import com.vci.corba.portal.data.PLAction;
 
public class ActionConstants implements IRightConstant{
 
 
    private static ActionConstants instance = null;
 
     ActionConstants() {
        
    }
    public static synchronized ActionConstants getInstance() {
        if (instance == null) {
            instance = new ActionConstants();
        }
        
        return instance;
    }
    
    /**
     * 获取所有业务对象的操作
     * @return
     */
    public String[] getAllBusinessActionNames() {
        return getActionsByType("business");
    }
    
    public String[] getAllBuinessActionNamesByType(String typeName, String type){
        return getAllActionsByType(typeName, type);
    }
    //add by caill start 2015.12.18
    public Map<String,String> getAllBuinessActionNamesByType2(String typeName, String type){
        return getAllActionsByType2(typeName, type);
    }
    //add by caill end
    /**
     * 获取所有链接对象的操作
     * @return
     */
    public String[] getAllLinkActionNames() {
        return getActionsByType("link");
    }
    //add by caill start 2015 12.18 将查询出来的action放入到map中
    private Map<String, String> getAllActionsByType2(String typeName, String type) {
        Map<String,String> boActions2 = new HashMap<String,String>();
        boActions2.put("查询", "query");
        PLAction[] allActions = this.getAllPLActionEntityByType(typeName);
        if (allActions == null || allActions.length == 0) {
            return boActions2;
        }
        for (int i = 0; i < allActions.length; i++) {
            if(allActions[i].plTypeType.equals(type)){    
                boActions2.put(allActions[i].plName,allActions[i].plCode);    //将中文显示作为key,英文显示作为value放到map中
            }
        }
        return boActions2;
    }
    //add by caill end
    private String[] getAllActionsByType(String typeName, String type) {
        List<String> boActions = new ArrayList<String>();
        //boActions.add("查询");
        boActions.add("query");
        PLAction[] allActions = this.getAllPLActionEntityByType(typeName);
        if (allActions == null || allActions.length == 0) {
            return boActions.toArray(new String[0]);
        }
        for (int i = 0; i < allActions.length; i++) {
            if(allActions[i].plTypeType.equals(type)){
                boActions.add(allActions[i].plCode);
            }
        }
        return boActions.toArray(new String[0]);
    }
    
    private String[] getActionsByType(String type) {
        List<String> boActions = new ArrayList<String>();
        boActions.add("query");
        PLAction[] allActions = this.getAllActions();
        if (allActions == null || allActions.length == 0) {
            return boActions.toArray(new String[0]);
        }
        for (int i = 0; i < allActions.length; i++) {
            if(allActions[i].plTypeType.equals(type)){
                boActions.add(allActions[i].plCode);
            }
        }
        return boActions.toArray(new String[0]);
    }
    
    public PLAction[] getAllPLActionEntityByType(String type){
        PLAction[] actions = null;
        try {
            actions = UITools.getService().getAllPLActionEntityByType(type);
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return actions;
    }
    
    public PLAction[] getAllActions() {
        PLAction[] actions = null;
        try {
            actions = UITools.getService().getAllPLAction();
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return actions;
    }
}