田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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<BusinessObject> ArrayTOList(BusinessObject[] bos){
        List<BusinessObject> list = new ArrayList<BusinessObject>();
        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;
    }
}