package com.vci.client.utils.excel; import java.util.ArrayList; import java.util.List; import com.vci.client.bof.ClientBusinessObject; import com.vci.common.utility.ObjectUtility; import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.data.BusinessObject; public class BOTool { /** * 获取指定BO的指定attVal * @param bo * @param attName * @return */ public static String getBOAttVal(BusinessObject bo, String attName){ AttributeValue[] attrValList = bo.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 ArrayTOList(BusinessObject[] bos){ List list = new ArrayList(); for(BusinessObject bo : bos){ list.add(bo); } return list; } /** * 克隆一个新的CBO对象,不调用 * @param source 源对象 * @param isNew 是否生成新的对象, * 如果为true则为克隆的对象生成新的oid、Revisionid、Nameoid * @return */ public static ClientBusinessObject cloneClientBusinessObject(ClientBusinessObject source, boolean isNew){ if(source == null){ return null; } ClientBusinessObject bo = new ClientBusinessObject(); if(isNew){ bo.setOid(ObjectUtility.getNewObjectID36()); bo.setRevisionid(ObjectUtility.getNewObjectID36()); bo.setNameoid(ObjectUtility.getNewObjectID36()); } else { bo.setOid(source.getOid()); bo.setRevisionid(source.getRevisionid()); bo.setNameoid(source.getNameoid()); } bo.setBtmName(source.getBtmName()); bo.setIsLastR(source.getIsLastR()); bo.setIsFirstR(source.getIsFirstR()); bo.setIsFirstV(source.getIsFirstV()); bo.setIsLastV(source.getIsLastV()); bo.setCreator(source.getCreator()); bo.setCreateTime(source.getCreateTime()); bo.setLastModifier(source.getLastModifier()); bo.setLastModifyTime(source.getLastModifyTime()); bo.setRevisionRule(source.getRevisionRule()); bo.setVersionRule(source.getVersionRule()); bo.setRevisionSeq(source.getRevisionSeq()); bo.setRevisionValue(source.getRevisionValue()); bo.setVersionSeq(source.getVersionSeq()); bo.setVersionValue(source.getVersionValue()); bo.setLctId(source.getLctId()); bo.setLcStatus(source.getLcStatus()); bo.setId(source.getId()); bo.setName(source.getName()); bo.setDescription(source.getDescription()); bo.setOwner(source.getOwner()); //bo.setCheckinBy(source.getCheckinBy()); bo.setCopyFromVersion(source.getCopyFromVersion()); //设置BO自定义属性 AttributeValue[] attrs = null; if(source.getBusinessObject().newAttrValList != null){ int size = source.getBusinessObject().newAttrValList.length; attrs = new AttributeValue[size]; AttributeValue[] sourceAttrs = source.getBusinessObject().newAttrValList; for(int i = 0; i < sourceAttrs.length; i++){ AttributeValue av = new AttributeValue(); av.attrName = sourceAttrs[i].attrName; av.attrVal = ""; attrs[i] = av; } } bo.getBusinessObject().newAttrValList = attrs; return bo; } }