package com.vci.client.utils;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.vci.client.bof.ClientLinkObject;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.omd.data.AttributeValue;
|
import com.vci.corba.omd.data.LinkObject;
|
|
public class LOTool {
|
/**
|
* 获取指定BO的指定attVal
|
* @param lo
|
* @param attName
|
* @return
|
*/
|
public static String getLOAttVal(LinkObject lo, String attName){
|
AttributeValue[] attrValList = lo.hisAttrValList;
|
for(int i = attrValList.length - 1; i >= 0; i--){
|
AttributeValue attVal = attrValList[i];
|
if(attVal.attrName.equalsIgnoreCase(attName)){
|
return attVal.attrVal;
|
}
|
}
|
return null;
|
}
|
|
public static List<LinkObject> ArrayTOList(LinkObject[] los){
|
List<LinkObject> list = new ArrayList<LinkObject>();
|
for(LinkObject lo : los){
|
list.add(lo);
|
}
|
return list;
|
}
|
|
/**
|
* 克隆一个LO对象,建立一个新的对象,只复制属性
|
* @param source lo对象
|
* @return
|
* @throws Exception
|
*/
|
public static ClientLinkObject cloneClientLinkObject(ClientLinkObject source, boolean isNew){
|
if(source == null){
|
return null;
|
}
|
//获得空的lo对象
|
//ClientLinkObject newlo = loOperation.createLinkObject(loType);
|
ClientLinkObject newlo = new ClientLinkObject();
|
//设置新的LO的信息
|
if(isNew){
|
newlo.setOid(ObjectUtility.getNewObjectID36());
|
} else {
|
newlo.setOid(source.getLinkObject().oid);
|
}
|
newlo.setCreator(source.getCreator());
|
newlo.setCreateTime(source.getCreateTime());
|
newlo.setLastModifier(source.getLastModifier());
|
newlo.setLastModifyTime(source.getLastModifyTime());
|
newlo.setLoName(source.getLoName());
|
newlo.setFromBTMName(source.getLinkObject().fromBTName);
|
newlo.setFromNameOid(source.getLinkObject().fromNameOid);
|
newlo.setFromOid(source.getLinkObject().fromOid);
|
newlo.setFromRevisionOid(source.getLinkObject().fromRevOid);
|
newlo.setToBTMName(source.getLinkObject().toBTName);
|
newlo.setToNameOid(source.getLinkObject().toNameOid);
|
newlo.setToOid(source.getLinkObject().toOid);
|
newlo.setToRevisionOid(source.getLinkObject().toRevOid);
|
newlo.setTs(source.getLinkObject().ts);
|
//设置lo的属性
|
AttributeValue[] attrs = source.getLinkObject().newAttrValList;
|
if(attrs != null){
|
AttributeValue[] newAttrs = new AttributeValue[attrs.length];
|
for(int i = 0; i < attrs.length; i++){
|
AttributeValue av = new AttributeValue();
|
av.attrName = attrs[i].attrName;
|
av.attrVal = "";
|
newAttrs[i] = av;
|
}
|
newlo.getLinkObject().newAttrValList = newAttrs;
|
}
|
return newlo;
|
}
|
}
|