groups.put(group.getObjectID(), rgroup);
final GroupBody body = rgroup.getBody();
if (body instanceof SubGroupBody)
{
final SubGroupBody subGroupBody = (SubGroupBody) body;
group = subGroupBody.getGroup();
}
else
{
group = null;
}
}
final RelationalGroup[] resultGroups = new RelationalGroup[newEntries.length];
for (int i = 0; i < newEntries.length; i++)
{
final GroupDataEntry o = newEntries[i];
final RelationalGroup sourceGroup = groups.get(o.getInstanceID());
if (sourceGroup == null)
{
resultGroups[i] = new RelationalGroup();
}
else
{
resultGroups[i] = sourceGroup;
}
resultGroups[i].setName(o.getName());
resultGroups[i].setFieldsArray(o.getFields());
}
final GroupBody innermostBody;
if (innermostGroup == null)
{
innermostBody = new SubGroupBody(abstractReportDefinition.getRootGroup());
}
else
{
innermostBody = innermostGroup.getBody();
}
if (resultGroups.length > 0)
{
for (int i = 0; i < resultGroups.length; i++)
{
final RelationalGroup resultGroup = resultGroups[i];
if (i == 0)
{
abstractReportDefinition.setRootGroup(resultGroup);
}
else
{
final RelationalGroup prevGroup = resultGroups[i - 1];
final GroupBody body = prevGroup.getBody();
if (body instanceof SubGroupBody)
{
final SubGroupBody sgb = (SubGroupBody) body;
sgb.setGroup(resultGroup);
}
else
{
final SubGroupBody sgb = new SubGroupBody();
sgb.setGroup(resultGroup);
prevGroup.setBody(sgb);
}
}
}