Commit 374f6a98 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

default column names are lower cased enum names

parent 32ed0b28
......@@ -584,7 +584,7 @@ public class LayoutService implements ILayoutService {
for (ColorSchemaColumn column : ColorSchemaColumn.values()) {
if (columns.contains(column)) {
sb.append(column.getTitle() + "\t");
sb.append(column.getColumnName() + "\t");
}
}
sb.append("matches<br/>\n");
......
......@@ -181,21 +181,21 @@ public class ColorSchemaReader {
throw new InvalidColorSchemaException("One of these columns is obligatory: name, identifier");
}
if (contigColumn == null) {
throw new InvalidColorSchemaException(ColorSchemaColumn.CONTIG.getTitle() + " column is obligatory");
throw new InvalidColorSchemaException(ColorSchemaColumn.CONTIG.getColumnName() + " column is obligatory");
}
if (positionColumn == null) {
throw new InvalidColorSchemaException(ColorSchemaColumn.POSITION.getTitle() + " column is obligatory");
throw new InvalidColorSchemaException(ColorSchemaColumn.POSITION.getColumnName() + " column is obligatory");
}
if (originalDnaColumn == null) {
throw new InvalidColorSchemaException(ColorSchemaColumn.ORIGINAL_DNA.getTitle() + " column is obligatory");
throw new InvalidColorSchemaException(ColorSchemaColumn.ORIGINAL_DNA.getColumnName() + " column is obligatory");
}
if (referenceGenomeTypeColumn == null && genomeType == null) {
throw new InvalidColorSchemaException(
ColorSchemaColumn.REFERENCE_GENOME_TYPE.getTitle() + " column is obligatory");
ColorSchemaColumn.REFERENCE_GENOME_TYPE.getColumnName() + " column is obligatory");
}
if (referenceGenomeVersionColumn == null && referenceGenomeVersionStr == null) {
throw new InvalidColorSchemaException(
ColorSchemaColumn.REFERENCE_GENOME_VERSION.getTitle() + " column is obligatory");
ColorSchemaColumn.REFERENCE_GENOME_VERSION.getColumnName() + " column is obligatory");
}
lineIndex++;
line = br.readLine();
......@@ -501,8 +501,8 @@ public class ColorSchemaReader {
if (nameColumn == null && identifierColumn == null && customIdentifiers.size() == 0
&& elementIdentifierColumn == null) {
throw new InvalidColorSchemaException("One of these columns is obligatory: " + ColorSchemaColumn.NAME.getTitle()
+ "," + ColorSchemaColumn.IDENTIFIER.getTitle() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getTitle());
throw new InvalidColorSchemaException("One of these columns is obligatory: " + ColorSchemaColumn.NAME.getColumnName()
+ "," + ColorSchemaColumn.IDENTIFIER.getColumnName() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getColumnName());
}
if (valueColumn == null && colorColumn == null) {
......@@ -688,7 +688,9 @@ public class ColorSchemaReader {
for (int i = 0; i < columns.length; i++) {
boolean found = false;
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
if (columns[i].trim().equalsIgnoreCase(schemaColumn.getTitle()) && schemaColumn.getTypes().contains(type)) {
if ((columns[i].trim().equalsIgnoreCase(schemaColumn.getColumnName()) ||
columns[i].trim().equalsIgnoreCase(schemaColumn.getDepractedColumnName()))
&& schemaColumn.getTypes().contains(type)) {
schemaColumns.put(schemaColumn, i);
found = true;
}
......@@ -700,7 +702,7 @@ public class ColorSchemaReader {
String columnNames = "";
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
if (schemaColumn.getTypes().contains(type)) {
columnNames += schemaColumn.getTitle() + ", ";
columnNames += schemaColumn.getColumnName() + ", ";
}
}
for (String string : acceptableIdentifiers.keySet()) {
......
......@@ -130,7 +130,7 @@ public class ColorSchemaXlsxReader {
String value = cell.getStringCellValue();
boolean found = false;
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
if (value.trim().equalsIgnoreCase(schemaColumn.getTitle())) {
if (value.trim().equalsIgnoreCase(schemaColumn.getDepractedColumnName()) || value.trim().equalsIgnoreCase(schemaColumn.getColumnName())) {
foundSchemaColumns.put(schemaColumn, columnIndex - 1);
found = true;
break;
......@@ -143,7 +143,7 @@ public class ColorSchemaXlsxReader {
} else {
String columnNames = "";
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
columnNames += schemaColumn.getTitle() + ", ";
columnNames += schemaColumn.getColumnName() + ", ";
}
for (String string : acceptableIdentifiers.keySet()) {
columnNames += ", " + string;
......@@ -174,8 +174,8 @@ public class ColorSchemaXlsxReader {
if (nameColumn == null && identifierColumn == null && foundCustomIdentifiers.size() == 0
&& elementIdentifierColumn == null) {
throw new InvalidColorSchemaException(
"One of these columns is obligatory: " + ColorSchemaColumn.NAME.getTitle() + ","
+ ColorSchemaColumn.IDENTIFIER.getTitle() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getTitle());
"One of these columns is obligatory: " + ColorSchemaColumn.NAME.getColumnName() + ","
+ ColorSchemaColumn.IDENTIFIER.getColumnName() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getColumnName());
}
if (valueColumn == null && colorColumn == null) {
......
......@@ -19,41 +19,41 @@ public enum ColorSchemaColumn {
/**
* Name of the element.
*/
NAME("name", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
NAME(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
GENE_NAME("gene_name", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
GENE_NAME(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/**
* Name of the element.
*/
MODEL_NAME("model_name", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
MODEL_NAME(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/**
* Value that will be transformed into new color.
*
* @see ColorSchemaColumn#COLOR
*/
VALUE("value", new ColorSchemaType[] { ColorSchemaType.GENERIC }),
VALUE(new ColorSchemaType[] { ColorSchemaType.GENERIC }),
/**
* In which compartment the element should be located.
*/
COMPARTMENT("compartment", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
COMPARTMENT(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/**
* Class type of the element.
*/
TYPE("type", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
TYPE(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/**
* New element/reaction color.
*/
COLOR("color", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
COLOR(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/**
* Identifier of the element.
*/
IDENTIFIER("identifier", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
IDENTIFIER(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/**
* Element identifier.
......@@ -74,48 +74,48 @@ public enum ColorSchemaColumn {
/**
* Position where gene variants starts.
*/
POSITION("position", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
POSITION(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* Original DNA of the variant.
*/
ORIGINAL_DNA("original_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
ORIGINAL_DNA(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* Alternative DNA of the variant.
*/
ALTERNATIVE_DNA("alternative_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
ALTERNATIVE_DNA(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* Short description of the entry.
*/
DESCRIPTION("description", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT, ColorSchemaType.GENERIC }),
DESCRIPTION(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT, ColorSchemaType.GENERIC }),
/**
* Variant references.
*/
REFERENCES("references", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
REFERENCES(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* What's the {@link ReferenceGenomeType}.
*/
REFERENCE_GENOME_TYPE("reference_genome_type", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
REFERENCE_GENOME_TYPE(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* {@link ReferenceGenome#version Version} of the reference genome.
*/
REFERENCE_GENOME_VERSION("reference_genome_version", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
REFERENCE_GENOME_VERSION(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* Contig where variant was observed.
*/
CONTIG("contig", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
CONTIG(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
CHROMOSOME("chromosome", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
CHROMOSOME(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
ALLEL_FREQUENCY("allele_frequency", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
VARIANT_IDENTIFIER("variant_identifier", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
VARIANT_IDENTIFIER(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/**
* Should the direction of reaction be reversed.
......@@ -125,18 +125,34 @@ public enum ColorSchemaColumn {
/**
* Optional amino acid change in the variant.
*/
AMINO_ACID_CHANGE("amino_acid_change", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT });
AMINO_ACID_CHANGE(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT });
/**
* Constructor that creates enum entry with deprecated column name.
*
* @param deprecatedColumnName
* {@link #deprecatedColumnName}
* @param types
* list of {@link ColorSchemaType types} where this column is allowed
* @deprecated As of release 12.3, replaced by {@link #ColorSchemaColumn(ColorSchemaType[])}
*/
@Deprecated
ColorSchemaColumn(String deprecatedColumnName, ColorSchemaType[] types) {
this.deprecatedColumnName = deprecatedColumnName;
for (ColorSchemaType colorSchemaType : types) {
this.types.add(colorSchemaType);
}
}
/**
* Default constructor that creates enum entry.
*
* @param title
* {@link #title}
* @param deprecatedColumnName
* {@link #deprecatedColumnName}
* @param types
* list of {@link ColorSchemaType types} where this column is allowed
*/
ColorSchemaColumn(String title, ColorSchemaType[] types) {
this.title = title;
ColorSchemaColumn(ColorSchemaType[] types) {
for (ColorSchemaType colorSchemaType : types) {
this.types.add(colorSchemaType);
}
......@@ -145,7 +161,7 @@ public enum ColorSchemaColumn {
/**
* Human readable title used in input file.
*/
private String title;
private String deprecatedColumnName;
/**
* Set of types where column is allowed.
......@@ -154,10 +170,16 @@ public enum ColorSchemaColumn {
/**
*
* @return {@link #title}
* @return {@link #deprecatedColumnName}
* @deprecated As of release 12.3, replaced by {@link #getColumnName()}
*/
public String getTitle() {
return title;
@Deprecated
public String getDepractedColumnName() {
return deprecatedColumnName;
}
public String getColumnName() {
return this.name().toLowerCase();
}
/**
......
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