package com.vci.client.framework.delegate; import com.vci.client.ClientSession; import com.vci.client.common.objects.UserEntityObject; import com.vci.client.framework.rightConfig.object.OperateObject; import com.vci.client.ui.exception.VCIException; import com.vci.corba.common.VCIError; import com.vci.corba.framework.data.OperateInfo; /** * 操作类型客户端 * * @author liudi * * 2011-6-9 */ public class OperateClientDelegate extends ClientBaseDelegate{ /** * */ private static final long serialVersionUID = 1L; public OperateClientDelegate(UserEntityObject userEntityObject) { super(userEntityObject); } public OperateClientDelegate() { } /** * 保存操作类型 * * @param OperateObject * @return * @throws VCIException */ public String saveOperate(OperateObject operateObj) throws VCIException { String res = ""; try{ res = ClientSession.getFrameworkService().saveOperate(transformPoToIdl(operateObj),userEntityInfo); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code), e.messages); } return res; } /** * 修改操作类型 * * @param OperateObject * @return * @throws VCIException */ public String updateOperate(OperateObject operateObj) throws VCIException { String res = ""; try{ res = ClientSession.getFrameworkService().updateOperate(transformPoToIdl(operateObj),userEntityInfo); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code), e.messages); } return res; } /** * 删除操作类型 * * @param id * @return * @throws VCIException */ public boolean deleteOperate(String id) throws VCIException { boolean res = true; try{ res = ClientSession.getFrameworkService().deleteOperate(id,userEntityInfo); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code), e.messages); } return res; } /** * 获取操作列表 * @param moduleId 为空时获取全部操作列表,否则获取除挂接在当前模块下操作之外的列表 * @return * @throws VCIException */ public OperateObject[] getOperateTreeList(String moduleId) throws VCIException { OperateObject[] operateObjs = null; try{ OperateInfo[] operateInfos = ClientSession.getFrameworkService().getOperateTreeList(moduleId); operateObjs = new OperateObject[operateInfos.length]; for(int i = 0; i < operateInfos.length;i++ ){ operateObjs[i] = transformIdlToPo(operateInfos[i]); } }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code),e.messages); } return operateObjs; } /** * 检查操作是否被引用 * @param operateId * @return 0表示无引用,1表示被模块引用,2表示有权限信息 * @throws VCIException */ public int checkOperateIsReferenced(String operateId) throws VCIException { try{ return (int)ClientSession.getFrameworkService().checkOperateIsReferenced(operateId); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 通过树节点取得信息 * * @param id * @return * @throws VCIError */ public OperateObject getOperatetById(String id) throws VCIException { try{ return transformIdlToPo(ClientSession.getFrameworkService().getOperatetById(id)); }catch(VCIError e) { throw new VCIException(String.valueOf(e.code),e.messages); } } public OperateObject getOperateByIdentify(String identify) throws VCIException { try{ OperateInfo info = ClientSession.getFrameworkService().getOperateByIdentify(identify); return transformIdlToPo(info); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code),e.messages); } } public OperateObject fetchOperateTypeByName(String name) throws VCIException { try{ OperateInfo info = ClientSession.getFrameworkService().fetchOperateTypeByName(name); return transformIdlToPo(info); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code),e.messages); } } /** * po对象和idl转换 * * @param o * @return */ private OperateInfo transformPoToIdl(OperateObject o) { OperateInfo po = new OperateInfo(); po.id = o.getId() == null ? "" : o.getId(); po.name = o.getName() == null ? "" : o.getName(); po.identify = o.getIdentify() == null ? "" : o.getIdentify(); po.alias = o.getAlias() == null ? "" : o.getAlias(); po.desc = o.getDesc() == null ? "" : o.getDesc(); po.seq = o.getSequence(); return po; } /** * idl对象和po转换 * * @param o * @return */ private OperateObject transformIdlToPo(OperateInfo o) { OperateObject po = new OperateObject(); po.setId(o.id); po.setName(o.name); po.setIdentify(o.identify); po.setAlias(o.alias); po.setDesc(o.desc); po.setSequence(o.seq); return po; } /** * * 获得所有操作类型的数量 * add by caill start 2015.12.11 * */ public int getAllOperitionsNum() throws VCIException{ int res = 0; try{ res = (int)ClientSession.getFrameworkService().getAllOperitionsNum(); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code), e.messages); } return res; } // add by caill end /** * * 获得所有的操作类型并导出到.sql文件中 * add by caill start 2015.12.11 * */ public String[][] getAllOperitions(int size) throws VCIException{ String[][] res = new String[size][6]; try{ res = ClientSession.getFrameworkService().getAllOperitions(size); }catch (VCIError e) { e.printStackTrace(); throw new VCIException(String.valueOf(e.code), e.messages); } return res; } // add by caill end }