Issue 124349 - grouping order doesnt works
Summary: grouping order doesnt works
Alias: None
Product: Base
Classification: Application
Component: code (show other issues)
Version: 3.4.1
Hardware: PC All
: P3 Normal (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2014-03-02 19:26 UTC by antonio1
Modified: 2014-04-21 15:10 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.1.0-dev
Developer Difficulty: ---

report not grouped by school (694.91 KB, application/octet-stream)
2014-03-02 19:26 UTC, antonio1
no flags Details
see reports in my base (718.17 KB, application/octet-stream)
2014-03-02 19:41 UTC, antonio1
no flags Details
remove READ_ONLY check and workaround for missing fields (2.91 KB, patch)
2014-04-02 22:01 UTC, j.nitschke
j.nitschke: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description antonio1 2014-03-02 19:26:28 UTC
Created attachment 82767 [details]
report not grouped by school

i choose grouping order by school, and sorting by date in wizard, but dosnt work.
if it help, i can create video, creating in wizard. see my report created now-in attach.
Comment 1 antonio1 2014-03-02 19:30:02 UTC
but when  i just sorted by 2 fields, it works! just cannot grouped report
Comment 2 antonio1 2014-03-02 19:41:38 UTC
Created attachment 82768 [details]
see reports in my base

i make 2 reports for your inquiry
Comment 3 j.nitschke 2014-03-02 22:23:11 UTC
confirmed with AOO 3.4.1 and 4.1-dev

generated report uses Command: 
> SELECT "Addresse"."ID", "Addresse"."card", "Addresse"."name", "Addresse"."date", "Addresse"."polis", "Addresse"."adress", "Addresse"."class", "Addresse"."school" FROM "Addresse" "Addresse" ORDER BY "Addresse"."date" DESC

while it should be:
> SELECT "Addresse"."ID", "Addresse"."card", "Addresse"."name", "Addresse"."date", "Addresse"."polis", "Addresse"."adress", "Addresse"."class", "Addresse"."school" FROM "Addresse" "Addresse" ORDER BY "Addresse"."school" ASC, "Addresse"."date" DESC

the command is available through
Edit report -> Form-Navigator (Form Design Toolbar):  Forms > ReportSource >  Command > Properties

workaround: edit Command or 
create query sorted by date and build report from query only sorted by school
Comment 4 j.nitschke 2014-03-04 15:31:15 UTC
probably related bug or cause:

if you go back from wizard step 5 (layout) to 4 (sorting) the first search criteria is missing but only if you have a group assigned in step 3 (if you have 2 groups assigned the first 2 criteria are missing)

this leads to
> main\wizards\com\sun\star\wizards\report\

I see nothing suspicious in enterStep(): line 157.

leaveStep(): line 214 however has a call [IReportDocument].setSorting(String[][])
which has two implementations but which one is called?

> main\wizards\com\sun\star\wizards\report\ (1 hit)
>	Line 609:     public void setSorting(String[][] aSortFieldNames)

> main\wizards\com\sun\star\wizards\reportbuilder\ (1 hit)
>	Line 507:     public void setSorting(String[][] _aSortFieldNames)
Comment 5 j.nitschke 2014-03-04 16:36:36 UTC
(In reply to j.nitschke from comment #4)
> which has two implementations but which one is called?
startReportWizard Line 459: loads class ""

> main\wizards\com\sun\star\wizards\reportbuilder\ (1 hit)
>	Line 507:     public void setSorting(String[][] _aSortFieldNames)

since it works without groups
> main\wizards\com\sun\star\wizards\reportbuilder\ (2 hits)
>	Line 512:             getRecordParser().prependSortFieldNames(groupNames);
is a hot candidate
> main\wizards\com\sun\star\wizards\db\ (1 hit)
>	Line 163:     public void prependSortFieldNames(String[] _fieldnames)
I don't see how groupnames get removed from SortFieldNames there

need someone with basic java skills to take a look
Comment 6 j.nitschke 2014-04-02 17:05:16 UTC
looked at the wrong place
not setSorting is the problem
getSortFieldNames shows unexpected behavior:
it returns array of pairs field names and sort direction
but excludes duplicates (OK) and fields marked READ_ONLY (What Why?)
> if (!((Boolean) CurUnoDialog.getControlProperty("lstSort" + (i + 1), PropertyNames.READ_ONLY)))

what happend before is:
- entering sort step of the wizard
- sort fields are filled with the group fields and marked READ_ONLY
main/wizards/com/sun/star/wizards/report/ : line 160

leaving sort step only the non READ_ONLY fields are fetched
Comment 7 j.nitschke 2014-04-02 19:12:05 UTC
remove exclusion of read only fields in getSortFieldNames() fixes the wizard

let's see who calls getSortFieldNames():
* ReportWizard.leaveStep this where we want it all SortFieldNames,
  result is used in setSorting which brings us to comment 4,
  setSorting has 2 implementation of which one has a hack, it prepends the
  group names to the list of SortFieldNames
  (see main/wizards/com/sun/star/wizards/reportbuilder/ line 507)
  seems this implementation is only used when the extension "Oracle Report Builder" is installed (huh?)
* QueryWizard.leaveStep 
  QueryWizard makes no use of READ_ONLY property in sort step

planed solution:
* remove exclusion in SortingComponent.getSortFieldNames()
* remove hack in ReportBuilderImplementation
Comment 8 j.nitschke 2014-04-02 22:01:02 UTC
Created attachment 83065 [details]
remove READ_ONLY check and workaround for missing fields

patch tested on linux with trunk
works without Oracle Report Builder
also seems to work with Oracle Report Builder but this extension is very unstable on my machine (ORB does not support 4.x according to website)

this will also fix Issue 122604 and Issue 122605

don't know why this exception was made in first place, but couldn't find any other affected code beside report wizard
Comment 9 Oliver-Rainer Wittmann 2014-04-03 08:18:49 UTC
I volunteer to review the provided patch on Windows.
But I will not have the time resources this week -  I think I will have a look next week.