package com.vci.server.base.utility;
|
|
import com.vci.corba.omd.atm.AttribItem;
|
import com.vci.omd.dataType.VTDataType;
|
import com.vci.server.cache.OMCacheProvider;
|
|
public class AttributeHelper {
|
|
|
private AttributeHelper(){
|
|
}
|
|
/**
|
* 获取属性的数据类型
|
* @param abName
|
* @return
|
*/
|
public static String getAbItemDataType(String abName){
|
String dataType = "VTString";
|
|
if (abName == null || abName.equals("")) {
|
return dataType;
|
}
|
if (abName.contains(".")) {
|
abName = abName.substring(abName.lastIndexOf(".") + 1);
|
}
|
|
String abUpperName = abName.toUpperCase();
|
//系统属性
|
if(abUpperName.equals("OID") || abUpperName.equals("REVISIONOID") || abUpperName.equals("NAMEOID") || abUpperName.equals("BTMNAME")
|
|| abUpperName.equals("CREATOR") || abUpperName.equals("LASTMODIFIER") || abUpperName.equals("REVISIONRULE")
|
|| abUpperName.equals("VERSIONRULE") || abUpperName.equals("REVISIONVALUE") || abUpperName.equals("VERSIONVALUE")
|
|| abUpperName.equals("LCTID") || abUpperName.equals("LCSTATUS")
|
|| abUpperName.equals("ID") || abUpperName.equals("NAME") || abUpperName.equals("DESCRIPTION")
|
|| abUpperName.equals("OWNER") || abUpperName.equals("CHECKINBY")
|
|| abUpperName.equals("CHECKOUTBY") || abUpperName.equals("COPYFROMVERSION")
|
|| abUpperName.equals("F_OID") || abUpperName.equals("F_REVISIONOID")
|
|| abUpperName.equals("F_NAMEOID") || abUpperName.equals("F_BTWNAME")
|
|| abUpperName.equals("T_OID") || abUpperName.equals("T_REVISIONOID")
|
|| abUpperName.equals("T_NAMEOID") || abUpperName.equals("T_BTWNAME")){
|
dataType = "VTString";
|
} else if (abUpperName.equals("ISLASTR") || abUpperName.equals("ISFIRSTR")
|
|| abUpperName.equals("ISLASTV") || abUpperName.equals("ISFIRSTV")) {
|
dataType = "VTBoolean";
|
}else if(abUpperName.equals("REVISIONSEQ") || abUpperName.equals("VERSIONSEQ")){
|
dataType = "VTInteger";
|
}else if(abUpperName.equals("CREATETIME") || abUpperName.equals("LASTMODIFYTIME")
|
|| abUpperName.equals("TS") || abUpperName.equals("CHECKINTIME") || abUpperName.equals("CHECKOUTTIME")){
|
dataType = "VTDateTime";
|
//属性池中属性
|
}else{
|
AttribItem attr = OMCacheProvider.getAttribute(abName);
|
if (attr == null)
|
return dataType;
|
|
dataType = attr.vtDataType;
|
// dataType = getService().getAttribItemDataType(abName, null);
|
}
|
return dataType;
|
}
|
|
|
|
/**
|
* 获取other中指定项目的值
|
* @return
|
*/
|
public static String getOtherValueByType(String other, String type){
|
String[] otherArray = other.split(";");
|
for(int i = 0; i < otherArray.length; i++){
|
String otherValue = otherArray[i];
|
if(otherValue.contains(type)){
|
return otherValue.substring(otherValue.indexOf("=") + 2, otherValue.length());
|
}
|
}
|
return null;
|
}
|
|
/**
|
* 检查属性类型与属性值是否匹配
|
* @param vtType
|
* @param value
|
* @return
|
*/
|
public static boolean checkDataType(String vtType, String value){
|
|
if(vtType.equals(VTDataType.VTSTRING)){
|
try{
|
String.valueOf(value);
|
}catch(Exception e){
|
return false;
|
}
|
}else if(vtType.equals(VTDataType.VTINTEGER)){
|
try{
|
Integer.valueOf(value);
|
}catch(Exception e){
|
return false;
|
}
|
}else if(vtType.equals(VTDataType.VTLONG)){
|
try{
|
Long.valueOf(value);
|
}catch(Exception e){
|
return false;
|
}
|
}else if(vtType.equals(VTDataType.VTDOUBLE)){
|
try{
|
Double.valueOf(value);
|
}catch(Exception e){
|
return false;
|
}
|
}
|
|
return true;
|
}
|
|
//
|
/**
|
* 将att转化成xmltext
|
* @param bt
|
* @return
|
*/
|
public static String getXmlText(AttribItem att) {
|
StringBuilder stb = new StringBuilder("<attribute>");
|
stb.append("<name>" + att.name + "</name>");
|
stb.append("<label>" + att.label + "</label>");
|
stb.append("<description>" + att.description + "</description>");
|
stb.append("<vtDataType>" + att.vtDataType + "</vtDataType>");
|
stb.append("<defValue>" + att.defValue + "</defValue>");
|
stb.append("<rage>" + att.rage + "</rage>");
|
stb.append("<other>" + att.other + "</other>");
|
stb.append("</attribute>");
|
return stb.toString();
|
}
|
|
}
|