/**
|
*
|
*/
|
package com.vci.client.framework.util;
|
|
import java.awt.Container;
|
|
|
/**
|
* <p>Title: 传递操作</p>
|
* @author wangxl
|
*
|
*/
|
public class PermissionUtil {
|
public enum PermissionType{ Object, Rule }
|
/**
|
* 对象模块的功能
|
* @author wangxl
|
*
|
*/
|
public enum ObjectFunction{
|
/**
|
* 查询
|
*/
|
Query,
|
/**
|
* 创建
|
*/
|
Create,
|
/**
|
* 删除
|
*/
|
Delete,
|
/**
|
* 更新
|
*/
|
Update,
|
/**
|
* 复制
|
*/
|
Copy,
|
/**
|
* 更改所有权
|
*/
|
ChangeOwnership,
|
/**
|
* 导入
|
*/
|
Import,
|
/**
|
* 导出
|
*/
|
Export
|
}
|
|
/**
|
* 规则的功能
|
* @author wangxl
|
*
|
*/
|
public enum RuleFunction{
|
/**
|
* 申请
|
*/
|
Apply,
|
/**
|
* 审核
|
*/
|
Audit,
|
/**
|
* 解析
|
*/
|
Parse,
|
/**
|
* 查询
|
*/
|
Query,
|
/**
|
* 导入
|
*/
|
Import,
|
/**
|
* 导出
|
*/
|
Export,
|
/**
|
* 冻结
|
*/
|
Freeze,
|
/**
|
* 解冻
|
*/
|
UnFreeze,
|
/**
|
* 报废
|
*/
|
Scrap,
|
/**
|
* 回收
|
*/
|
Retrieve,
|
/**
|
* 码值修改
|
*/
|
CodeValModify
|
}
|
|
|
/**
|
* <p>Description: 对象权限</p>
|
* @param moduleId 模块id
|
* @param function 检查的功能
|
* @param button 功能代表的控件对象
|
*/
|
public static boolean checkObjectPermission(String moduleId, ObjectFunction function){
|
// UserEntityObject userEntity = CodeClientApplication.getUserEntityObject();
|
// boolean enable = checkObjectPermission(userEntity, moduleId, function);
|
return true;
|
}
|
// /**
|
// * �������Ȩ��
|
// * @param moduleId �ID
|
// * @param function ������
|
// * @param button ���ܴ��Ŀؼ�����
|
// */
|
public static boolean checkObjectPermission(String moduleId, ObjectFunction function, Container button){
|
// UserEntityObject userEntity = CodeClientApplication.getUserEntityObject();
|
// boolean enable = checkObjectPermission(userEntity, moduleId, function);
|
// button.setEnabled(enable);
|
return true;
|
}
|
//
|
// /**
|
// * ������Ȩ��
|
// * @param userEntity �û�
|
// * @param moduleId �ID
|
// * @param function ģ�鹦��
|
// * @return
|
// */
|
// public static boolean checkObjectPermission(UserEntityObject userEntity, String moduleId, ObjectFunction function){
|
// boolean res = false;
|
// UserEntityInfo info = UserEntityClientDelegate.changeUserEntityToInfo(userEntity);
|
// int functionIndex = getObjectFunctionIndex(function);
|
// String type = "OBJ";
|
// try {
|
// res = Code2ClientSession._code2.checkPermission(info, type, moduleId, functionIndex);
|
// } catch (VCIError e) {
|
// // TODO Auto-generated catch block
|
// e.printStackTrace();
|
// }
|
// return res;
|
// }
|
//
|
/**
|
* ������Ȩ��
|
* @param ruleId ����ID
|
* @param function ����
|
* @return
|
*/
|
public static boolean checkRulePermission(String ruleId, RuleFunction function, Container button){
|
boolean enable = checkRulePermission(ruleId, function);
|
button.setEnabled(enable);
|
return enable;
|
}
|
|
/**
|
* ������Ȩ��
|
* @param ruleId ����ID
|
* @param function ����
|
* @return
|
*/
|
public static boolean checkRulePermission(String ruleId, RuleFunction function){
|
// boolean res = false;
|
// UserEntityObject userEntity = CodeClientApplication.frame.getUserEntityObject();
|
// UserEntityInfo info = UserEntityClientDelegate.changeUserEntityToInfo(userEntity);
|
// int functionIndex = getRuleFunctionIndex(function);
|
// String type = "RULE";
|
// try {
|
// res = Code2ClientSession._code2.checkPermission(info, type, ruleId, functionIndex);
|
// } catch (VCIError e) {
|
// // TODO Auto-generated catch block
|
// e.printStackTrace();
|
// }
|
return true;
|
}
|
|
|
|
private static int getObjectFunctionIndex(ObjectFunction function){
|
int index = 1;
|
if(function == ObjectFunction.Query){ index = 1;}
|
else if(function == ObjectFunction.Create){ index = 2;}
|
else if(function == ObjectFunction.Delete){ index = 3;}
|
else if(function == ObjectFunction.Update){ index = 4;}
|
else if(function == ObjectFunction.Copy){ index = 5;}
|
else if(function == ObjectFunction.ChangeOwnership){ index = 6;}
|
else if(function == ObjectFunction.Import){ index = 7;}
|
else if(function == ObjectFunction.Export){ index = 8;}
|
return index;
|
}
|
|
private static int getRuleFunctionIndex(RuleFunction function){
|
int index = 1;
|
if(function == RuleFunction.Apply){ index = 1;}
|
else if(function == RuleFunction.Audit){ index = 2;}
|
else if(function == RuleFunction.Parse){ index = 3;}
|
else if(function == RuleFunction.Query){ index = 4;}
|
else if(function == RuleFunction.Import){ index = 5;}
|
else if(function == RuleFunction.Export){ index = 6;}
|
else if(function == RuleFunction.Freeze){ index = 7;}
|
else if(function == RuleFunction.UnFreeze){ index = 8;}
|
else if(function == RuleFunction.Scrap){ index = 9;}
|
else if(function == RuleFunction.Retrieve){ index = 10;}
|
else if(function == RuleFunction.CodeValModify){ index = 11;}
|
return index;
|
}
|
}
|