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 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 getAllActionsByType2(String typeName, String type) { Map boActions2 = new HashMap(); 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 boActions = new ArrayList(); //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 boActions = new ArrayList(); 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; } }