Query to get all the available object types within a selected context in Windchill
Good morning I'm SeonHo
There are some questions about configuring the Promotion Request Approval Process.
We have configured as follows.
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult qr= wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
while (qr.hasMoreElements())
{
wt.doc.WTDocument doc=(wt.doc.WTDocument) qr.nextElement();
wt.lifecycle.LifeCycleServerHelper.service.setState((wt.lifecycle.LifeCycleManaged)doc,wt.lifecycle.State.toState("DESIGNCHANGE"));
}
try
{
wt.util.WTProperties props = wt.util.WTProperties.getLocalProperties();
VERBOSE = props.getProperty("wt.maturity.verbose",VERBOSE);
}
catch( Throwable t )
{
}
try{
wt.maturity.MaturityServerHelper.service.unlockTargets (pn);
} catch (wt.maturity.MaturityException me){
if ( VERBOSE )
me.printStackTrace();
}
As a result, when I rejected it, I succeeded in designing the life cycle by design change.
But it was the case of WTDocument.
For WTParts, an error has occurred.
Nested exception: java.lang.ClassCastException: wt.part.WTPart can not be cast to wt.doc.WTDocument
Nested exception: wt.util.WTException: java.lang.ClassCastException: wt.part.WTPart can not be cast to wt.doc.WTDocument
Nested exception: java.lang.ClassCastException: wt.part.WTPart can not be cast to wt.doc.WTDocument
wt.workflow.engine.FailedExpressionException: wt.util.WTException: java.lang.ClassCastException: wt.part.WTPart can not be cast to wt.doc.WTDocument
So I modified the code as follows.
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult qr= wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
try
{
while (qr.hasMoreElements())
{
wt.doc.WTDocument doc=(wt.doc.WTDocument) qr.nextElement();
wt.lifecycle.LifeCycleServerHelper.service.setState((wt.lifecycle.LifeCycleManaged)doc,wt.lifecycle.State.toState("DESIGNCHANGE"));
}
}catch(wt.util.WTException e){
wt.part.WTPart pt=(wt.part.WTPart) qr.nextElement();
wt.lifecycle.LifeCycleServerHelper.service.setState((wt.lifecycle.LifeCycleManaged)pt,wt.lifecycle.State.toState("DESIGNCHANGE"));
}
try
{
wt.util.WTProperties props = wt.util.WTProperties.getLocalProperties();
VERBOSE = props.getProperty("wt.maturity.verbose",VERBOSE);
}
catch( Throwable t )
{
}
try{
wt.maturity.MaturityServerHelper.service.unlockTargets (pn);
} catch (wt.maturity.MaturityException me){
if ( VERBOSE )
me.printStackTrace();
}
However, I have also encountered the same error.
In my opinion, i can figure out the type of WTObject and then use switch to specify a specific lifecycle as in the first case for WTDocument.
After that, we follow the origin process for the remainder and return to the state before the promotion.
The code will look roughly like this:
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult qr= wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
while (qr.hasMoreElements())
{
wt.object.type ot = qr.getObjectType ???
switch(ot)
{
case "WTDocument" : wt.doc.WTDocument doc=(wt.doc.WTDocument) qr.nextElement();
wt.lifecycle.LifeCycleServerHelper.service.setState((wt.lifecycle.LifeCycleManaged)doc,wt.lifecycle.State.toState("DESIGNCHANGE")); break;
default : break;
}
}
Is it wrong?
I would appreciate your feedback.
thank

