xiejun
2023-06-14 ffb3d0f1af7e5a93b9a509b0838d9b58a1449bdc
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
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.vci.ubcs.code.util;
 
import com.vci.ubcs.code.bo.AttributeValue;
import com.vci.ubcs.code.vo.pagemodel.BaseModelVO;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.revision.model.BaseModel;
import lombok.Data;
 
import java.util.ArrayList;
 
@Data
public class ClientBusinessObject extends BaseModel {
 
    public AttributeValue[] newAttrValList;
    public AttributeValue[] hisAttrValList;
 
    public void setAttributeValue(String attributeName, String attributeValue) throws VciBaseException {
        this.setAttributeValue(attributeName, attributeValue, false);
    }
 
    public void setAttributeValue(String attributeName, String attributeValue, boolean isCreate) throws VciBaseException {
        int isValid = (new AttributeChecker()).isAttrValValid(attributeName, attributeValue);
        if (isValid == 1) {
            throw getLocalError("P0010SOF-00017", new String[]{attributeName, attributeValue});
        } else if (isValid == 2) {
            throw this.getLocalError("P0010SOF-00018", new String[]{attributeName, attributeValue});
        } else if (isValid == 3) {
            throw this.getLocalError("P0010SOF-00019", new String[]{attributeName, attributeValue});
        } else {
            this.setAttributeValueWithNoCheck(attributeName, attributeValue, isCreate);
        }
    }
 
    public void setAttributeValueWithNoCheck(String attributeName, String attributeValue) throws VciBaseException {
        this.setAttributeValueWithNoCheck(attributeName, attributeValue, false);
    }
 
    public void setAttributeValueWithNoCheck(String attributeName, String attributeValue, boolean isCreate) throws VciBaseException {
        /*if (isCreate) {//&& BusinessConstants.BO_CONSTANTS.containsKey(attributeName.toUpperCase())
            this.setConstantsAttrVal(attributeName, attributeValue);
        } else {*/
            AttributeValue[] attrValues = this.newAttrValList;
            ArrayList<AttributeValue> attrValList = new ArrayList();
            AttributeValue attrVal;
            int i;
            if (attrValues != null && attrValues.length > 0) {
                AttributeValue[] var9 = attrValues;
                i = attrValues.length;
 
                for(int var7 = 0; var7 < i; ++var7) {
                    attrVal = var9[var7];
                    attrValList.add(attrVal);
                }
            }
 
            attrVal = null;
            boolean isExist = false;
 
            for(i = 0; i < attrValList.size(); ++i) {
                attrVal = (AttributeValue)attrValList.get(i);
                if (attrVal.attrName.toUpperCase().equals(attributeName.toUpperCase())) {
                    attrVal.attrVal = attributeValue;
                    isExist = true;
                    break;
                }
            }
 
            if (!isExist) {
                attrVal = new AttributeValue();
                attrVal.attrName = attributeName.toUpperCase();
                attrVal.attrVal = attributeValue;
                attrValList.add(attrVal);
            }
 
            this.newAttrValList = (AttributeValue[])attrValList.toArray(new AttributeValue[attrValList.size()]);
    //    }
    }
 
    public String getAttributeValue(String attrName) {
        String res = "";
        boolean existInNewAttr = false;
        int i;
        if (this.newAttrValList != null) {
            for(i = 0; i < this.newAttrValList.length; ++i) {
                if (this.newAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
                    existInNewAttr = true;
                    res = this.newAttrValList[i].attrVal;
                }
            }
        }
 
        if (existInNewAttr) {
            return res;
        } else if (this.hisAttrValList == null) {
            return "";
        } else {
            for(i = 0; i < this.hisAttrValList.length; ++i) {
                if (this.hisAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
                    res = this.hisAttrValList[i].attrVal;
                }
            }
 
            return res;
        }
    }
 
    public VciBaseException getLocalError(String error_code ,String[] error_messages) {
        return new VciBaseException(error_code, error_messages);
    }
 
}