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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

getting class cast Exception when casting WTPartMaster type of Object to WTPart

ptc-6328570
1-Newbie

getting class cast Exception when casting WTPartMaster type of Object to WTPart

Is there any way to get WTPart type Object from WTPartMaster like casting or any other method?

1 ACCEPTED SOLUTION

Accepted Solutions

QueryResult linksQueryResult = VersionControlHelper.service.allVersionsOf(wtPartMaster);

WTPart wtPart = null;

boolean latestIteration = false;

while ((linksQueryResult.hasMoreElements()) && (!latestIteration))

{

WTPart tempPart = (WTPart)linksQueryResult.nextElement();

latestIteration = tempPart.isLatestIteration();

if (latestIteration)

{

wtPart = tempPart;

}

}

View solution in original post

2 REPLIES 2

QueryResult linksQueryResult = VersionControlHelper.service.allVersionsOf(wtPartMaster);

WTPart wtPart = null;

boolean latestIteration = false;

while ((linksQueryResult.hasMoreElements()) && (!latestIteration))

{

WTPart tempPart = (WTPart)linksQueryResult.nextElement();

latestIteration = tempPart.isLatestIteration();

if (latestIteration)

{

wtPart = tempPart;

}

}

AL_ANDERSON
5-Regular Member
(To:ptc-6328570)

You cannot cast a WTPartMater into a WTPart because they are entirely different classes that are not related in a java class parent-child relationship. However, there are a lot of helper APIs to use in

wt.vc.VersionControlHelper

and

wt.vc.VersionControlService

You access the service methods using wt.vc.VersionControlHelper.service.xxxxx()

For example, one method among the many to look at is this one.

wt.vc.VersionControlHelper.service.allVersionsFrom(Versioned version), defined from the API, below.

QueryResult allVersionsFrom(Versioned version) throws WTException, PersistenceException
Finds all of the versions of a master from the first one created to the given version. The result is an ordered list of versions (i.e., latest iterations) from the given iteration to the first one created. For example, if version C is given, the list returned is C, B, A.

Supported API: true

Parameters:
version -
Returns:
QueryResult
Throws:
WTException
PersistenceException
Top Tags