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

identifier column name contains from 'identifier_' string and name of the enum field

parent 374f6a98
......@@ -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,9 +682,11 @@ 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++) {
......@@ -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()) {
......
......@@ -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 {
......
name identifier_Entrez identifier_Chebi identifier_go value
120892 1
CHEBI:26523 1
GO:0036489 1
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