ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.server.portal.tools;
 
import java.util.ArrayList;
import java.util.List;
 
import com.vci.server.base.exception.ExceptionLocalHandler;
import com.vci.server.cache.PLCacheRecordService;
import com.vci.server.portal.cache.ActionClsCacheUtil;
import com.vci.server.portal.cache.ActionParamCacheUtil;
import com.vci.server.portal.cache.ComponentBtnCacheUtil;
import com.vci.server.portal.cache.ButtonParamCacheUtil;
import com.vci.server.portal.cache.UIContextCacheUtil;
import com.vci.server.portal.cache.ActionCacheUtil;
import com.vci.server.portal.cache.ComponentCacheUtil;
import com.vci.server.portal.cache.PortalVICacheUtil;
import com.vci.server.portal.cache.TabPageCacheUtil;
import com.vci.server.portal.cache.UICacheNames;
import com.vci.common.exception.VciExceptionTool;
import com.vci.corba.common.VCIError;
import com.vci.corba.portal.data.PLAction;
import com.vci.corba.portal.data.PLActionCls;
import com.vci.corba.portal.data.PLActionParam;
import com.vci.corba.portal.data.PLCommandParameter;
import com.vci.corba.portal.data.PLPageDefination;
import com.vci.corba.portal.data.PLUILayout;
import com.vci.corba.portal.data.PLTabButton;
import com.vci.corba.portal.data.PLTabPage;
import com.vci.corba.portal.data.PortalVI;
 
public class UICacheDataFetcher {
    
    private static volatile UICacheDataFetcher instance = null;
    
    
    private UICacheDataFetcher() {
        try {
            initUICache();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    
    public static UICacheDataFetcher getInstance() {
        if (instance == null) {
            synchronized (UICacheDataFetcher.class) {
                if (instance == null) {
                    instance = new UICacheDataFetcher();
                }
            }
        }
        
        return instance;
    }
    
    public void reInitUICache() throws VCIError {
        try {
            initUICache();
        } catch (Throwable e) {
            e.printStackTrace();
            throw getLocalVciError("P0010UIService-00046", e);
        }
    }
    
    public void resetObjType(String objType) {
        PLCacheRecordService.getInstance().resetObjType(objType);
    }
    
    public void initUICache() throws Throwable{
        ActionClsCacheUtil.initCache();
        ActionCacheUtil.initCache();
        ActionParamCacheUtil.initCache();
        
        UIContextCacheUtil.initCache();
        TabPageCacheUtil.initCache();
        ComponentCacheUtil.initCache();
        ComponentBtnCacheUtil.initCache();
        ButtonParamCacheUtil.initCache();
        PortalVICacheUtil.initCache();
    }
    
    public void updateCacheObj(Object obj) {
        
        if (obj instanceof  PLActionCls) {
            ActionClsCacheUtil.getInstance().setObject((PLActionCls)obj);
        } else if (obj instanceof  PLAction) {
            ActionCacheUtil.getInstance().setObject((PLAction)obj);
        } else if (obj instanceof  PLActionParam) {
            ActionParamCacheUtil.getInstance().setObject((PLActionParam)obj);
        } else if (obj instanceof  PLUILayout) {
            UIContextCacheUtil.getInstance().setObject((PLUILayout)obj);
        } else if (obj instanceof  PLTabPage) {
            TabPageCacheUtil.getInstance().setObject((PLTabPage)obj);
        } else if (obj instanceof  PLPageDefination) {
            ComponentCacheUtil.getInstance().setObject((PLPageDefination)obj);
        } else if (obj instanceof  PLTabButton) {
            ComponentBtnCacheUtil.getInstance().setObject((PLTabButton)obj);
        } else if (obj instanceof  PLCommandParameter) {
            ButtonParamCacheUtil.getInstance().setObject((PLCommandParameter)obj);
        } else if (obj instanceof  PortalVI) {
            PortalVICacheUtil.getInstance().setObject((PortalVI)obj);
        } 
    }
    
    
    public void delCacheObj(Object obj) {
        
        if (obj instanceof  PLActionCls) {
            ActionClsCacheUtil.getInstance().delObject((PLActionCls)obj);
        } else if (obj instanceof  PLAction) {
            ActionCacheUtil.getInstance().delObject((PLAction)obj);
        } else if (obj instanceof  PLActionParam) {
            ActionParamCacheUtil.getInstance().delObject((PLActionParam)obj);
        } else if (obj instanceof  PLUILayout) {
            UIContextCacheUtil.getInstance().delObject((PLUILayout)obj);
        } else if (obj instanceof  PLTabPage) {
            TabPageCacheUtil.getInstance().delObject((PLTabPage)obj);
        } else if (obj instanceof  PLPageDefination) {
            ComponentCacheUtil.getInstance().delObject((PLPageDefination)obj);
        } else if (obj instanceof  PLTabButton) {
            ComponentBtnCacheUtil.getInstance().delObject((PLTabButton)obj);
        } else if (obj instanceof  PLCommandParameter) {
            ButtonParamCacheUtil.getInstance().delObject((PLCommandParameter)obj);
        } else if (obj instanceof  PortalVI) {
            PortalVICacheUtil.getInstance().delObject((PortalVI)obj);
        } 
    }
 
    
    public void updateCacheObj(String type, Object obj) {
        switch (type) {
        case UICacheNames.ACTIONCLS:
            ActionClsCacheUtil.getInstance().setObject((PLActionCls)obj);
            break;
        case UICacheNames.ACTION:
            ActionCacheUtil.getInstance().setObject((PLAction)obj);
            break;
        case UICacheNames.ACTIONPARAM:
            ActionParamCacheUtil.getInstance().setObject((PLActionParam)obj);
            break;
        case UICacheNames.UICONTEXT:
            UIContextCacheUtil.getInstance().setObject((PLUILayout)obj);
            break;
        case UICacheNames.TABPAGE:
            TabPageCacheUtil.getInstance().setObject((PLTabPage)obj);
            break;
        case UICacheNames.PAGECOMPONENT:
            ComponentCacheUtil.getInstance().setObject((PLPageDefination)obj);
            break;
        case UICacheNames.BUTTON:
            ComponentBtnCacheUtil.getInstance().setObject((PLTabButton)obj);
            break;
        case UICacheNames.BUTTONPARAM:
            ButtonParamCacheUtil.getInstance().setObject((PLCommandParameter)obj);
            break;
        case UICacheNames.PORTALVI:
            PortalVICacheUtil.getInstance().setObject((PortalVI)obj);
            break;
        }
    }
    
    public void delCacheObj(String type, Object obj) {
        switch (type) {
        case UICacheNames.ACTIONCLS:
            ActionClsCacheUtil.getInstance().delObject((PLActionCls)obj);
            break;
        case UICacheNames.ACTION:
            ActionCacheUtil.getInstance().delObject((PLAction)obj);
            break;
        case UICacheNames.ACTIONPARAM:
            ActionParamCacheUtil.getInstance().delObject((PLActionParam)obj);
            break;
        case UICacheNames.UICONTEXT:
            UIContextCacheUtil.getInstance().delObject((PLUILayout)obj);
            break;
        case UICacheNames.TABPAGE:
            TabPageCacheUtil.getInstance().delObject((PLTabPage)obj);
            break;
        case UICacheNames.PAGECOMPONENT:
            ComponentCacheUtil.getInstance().delObject((PLPageDefination)obj);
            break;
        case UICacheNames.BUTTON:
            ComponentBtnCacheUtil.getInstance().delObject((PLTabButton)obj);
            break;
        case UICacheNames.BUTTONPARAM:
            ButtonParamCacheUtil.getInstance().delObject((PLCommandParameter)obj);
            break;
        case UICacheNames.PORTALVI:
            PortalVICacheUtil.getInstance().delObject((PortalVI)obj);
            break;
        }
    }
    
    public PLUILayout[] getPageLayouts() throws VCIError {
        return UIContextCacheUtil.getInstance().getAlls();
    }
 
    public PLTabPage[] getTabPages() throws VCIError {
        return TabPageCacheUtil.getInstance().getAlls();
    }
 
    public PLPageDefination[] getPageDefinations() throws VCIError {
        return ComponentCacheUtil.getInstance().getAlls();
    }
 
    public PLPageDefination[] getPageDefinationNoConfs() throws VCIError {
        PLPageDefination[] pds = this.getPageDefinations();
        if (pds == null) {
            return new PLPageDefination[0];
        }
        
        PLPageDefination[] cpds = new PLPageDefination[pds.length];
        for (int i = 0; i < cpds.length; i++) {
            PLPageDefination cpd = new PLPageDefination();
            cpd.plOId = pds[i].plOId;
            cpd.desc = pds[i].desc;
            cpd.name = pds[i].name;
            cpd.plDefination = "";
            cpd.plTabPageOId = pds[i].plTabPageOId;
            cpd.plType = pds[i].plType;
            cpd.seq = pds[i].seq;
            cpds[i] = cpd;
        }
        return cpds;
    }
 
    public PLTabButton[] getButtons() throws VCIError {
        return ComponentBtnCacheUtil.getInstance().getAlls();
    }
 
    public PLActionCls[] getActionCls() throws VCIError {
        return ActionClsCacheUtil.getInstance().getAlls();
    }
 
    public PLAction[] getActions() throws VCIError {
        return ActionCacheUtil.getInstance().getAlls();
    }
 
    public PLActionParam[] getActionParams() throws VCIError {
        return ActionParamCacheUtil.getInstance().getAlls();
    }
 
    public PLCommandParameter[] getCommandParams() throws VCIError {
        return ButtonParamCacheUtil.getInstance().getAlls();
    }
 
    public PortalVI[] getPortalVis() throws VCIError {
        return PortalVICacheUtil.getInstance().getAlls();
    }
    
    /**
     * 获取业务类型下的上下文信息
     * @param btmType
     * @return
     * @throws VCIError 
     */
    public PLUILayout[] getContext(String btmType) throws VCIError {
        return UIContextCacheUtil.getInstance().getContext(btmType);
    }
    
    /**
     * 获取上下文件下的tab页签信息
     * @param contextId
     * @return
     * @throws VCIError 
     */
    public List<PLTabPage> getTabs(String contextId) throws VCIError {
        return TabPageCacheUtil.getInstance().getTabs(contextId);
    }
    
    /**
     * 获取tab页签下的组件信息
     * @param tabId
     * @return
     * @throws VCIError 
     */
    public List<PLPageDefination> getComopnent(String tabId) throws VCIError {
        return ComponentCacheUtil.getInstance().getComopnent(tabId);
    }
    
    /**
     * 获取组件下的按钮信息
     * @param componentId
     * @return
     * @throws VCIError 
     */
    public PLTabButton[] getButtons(String componentId) throws VCIError {
        return ComponentBtnCacheUtil.getInstance().getButtons(componentId);
    }
    
    public PLCommandParameter[] getCommandParameters(String buttonId) throws VCIError {
        return ButtonParamCacheUtil.getInstance().getCommandParameters(buttonId);
    }
    
    public PortalVI[] getPortalVIArrayByTypeName(String typeName) throws VCIError {
        return PortalVICacheUtil.getInstance().getPortalVIArrayByTypeName(typeName);
    }
    
//    public PortalVI[] getPagePortalVIArrayByTypeName(String typeName, long startPage, long endPage) throws VCIError {
//        return PortalVICacheUtil.getInstance().getPagePortalVIArrayByTypeName(typeName, startPage, endPage);
//    }
//    
//    public PortalVI[] getPagePortalVIArrayByCondition(String typeName,
//            short sheetType, String sheetName, long startPage, long endPage)
//            throws Throwable {
//        return PortalVICacheUtil.getInstance()
//                .getPagePortalVIArrayByCondition(typeName, sheetType, sheetName, startPage, endPage);
//    }
    
    public int getPortalVICountByTypeName(String typeName) throws VCIError {
        return PortalVICacheUtil.getInstance().getPortalVICountByTypeName(typeName);
    }
    
//    public int getPortalVICountByCondition(String typeName, int sheetType,
//            String sheetName) throws VCIError {
//        return PortalVICacheUtil.getInstance().getPortalVICountByCondition(typeName, sheetType, sheetName);
//    }
//    
    
    
    public PortalVI getPortalVIById(String id) throws VCIError {
        return PortalVICacheUtil.getInstance().getObject(id);
    }
    
//    public PortalVI getPortalVIBySymbol(String symbol) throws VCIError {
//        return PortalVICacheUtil.getInstance().getPortalVIBySymbol(symbol);
//    }
    
    public PLAction getPLActionById(String plOId) throws VCIError {
        return ActionCacheUtil.getInstance().getObject(plOId);
    }
    
    public PLCommandParameter getPLCommandParameterById(String plOId) throws VCIError {
        return ButtonParamCacheUtil.getInstance().getObject(plOId);
    }
    
    public PLUILayout getPLUILayoutById(String plOId) throws VCIError {
        return UIContextCacheUtil.getInstance().getObject(plOId);
    }
    
    public PLUILayout[] getPLUILayoutEntity(
            String contentStr) throws Throwable {
        PLUILayout[] contexts = this.getPageLayouts();
        if (contexts == null) {
            return new PLUILayout[0];
        }
        
        List<PLUILayout> contextList = new ArrayList<PLUILayout>();
        for (PLUILayout context : contexts) {
            if (context.plName.indexOf(contentStr) >=0 || context.plCode.indexOf(contentStr) >= 0) {
                contextList.add(context);
            }
        }
        
        return contextList.toArray(new PLUILayout[0]);
    }
    
    public PLTabPage getPLTabPageById(String plOId) throws VCIError {
        return TabPageCacheUtil.getInstance().getObject(plOId);
    }
    
    public PLTabButton getPLTabButtonById(String plOId) throws VCIError {
        return ComponentBtnCacheUtil.getInstance().getObject(plOId);
    }
    
    public PLPageDefination getPLPageDefinationById(String plOId) throws VCIError {
        return ComponentCacheUtil.getInstance().getObject(plOId);
    }
    
    public PLActionParam[] getPLActionParamArrayByActionId(String actionId) throws VCIError {
        return ActionParamCacheUtil.getInstance().getPLActionParamById(actionId);
    }
    
    private VCIError getLocalVciError(String key, Throwable e) {
        VCIError error = new VCIError(key, new String[]{VciExceptionTool.getExceptionStr(e), VciExceptionTool.getExceptionDetail(e)});
        VCIError rsError = ExceptionLocalHandler.getInstance().getLocalString(error, "PLMUIService");
        return rsError;
    }
}