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
package com.vci.client.omd.btm.ui;
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import javax.swing.JOptionPane;
 
import com.vci.corba.common.VCIError;
import com.vci.mw.InvocationUtility;
 
@Deprecated     
public class Xml2DBActionListener implements ActionListener{
    public static final String SP = "sp";
    public static final String BT = "bt";
    public static final String LT = "lt";
    public static final String LC = "lc";
    public static final String VR = "vr";
    public static final String ATT = "att";
    public static final String ENUM = "enum";
    
    public static final String LTSQL = "create table pllinktype (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),description varchar2(256), ts timestamp(6),creator varchar2(64), createtime timestamp(6),modifier varchar2(64),modifytime timestamp(6),content xmltype,CONSTRAINT PK_linktype PRIMARY KEY (oid),CONSTRAINT IDX_linktype_NAME unique (NAME))";
    public static final String BTSQL = "create table plbtmtype (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),description varchar2(256),ts timestamp(6),creator varchar2(64),createtime timestamp(6),modifier varchar2(64),modifytime timestamp(6),content xmltype,CONSTRAINT PK_btmtype PRIMARY KEY (oid),CONSTRAINT IDX_BTMTYPE_NAME unique (NAME))";
    public static final String ATTSQL = "create table plattribute (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),description varchar2(256),ts timestamp(6),creator varchar2(64),createtime timestamp(6),modifier varchar2(64), modifytime timestamp(6),content xmltype,CONSTRAINT PK_attribute PRIMARY KEY (oid),CONSTRAINT IDX_attribute_NAME unique (NAME))";
    public static final String ENUMSQL = "create table plenum (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),ts timestamp(6),creator varchar2(64),createtime timestamp(6),modifier varchar2(64),modifytime timestamp(6),content xmltype,CONSTRAINT PK_enum PRIMARY KEY (oid),CONSTRAINT IDX_enum_NAME unique (NAME))";
    public static final String LCSQL = "create table pllifecycle (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),description varchar2(256),ts timestamp(6),creator varchar2(64),createtime timestamp(6),modifier varchar2(64),modifytime timestamp(6),content xmltype,CONSTRAINT PK_lifecycle PRIMARY KEY (oid),CONSTRAINT IDX_lifecycle_NAME unique (NAME))";
    public static final String VRSQL = "create table plversionrule (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),description varchar2(256),ts timestamp(6),creator varchar2(64),createtime timestamp(6),modifier varchar2(64),modifytime timestamp(6),content xmltype,CONSTRAINT PK_versionrule PRIMARY KEY (oid),CONSTRAINT IDX_versionrule_NAME unique (NAME))";
    public static final String SPSQL = "create table plstatepool (oid varchar2(64) not null,name varchar2(128) not null,label varchar2(256),description varchar2(256),ts timestamp(6),creator varchar2(64),createtime timestamp(6),modifier varchar2(64),modifytime timestamp(6),content xmltype,CONSTRAINT PK_statepool PRIMARY KEY (oid),CONSTRAINT IDX_statepool_NAME unique (NAME))";
    @Override
    public void actionPerformed(ActionEvent e) {
        if(JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(null, "迁移将覆盖原有数据", "迁移将覆盖原有数据", JOptionPane.OK_CANCEL_OPTION)){
            return;
        }
        try {
            BtmClient.getService().checkTable("pllinktype", LTSQL);
            BtmClient.getService().checkTable("plbtmtype", BTSQL);
            BtmClient.getService().checkTable("plattribute", ATTSQL);
            BtmClient.getService().checkTable("plenum", ENUMSQL);
            BtmClient.getService().checkTable("pllifecycle", LCSQL);
            BtmClient.getService().checkTable("plversionrule", VRSQL);
            BtmClient.getService().checkTable("plstatepool", SPSQL);
            
            BtmClient.getService().truncateTable("pllinktype");
            BtmClient.getService().truncateTable("plbtmtype");
            BtmClient.getService().truncateTable("pllifecycle");
            BtmClient.getService().truncateTable("plstatepool");
            BtmClient.getService().truncateTable("plversionrule");
            BtmClient.getService().truncateTable("plattribute");
            BtmClient.getService().truncateTable("plenum");
        } catch (VCIError e2) {
            e2.printStackTrace();
        }
        Map<String, Boolean> rs = new HashMap<String, Boolean>();
        String userName = InvocationUtility.getInvocation().userName;
        CountDownLatch countDown = new CountDownLatch(7);
        new Thread(new Xml2DBRunnableSP(userName, rs, countDown)).start();
        new Thread(new Xml2DBRunnableVR(userName, rs, countDown)).start();
        new Thread(new Xml2DBRunnableLC(userName, rs, countDown)).start();
        new Thread(new Xml2DBRunnableEnum(userName, rs, countDown)).start();
        new Thread(new Xml2DBRunnableAtt(userName, rs, countDown)).start();
        new Thread(new Xml2DBRunnableBtm(userName, rs, countDown)).start();
        new Thread(new Xml2DBRunnableLT(userName, rs, countDown)).start();
        try {
            countDown.await();
            Boolean spFlag = rs.get(SP);
            Boolean btFlag = rs.get(BT);
            Boolean ltFlag = rs.get(LT);
            Boolean lcFlag = rs.get(LC);
            Boolean vrFlag = rs.get(VR);
            Boolean attFlag = rs.get(ATT);
            Boolean eFlag = rs.get(ENUM);
            StringBuilder stb = new StringBuilder();
            stb.append("业务类型:" + (btFlag ? "成功" : "失败") + "\n");
            stb.append("链接类型:" + (ltFlag ? "成功" : "失败") + "\n");
            stb.append("属性池:" + (attFlag ? "成功" : "失败") + "\n");
            stb.append("枚举:" + (eFlag ? "成功" : "失败") + "\n");
            stb.append("状态池:" + (spFlag ? "成功" : "失败") + "\n");
            stb.append("生命周期:" + (lcFlag ? "成功" : "失败") + "\n");
            stb.append("版本规则:" + (vrFlag ? "成功" : "失败") + "\n");
            JOptionPane.showMessageDialog(null, stb.toString(), "迁移结果", JOptionPane.INFORMATION_MESSAGE);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }
    }
 
}
 
class Xml2DBRunnableBtm implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    
    public Xml2DBRunnableBtm(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
        try {
            boolean flag = false;//BtmClient.getService().xml2DB(userName);
            rs.put(Xml2DBActionListener.BT, flag);
            countDownLatch.countDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
class Xml2DBRunnableEnum implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    
    public Xml2DBRunnableEnum(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
        try {
            boolean flag = false;//EnumClient.getService().xml2DB(userName);
            rs.put(Xml2DBActionListener.ENUM, flag);
            countDownLatch.countDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
class Xml2DBRunnableAtt implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    public Xml2DBRunnableAtt(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
        try {
            boolean flag = false;//APClient.getService().xml2DB(userName);
            rs.put(Xml2DBActionListener.ATT, flag);
            countDownLatch.countDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
class Xml2DBRunnableSP implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    public Xml2DBRunnableSP(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
        try {
            boolean flag = false;//StatePoolStart.getService().xml2DB(userName);
            rs.put(Xml2DBActionListener.SP, flag);
            countDownLatch.countDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
class Xml2DBRunnableVR implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    
    public Xml2DBRunnableVR(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
        try {
            boolean flag = false;//VRClientStart.getService().xml2DB(userName);
            rs.put(Xml2DBActionListener.VR, flag);
            countDownLatch.countDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
class Xml2DBRunnableLC implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    
    public Xml2DBRunnableLC(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
        try {
            boolean flag = false;//LifeCycleStart.getService().xml2DB(userName);
            rs.put(Xml2DBActionListener.LC, flag);
            countDownLatch.countDown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
class Xml2DBRunnableLT implements Runnable {
    private String userName;
    private Map<String, Boolean> rs;
    private CountDownLatch countDownLatch;
    
    public Xml2DBRunnableLT(String userName, Map<String, Boolean> rs, CountDownLatch countDown){
        this.userName = userName;
        this.rs = rs;
        this.countDownLatch = countDown;
    }
    public void run() {
//        try {
//            boolean flag = LinkTypeProvider.getInstance().getService().xml2DB(userName);
//            rs.put(Xml2DBActionListener.LT, flag);
//            countDownLatch.countDown();
//        } catch (VCIError e) {
//            e.printStackTrace();
//        }
    }
}