田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
package com.vci.client.bof;
 
import java.util.ArrayList;
import java.util.Locale;
 
import com.vci.common.exception.LocaleCommonDisplay;
import com.vci.common.exception.VciException;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.data.AttributeValue;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.data.LinkObject;
import com.vci.omd.constants.BusinessConstants;
 
 
public class ClientBusinessObject {
 
    private BusinessObject _bo = null;
 
    public BusinessObject getBusinessObject() {
        return _bo;
    }
 
    public void setBusinessObject(BusinessObject bo) {
        this._bo = bo;
    }
 
    public ClientBusinessObject() {
        _bo = new BusinessObject();
        _bo.newAttrValList = new AttributeValue[0];
        _bo.hisAttrValList = new AttributeValue[0];
    }
 
    public String getOid() {
        return _bo.oid;
    }
    public String getRevisionid() {
        return _bo.revisionid;
    }
    public String getNameoid() {
        return _bo.nameoid;
    }
    public String getBtmName() {
        return _bo.btName;
    }
    public boolean getIsLastR() {
        return _bo.isLastR;
    }
    public boolean getIsFirstR() {
        return _bo.isFirstR;
    }
    public boolean getIsLastV() {
        return _bo.isLastV;
    }
    public boolean getIsFirstV() {
        return _bo.isFirstV;
    }
    public String getCreator() {
        return _bo.creator;
    }
    public long getCreateTime() {
        return _bo.createTime;
    }
    public String getLastModifier() {
        return _bo.modifier;
    }
    public long getLastModifyTime() {
        return _bo.modifyTime;
    }
    public String getRevisionRule() {
        return _bo.revisionRule;
    }
    public String getVersionRule() {
        return _bo.versionRule;
    }
    public short getRevisionSeq() {
        return _bo.revisionSeq;
    }
    public String getRevisionValue() {
        return _bo.revisionValue;
    }
    public short getVersionSeq() {
        return _bo.versionSeq;
    }
    public String getVersionValue() {
        return _bo.versionValue;
    }
    public String getLctId() {
        return _bo.lctId;
    }
    public String getLcStatus() {
        return _bo.lcStatus;
    }
    public long getTs() {
        return _bo.ts;
    }
    public void setOid(String oid) {
        this._bo.oid = oid;
    }
    public void setRevisionid(String revisionid) {
        this._bo.revisionid = revisionid;
    }
    public void setNameoid(String nameoid) {
        this._bo.nameoid = nameoid;
    }
    public void setBtmName(String btmName) {
        this._bo.btName = btmName;
    }
    public void setIsLastR(boolean isLastR) {
        this._bo.isLastR = isLastR;
    }
    public void setIsFirstR(boolean isFirstR) {
        this._bo.isFirstR = isFirstR;
    }
    public void setIsLastV(boolean isLastV) {
        this._bo.isLastV = isLastV;
    }
    public void setIsFirstV(boolean isFirstV) {
        this._bo.isFirstV = isFirstV;
    }
    public void setCreator(String creator) {
        this._bo.creator = creator;
    }
    public void setCreateTime(long createTime) {
        this._bo.createTime = createTime;
    }
    public void setLastModifier(String lastModifier) {
        this._bo.modifier = lastModifier;
    }
    public void setLastModifyTime(long lastModifyTime) {
        this._bo.modifyTime = lastModifyTime;
    }
    public void setRevisionRule(String revisionRule) {
        this._bo.revisionRule = revisionRule;
    }
    public void setVersionRule(String versionRule) {
        this._bo.versionRule = versionRule;
    }
    public void setRevisionSeq(short revisionSeq) {
        this._bo.revisionSeq = revisionSeq;
    }
    public void setRevisionValue(String revisionValue) {
        this._bo.revisionValue = revisionValue;
    }
    public void setVersionSeq(short versionSeq) {
        this._bo.versionSeq = versionSeq;
    }
    public void setVersionValue(String versionValue) {
        this._bo.versionValue = versionValue;
    }
    public void setLctId(String lctId) {
        this._bo.lctId = lctId;
    }
    public void setLcStatus(String lcStatus) {
        this._bo.lcStatus = lcStatus;
    }
    public void setTs(long ts) {
        this._bo.ts = ts;
    }
    
    public String getId() {
        return _bo.id;
    }
 
    public String getName() {
        return _bo.name;
    }
 
    public String getDescription() {
        return _bo.description;
    }
 
    public String getOwner() {
        return _bo.owner;
    }
 
//    public String getCheckinBy() {
//        return _bo.checkinBy;
//    }
//
//    public String getCheckinTime() {
//        return _bo.checkinTime;
//    }
//
//    public String getCheckoutBy() {
//        return _bo.checkoutBy;
//    }
//
//    public String getCheckoutTime() {
//        return _bo.checkoutTime;
//    }
 
    public String getCopyFromVersion() {
        return _bo.fromVersion;
    }
 
    public void setId(String id) {
        this._bo.id = id;
    }
 
    public void setName(String name) {
        this._bo.name = name;
    }
 
    public void setDescription(String description) {
        this._bo.description = description;
    }
 
    public void setOwner(String owner) {
        this._bo.owner = owner;
    }
 
//    public void setCheckinBy(String checkinBy) {
//        this._bo.checkinBy = checkinBy;
//    }
//
//    public void setCheckinTime(String checkinTime) {
//        this._bo.checkinTime = checkinTime;
//    }
//
//    public void setCheckoutBy(String checkoutBy) {
//        this._bo.checkoutBy = checkoutBy;
//    }
//
//    public void setCheckoutTime(String checkoutTime) {
//        this._bo.checkoutTime = checkoutTime;
//    }
 
    public void setCopyFromVersion(String copyFromVersion) {
        this._bo.fromVersion = copyFromVersion;
    }
    
    /**
     * 根据属性名称设置属性值,执行此方法中的属性均为自定义属性
     * @param attributeName
     * @param attributeValue
     * @throws VCIError
     */
    public void setAttributeValue(String attributeName, String attributeValue) throws VCIError {
        this.setAttributeValue(attributeName, attributeValue, false);
    }
 
    /**
     * 根据属性名称设定属性值,如果isCreate=true时,则需要判断传入的参数是否为系统默认的属性,
     * 如果是默认属性,需要设定默认值,主要用于创建BO。
     * @param attributeName
     * @param attributeValue
     * @param isCreate
     * @throws VCIError
     */
    public void setAttributeValue(String attributeName, String attributeValue, boolean isCreate) throws VCIError {
        int isValid = new AttributeChecker().isAttrValValid(attributeName, attributeValue);
        if (isValid == 1) {
            throw getLocalError(new VCIError("P0010SOF-00017", new String[]{attributeName,attributeValue}), "PLMBOFactory");
        } else if (isValid == 2) {
            throw getLocalError(new VCIError("P0010SOF-00018", new String[]{attributeName,attributeValue}), "PLMBOFactory");
        } else if (isValid == 3) {
            throw getLocalError(new VCIError("P0010SOF-00019", new String[]{attributeName,attributeValue}), "PLMBOFactory");
        }
        setAttributeValueWithNoCheck(attributeName, attributeValue, isCreate);
    }
    
    /**
     * 设置bo的属性,不对属性是否属于已经定义属性进行判断
     * @param attributeName
     * @param attributeValue
     * @throws VCIError
     */
    public void setAttributeValueWithNoCheck(String attributeName, String attributeValue) throws VCIError {
        setAttributeValueWithNoCheck(attributeName, attributeValue, false);
    }
    
    /**
     * 设置bo的属性,不对属性是否属于已经定义属性进行判断
     * @param attributeName
     * @param attributeValue
     * @param isCreate
     * @throws VCIError
     */
    public void setAttributeValueWithNoCheck(String attributeName, String attributeValue, boolean isCreate) throws VCIError {
        if (isCreate && BusinessConstants.BO_CONSTANTS.containsKey(attributeName.toUpperCase())) {
            setConstantsAttrVal(attributeName, attributeValue);
            return;
        }
        AttributeValue[] attrValues = _bo.newAttrValList;
        ArrayList<AttributeValue> attrValList = new ArrayList<AttributeValue>();
        if (attrValues != null && attrValues.length > 0) {
            for (AttributeValue attrVal: attrValues) {
                attrValList.add(attrVal);
            }
        }
        AttributeValue attrVal = null;
        boolean isExist = false;
        for (int i = 0; i < attrValList.size(); i++) {
            attrVal = 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);
        }
        _bo.newAttrValList = attrValList.toArray(new AttributeValue[attrValList.size()]);
    }
    
    /**
     * 设置系统默认属性的属性值
     * @param attributeName
     * @param attributeValue
     */
    private void setConstantsAttrVal(String attributeName, String attributeValue) {
        if (attributeName.equalsIgnoreCase(BusinessConstants.SELECT_NAME)) {
            this.setName(attributeValue);
        } else if (attributeName.equalsIgnoreCase(BusinessConstants.SELECT_ID)) {
            this.setId(attributeValue);
        } else if (attributeName.equalsIgnoreCase(BusinessConstants.SELECT_DESCRIPTION)) {
            this.setDescription(attributeValue);
        }
    }
    
    public String getAttributeValue(String attrName) {
        String res = "";
        boolean existInNewAttr = false;
        if (_bo.newAttrValList != null) {
            for (int i = 0; i < _bo.newAttrValList.length; i++) {
                if (_bo.newAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
                    existInNewAttr = true;
                    res = _bo.newAttrValList[i].attrVal;
                }
            }
        }
        if(existInNewAttr){
            return res;
        }
        if (_bo.hisAttrValList == null) {
            return "";
        }
        for (int i = 0; i < _bo.hisAttrValList.length; i++) {
            if (_bo.hisAttrValList[i].attrName.toUpperCase().equals(attrName.toUpperCase())) {
                res = _bo.hisAttrValList[i].attrVal;
            }
        }
        return res;
    }
    
    public void dealBusinessObjectNullValue() {
        _bo.newAttrValList = _bo.newAttrValList == null ? new AttributeValue[0] : _bo.newAttrValList;
        _bo.hisAttrValList = _bo.hisAttrValList == null ? new AttributeValue[0] : _bo.hisAttrValList;
    }
    
    public void dealLinkObjectNullValue(LinkObject lo) {
        lo.newAttrValList = lo.newAttrValList == null ? new AttributeValue[0] : lo.newAttrValList;
        lo.hisAttrValList = lo.hisAttrValList == null ? new AttributeValue[0] : lo.hisAttrValList;
    }
    
    public void dealArrayNullValue(String[] array) {
        if (array == null) {
            array = new String[0];
        }
        for (int i = 0; i < array.length; i++) {
            if (array[i] == null) {
                array[i] = "";
            }
        }
    }
    
    public VCIError getLocalError(VCIError vciError, String fileName) {
        String str = LocaleCommonDisplay.getI18nString(new VciException(vciError.code, vciError.messages), fileName, Locale.getDefault());
        return new VCIError(str, vciError.messages);
    }
}