Commit 014b789a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

search results must be eagerly initialized

parent 8165d984
......@@ -112,13 +112,13 @@ public class PublicationsController extends BaseController {
elementSearch.put(ElementProperty.MAP, models);
List<BioEntity> bioEntities = new ArrayList<>();
bioEntities.addAll(elementService.getElementsByFilter(elementSearch));
bioEntities.addAll(elementService.getElementsByFilter(elementSearch, true));
Map<ReactionProperty, List<? extends Object>> reactionSearch = new HashMap<>();
reactionSearch.put(ReactionProperty.ANNOTATION, mds);
reactionSearch.put(ReactionProperty.MAP, models);
bioEntities.addAll(reactionService.getReactionsByFilter(reactionSearch).getContent());
bioEntities.addAll(reactionService.getReactionsByFilter(reactionSearch, true).getContent());
List<ArticleDTO> resultList = new ArrayList<>();
......
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.services.impl;
import java.util.*;
import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -70,8 +71,14 @@ public class ReactionService implements IReactionService {
}
@Override
public Page<Reaction> getReactionsByFilter(Map<ReactionProperty, List<? extends Object>> reactionSearch) {
return reactionDao.getByFilter(Pageable.unpaged(), reactionSearch);
public Page<Reaction> getReactionsByFilter(Map<ReactionProperty, List<? extends Object>> reactionSearch, boolean initializeLazy) {
Page<Reaction> result = reactionDao.getByFilter(Pageable.unpaged(), reactionSearch);
if (initializeLazy) {
for (Reaction reaction : result) {
Hibernate.initialize(reaction.getModelData());
}
}
return result;
}
}
......@@ -23,6 +23,5 @@ public interface IReactionService {
Map<MiriamType, Integer> getAnnotationStatistics(String projectId, String mapId) throws QueryException;
Page<Reaction> getReactionsByFilter(Map<ReactionProperty, List<? extends Object>> reactionSearch);
Page<Reaction> getReactionsByFilter(Map<ReactionProperty, List<? extends Object>> reactionSearch, boolean initializeLazy);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment