Commit 33e4a35c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '917-overlay-type' into 'devel_13.2.x'

Resolve "MINERVANET - Error Report 106"

See merge request !921
parents a1e42577 52d9ef3c
minerva (13.2.0) stable; urgency=medium
* Bug fix:search by drugs didn't check synonyms in chembl database
* Bug fix: search by drugs didn't check synonyms in chembl database
* Bug fix: verification of overlay type added (#917)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 21 Aug 2019 17:00:00 +0200
......
......@@ -163,6 +163,9 @@ AddOverlayDialog.prototype.processFile = function (file) {
descriptionInput.value = overlay.getDescription();
}
if (overlay.getType() !== undefined) {
if ($("option[value='" + overlay.getType() + "']", typeSelect).length === 0) {
GuiConnector.warn("Invalid type: " + overlay.getType());
}
typeSelect.val(overlay.getType());
}
if (overlayParser.containsMixedNewLineCharacters(evt.target.result)) {
......
......@@ -104,7 +104,14 @@ public class ColorSchemaReader {
return readGenericColorSchema(colorInputStream);
}
} else {
ColorSchemaType type = ColorSchemaType.valueOf(params.get(ZipEntryFileFactory.LAYOUT_HEADER_PARAM_TYPE));
ColorSchemaType type = null;
try {
type = ColorSchemaType.valueOf(params.get(ZipEntryFileFactory.LAYOUT_HEADER_PARAM_TYPE));
} catch (IllegalArgumentException e) {
String options = StringUtils.join(ColorSchemaType.values(), ", ");
throw new InvalidColorSchemaException("Invalid overlay type: "
+ params.get(ZipEntryFileFactory.LAYOUT_HEADER_PARAM_TYPE) + ". Allowed options: " + options);
}
if (type == null) {
logger.warn("Unknown type of layout file: " + params.get(ZipEntryFileFactory.LAYOUT_HEADER_PARAM_TYPE));
return readGenericColorSchema(colorInputStream);
......
......@@ -480,5 +480,14 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
}
}
@Test(expected = InvalidColorSchemaException.class)
public void testReadColorSchemaWithInvalidType() throws Exception {
FileInputStream fis = new FileInputStream("testFiles/coloring/invalidType.txt");
FileInputStream fis2 = new FileInputStream("testFiles/coloring/invalidType.txt");
ColorSchemaReader reader = new ColorSchemaReader();
reader.readColorSchema(fis, TextFileUtils.getHeaderParametersFromFile(fis2));
}
}
#TYPE=gen
value identifier Chebi
-0,943978048 HGNC:11138
-0,941309505 CHEBI:15377
1 CHEBI:15376
Supports Markdown
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