package com.vci.client.uif.actions.client; import java.util.ArrayList; import java.util.List; import javax.swing.JOptionPane; import com.vci.client.bof.ClientBusinessObject; import com.vci.client.bof.ClientLinkObject; import com.vci.client.ui.swing.VCIOptionPane; import com.vci.client.uif.engine.common.DefaultTableNode; import com.vci.mw.ClientContextVariable; /** * 升级版次事件 * 参数信息: * oid(升级版次对象的oid) * btmname(升级版次对象的类型) * name(升级版次对象的名称、用于显示信息) * @author VCI-STGK006 * */ public class VersionAction extends AbstractBatchBusionessOperationAction { /** * 方法集合 */ UIFUtils operation = new UIFUtils(); public VersionAction(){ super(); } @Override public String getKey() { return VERSION; } @Override public boolean checkHasRight(){ // 按BO进行数据权限检查 setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B); return super.checkHasRight(); } @Override public boolean doPost() { //获得业务对象数据 Object[] objs = getDataModel().getSelectObjects(); if(objs == null || objs.length < 1){ return false; } //modify 2014.03.09 start List cboList = new ArrayList(); for(int i = 0; i < objs.length; i++){ DefaultTableNode dtn = (DefaultTableNode) objs[i]; try { //判断主对象类型 if(dtn.getMaterObject() instanceof ClientBusinessObject){ //如果是业务类型 ClientBusinessObject cbo = (ClientBusinessObject) dtn.getMaterObject(); if(cbo == null){ int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(), "“" + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) + "”不存在或者已经被删除,继续执行升版操作系统将会忽略“" + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) +"”.\n是否继续执行升版操作?", "系统提示",JOptionPane.YES_NO_OPTION); if(confirm == JOptionPane.NO_OPTION){ return false; } } cboList.add(cbo); } else if (dtn.getMaterObject() instanceof ClientLinkObject){ //如果是link类型 String oid = this.getParameterValue(ValueType.RuntimeData, "t_oid", i); String btmName = this.getParameterValue(ValueType.RuntimeData, "t_btwname", i); //如果操作所需参数不存在则直接停止操作 if(oid == null || oid.equals("") ||btmName == null || btmName.equals("")){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.syserror.parmerror.bo"); return false; } //需要重新下载cbo对象 ClientBusinessObject cbo = operation .reloadClientBusinessObject(ClientContextVariable.getFrame(), oid, btmName); System.out.println("** TS:" + cbo.getBusinessObject().ts); //对象不存在或者已经被删除 if(cbo.getBusinessObject().oid == null || cbo.getBusinessObject().oid.equals("")){ int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(), "“" + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) + "”不存在或者已经被删除,继续执行升版操作系统将会忽略“" + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) +"”.\n是否继续执行升版操作?", "系统提示",JOptionPane.YES_NO_OPTION); if(confirm == JOptionPane.NO_OPTION){ return false; } } else { cboList.add(cbo); } } } catch (Exception e){ UIFUtils.showErrorMessage( ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.editboerror", e); int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(), "系统在加载对象时发生异常,升版操作可能会失败\n是否继续执行升版操作?", "系统提示",JOptionPane.YES_NO_OPTION); if(confirm == JOptionPane.NO_OPTION){ return false; } } } //modify 2014.03.09 end //得到需要升版的业务对象 当为多个时 有升级成功的就算成功 boolean success = false; if(!cboList.isEmpty()){ for(int j = 0; j < cboList.size(); j++){ ClientBusinessObject cbo = cboList.get(j); //升级版次 try { if(operation.upBusinessObjectVersion(ClientContextVariable.getFrame(), cbo)){ success = true; } } catch (Exception e) { e.printStackTrace(); int confirm = VCIOptionPane.showConfirmDialog( ClientContextVariable.getFrame(), "“" + cbo.getBusinessObject().name +"”升级版次失败.\n是否继续执行升级版次操作?", "系统提示",JOptionPane.YES_NO_OPTION); if(confirm == JOptionPane.NO_OPTION){ return false; } //XXX 需要增加是否继续还有文件需要继续升级版次的判断 //if(j < cboList.size() - 1){ //} } } } if(success){ UIFUtils.showMessage(ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.versionsuccessmsg"); } return success; } }