Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » String sorting and Locale problem
String sorting and Locale problem [message #500664] Fri, 27 November 2009 11:42 Go to next message
Eclipse UserFriend
Originally posted by: bdraba.gmail.com

Hello,

What I need to set to have properly (in locale different than English)
sorted column of strings data in the table?

Thanks!
Bartek
Re: String sorting and Locale problem [message #500949 is a reply to message #500664] Mon, 30 November 2009 12:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bdraba.gmail.com

Hi again,

Maybe I wasn't clear enough. I want to sort column of strings in my table
and BIRT sorts it in natural order in English alphabet
but I need to do this in other language (alphabet).
The question is what and where set my Locale (or other properties) to make
BIRT sorting in my Language.

Thanks a lot,
Bartek

> Hello,
>
> What I need to set to have properly (in locale different than English)
> sorted column of strings data in the table?
>
> Thanks!
> Bartek
>
>
Re: String sorting and Locale problem [message #500984 is a reply to message #500949] Mon, 30 November 2009 15:16 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Are you adding &__locale=yourlocale to the report url?
Two other things you can do:

1 - Build a custom sort order by entering an expression for the key.
For example assume I sort on orderlinenumber and I want to sort it like
3
1
2
4
I could enter this expression:
var ol = row["ORDERLINENUMBER"];
if( ol == 3 ){
1
}else if( ol == 1 ){
2
}else if( ol == 2 ){
3
}else if( ol == 4 ){
4
}

2 - Try adding the sort key in the beforeFactory script of the report.

importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.ele ments);
importPackage(Packages.com.ibm.icu.util);

var lc = new ULocale("fr_FR");
delm = reportContext.getDesignHandle().findElement("mytable");
sc = StructureFactory.createSortKey();
sc.setKey("row[\"ORDERNUMBER\"]");
sc.setDirection("desc");
sc.setLocale(lc);

ph = delm.getPropertyHandle(TableHandle.SORT_PROP);
ph.addItem(sc);


notice the ULocale object. The sort key has a setLocale method. I have
not tried this but its worth a try.

Jason

drabek wrote:
> Hi again,
>
> Maybe I wasn't clear enough. I want to sort column of strings in my table
> and BIRT sorts it in natural order in English alphabet
> but I need to do this in other language (alphabet).
> The question is what and where set my Locale (or other properties) to make
> BIRT sorting in my Language.
>
> Thanks a lot,
> Bartek
>
>> Hello,
>>
>> What I need to set to have properly (in locale different than English)
>> sorted column of strings data in the table?
>>
>> Thanks!
>> Bartek
>>
>>
>
>
Re: String sorting and Locale problem [message #502435 is a reply to message #500984] Tue, 08 December 2009 08:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: maciej.dot.kruk.alan-systems.dot.com

hi,
no way:

> importPackage(Packages.org.eclipse.birt.report.model.api);
> importPackage(Packages.org.eclipse.birt.report.model.api.ele ments);
> importPackage(Packages.com.ibm.icu.util);
>
> var lc = new ULocale("fr_FR");
> delm = reportContext.getDesignHandle().findElement("mytable");
> sc = StructureFactory.createSortKey();
> sc.setKey("row[\"ORDERNUMBER\"]");
> sc.setDirection("desc");
> sc.setLocale(lc);
>
> ph = delm.getPropertyHandle(TableHandle.SORT_PROP);
> ph.addItem(sc);
>
>
> notice the ULocale object. The sort key has a setLocale method. I have
> not tried this but its worth a try.

No, org.eclipse.birt.report.model.api.elements.structures.SortKe y does not
have the setLocale method.

Actually, BIRT is able only to sort the data binary or not. Don't think of
use java.text.Collator strengths or any kind of it!
The lack of this feature disqualifies BIRT to use in multilingual
applications, doesn't it?

Maciek
Re: String sorting and Locale problem [message #502562 is a reply to message #502435] Tue, 08 December 2009 20:02 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Maciek,

What version of BIRT are you using?
2.5.1
org.eclipse.birt.report.model.api.elements.structures.SortKe y does have
a setLocale method, which the SortKeyHandle uses. There is also a
setStrength method. The data engine uses com.ibm.icu.text.Collator. If
this is not functioning right a bug will need to be logged.

Can you try this:

importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.ele ments);
importPackage(Packages.com.ibm.icu.util);
importPackage(Packages.org.eclipse.birt.data.engine.api);

var lc = new ULocale("fr_FR");
delm = reportContext.getDesignHandle().findElement("mytable");
sc = StructureFactory.createSortKey();
sc.setKey("row[\"ORDERNUMBER\"]");
sc.setDirection("desc");
sc.setLocale(lc);
//ASCII_SORT_STRENGTH or DEFAULT_SORT_STRENGTH for Collator
sc.setStrength( ISortDefinition.DEFAULT_SORT_STRENGTH );

ph = delm.getPropertyHandle(TableHandle.SORT_PROP);
ph.addItem(sc);


Jason

Maciej Kruk wrote:
> hi,
> no way:
>
>> importPackage(Packages.org.eclipse.birt.report.model.api);
>> importPackage(Packages.org.eclipse.birt.report.model.api.ele ments);
>> importPackage(Packages.com.ibm.icu.util);
>>
>> var lc = new ULocale("fr_FR");
>> delm = reportContext.getDesignHandle().findElement("mytable");
>> sc = StructureFactory.createSortKey();
>> sc.setKey("row[\"ORDERNUMBER\"]");
>> sc.setDirection("desc");
>> sc.setLocale(lc);
>>
>> ph = delm.getPropertyHandle(TableHandle.SORT_PROP);
>> ph.addItem(sc);
>>
>>
>> notice the ULocale object. The sort key has a setLocale method. I have
>> not tried this but its worth a try.
>
> No, org.eclipse.birt.report.model.api.elements.structures.SortKe y does not
> have the setLocale method.
>
> Actually, BIRT is able only to sort the data binary or not. Don't think of
> use java.text.Collator strengths or any kind of it!
> The lack of this feature disqualifies BIRT to use in multilingual
> applications, doesn't it?
>
> Maciek
>
>
Previous Topic:Using variables in tables
Next Topic:Same report parameter gives two different results
Goto Forum:
  


Current Time: Fri Apr 26 15:21:24 GMT 2024

Powered by FUDForum. Page generated in 0.03994 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top