Skip to content
Snippets Groups Projects
Commit df998273 authored by srosse's avatar srosse
Browse files

OO-1735: use a hashmap which scale better with the number of courses

parent bf3f1359
No related branches found
No related tags found
No related merge requests found
......@@ -1108,6 +1108,7 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr
}
}
List<BGRepositoryEntryRelation> resources = businessGroupService.findRelationToRepositoryEntries(groupKeysWithRelations, 0, -1);
//find offers
List<Long> groupWithOfferKeys = new ArrayList<Long>(groups.size());
for(BusinessGroupView view:groups) {
......@@ -1131,6 +1132,7 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr
}
List<BGTableItem> items = new ArrayList<BGTableItem>();
Map<Long, BGTableItem> groupKeyToItems = new HashMap<>();
for(BusinessGroupView group:groups) {
Long oresKey = group.getResource().getKey();
List<PriceMethodBundle> accessMethods = null;
......@@ -1150,13 +1152,21 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr
markLink.setIconLeftCSS(marked ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
BGTableItem tableItem = new BGTableItem(group, markLink, marked, membership, allowLeave, allowDelete, accessMethods);
tableItem.setUnfilteredRelations(resources);
//tableItem.setUnfilteredRelations(resources);
items.add(tableItem);
markLink.setUserObject(tableItem);
if(group.getNumOfValidOffers() > 0l) {
addAccessLink(tableItem);
}
groupKeyToItems.put(group.getKey(), tableItem);
}
for(BGRepositoryEntryRelation relation:resources) {
BGTableItem tableItem = groupKeyToItems.get(relation.getGroupKey());
if(tableItem != null) {
tableItem.addRelation(relation);
}
}
groupTableModel.setObjects(items);
......
......@@ -216,19 +216,11 @@ public class BGTableItem {
return relations;
}
/**
* Give the item a list of relations, it found alone which are its own
* @param resources
*/
public void setUnfilteredRelations(List<BGRepositoryEntryRelation> resources) {
relations = new ArrayList<RepositoryEntryShort>(3);
for(BGRepositoryEntryRelation resource:resources) {
if(businessGroup.getKey().equals(resource.getGroupKey())) {
relations.add(new REShort(resource));
if(relations.size() >= 3) {
return;
}
}
public void addRelation(BGRepositoryEntryRelation resource) {
if(relations == null) {
relations = new ArrayList<RepositoryEntryShort>(3);
} else if(relations.size() < 3) {
relations.add(new REShort(resource));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment