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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Expression Robot java: REVISE to a specific Version

pb_max
4-Participant

Expression Robot java: REVISE to a specific Version

Hello PTC Community,

I am fairly new to both Java and especially to the WC API, but I muddle through ok. I am stuck on some API and need the guru help! The intent: check for next available Version (Rev), common to a WTSet (that part works), then if the result is numeric, rev the whole WTSet to A.1, or if the result is alpha, then rev the whole set to the result. Most of the time the items should all be numeric, going to A.1, which is "legal" in our WC setup. I have tried both the following approaches:

newVersion(Versioned version, VersionIdentifier version_id, IterationIdentifier iteration_id)
-OR-
newAdHocStringVersion(AdHocStringVersioned version, java.lang.String adHocVersionId)

 

I gave up on "newVersion" because I could not get the "userClassName" reference to work out in MultilevelSeries (needed for VersionIdentifier)...there is no explanation for what is realy needed in this argument in the API. I tried using several things as the "user". Here are a few with the associated errors:

 

self.getClass().toString();

(wt.series.seriesResource/6) wt.series.SeriesConstructionException: The series was unable to be constructed.
Nested exception is: java.lang.ClassNotFoundException: class wt.fc

 

wt.workflow.engine.WfProcess myWFP = wt.workflow.engine.WfProcess.newWfProcess;
String thisClass = myWFP.getClass().toString();

(wt.series.seriesResource/6) wt.series.SeriesConstructionException: The series was unable to be constructed.
Nested exception is: java.lang.ClassNotFoundException: class wt.workflow.engine

 

String thisClass = "wt.workflow.engine.WfProcess";

java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.series.MultilevelSeries


I thought maybe that was the wrong tree to climb...I tried "newAdHocStringVersion" instead, since it takes just a String as the Version argument.  But then I ran into where my items didn't want to be cast as AdHocStringVersioned (where they cast as Versioned just fine for the "newVersion" tries above)...

 

java.lang.ClassCastException: wt.epm.EPMDocument cannot be cast to wt.vc.AdHocStringVersioned

 

here are the codes:

// "newVersion" fail...


String thisClass = "wt.workflow.engine.WfProcess";

String[] myNextRevsArray = wt.vc.VersionControlHelper.service.getNextCommonLabels(myWTKeySet,1);

if (myNextRevsArray[0].matches("[0-9]+")){
  java.util.Iterator myKSitr = myWTKeySet.persistableIterator();
  while(myKSitr.hasNext()){
    wt.fc.Persistable myP = (wt.fc.Persistable) myKSitr.next();
    wt.vc.Versioned myVersioned = (wt.vc.Versioned) myP;
    wt.series.MultilevelSeries myMLS = wt.series.MultilevelSeries.newMultilevelSeries(thisClass, "A");
    wt.vc.VersionIdentifier myVI = wt.vc.VersionIdentifier.newVersionIdentifier(myMLS);
    wt.vc.IterationIdentifier myIID = wt.vc.IterationIdentifier.newIterationIdentifier("1");
    wt.vc.VersionControlHelper.service.newVersion(myVersioned, myVI, myIID);
  }
}else{
  if (myNextRevsArray[0].matches("[a-zA-Z]+")){
    java.util.Iterator myKSitr = myWTKeySet.persistableIterator();
    while(myKSitr.hasNext()){
      wt.fc.Persistable myP = (wt.fc.Persistable) myKSitr.next();
      wt.vc.Versioned myVersioned = (wt.vc.Versioned) myP;
      wt.series.MultilevelSeries myMLS = wt.series.MultilevelSeries.newMultilevelSeries(thisClass, myNextRevsArray[0]);
      wt.vc.VersionIdentifier myVI = wt.vc.VersionIdentifier.newVersionIdentifier(myMLS);
      wt.vc.IterationIdentifier myIID = wt.vc.IterationIdentifier.newIterationIdentifier("1");
      wt.vc.VersionControlHelper.service.newVersion(myVersioned, myVI, myIID);
    }
  }
}

----------------------------------------------------------------------------------------------------------------------------
// "newAdHocStringVersion" fail...


String[] myNextRevsArray = wt.vc.VersionControlHelper.service.getNextCommonLabels(myWTKeySet,1);

if (myNextRevsArray[0].matches("[0-9]+")){
  java.util.Iterator myKSitr = myWTKeySet.persistableIterator();
  while(myKSitr.hasNext()){
    wt.fc.Persistable myP = (wt.fc.Persistable) myKSitr.next();
    wt.vc.AdHocStringVersioned myVersioned = (wt.vc.AdHocStringVersioned) myP;
    wt.vc.VersionControlHelper.service.newAdHocStringVersion(myVersioned, "A");
  }
}else{
  if (myNextRevsArray[0].matches("[a-zA-Z]+")){
    java.util.Iterator myKSitr = myWTKeySet.persistableIterator();
    while(myKSitr.hasNext()){
      wt.fc.Persistable myP = (wt.fc.Persistable) myKSitr.next();
      wt.vc.Versioned myVersioned = (wt.vc.Versioned) myP;
      wt.vc.AdHocStringVersioned myVersioned = (wt.vc.AdHocStringVersioned) myP;
      wt.vc.VersionControlHelper.service.newAdHocStringVersion(myVersioned, myNextRevsArray[0]);
    }
  }
}

----------------------------------------------------------------------------------------------------------------------------
***Note: myWTKeySet = [wt.epm.EPMDocument:919951127, wt.doc.WTDocument:919952259, wt.epm.EPMDocument:919949538, wt.doc.WTDocument:919952015, wt.part.WTPart:920335120]...these are a WTPart and its Described By, and CAD, Docs.
1 REPLY 1
pb_max
4-Participant
(To:pb_max)

UPDATE:

 

I was able to fix this.  However, there is a whole new problem was created in the process.  Here was the fix:

 

String thisClass = "wt.series.HarvardSeries.XSeries"; //used for the userNameClass argument.
 
wt.fc.PersistenceHelper.manager.store(newVersion);//persisted(?) the new versions

 

In a folder view, I can see that each of the 5 items got revised to A.1, but when I open the Related Objects tab of the WTPart A.1, only the DRW is A.1...the cad.prt and 2 pdf's all remained at their original revs.

 

Any help here would be appreciated.

Top Tags