Commit 6776cd9e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fetching gene variants returned 500

parent 8ff3c1e0
...@@ -11,6 +11,8 @@ minerva (16.0.0~alpha.2) stable; urgency=medium ...@@ -11,6 +11,8 @@ minerva (16.0.0~alpha.2) stable; urgency=medium
their lines (#1471) their lines (#1471)
* Bug fix: when selecting drug in the alias window the input text is updated * Bug fix: when selecting drug in the alias window the input text is updated
(#1365) (#1365)
* Bug fix: there was no possibility to see gene variants
(regression 16.0.0~alpha.1)
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 26 Mar 2021 10:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 26 Mar 2021 10:00:00 +0200
......
This diff is collapsed.
...@@ -7,6 +7,8 @@ import javax.persistence.*; ...@@ -7,6 +7,8 @@ import javax.persistence.*;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.exception.NotImplementedException;
/** /**
...@@ -72,6 +74,7 @@ public class GeneVariant implements Serializable { ...@@ -72,6 +74,7 @@ public class GeneVariant implements Serializable {
*/ */
private String variantIdentifier; private String variantIdentifier;
@JsonIgnore
@ManyToOne @ManyToOne
private GeneVariantDataOverlayEntry dataOverlayEntry; private GeneVariantDataOverlayEntry dataOverlayEntry;
......
...@@ -7,6 +7,7 @@ import java.util.stream.Collectors; ...@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.hibernate.Hibernate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -431,6 +432,7 @@ public class OverlayRestImpl extends BaseRestImpl { ...@@ -431,6 +432,7 @@ public class OverlayRestImpl extends BaseRestImpl {
case "genevariations": case "genevariations":
if (overlayEntry instanceof GeneVariantDataOverlayEntry) { if (overlayEntry instanceof GeneVariantDataOverlayEntry) {
value = ((GeneVariantDataOverlayEntry) overlayEntry).getGeneVariants(); value = ((GeneVariantDataOverlayEntry) overlayEntry).getGeneVariants();
Hibernate.initialize(((GeneVariantDataOverlayEntry) overlayEntry).getGeneVariants());
} else { } else {
value = new Object[] {}; value = new Object[] {};
} }
......
...@@ -42,6 +42,7 @@ import org.springframework.web.context.WebApplicationContext; ...@@ -42,6 +42,7 @@ import org.springframework.web.context.WebApplicationContext;
import lcsb.mapviewer.api.projects.chemicals.ChemicalRestImpl; import lcsb.mapviewer.api.projects.chemicals.ChemicalRestImpl;
import lcsb.mapviewer.common.*; import lcsb.mapviewer.common.*;
import lcsb.mapviewer.converter.zip.ZipEntryFileFactory;
import lcsb.mapviewer.model.*; import lcsb.mapviewer.model.*;
import lcsb.mapviewer.model.cache.UploadedFileEntry; import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.graphics.*; import lcsb.mapviewer.model.graphics.*;
...@@ -560,6 +561,11 @@ abstract public class ControllerIntegrationTest { ...@@ -560,6 +561,11 @@ abstract public class ControllerIntegrationTest {
} }
protected DataOverlay createOverlay(Project project, User admin, String content) throws Exception { protected DataOverlay createOverlay(Project project, User admin, String content) throws Exception {
return createOverlay(project, admin, content, DataOverlayType.GENERIC);
}
protected DataOverlay createOverlay(Project project, User admin, String content, DataOverlayType type)
throws Exception {
UploadedFileEntry file = new UploadedFileEntry(); UploadedFileEntry file = new UploadedFileEntry();
file.setFileContent(content.getBytes()); file.setFileContent(content.getBytes());
file.setLength(content.getBytes().length); file.setLength(content.getBytes().length);
...@@ -568,7 +574,7 @@ abstract public class ControllerIntegrationTest { ...@@ -568,7 +574,7 @@ abstract public class ControllerIntegrationTest {
ColorSchemaReader reader = new ColorSchemaReader(); ColorSchemaReader reader = new ColorSchemaReader();
DataOverlay overlay = new DataOverlay(); DataOverlay overlay = new DataOverlay();
overlay.setColorSchemaType(DataOverlayType.GENERIC); overlay.setColorSchemaType(type);
overlay.setInputData(file); overlay.setInputData(file);
overlay.setProject(project); overlay.setProject(project);
overlay.setName("test title"); overlay.setName("test title");
...@@ -576,6 +582,7 @@ abstract public class ControllerIntegrationTest { ...@@ -576,6 +582,7 @@ abstract public class ControllerIntegrationTest {
overlay.setCreator(admin); overlay.setCreator(admin);
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put(TextFileUtils.COLUMN_COUNT_PARAM, "2"); headers.put(TextFileUtils.COLUMN_COUNT_PARAM, "2");
headers.put(ZipEntryFileFactory.LAYOUT_HEADER_PARAM_TYPE, type.toString());
overlay.addEntries(reader.readColorSchema(new ByteArrayInputStream(content.getBytes()), headers)); overlay.addEntries(reader.readColorSchema(new ByteArrayInputStream(content.getBytes()), headers));
dataOverlayDao.add(overlay); dataOverlayDao.add(overlay);
return overlay; return overlay;
......
...@@ -1483,7 +1483,6 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest ...@@ -1483,7 +1483,6 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
} }
@Test @Test
public void testRemoveUserOverlayAsAnonymous() throws Exception { public void testRemoveUserOverlayAsAnonymous() throws Exception {
DataOverlay overlay = createOverlayInSeparateThread(TEST_PROJECT, user); DataOverlay overlay = createOverlayInSeparateThread(TEST_PROJECT, user);
RequestBuilder request = delete("/projects/" + TEST_PROJECT + "/overlays/" + overlay.getId()); RequestBuilder request = delete("/projects/" + TEST_PROJECT + "/overlays/" + overlay.getId());
...@@ -1492,4 +1491,37 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest ...@@ -1492,4 +1491,37 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
.andExpect(status().isForbidden()); .andExpect(status().isForbidden());
} }
@Test
public void testFetchGeneticDataOverlayData() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
DataOverlay overlay = callInSeparateThread(() -> {
try {
return createOverlay(project, user, "#TYPE=GENETIC_VARIANT\n" +
"#GENOME_TYPE=UCSC\n" +
"#GENOME_VERSION=xenLae2\n" +
"position\toriginal_dna\talternative_dna\tgene_name\tdescription\tcolor\tcontig\n" +
"10146\tAC\tA\tGSTA4\tupstream\t#ff0000\tchr1", DataOverlayType.GENETIC_VARIANT);
} catch (Exception e) {
e.printStackTrace();
return null;
}
});
assertNotNull(overlay);
for (Element element_iterator : map.getElements()) {
if (element_iterator.getName().equals("GSTA4")) {
element = element_iterator;
}
}
assertEquals(element.getName(), "GSTA4");
RequestBuilder request = get(
"/projects/{projectId}/overlays/{overlayId}/models/{mapId}/bioEntities/elements/{elementId}/",
TEST_PROJECT, overlay.getId(), map.getId(), element.getId())
.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