From d59443af63faefd0ae85621189f4547c9479711e Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Tue, 8 Apr 2025 09:30:13 +0200 Subject: [PATCH] fix test issues --- .../services/impl/ReactionService.java | 39 ++++++++++--------- .../lcsb/mapviewer/web/api/NewApiDocs.java | 12 ++++++ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ReactionService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ReactionService.java index 0865c6ff84..1d312720ef 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ReactionService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ReactionService.java @@ -1,28 +1,28 @@ package lcsb.mapviewer.services.impl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import org.hibernate.Hibernate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.reaction.ReactionNode; import lcsb.mapviewer.persist.dao.map.ReactionDao; import lcsb.mapviewer.persist.dao.map.ReactionProperty; import lcsb.mapviewer.services.ObjectNotFoundException; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.IReactionService; +import org.hibernate.Hibernate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; @Transactional @Service @@ -43,8 +43,8 @@ public class ReactionService implements IReactionService { public Reaction getReactionById(final String projectId, final int mapId, final int elementId) throws ObjectNotFoundException { ModelData map = modelService.getModelByMapId(projectId, mapId); Map<ReactionProperty, Object> filter = new HashMap<>(); - filter.put(ReactionProperty.MAP, Arrays.asList(map)); - filter.put(ReactionProperty.ID, Arrays.asList(elementId)); + filter.put(ReactionProperty.MAP, Collections.singletonList(map)); + filter.put(ReactionProperty.ID, Collections.singletonList(elementId)); Page<Reaction> page = reactionDao.getAll(filter, Pageable.unpaged()); if (page.getNumberOfElements() > 0) { return page.getContent().get(0); @@ -54,7 +54,7 @@ public class ReactionService implements IReactionService { @Override public List<Reaction> getReactionById(final String projectId, final String mapId, final Set<Integer> ids, - final Set<Integer> participantIds) throws ObjectNotFoundException { + final Set<Integer> participantIds) throws ObjectNotFoundException { List<ModelData> maps = modelService.getModelsByMapId(projectId, mapId); Map<ReactionProperty, Object> filter = new HashMap<>(); filter.put(ReactionProperty.MAP, maps); @@ -87,6 +87,9 @@ public class ReactionService implements IReactionService { if (initializeLazy) { for (final Reaction reaction : result) { Hibernate.initialize(reaction.getModelData()); + for (ReactionNode node : reaction.getReactionNodes()) { + Hibernate.initialize(node.getElement()); + } } } return result; diff --git a/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java b/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java index a0d15eec7c..e07f84d8f8 100644 --- a/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java +++ b/web/src/test/java/lcsb/mapviewer/web/api/NewApiDocs.java @@ -991,6 +991,10 @@ public class NewApiDocs { .description("identifier of the element for this product") .type(JsonFieldType.NUMBER) .optional(), + fieldWithPath(prefix + "products[].elementId") + .description("element identifier of the element for this product") + .type(JsonFieldType.STRING) + .optional(), fieldWithPath(prefix + "products[].stoichiometry") .description("SBML stoichiometry") .type(JsonFieldType.NUMBER) @@ -1012,6 +1016,10 @@ public class NewApiDocs { .description("identifier of the element for this reactant") .type(JsonFieldType.NUMBER) .optional(), + fieldWithPath(prefix + "reactants[].elementId") + .description("element identifier of the element for this reactant") + .type(JsonFieldType.STRING) + .optional(), fieldWithPath(prefix + "reactants[].stoichiometry") .description("SBML stoichiometry") .type(JsonFieldType.NUMBER) @@ -1033,6 +1041,10 @@ public class NewApiDocs { .description("identifier of the element for this modifier") .type(JsonFieldType.NUMBER) .optional(), + fieldWithPath(prefix + "modifiers[].elementId") + .description("element identifier of the element for this modifier") + .type(JsonFieldType.STRING) + .optional(), fieldWithPath(prefix + "modifiers[].stoichiometry") .description("SBML stoichiometry") .type(JsonFieldType.NUMBER) -- GitLab