Windchill 设置大版本的代码

时间:2014-07-01 23:19:54   收藏:0   阅读:450
    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);
        }
    }

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

Windchill 设置大版本的代码,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!