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());
}
}
Solved! Go to Solution.
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));
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!