package com.vci.server.bof.delegate; import com.vci.server.base.persistence.dao.HibernateSessionFactory; import com.vci.common.utility.ObjectUtility; import com.vci.corba.common.VCIError; import com.vci.corba.omd.data.AttributeValue; import com.vci.corba.omd.data.LinkObject; public class LOFacotryBaseDelegate extends FactoryBaseDelegate{ /** * 克隆一全新的LinkObject * @param loSrc 原始 LinkObject * @return 全新的 LinkObject *
如果 loSrc == null 或 loSrc != null 且 loSrc.linkTypeName 为空,返回一个 null,否则返回克隆的对象
* @throws VCIError */ public LinkObject cloneLinkObject(LinkObject loSrc) throws VCIError{ if(loSrc == null ) return null; if("".equals(loSrc.ltName)) return null; LinkObject lo = getNewEmptyLinkObject(loSrc.ltName); lo = initLinkTypeBaseAttr(lo, loSrc.creator, loSrc.createTime, loSrc.modifier, loSrc.modifyTime, loSrc.fromOid, loSrc.fromRevOid, loSrc.fromNameOid, loSrc.fromBTName, loSrc.toOid, loSrc.toRevOid, loSrc.toNameOid, loSrc.toBTName); lo.newAttrValList = cloneAttrVals(loSrc.newAttrValList); lo.hisAttrValList = cloneAttrVals(loSrc.hisAttrValList); return lo; } protected AttributeValue[] cloneAttrVals(AttributeValue[] srcAttrVals){ AttributeValue[] destAttrVals = new AttributeValue[0]; if(srcAttrVals == null || srcAttrVals.length == 0) return destAttrVals; destAttrVals = new AttributeValue[srcAttrVals.length]; for (int i = 0; i < destAttrVals.length; i++) { destAttrVals[i] = new AttributeValue(srcAttrVals[i].attrName, srcAttrVals[i].attrVal); } return destAttrVals; } protected LinkObject getNewEmptyLinkObject(String linkTypeName){ LinkObject lo = new LinkObject(); lo.oid = ObjectUtility.getNewObjectID36(); lo.ltName = linkTypeName; lo = initLinkTypeBaseAttr(lo, HibernateSessionFactory.getVciSessionInfo().userName, System.currentTimeMillis(), HibernateSessionFactory.getVciSessionInfo().userName, System.currentTimeMillis(), "", "", "", "", "", "", "", ""); return lo; } protected LinkObject initLinkTypeBaseAttr( LinkObject lo, String creator, long createTime, String lastModifier, long lastModifyTime, String fromOid, String fromRevisionOid, String fromNameOid, String fromBtmName, String toOid, String toRevisionOid, String toNameOid, String toBtmName){ lo.creator = creator; lo.createTime = createTime; lo.modifier = lastModifier; lo.modifyTime = lastModifyTime; lo.fromOid = fromOid; lo.fromRevOid = fromRevisionOid; lo.fromNameOid = fromNameOid; lo.fromBTName = fromBtmName; lo.toOid = toOid; lo.toRevOid = toRevisionOid; lo.toNameOid = toNameOid; lo.toBTName = toBtmName; lo.newAttrValList = new AttributeValue[0]; lo.hisAttrValList = new AttributeValue[0]; return lo; } }