Commit dcf2b8ee authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1132-transcription-site-color' into 'devel_14.0.x'

Resolve "Transcription Site colour is not white black in Empty view"

See merge request !1069
parents 363f7008 03cf523d
Pipeline #21436 passed with stage
in 15 minutes and 17 seconds
......@@ -11,6 +11,9 @@ minerva (14.0.9) stable; urgency=medium
* Bug fix: when data overlay name in zip uploaded zip file is not present the
name of a file is used as overlay name (#1065)
* Bug fix: uploading empty data overlay resulted in an error (#1123)
* Bug fix: exporting map with glyphs crashed (#1130)
* Bug fix: transcription factor on black&white gene are drawn in black
(#1132)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 3 Feb 2020 15:00:00 +0200
......
......@@ -620,6 +620,9 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
} else {
color = Color.BLACK;
}
if (transcriptionSite.getSpecies() != null && transcriptionSite.getSpecies().getColor().equals(Color.WHITE)) {
color = Color.BLACK;
}
double y = transcriptionSite.getPosition().getY();
double x = transcriptionSite.getPosition().getX();
PolylineData line = new PolylineData();
......
......@@ -69,6 +69,10 @@ public class Glyph implements Serializable {
public Glyph(Glyph original) {
// we should reference to the same file
setFile(original.getFile());
if (original.getFile() != null) {
// make sure that the content is available
original.getFile().getFileContent();
}
}
public UploadedFileEntry getFile() {
......
......@@ -16,6 +16,7 @@ import org.junit.runners.Suite.SuiteClasses;
FileControllerIntegrationTestWithoutTransaction.class,
FunctionControllerIntegrationTest.class,
MapControllerIntegrationTest.class,
MapControllerIntegrationTestWithoutTransaction.class,
MiRnaControllerIntegrationTest.class,
OverlayControllerIntegrationTest.class,
OverlayControllerIntegrationTestWithoutTransaction.class,
......
......@@ -4,6 +4,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.awt.geom.Point2D;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
......@@ -34,6 +37,7 @@ import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.layout.ColorSchemaType;
import lcsb.mapviewer.model.map.layout.Layout;
import lcsb.mapviewer.model.map.layout.graphics.Glyph;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
......@@ -189,6 +193,33 @@ abstract public class ControllerIntegrationTest {
return user;
}
protected Project createProjectWithGlyph(String projectId) throws IOException {
User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN);
Project project = new Project(projectId);
project.setOwner(admin);
UploadedFileEntry file = createFile(Files.readAllBytes(Paths.get("./src/test/resources/empty.png")), admin);
ModelData map = new ModelData();
map.setTileSize(256);
map.setWidth(100);
map.setHeight(100);
Element element = new GenericProtein("p1");
element.setWidth(100.0);
element.setHeight(20.0);
element.setX(10);
element.setX(20);
element.setZ(2);
Glyph g = new Glyph();
g.setFile(file);
element.setGlyph(g);
map.addElement(element);
project.addModel(map);
project.addGlyph(g);
projectDao.add(project);
return project;
}
protected Project createProject(String projectId) {
Project project = new Project(projectId);
project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
......
package lcsb.mapviewer.web;
import static org.junit.Assert.assertNotNull;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.IOException;
import java.util.function.Supplier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.RequestBuilder;
import lcsb.mapviewer.converter.graphics.PngImageGenerator;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.services.interfaces.IModelService;
@RunWith(SpringJUnit4ClassRunner.class)
public class MapControllerIntegrationTestWithoutTransaction extends ControllerIntegrationTest {
private static final String TEST_PROJECT = "test_project";
Logger logger = LogManager.getLogger();
private Project project;
private ModelData map;
@Autowired
private IModelService modelService;
@Before
public void setup() throws Exception {
callInSeparateThread(new Supplier<Void>() {
@Override
public Void get() {
try {
project = createProjectWithGlyph(TEST_PROJECT);
map = project.getModels().iterator().next();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
});
assertNotNull(project);
modelService.removeModelFromCache(map);
}
@After
public void tearDown() throws Exception {
removeProjectInSeparateThread(project);
}
@Test
public void testDownloadImageWithGlyphs() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
//fetch the map (but don't do anything with glyphs)
RequestBuilder request2 = get("/projects/" + TEST_PROJECT + "/models/")
.session(session);
mockMvc.perform(request2)
.andExpect(status().is2xxSuccessful());
RequestBuilder request = get("/projects/" + TEST_PROJECT + "/models/" + map.getId() + ":downloadImage?" +
"handlerClass=" + PngImageGenerator.class.getCanonicalName())
.session(session);
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful());
}
}
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