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

We are happy to announce the new Windchill Customization board! Learn more.

Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

ptc-4896214
1-Newbie

Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

Hi,

Need to pass the number, iteration and the version of my document to a query.

But I'm not getting to version.

How can I do this?

My code:

public static void main(String[] args) throws WTException {

wt.doc.WTDocument document = null;

String number = "C121-0019";

String version = "A";

wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.doc.WTDocument.class);

qs.setAdvancedQueryEnabled(true);

qs.appendWhere(new wt.query.SearchCondition(wt.doc.WTDocument.class,

"master>number", wt.query.SearchCondition.LIKE, number),

new int[] { 0 });

qs.appendAnd();

qs.appendWhere(new wt.query.SearchCondition(wt.doc.WTDocument.class, "iterationInfo.latest" , "TRUE"), new int[] { 0 });

qs.appendAnd();

qs.appendWhere(new wt.query.SearchCondition(wt.doc.WTDocument.class,

WTDocument.VERSION_DISPLAY_IDENTIFIER, wt.query.SearchCondition.EQUAL, version));

wt.fc.QueryResult qr = wt.fc.PersistenceHelper.manager.find(qs);

System.out.println("Query : "+ qs);

if (qr.size() > 0) {

while (qr.hasMoreElements()) {

System.out.println("Query: " + qr.hasMoreElements());

document = (wt.doc.WTDocument) qr.nextElement();

System.out.println("Número do documento= "

+ document.getNumber());

System.out.println("Revisão do documento = "

+ document.getVersionIdentifier().getValue());

System.out.println("Iteração do documento = "

+ document.getIterationIdentifier().getValue());

System.out.println("Estado do documento = "

+ document.getState());

break;

}

}else{

System.out.println("Não encontrou registro: " + qr.size());

}

}

1 ACCEPTED SOLUTION

Accepted Solutions

You can try following (with modification to wt.doc.WTDocument)

String partRevision="B";

qs.appendAnd();

qs.appendWhere( new wt.query.SearchCondition(wt.part.WTPart.class, wt.vc.Versioned.VERSION_IDENTIFIER+"."+wt.vc.VersionIdentifier.VERSIONID,wt.query.SearchCondition.EQUAL,partRevision));

View solution in original post

2 REPLIES 2

You can try following (with modification to wt.doc.WTDocument)

String partRevision="B";

qs.appendAnd();

qs.appendWhere( new wt.query.SearchCondition(wt.part.WTPart.class, wt.vc.Versioned.VERSION_IDENTIFIER+"."+wt.vc.VersionIdentifier.VERSIONID,wt.query.SearchCondition.EQUAL,partRevision));

Hi, Yogesh.

Thanks!

Top Tags