Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
c2e88a2f
Commit
c2e88a2f
authored
Mar 11, 2019
by
Piotr Gawron
Browse files
identifier column name contains from 'identifier_' string and name of the enum field
parent
374f6a98
Changes
3
Hide whitespace changes
Inline
Side-by-side
service/src/main/java/lcsb/mapviewer/services/utils/ColorSchemaReader.java
View file @
c2e88a2f
...
...
@@ -501,8 +501,10 @@ public class ColorSchemaReader {
if
(
nameColumn
==
null
&&
identifierColumn
==
null
&&
customIdentifiers
.
size
()
==
0
&&
elementIdentifierColumn
==
null
)
{
throw
new
InvalidColorSchemaException
(
"One of these columns is obligatory: "
+
ColorSchemaColumn
.
NAME
.
getColumnName
()
+
","
+
ColorSchemaColumn
.
IDENTIFIER
.
getColumnName
()
+
","
+
ColorSchemaColumn
.
ELEMENT_IDENTIFIER
.
getColumnName
());
throw
new
InvalidColorSchemaException
(
"One of these columns is obligatory: "
+
ColorSchemaColumn
.
NAME
.
getColumnName
()
+
","
+
ColorSchemaColumn
.
IDENTIFIER
.
getColumnName
()
+
","
+
ColorSchemaColumn
.
ELEMENT_IDENTIFIER
.
getColumnName
());
}
if
(
valueColumn
==
null
&&
colorColumn
==
null
)
{
...
...
@@ -680,16 +682,18 @@ public class ColorSchemaReader {
*/
public
void
parseColumns
(
String
[]
columns
,
Map
<
ColorSchemaColumn
,
Integer
>
schemaColumns
,
List
<
Pair
<
MiriamType
,
Integer
>>
customIdentifiers
,
ColorSchemaType
type
)
throws
InvalidColorSchemaException
{
Map
<
String
,
MiriamType
>
acceptableIdentifiers
=
new
HashMap
<
String
,
MiriamType
>();
Map
<
String
,
MiriamType
>
acceptableIdentifiers
=
new
HashMap
<>();
Map
<
String
,
MiriamType
>
deprecatedIdentifiers
=
new
HashMap
<>();
for
(
MiriamType
miriamType
:
MiriamType
.
values
())
{
acceptableIdentifiers
.
put
(
miriamType
.
getCommonName
().
toLowerCase
(),
miriamType
);
acceptableIdentifiers
.
put
(
"identifier_"
+
miriamType
.
name
().
toLowerCase
(),
miriamType
);
deprecatedIdentifiers
.
put
(
miriamType
.
getCommonName
().
toLowerCase
(),
miriamType
);
}
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
boolean
found
=
false
;
for
(
ColorSchemaColumn
schemaColumn
:
ColorSchemaColumn
.
values
())
{
if
((
columns
[
i
].
trim
().
equalsIgnoreCase
(
schemaColumn
.
getColumnName
())
||
columns
[
i
].
trim
().
equalsIgnoreCase
(
schemaColumn
.
getDepractedColumnName
()))
columns
[
i
].
trim
().
equalsIgnoreCase
(
schemaColumn
.
getDepractedColumnName
()))
&&
schemaColumn
.
getTypes
().
contains
(
type
))
{
schemaColumns
.
put
(
schemaColumn
,
i
);
found
=
true
;
...
...
@@ -698,6 +702,8 @@ public class ColorSchemaReader {
if
(!
found
)
{
if
(
acceptableIdentifiers
.
keySet
().
contains
(
columns
[
i
].
toLowerCase
()))
{
customIdentifiers
.
add
(
new
Pair
<>(
acceptableIdentifiers
.
get
(
columns
[
i
].
toLowerCase
()),
i
));
}
else
if
(
deprecatedIdentifiers
.
keySet
().
contains
(
columns
[
i
].
toLowerCase
()))
{
customIdentifiers
.
add
(
new
Pair
<>(
deprecatedIdentifiers
.
get
(
columns
[
i
].
toLowerCase
()),
i
));
}
else
{
String
columnNames
=
""
;
for
(
ColorSchemaColumn
schemaColumn
:
ColorSchemaColumn
.
values
())
{
...
...
service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java
View file @
c2e88a2f
...
...
@@ -412,6 +412,25 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions {
}
}
@Test
public
void
testSchemasWithIdSnakeCase
()
throws
Exception
{
try
{
ColorSchemaReader
reader
=
new
ColorSchemaReader
();
Collection
<
ColorSchema
>
schemas
=
reader
.
readColorSchema
(
"testFiles/coloring/schema_with_identifiers_in_snake_case.txt"
);
for
(
ColorSchema
colorSchema
:
schemas
)
{
for
(
MiriamData
md
:
colorSchema
.
getMiriamData
())
{
assertNotNull
(
md
.
getResource
());
assertFalse
(
md
.
getResource
().
isEmpty
());
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testSchemasWithEmptyNameAndId
()
throws
Exception
{
try
{
...
...
service/testFiles/coloring/schema_with_identifiers_in_snake_case.txt
0 → 100644
View file @
c2e88a2f
name identifier_Entrez identifier_Chebi identifier_go value
120892 1
CHEBI:26523 1
GO:0036489 1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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