Version: Windchill 11.0
Use Case: I m querying the objects based on input list. input list contains all epmdocument numbers as input.. all objects are queried and retrieved using QuerSpec/QueryResult API as part of a custom java class method. However, there are some numbers in epmdocs list that contain european characters, so QuerSpec/QueryResult API unable to fetch these objects. can some one help with this issue. below is my API method,
public List<EPMDocument> getAllEPMDocuments(String number, String revision) {
List<EPMDocument> documentList = new ArrayList<>();
try {
// Create a QuerySpec object to build the query
QuerySpec qs = new QuerySpec();
// Add EPMDocument as the class to query
int idx0 = qs.appendClassList(EPMDocument.class, true);
// Add condition for the EPM document number
qs.appendWhere(new SearchCondition(EPMDocument.class, "master>number", SearchCondition.EQUAL, number),
new int[] { idx0 });
// Add conditions for both latest versions (true) and historical versions
// (false)
qs.appendAnd();
qs.appendOpenParen(); // Start of OR condition
qs.appendWhere(VersionControlHelper.getSearchCondition(EPMDocument.class, true), new int[] { idx0 }); // Latest
// versions
qs.appendOr(); // OR condition
qs.appendWhere(VersionControlHelper.getSearchCondition(EPMDocument.class, false), new int[] { idx0 }); // Historical
// versions
qs.appendCloseParen(); // End of OR condition
// Add condition for revision if provided
if (revision != null && revision.trim().length() > 0) {
qs.appendAnd();
qs.appendWhere(new SearchCondition(EPMDocument.class, "versionInfo.identifier.versionId",
SearchCondition.EQUAL, revision), new int[] { idx0 });
}
// Enable advanced query
qs.setAdvancedQueryEnabled(true);
// Execute the query
QueryResult qr = PersistenceServerHelper.manager.query(qs);
// Iterate through the query results and add to the list
while (qr.hasMoreElements()) {
Object[] obj = (Object[]) qr.nextElement();
EPMDocument document = (EPMDocument) obj[0];
documentList.add(document);
}
} catch (WTException e) {
System.out.println("Exception while querying EPMDocuments: " + e.getMessage());
e.printStackTrace();
}
return documentList;
}