ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.server.bof.objects;
 
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
 
import com.vci.corba.omd.data.AttributeValue;
import com.vci.corba.omd.data.LinkObject;
import com.vci.omd.constants.LinkConstants;
import com.vci.server.bof.utils.ServerObjectUtil;
 
public class ServerLinkObject {
 
    private String oid;
    private String creator;
    private long createTime;
    private String lastModifier;
    private long lastModifyTime;
    private String f_Oid;
    private String f_RevisionOid;
    private String f_NameOid;
    private String f_BtwName;
    private String t_Oid;
    private String t_RevisionOid;
    private String t_NameOid;
    private String t_BtwName;
    private long ts;
    
    private LinkObject linkObject;
    
    public ServerLinkObject() {
        linkObject = new LinkObject();
    }
 
    public String getOid() {
        return oid;
    }
 
    public String getCreator() {
        return creator;
    }
 
    public long getCreateTime() {
        return createTime;
    }
 
    public String getLastModifier() {
        return lastModifier;
    }
 
    public long getLastModifyTime() {
        return lastModifyTime;
    }
 
    public String getF_Oid() {
        return f_Oid;
    }
 
    public String getF_RevisionOid() {
        return f_RevisionOid;
    }
 
    public String getF_NameOid() {
        return f_NameOid;
    }
 
    public String getF_BtwName() {
        return f_BtwName;
    }
 
    public String getT_Oid() {
        return t_Oid;
    }
 
    public String getT_RevisionOid() {
        return t_RevisionOid;
    }
 
    public String getT_NameOid() {
        return t_NameOid;
    }
 
    public String getT_BtwName() {
        return t_BtwName;
    }
 
    public long getTs() {
        return ts;
    }
 
    public LinkObject getLinkObject() {
        dealLinkObjectNullValue();
        return linkObject;
    }
 
    public void setOid(String oid) {
        this.oid = oid;
        this.linkObject.oid = oid;
    }
 
    public void setCreator(String creator) {
        this.creator = creator;
        this.linkObject.creator = creator;
    }
 
    public void setCreateTime(long createTime) {
        this.createTime = createTime;
        this.linkObject.createTime = createTime;
    }
 
    public void setLastModifier(String lastModifier) {
        this.lastModifier = lastModifier;
        this.linkObject.modifier = lastModifier;
    }
 
    public void setLastModifyTime(long lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
        this.linkObject.modifyTime = lastModifyTime;
    }
 
    public void setF_Oid(String f_Oid) {
        this.f_Oid = f_Oid;
        this.linkObject.fromOid = f_Oid;
    }
 
    public void setF_RevisionOid(String f_RevisionOid) {
        this.f_RevisionOid = f_RevisionOid;
        this.linkObject.fromRevOid = f_RevisionOid;
    }
 
    public void setF_NameOid(String f_NameOid) {
        this.f_NameOid = f_NameOid;
        this.linkObject.fromNameOid = f_NameOid;
    }
 
    public void setF_BtwName(String f_BtwName) {
        this.f_BtwName = f_BtwName;
        this.linkObject.fromBTName = f_BtwName;
    }
 
    public void setT_Oid(String t_Oid) {
        this.t_Oid = t_Oid;
        this.linkObject.toOid = t_Oid;
    }
 
    public void setT_RevisionOid(String t_RevisionOid) {
        this.t_RevisionOid = t_RevisionOid;
        this.linkObject.toRevOid = t_RevisionOid;
    }
 
    public void setT_NameOid(String t_NameOid) {
        this.t_NameOid = t_NameOid;
        this.linkObject.toNameOid = t_NameOid;
    }
 
    public void setT_BtwName(String t_BtwName) {
        this.t_BtwName = t_BtwName;
        this.linkObject.toBTName = t_BtwName;
    }
 
    public void setTs(long ts) {
        this.ts = ts;
        this.linkObject.ts = ts;
    }
 
    public void setLinkObject(LinkObject linkObject) {
        this.linkObject = linkObject;
    }
    
    private void dealLinkObjectNullValue() {
        this.linkObject.newAttrValList = this.linkObject.newAttrValList == null ? new AttributeValue[0] : this.linkObject.newAttrValList;
        this.linkObject.hisAttrValList = this.linkObject.hisAttrValList == null ? new AttributeValue[0] : this.linkObject.hisAttrValList;
    }
    
    public void setAttributeValue(String attributeName, String attrType, Object attributeValue) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        if (LinkConstants.LO_CONSTANTS.containsKey(attributeName)) {
            dealWithSystemAttributeValue(attributeName, attributeValue);
            attrType = LinkConstants.LO_CONSTANTS.get(attributeName);
        } 
        dealWithLOAttributeValue(attributeName, attrType, attributeValue);
    }
    
    private void dealWithSystemAttributeValue(String attributeName, Object attributeValue) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
        String changeValue = ServerObjectUtil.getInstance().tansferSystemDBDateToString(LinkConstants.LO_CONSTANTS, attributeName, attributeValue);
        
        Field[] fields=ServerLinkObject.class.getDeclaredFields();
        for (Field field : fields) {
            String fieldName = field.getName();
            if (!fieldName.toUpperCase().equals(attributeName.toUpperCase())) {
                continue;
            }
            //将属性名首字母转换成大写字母
            String firstLetter = fieldName.substring(0, 1).toUpperCase();
            String setMethodName = "set" + firstLetter + fieldName.substring(1);
            Method setMethod = ServerLinkObject.class.getMethod(setMethodName, new Class[]{changeValue.getClass()});
            setMethod.invoke(this, new Object[]{changeValue});
            break;
        }
    }
    
    private void dealWithLOAttributeValue(String attributeName, String attrType, Object attributeValue) {
        String changeValue = ServerObjectUtil.getInstance().tansferTypeDBDateToString(attrType, attributeValue);
        AttributeValue[] attrValues = linkObject.hisAttrValList;
        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 = changeValue;
                isExist = true;
                break;
            }
        }
        if (!isExist) {
            attrVal = new AttributeValue();
            attrVal.attrName = attributeName.toUpperCase();
            attrVal.attrVal = changeValue;
            attrValList.add(attrVal);
        }
        linkObject.hisAttrValList = attrValList.toArray(new AttributeValue[attrValList.size()]);
    }
    
    public String[] getQueryColumnAccordingToSQL(String sql, String start, String end) {
        sql = sql.toUpperCase();
        sql = sql.substring(start.length());
        sql = sql.substring(0, sql.indexOf(end));
        sql = sql.replaceAll(" ", "");
        return sql.split(",");
    }
}