dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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;
    }
}