Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Gitlab will go into maintenance Friday 3rd February from 9:00 to 10:00
Open sidebar
minerva
core
Commits
0ce36e62
Commit
0ce36e62
authored
Jul 26, 2019
by
Piotr Gawron
Browse files
sometimes there was an error when looking for deprecated columns
parent
05f881c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java
View file @
0ce36e62
...
...
@@ -820,13 +820,28 @@ public class ColorSchemaReader {
}
String
[]
columns
=
line
.
split
(
"\t"
);
if
(
columns
.
length
>
1
)
{
ColorSchemaType
type
=
overlay
.
getColorSchemaType
();
if
(
type
==
null
)
{
Map
<
String
,
String
>
params
=
TextFileUtils
.
getHeaderParametersFromFile
(
new
ByteArrayInputStream
(
overlay
.
getInputData
().
getFileContent
()));
String
typeString
=
params
.
get
(
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
);
if
(
typeString
!=
null
)
{
type
=
ColorSchemaType
.
valueOf
(
typeString
);
}
else
{
logger
.
warn
(
"Undefined color schema type for overlay: "
+
overlay
.
getId
());
type
=
ColorSchemaType
.
GENERIC
;
}
}
Map
<
ColorSchemaColumn
,
Integer
>
schemaColumns
=
new
HashMap
<>();
parseColumns
(
columns
,
schemaColumns
,
ColorSchemaType
.
GENERIC
);
parseColumns
(
columns
,
schemaColumns
,
type
);
for
(
ColorSchemaColumn
column
:
schemaColumns
.
keySet
())
{
try
{
Field
f
=
ColorSchemaColumn
.
class
.
getField
(
column
.
name
());
if
(
column
.
getDepractedColumnName
()
!=
null
||
f
.
isAnnotationPresent
(
Deprecated
.
class
))
{
if
(
f
.
isAnnotationPresent
(
Deprecated
.
class
))
{
result
.
add
(
column
);
}
else
if
(
column
.
getDepractedColumnName
()
!=
null
&&
column
.
getDepractedColumnName
().
equalsIgnoreCase
(
columns
[
schemaColumns
.
get
(
column
)]))
{
result
.
add
(
column
);
}
}
catch
(
NoSuchFieldException
|
SecurityException
e
)
{
...
...
service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java
View file @
0ce36e62
...
...
@@ -15,12 +15,14 @@ import org.junit.*;
import
lcsb.mapviewer.commands.ColorExtractor
;
import
lcsb.mapviewer.commands.ColorModelCommand
;
import
lcsb.mapviewer.common.TextFileUtils
;
import
lcsb.mapviewer.converter.zip.ZipEntryFileFactory
;
import
lcsb.mapviewer.model.cache.UploadedFileEntry
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.layout.*
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.services.ServiceTestFunctions
;
import
lcsb.mapviewer.services.utils.data.ColorSchemaColumn
;
public
class
ColorSchemaReaderTest
extends
ServiceTestFunctions
{
Logger
logger
=
LogManager
.
getLogger
(
ColorSchemaReaderTest
.
class
);
...
...
@@ -334,4 +336,35 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
overlay
.
setInputData
(
file
);
assertEquals
(
0
,
reader
.
getDeprecatedColumns
(
overlay
).
size
());
}
@Test
public
void
testGetDeprecatedColumnsForValidGeneticColumns
()
throws
Exception
{
Layout
overlay
=
new
Layout
();
overlay
.
setColorSchemaType
(
ColorSchemaType
.
GENETIC_VARIANT
);
UploadedFileEntry
file
=
new
UploadedFileEntry
();
file
.
setFileContent
((
ColorSchemaColumn
.
POSITION
.
name
()
+
"\tgene_name\n"
).
getBytes
(
"UTF-8"
));
overlay
.
setInputData
(
file
);
assertEquals
(
0
,
reader
.
getDeprecatedColumns
(
overlay
).
size
());
}
@Test
public
void
testGetDeprecatedColumnsForDeprecatedGeneticColumns
()
throws
Exception
{
Layout
overlay
=
new
Layout
();
overlay
.
setColorSchemaType
(
ColorSchemaType
.
GENETIC_VARIANT
);
UploadedFileEntry
file
=
new
UploadedFileEntry
();
file
.
setFileContent
((
ColorSchemaColumn
.
POSITION
.
name
()
+
"\tname\n"
).
getBytes
(
"UTF-8"
));
overlay
.
setInputData
(
file
);
assertEquals
(
1
,
reader
.
getDeprecatedColumns
(
overlay
).
size
());
}
@Test
public
void
testGetDeprecatedColumnsForOverlayWithHeader
()
throws
Exception
{
Layout
overlay
=
new
Layout
();
UploadedFileEntry
file
=
new
UploadedFileEntry
();
String
content
=
"#"
+
ZipEntryFileFactory
.
LAYOUT_HEADER_PARAM_TYPE
+
"="
+
ColorSchemaType
.
GENERIC
+
"\n"
+
ColorSchemaColumn
.
VALUE
.
name
()
+
"\tname\n"
;
file
.
setFileContent
((
content
).
getBytes
(
"UTF-8"
));
overlay
.
setInputData
(
file
);
assertEquals
(
0
,
reader
.
getDeprecatedColumns
(
overlay
).
size
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment