cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Version of an EPMDocument (and WTPart)

Highlighted
Level 7

Set Version of an EPMDocument (and WTPart)

Hi All,

 

I have written a checkin listener that should set a particular revision number (the iteration is not important) given a certain parameter passed by Creo (it is only done under special and particular circumstances). It only happens with parts and assemblies that are not already present in Windchill. This is the code I am using,

 

QueryResult qr = VersionControlHelper.service.allVersionsOf((Versioned) epmDocument);
long branchIdentifier = VersionControlHelper.getBranchIdentifier(epmDocument);
String revisionRetrieved = "D";

 while (qr.hasMoreElements()) {
                Iterated iterated = (Versioned) qr.nextElement();
                if (iterated.getBranchIdentifier() == branchIdentifier) {
                    MultilevelSeries mls = MultilevelSeries.newMultilevelSeries(epmDocumentMaster.getSeries());
                    mls.setValueWithoutValidating(revisionRetrieved.trim());
                    VersionIdentifier vid = VersionIdentifier.newVersionIdentifier(mls);
                    //System.out.println("Inside vid: " + vid.getValue());
                    VersionControlHelper.setVersionIdentifier((Versioned) iterated, vid);
                } else {
                    System.out.println("iterated branch: " + iterated.getBranchIdentifier());
                    System.out.println("Base branch id: " + branchIdentifier);
                }
            }

Does anyone has any suggestion? Perhaps the checkin is the wrong event, and I should create a listener to a previous even (like upload)?

 

Thank you in advance!