package com.vci.client.portal.NewNewUI.actionExport; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Map.Entry; import com.vci.client.portal.utility.UITools; 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; public class ExportBeans implements Serializable{ private static final long serialVersionUID = 10086L; private HashMap PLActionBeans = new HashMap(); private HashMap PLActionClsExt = new HashMap(); private HashMap PLActionClsBeans = new HashMap(); private HashMap > PLActionParamBeans = new HashMap >(); private HashMap > PLActionListsMap = null; private ExportActionLogBean logBean = null;//日志文件 public ExportBeans() { logBean = new ExportActionLogBean(); } public HashMap getPLActionClsBeans() { return PLActionClsBeans; } public HashMap getPLActions() { return PLActionBeans; } public void addPLActionClsBean(PLActionCls pLActionCls){ PLActionClsBeans.put(pLActionCls.id, pLActionCls); PLActionClsExt.put(pLActionCls.name,pLActionCls.id); } public PLActionCls getPLActionClsBeanById(String id){ return PLActionClsBeans.get(id); } public PLActionCls getPLActionClsBeanByName(String name){ if(PLActionClsExt.get(name) == null){ return null; } return PLActionClsBeans.get(PLActionClsExt.get(name)); } /** * 添加PLActionBean并同时添加PLActionBean对应参数进行记录 * @param pLAction */ public void addPLActionBean(PLAction pLAction){ this.addPLActionBean(pLAction,null); } /** * 添加PLActionBean后 logBean存入值 * */ public ExportActionLogBean getLogBean() { return logBean; } public PLAction getPLActionById(String pLActionId){ return PLActionBeans.get(pLActionId); } public ArrayList getPLActionByPlActionClsId(String plActionClsId){ if( PLActionListsMap == null){ PLActionListsMap = new HashMap>(); for (Entry PLActionEntry : PLActionBeans.entrySet()) { String PLActionListsMapKey = PLActionEntry.getValue().plActionCls ; if(PLActionListsMapKey.equals("")){ PLActionListsMapKey = "when key is null ,change the key to this"; } ArrayList actionList = PLActionListsMap.get(PLActionListsMapKey); if( actionList == null){ actionList = new ArrayList(); actionList.add(PLActionEntry.getValue()); PLActionListsMap.put(PLActionListsMapKey,actionList); }else{ actionList.add(PLActionEntry.getValue()); } } }; if(plActionClsId.equals("")){ plActionClsId = "when key is null ,change the key to this"; } return PLActionListsMap.get(plActionClsId); } public void addPLActionParamBean(PLActionParam pLActionParam){ if(pLActionParam.action!=null && pLActionParam.action!=""){ if(PLActionParamBeans.get(pLActionParam.action) == null){ ArrayList arraylist = new ArrayList(); PLActionParamBeans.put(pLActionParam.action, arraylist); } PLActionParamBeans.get(pLActionParam.action).add(pLActionParam); } } public PLActionParam[] getPLActionParamArrayByActionId(String paramString){ ArrayList pLActionParams = PLActionParamBeans.get(paramString); if(pLActionParams != null && pLActionParams.size() > 0 ){ PLActionParam[] actionParams = new PLActionParam[pLActionParams.size()]; for (int i = 0; i < pLActionParams.size(); i++) { actionParams[i] = pLActionParams.get(i); } return actionParams; } return null; } /** * 添加PLActionBean并同时添加PLActionBean对应参数进行记录 * 能过方便获得category时用此方法. 可以降低系统消耗 * @param pLAction */ public void addPLActionBean(PLAction plAction, String category) { PLActionBeans.put(plAction.plOId, plAction); PLActionCls[] plActionCls = null; try { if(category == null ){ plActionCls = UITools.getService().getPLActionClsArray(); for (PLActionCls plActionCls2 : plActionCls) {//获得分类名称 if(plActionCls2.id.equals(plAction.plActionCls)){ category = plActionCls2.name ; } } } PLActionParam[] params = UITools.getService().getPLActionParamArrayByActionId(plAction.plOId); if(params != null && params.length > 0){//如果参数存在 for (PLActionParam plActionParam : params) {//添加action参数 this.addPLActionParamBean(plActionParam); } } logBean = new ExportActionLogBean(ExportActionLogBean.RIGHT_STATE, plAction.plCode,plAction.plName,plAction.plCSClass,plAction.plBSUrl, plAction.plTypeType,plAction.plDesc,category); } catch (VCIError e) { logBean = new ExportActionLogBean(e.getMessage(), plAction.plCode,plAction.plName,plAction.plCSClass,plAction.plBSUrl, plAction.plTypeType,plAction.plDesc,category); e.printStackTrace(); } } }