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();
|
// }
|
}
|
}
|