Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

Querying(using QuerySpec API) the Objects having european special characters

NP_10570407
12-Amethyst

Querying(using QuerySpec API) the Objects having european special characters

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;
}

 

1 REPLY 1

Hi @NP_10570407 

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.

 

Best regards,

Catalina
PTC Community Moderator
Announcements


Top Tags