on 11-14-2006 7:21 PM
Is there any way to sort the elements in a ResultSet? I have code that accesses the UME users and displays their name and email in an EVS search help. I'd like to sort the list by name if possible. In case it is helpful here is the code I am using in the WDDoInit method of the view:
IUserFactory ufact = UMFactory.getUserFactory();
IUserSearchFilter isf;
try {
isf = ufact.getUserSearchFilter();
isf.setUniqueName("*", ISearchAttribute.LIKE_OPERATOR,false);
isf.setCity("Tewksbury", ISearchAttribute.EQUALS_OPERATOR,false);
ISearchResult sr = ufact.searchUsers(isf);
String strtest = "";
String strnamen = "";
String stremail = "";
String attributeName =
IPrivateGenReceiptsMainView.IReceiptElement.ADDRESSED_TO;
IWDAttributeInfo attributeInfo =
wdThis.wdGetContext().nodeReceipt().getNodeInfo().getAttribute(attributeName);
ISimpleTypeModifiable AddressedType = attributeInfo.getModifiableSimpleType();
AddressedType.setFieldLabel("AddressedTo");
IModifiableSimpleValueSet valueSet =
AddressedType.getSVServices().getModifiableSimpleValueSet();
while (sr.hasNext()) {
strtest = sr.next().toString();
IUser user = UMFactory.getUserFactory().getUser(strtest);
strnamen = user.getDisplayName();
stremail = user.getEmail();
valueSet.put(user.getDisplayName(),stremail);
}
} catch (UMException e) {
e.printStackTrace();
}
Hi Dana,
The simplest way is by using the <b>sort </b> function in IModifiableSimpleValueSet.
After the while loop: <b>valueSet.sort(false,true,true);</b>
The first paramter is <b>sortKey</b> - if true, it sorts according to the order of the keys contained in this SimpleValueSet, otherwise it sorts according to the order of the texts for the current internal default locale.
The second paramter is <b>up</b> - if true, it sorts into ascending order, otherwise into descending order.
The third paramter is <b>ignoreCase</b> - if true, ignore the capitalization of letters.
Regards
Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dana,
Try this out ..
After you have put your elements into the valueSet, do the following(You can put this code at the end).
Vector v = new Vector(valueSet.keySet());
Collections.sort(v);
See if it works,
Cheers,
LM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check this example out
https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/bad3e990-0201-0010-3985-fa0936d901b4
Firasath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.