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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to get actual Iteration version of WTPartMaster

VINO
12-Amethyst

How to get actual Iteration version of WTPartMaster

I'm passing WTPart roleA(parent) object in a query of UsageLink object i'm getting roleB(child) objects.Here the roleB objects which I'm getting are the WTPartMaster..

How can I get the actual Iteration of child object which has been attached to parent part??

Thanks

vignesh

ACCEPTED SOLUTION

Accepted Solutions
KD
12-Amethyst
12-Amethyst
(To:VINO)

Hi ,

Using the following method you can get child WTPart instead of WTPartMaster.

public static void getChildParts(WTPart parentPart) throws WTException

{

@SuppressWarnings("deprecation")

QueryResult queryResult= WTPartHelper.service.getUsesWTParts(parentPart, new LatestConfigSpec());

while(queryResult.hasMoreElements())

{

WTPart part=null;

Persistable[] persistable=(Persistable[])queryResult.nextElement();

part=(WTPart)persistable[1];

System.out.println(part.getName() + " Child part");

WTPartUsageLink partLink=(WTPartUsageLink)persistable[0];

}

}

and if you don't want to use deprecated method then there is another method.

public static void getChildParts(WTPart[] parentParts) throws WTException //use this method if you have to find for WTPart Array

{

WTArrayList paramWTList = new WTArrayList();

for(WTPart part : parentParts)

paramWTList.add(part);

Persistable[][][] queryResult= WTPartHelper.service.getUsesWTParts(paramWTList, new LatestConfigSpec());

for(int i=0 ; i < queryResult.length; i++)

{

System.out.println("Parent part :-" + parentParts[i].getName());

for(int j=0;j<queryResult[i].length;j++)

{

WTPart part = (WTPart)queryResult[i][j][1];

//if you need WTPartUsageLink object then change 1 to 0

System.out.println("Child Part :- " + part.getName());

}

}

}

After getting the WTPart object you can easily find the iteration and version value.

String str1 = part.getVersionInfo().getIdentifier().getValue();//for revision

String str2 = part.getIterationIdentifier().getValue();//for iteration

VersionControlHelper.getIterationDisplayIdentifier(part);

I guess from WTPartMaster there is no direct way to get the latest version and iteration without querying the database.

Thanks and Regards,

Kaushik

Message was edited by: kaushik das

View solution in original post

3 REPLIES 3
GregoryPERASSO
15-Moonstone
(To:VINO)

Hello

As you said, the usage link is to the child master

So you need to use a filter criteria to identify the Version : for example LATEST (ie latest version iteration)

regards

KD
12-Amethyst
12-Amethyst
(To:VINO)

Hi ,

Using the following method you can get child WTPart instead of WTPartMaster.

public static void getChildParts(WTPart parentPart) throws WTException

{

@SuppressWarnings("deprecation")

QueryResult queryResult= WTPartHelper.service.getUsesWTParts(parentPart, new LatestConfigSpec());

while(queryResult.hasMoreElements())

{

WTPart part=null;

Persistable[] persistable=(Persistable[])queryResult.nextElement();

part=(WTPart)persistable[1];

System.out.println(part.getName() + " Child part");

WTPartUsageLink partLink=(WTPartUsageLink)persistable[0];

}

}

and if you don't want to use deprecated method then there is another method.

public static void getChildParts(WTPart[] parentParts) throws WTException //use this method if you have to find for WTPart Array

{

WTArrayList paramWTList = new WTArrayList();

for(WTPart part : parentParts)

paramWTList.add(part);

Persistable[][][] queryResult= WTPartHelper.service.getUsesWTParts(paramWTList, new LatestConfigSpec());

for(int i=0 ; i < queryResult.length; i++)

{

System.out.println("Parent part :-" + parentParts[i].getName());

for(int j=0;j<queryResult[i].length;j++)

{

WTPart part = (WTPart)queryResult[i][j][1];

//if you need WTPartUsageLink object then change 1 to 0

System.out.println("Child Part :- " + part.getName());

}

}

}

After getting the WTPart object you can easily find the iteration and version value.

String str1 = part.getVersionInfo().getIdentifier().getValue();//for revision

String str2 = part.getIterationIdentifier().getValue();//for iteration

VersionControlHelper.getIterationDisplayIdentifier(part);

I guess from WTPartMaster there is no direct way to get the latest version and iteration without querying the database.

Thanks and Regards,

Kaushik

Message was edited by: kaushik das

AR_9920456
14-Alexandrite
(To:KD)

Hello,

The above code for get the latest child parts having latest revision. in that i need a latest  manufacturing view( For Example: The WTPart previously it was in xyz   C.3(Design) view and later view was changed to xyz B.1(manufacture) view in this i need only latest manufacturing view).

I build a query builder which was not working fail to pick the objects which are from Design to Manufacture view. 

Announcements


Top Tags