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;
|
}
|
}
|