Commit 4b1daefe authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when caching make sure we have new db session

parent 1aba71f5
Pipeline #28228 failed with stage
in 11 minutes and 5 seconds
......@@ -25,8 +25,10 @@ minerva (15.0.0~beta.5) unstable; urgency=medium
notes (#1287)
* Bug fix: import from GPML introduces space between inhibition and process
(#1270)
* Bug fix: map cantaining kinetic equations exported to CellDesigner was not
* Bug fix: map containing kinetic equations exported to CellDesigner was not
a valid SBML file (#1271)
* Bug fix: search for drugs for in target element in submap did not work after
uploading map (#1285, #1288)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 2 Jun 2020 16:00:00 +0200
......
......@@ -389,7 +389,6 @@ public class ProjectService implements IProjectService {
}
logger.info("Project " + project.getProjectId() + " created successfully.");
modelService.getLastModelByProjectId(project.getProjectId());
} catch (PersistenceException e) {
outOfMemoryBuffer = null;
logger.error("Problem with database", e);
......@@ -420,6 +419,19 @@ public class ProjectService implements IProjectService {
problems.add(t);
waitForInitialData.countDown();
}
try {
if (params.isAsync()) {
// because we are running this in separate thread we need to open a
// new session for db connection
dbUtils.createSessionForCurrentThread();
}
modelService.getLastModelByProjectId(params.getProjectId());
} finally {
if (params.isAsync()) {
// close the transaction for this thread
dbUtils.closeSessionForCurrentThread();
}
}
}
});
......
......@@ -243,6 +243,7 @@ abstract public class ControllerIntegrationTest {
submap.setTileSize(256);
submap.setWidth(100);
submap.setHeight(100);
submap.addElement(createProtein());
ModelSubmodelConnection submodelConnection = new ModelSubmodelConnection(submap, SubmodelType.UNKNOWN);
map.addSubmodel(submodelConnection);
......@@ -253,8 +254,10 @@ abstract public class ControllerIntegrationTest {
return project;
}
int counter = 1;
private GenericProtein createProtein() {
GenericProtein element = new GenericProtein("p1");
GenericProtein element = new GenericProtein("p"+(counter++));
element.setWidth(100.0);
element.setHeight(20.0);
element.setX(10);
......
......@@ -16,6 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.user.ConfigurationElementType;
import lcsb.mapviewer.services.interfaces.IConfigurationService;
......@@ -74,6 +75,20 @@ public class DrugControllerIntegrationTest extends ControllerIntegrationTest {
.andExpect(status().isNotFound());
}
@Test
public void testSearchDrugsByTargetInSubmap() throws Exception {
Project project = createProject("test");
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
int submapId = project.getModels().iterator().next().getSubmodels().iterator().next().getSubmodel().getElements()
.iterator().next().getId();
RequestBuilder request = get("/projects/" + project.getProjectId() + "/drugs:search?target=ALIAS:" + submapId)
.session(session);
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful());
}
@Test
public void testGetSuggestedList() throws Exception {
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
......
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