Performance improvement
When calculating the load ratio of each resource, a new transaction is being created for each one. Now one transaction is reused for everyone, which gives a good performance boost when loading the `Advanced search`.
This commit is contained in:
parent
18b187fad8
commit
a109c50984
2 changed files with 19 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ package org.libreplan.web.resources.search;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.resources.daos.IResourceLoadRatiosCalculator;
|
||||
import org.libreplan.business.resources.daos.IResourcesSearcher;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
|
|
@ -42,6 +43,9 @@ public abstract class AllocationSelectorController extends
|
|||
// injected by name
|
||||
protected IResourcesSearcher resourcesSearcher;
|
||||
|
||||
// injected by name
|
||||
protected IAdHocTransactionService adHocTransactionService;
|
||||
|
||||
// injected by name
|
||||
protected IResourceLoadRatiosCalculator resourceLoadRatiosCalculator;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import java.util.Set;
|
|||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.common.IOnTransaction;
|
||||
import org.libreplan.business.resources.daos.IResourceLoadRatiosCalculator.ILoadRatiosDataType;
|
||||
import org.libreplan.business.resources.daos.IResourcesSearcher.IResourcesQuery;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
|
|
@ -394,14 +395,25 @@ public class NewAllocationSelectorController extends
|
|||
public void clearAll() {
|
||||
}
|
||||
|
||||
public void open(LocalDate start, LocalDate end) {
|
||||
public void open(final LocalDate start, final LocalDate end) {
|
||||
setStartFilteringDate(start);
|
||||
setEndFilteringDate(end);
|
||||
|
||||
refreshListBoxResources();
|
||||
clearSelection(listBoxResources);
|
||||
clearSelection(criterionsTree);
|
||||
criterionsTree.setModel(getCriterions());
|
||||
|
||||
|
||||
adHocTransactionService
|
||||
.runOnReadOnlyTransaction(new IOnTransaction<Void>() {
|
||||
@Override
|
||||
public Void execute() {
|
||||
refreshListBoxResources();
|
||||
criterionsTree.setModel(getCriterions());
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doInitialSelection();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue