public Page<ProjectHistory> fetchPage(Page<ProjectHistory> page, long projectId) {
page = projectHistoryDao.fetchByProjectId(page, projectId);
// TODO performance tuning
for (ProjectHistory history : page.getResults()) {
Project project = projectDao.select(history.getProjectId());
ProjectUser projectUser = projectUserDao.selectWithProject(history.getCreatedById());
history.setProject(project);
history.setCreatedBy(projectUser);
//
List<ProjectHistory> children = projectHistoryDao.selectByParentId(history.getId());
for (ProjectHistory child : children) {
//
Project childProject = projectDao.select(child.getProjectId());
ProjectUser childProjectUser = projectUserDao.selectWithProject(child.getCreatedById());
child.setProject(childProject);
child.setCreatedBy(childProjectUser);
}
history.setChildren(children);