Windchill 设置大版本的代码

    public static void setVersion(final Versioned versioned, String version)
            throws WTException {
        try {
            if (version == null || version.trim().length() == 0) {
                // If the version ID string is null then the load file did not
                // specify it.
                version = null;
                if (versioned.getVersionInfo() != null) {
                    // If the object already has a VersionInfo object then
                    // assume it is correct
                    // and no further action is needed. Otherwise, make a
                    // default VersionInfo object.
                    return;
                }
            }
            // Get the version series of the object.
            MultilevelSeries mls = null;
            final Mastered master = versioned.getMaster();
            if (master != null) {
                final String masterSeriesName = master.getSeries();
                if (masterSeriesName == null) {
                    if (versioned instanceof WTContained
                            && ((WTContained) versioned).getContainer() != null) {
                        // Retrieve the series based on the OIR in effect for
                        // the container and object type/soft type.
                        mls = VersionControlHelper
                                .getVersionIdentifierSeries(versioned);
                        wt.vc.VersionControlServerHelper.changeSeries(master,
                                mls.getUniqueSeriesName());
                    }
                } else {
                    // Series name was already set in the master, just use it.
                    mls = MultilevelSeries
                            .newMultilevelSeries(masterSeriesName);
                }
            }
            if (mls == null) {
                // Unable to get the series from the master, just use the
                // default series.
                mls = MultilevelSeries.newMultilevelSeries(
                        "wt.vc.VersionIdentifier", version);
            }
            if (version != null) {
                // Set the revision ID value if it was given in the load file.
                mls.setValueWithoutValidating(version.trim());
            }
            // Replace the default VID object (if there is one) with the correct
            // one.
            VersionIdentifier vid = VersionIdentifier.newVersionIdentifier(mls);
            VersionControlServerHelper.setVersionIdentifier(versioned, vid,
                    false /* validateIncreasing */);
        } catch (WTPropertyVetoException e) {
            LoadServerHelper.printMessage("\nsetVersion: " + e.getMessage());
            e.printStackTrace();
            throw new WTException(e);
        } catch (Exception e) {
            throw new WTException(e);
        }
    }

 代码由卡卡大神提供,特记录。

转载于:https://www.cnblogs.com/sosomaxba/p/3816462.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值