[Building Sakai] [Using Sakai] Weird issue ordering by Lastname

Zhen Qian zqian at umich.edu
Thu Jan 26 11:03:01 PST 2012


No. It doesn't help. Here is the diff file:

Index: site-manage-util/util/src/java/org/sakaiproject/site/util/SiteComparator.java
===================================================================
--- site-manage-util/util/src/java/org/sakaiproject/site/util/SiteComparator.java       (revision 103480)
+++ site-manage-util/util/src/java/org/sakaiproject/site/util/SiteComparator.java       (working copy)
@@ -14,13 +14,18 @@
 import org.sakaiproject.entity.api.ResourceProperties;
 import org.sakaiproject.entity.api.EntityPropertyNotDefinedException;
 import org.sakaiproject.entity.api.EntityPropertyTypeException;
+import org.sakaiproject.util.ResourceLoader;
+import java.util.Locale;
 
 /**
  * The comparator to be used in Worksite Setup/Site Info tool
  */
 public class SiteComparator implements Comparator {
+
+       ResourceLoader rb = new ResourceLoader();
 
-       Collator collator = Collator.getInstance();
+       Locale r = rb.getLocale();
+       Collator collator = Collator.getInstance(r);

Can you please attach your patch?

Thanks,

- Zhen
On Jan 26, 2012, at 1:00 PM, Feliz Gouveia wrote:

> have you tried:
> 
> Collator myCollator = Collator.getInstance(User or session locale in here);
> myCollator.compare(username1, username2);
> 
> I do not have the code here, but I think we went that way.
> 
> Feliz
> 
> 
> On 26 January 2012 17:47, Zhen Qian <zqian at umich.edu> wrote:
>> @Qu: I think the original problem is that both "Martinez Torcal" and
>> "Martin Troncoso" are last names.
>> 
>> The participant last name sort is based on the compare(String, String)
>> result of java.text.Collator. (1)
>> 
>> By default, java.text.RuleBasedCollator is implementation of Collator API.
>> According to the javadoc (2), empty space is not counted in String
>> comparison:
>> 
>> "A text-argument is any sequence of characters, excluding special characters
>> (that is, common whitespace characters [0009-000D, 0020] and rule syntax
>> characters [0021-002F, 003A-0040, 005B-0060, 007B-007E]). If those
>> characters are desired, you can put them in single quotes (e.g. ampersand =>
>> '&'). Note that unquoted white space characters are ignored; e.g. b c is
>> treated as bc."
>> 
>> I tried wrapping the whole string with single quotes, like 'Martinez Torcal'
>> and 'Martin Troncoso', and then do comparison, but the result is still the
>> same as before.
>> 
>> However, I don't want to go to the route of (1) detect empty space inside
>> and string and (2) wrap the space, if any, with single quotes.
>> 
>> Any suggestions?
>> 
>> Thanks,
>> 
>> - Zhen
>> 
>> ---------------
>> 1. https://source.sakaiproject.org/svn/site-manage/trunk/site-manage-util/util/src/java/org/sakaiproject/site/util/SiteComparator.java
>> 
>> 2.
>> http://docs.oracle.com/javase/1.4.2/docs/api/java/text/RuleBasedCollator.html
>> 
>> On Jan 26, 2012, at 11:40 AM, Qu, Yuanhua wrote:
>> 
>> It appears correct to me if user names are sorted by lastname:
>> 
>> "John Del Potro" and "Peter Delaware"
>> 
>> Last name “ Potro” should list after “Delaware” if sort names ascending
>> order.  We did notice that sakai sort users by last names mostly, not by
>> first name or full name.  We do have request from our users to change name
>> sorting by first names instead of last name, I guess most people know first
>> names better than last names.
>> 
>> -Qu
>> 
>> 
>> 
>> 
>> 
>> 
>> On 1/26/12 7:06 AM, "Feliz Gouveia" <fribeiro at ufp.edu.pt> wrote:
>> 
>> could be because the default Java collation sort order ignores
>> whitespaces? if so, maybe the code should be modified to always
>> include the collation of the current locale. That would solve at the
>> same time the language specific ordering issues.
>> 
>> regards, Feliz
>> 
>> On 26 January 2012 12:59, Daniel Merino <daniel.merino at unavarra.es> wrote:
>>> Hi, Feliz, and thanks for your answer.
>>> 
>>> We don't have the KNL-696 patch applied. However, after taking a look on
>>> it, I understand that this patch is applied to make a custom sort order
>>> for the last names according to the locale preferences.
>>> 
>>> However, our issue is happening with last names without non-ASCII
>>> characters and also working in english language.
>>> 
>>> For example, in a fresh english installation the same problem would
>>> happen (or that's what I think!) for, i.e., the ficticious users "John
>>> Del Potro" and "Peter Delaware". Peter would be listed before John.
>>> 
>>> We have the 2.7.1 version. Could somebody confirm if I am right or wrong?
>>> 
>>> I have created this JIRA about this:
>>> https://jira.sakaiproject.org/browse/KNL-873
>>> 
>>> Best regards.
>>> 
>>> Feliz Gouveia escribió:
>>>> Daniel, I'm not sure if this could be the case but check
>>>> https://jira.sakaiproject.org/browse/KNL-696.
>>>> 
>>>> For languages with special characters, the collation should be
>>>> specified for the locale being used. Otherwise you'll have also
>>>> problems ordering with accents and other non-ascii characters. I
>>>> remember this was not in the code and we had to do it to sort names.
>>>> 
>>>> regards, Feliz
>>>> 
>>>> 
>>>> On 26 January 2012 09:44, Daniel Merino <daniel.merino at unavarra.es>
>>>> wrote:
>>>> 
>>>>> Hi everybody.
>>>>> 
>>>>> One of our teachers has reported us a weird issue we hadn't noticed
>>>>> before.
>>>>> 
>>>>> Given two students, whose lastnames are "Martinez Torcal" and "Martin
>>>>> Troncoso", these lastnames are written in the LASTNAME field of the
>>>>> SAKAI_USER table.
>>>>> 
>>>>> Ordering in the database client, in excel or any other application, the
>>>>> logical alphabetical order is first "Martin Troncoso" and after
>>>>> "Martinez Torcal", just because the blank space is counted as a
>>>>> character.
>>>>> 
>>>>> However, in our Sakai 2.7.1 with kernel 1.1.13 they are ordered at Site
>>>>> Info, Assignments, etc. just the opposite: first "Martinez Torcal" and
>>>>> after "Martin Troncoso". The same issue happens with LDAP users.
>>>>> 
>>>>> I have searched at JIRA, but I haven't found any clue about this. Also,
>>>>> I have looked at BaseUserDirectoryService in the Kernel code:
>>>>> 
>>>>> 
>>>>> http://source.sakaiproject.org/viewsvn/kernel/trunk/kernel-impl/src/main/java/org/sakaiproject/user/impl/BaseUserDirectoryService.java?view=markup
>>>>> 
>>>>> but the getSortName() method doesn't seem to do nothing wrong.
>>>>> 
>>>>> Please, could you tell me if this problem has been reported and solved
>>>>> in the past?
>>>>> 
>>>>> Thanks in advance.
>>>>> Best regards.
>>>>> --
>>>>> Daniel Merino Echeverría
>>>>> daniel.merino at unavarra.es
>>>>> Gestor de teleformación - Centro Superior de Innovación Educativa.
>>>>> Tfno: 948-168489 - Universidad Pública de Navarra.
>>>>> --
>>>>> Donde todos piensan igual nadie piensa mucho. (Walter Lippmann)
>>>>> 
>>>>> _______________________________________________
>>>>> sakai-dev mailing list
>>>>> sakai-dev at collab.sakaiproject.org
>>>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>>> 
>>>>> TO UNSUBSCRIBE: send email to
>>>>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>>>>> "unsubscribe"
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>>> --
>>> Daniel Merino Echeverría
>>> daniel.merino at unavarra.es
>>> Gestor de teleformación - Centro Superior de Innovación Educativa.
>>> Tfno: 948-168489 - Universidad Pública de Navarra.
>>> --
>>> Tener la conciencia limpia es síntoma de mala memoria. (Les Luthiers)
>>> _______________________________________________
>>> sakai-user mailing list
>>> sakai-user at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>>> 
>>> TO UNSUBSCRIBE: send email to
>>> sakai-user-unsubscribe at collab.sakaiproject.org with a subject of
>>> "unsubscribe"
>> 
>> 
>> 
>> --
>> Feliz Ribeiro Gouveia
>> 
>> Universidade Fernando Pessoa            http://www.ufp.pt
>> Centro de Recursos Multimediaticos      Tel 351-22.507.13.06
>> M.I.N.D. Lab                            Fax 351-22.550.82.69
>> Pr 9 de Abril 349                       fribeiro at ufp.edu.pt
>> P-4249-004 Porto
>> _______________________________________________
>> sakai-user mailing list
>> sakai-user at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>> 
>> TO UNSUBSCRIBE: send email to sakai-user-unsubscribe at collab.sakaiproject.org
>> with a subject of "unsubscribe"
>> 
>> _______________________________________________
>> sakai-user mailing list
>> sakai-user at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-user
>> 
>> TO UNSUBSCRIBE: send email to sakai-user-unsubscribe at collab.sakaiproject.org
>> with a subject of "unsubscribe"
>> 
>> 
> 
> 
> 
> -- 
> Feliz Ribeiro Gouveia
> 
> Universidade Fernando Pessoa            http://www.ufp.pt
> Centro de Recursos Multimediaticos      Tel 351-22.507.13.06
> M.I.N.D. Lab                            Fax 351-22.550.82.69
> Pr 9 de Abril 349                       fribeiro at ufp.edu.pt
> P-4249-004 Porto
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
> 
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
> 
> 



More information about the sakai-dev mailing list