Skip to content

Commit

Permalink
EDA/ERS: Modified API to address multi-level grouping issues
Browse files Browse the repository at this point in the history
- All previous levels of groupings should be checked for different IDs,
 now passing groupings array and level to make this possible
- Note: Default Grouping::Advance() implementation does not address the issue
- Should eventually get rid of the 'fieldLink' and other members added for specific
  types of reports as it is all overly complicated, and be addressed much simpler
  with proper queries.
  • Loading branch information
jerstlouis committed Dec 22, 2015
1 parent de4adf5 commit 7f568fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions eda/libeda/src/ers.ec
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public:
break;
case groupStart:
lastDetail = null;
if(report.Advance(report.groupings[level], level ? report.groupings[level - 1].groupId : 0, &dontAdvance))
if(report.Advance(level, &dontAdvance))
{
report.ExecuteRowData(level);
if(report.groupings[level].header)
Expand Down Expand Up @@ -349,7 +349,7 @@ public:
renderAction = groupStart;
break;
case actualRows:
if(report.Advance(report.groupings[level], level ? report.groupings[level - 1].groupId : 0, &dontAdvance))
if(report.Advance(level, &dontAdvance))
{
Detail detail;
if(AddDetailToPage(destination, (detail = eInstance_New(report.rowDetail))))
Expand Down Expand Up @@ -749,9 +749,10 @@ public:
return false;
}

virtual bool Advance(Id linkId, bool *dontAdvance)
virtual bool Advance(Array<Grouping> groupings, int level, bool *dontAdvance)
{
bool result;
Id linkId = level ? groupings[level - 1].groupId : 0;
IdList reverseIdList = null;

if(dontAdvance && *dontAdvance)
Expand Down Expand Up @@ -800,6 +801,7 @@ public:
}
else if(fieldLink)
{
// WARNING: This implementation may not work properly with more than 1 level of grouping
Id id = 0;
row.GetData(fieldLink, id);
if(id != linkId)
Expand Down Expand Up @@ -882,9 +884,9 @@ public:

subclass(Detail) rowDetail;

virtual bool Advance(Grouping grouping, Id linkId, bool *dontAdvance)
virtual bool Advance(int level, bool *dontAdvance)
{
return grouping.Advance(linkId, dontAdvance);
return groupings[level].Advance(groupings, level, dontAdvance);
}

virtual bool ExecuteData(Database db)
Expand Down
2 changes: 1 addition & 1 deletion samples/db/MovieCollection/borrowerReport.ec
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class BorrowerGrouping : Grouping
bool ShouldSkip()
{
RowBorrowers r = (RowBorrowers)row;
int id = r.id;
Id id = r.id;
return !rowMovies.Find(dbfield("Movies", borrower), middle, nil, id);
}
}
Expand Down

0 comments on commit 7f568fe

Please sign in to comment.