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 { ...@@ -584,7 +584,7 @@ public class LayoutService implements ILayoutService {
for (ColorSchemaColumn column : ColorSchemaColumn.values()) { for (ColorSchemaColumn column : ColorSchemaColumn.values()) {
if (columns.contains(column)) { if (columns.contains(column)) {
sb.append(column.getTitle() + "\t"); sb.append(column.getColumnName() + "\t");
} }
} }
sb.append("matches<br/>\n"); sb.append("matches<br/>\n");
......
...@@ -181,21 +181,21 @@ public class ColorSchemaReader { ...@@ -181,21 +181,21 @@ public class ColorSchemaReader {
throw new InvalidColorSchemaException("One of these columns is obligatory: name, identifier"); throw new InvalidColorSchemaException("One of these columns is obligatory: name, identifier");
} }
if (contigColumn == null) { if (contigColumn == null) {
throw new InvalidColorSchemaException(ColorSchemaColumn.CONTIG.getTitle() + " column is obligatory"); throw new InvalidColorSchemaException(ColorSchemaColumn.CONTIG.getColumnName() + " column is obligatory");
} }
if (positionColumn == null) { if (positionColumn == null) {
throw new InvalidColorSchemaException(ColorSchemaColumn.POSITION.getTitle() + " column is obligatory"); throw new InvalidColorSchemaException(ColorSchemaColumn.POSITION.getColumnName() + " column is obligatory");
} }
if (originalDnaColumn == null) { 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) { if (referenceGenomeTypeColumn == null && genomeType == null) {
throw new InvalidColorSchemaException( throw new InvalidColorSchemaException(
ColorSchemaColumn.REFERENCE_GENOME_TYPE.getTitle() + " column is obligatory"); ColorSchemaColumn.REFERENCE_GENOME_TYPE.getColumnName() + " column is obligatory");
} }
if (referenceGenomeVersionColumn == null && referenceGenomeVersionStr == null) { if (referenceGenomeVersionColumn == null && referenceGenomeVersionStr == null) {
throw new InvalidColorSchemaException( throw new InvalidColorSchemaException(
ColorSchemaColumn.REFERENCE_GENOME_VERSION.getTitle() + " column is obligatory"); ColorSchemaColumn.REFERENCE_GENOME_VERSION.getColumnName() + " column is obligatory");
} }
lineIndex++; lineIndex++;
line = br.readLine(); line = br.readLine();
...@@ -501,8 +501,8 @@ public class ColorSchemaReader { ...@@ -501,8 +501,8 @@ public class ColorSchemaReader {
if (nameColumn == null && identifierColumn == null && customIdentifiers.size() == 0 if (nameColumn == null && identifierColumn == null && customIdentifiers.size() == 0
&& elementIdentifierColumn == null) { && elementIdentifierColumn == null) {
throw new InvalidColorSchemaException("One of these columns is obligatory: " + ColorSchemaColumn.NAME.getTitle() throw new InvalidColorSchemaException("One of these columns is obligatory: " + ColorSchemaColumn.NAME.getColumnName()
+ "," + ColorSchemaColumn.IDENTIFIER.getTitle() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getTitle()); + "," + ColorSchemaColumn.IDENTIFIER.getColumnName() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getColumnName());
} }
if (valueColumn == null && colorColumn == null) { if (valueColumn == null && colorColumn == null) {
...@@ -688,7 +688,9 @@ public class ColorSchemaReader { ...@@ -688,7 +688,9 @@ public class ColorSchemaReader {
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
boolean found = false; boolean found = false;
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { 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); schemaColumns.put(schemaColumn, i);
found = true; found = true;
} }
...@@ -700,7 +702,7 @@ public class ColorSchemaReader { ...@@ -700,7 +702,7 @@ public class ColorSchemaReader {
String columnNames = ""; String columnNames = "";
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
if (schemaColumn.getTypes().contains(type)) { if (schemaColumn.getTypes().contains(type)) {
columnNames += schemaColumn.getTitle() + ", "; columnNames += schemaColumn.getColumnName() + ", ";
} }
} }
for (String string : acceptableIdentifiers.keySet()) { for (String string : acceptableIdentifiers.keySet()) {
......
...@@ -130,7 +130,7 @@ public class ColorSchemaXlsxReader { ...@@ -130,7 +130,7 @@ public class ColorSchemaXlsxReader {
String value = cell.getStringCellValue(); String value = cell.getStringCellValue();
boolean found = false; boolean found = false;
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { 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); foundSchemaColumns.put(schemaColumn, columnIndex - 1);
found = true; found = true;
break; break;
...@@ -143,7 +143,7 @@ public class ColorSchemaXlsxReader { ...@@ -143,7 +143,7 @@ public class ColorSchemaXlsxReader {
} else { } else {
String columnNames = ""; String columnNames = "";
for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) { for (ColorSchemaColumn schemaColumn : ColorSchemaColumn.values()) {
columnNames += schemaColumn.getTitle() + ", "; columnNames += schemaColumn.getColumnName() + ", ";
} }
for (String string : acceptableIdentifiers.keySet()) { for (String string : acceptableIdentifiers.keySet()) {
columnNames += ", " + string; columnNames += ", " + string;
...@@ -174,8 +174,8 @@ public class ColorSchemaXlsxReader { ...@@ -174,8 +174,8 @@ public class ColorSchemaXlsxReader {
if (nameColumn == null && identifierColumn == null && foundCustomIdentifiers.size() == 0 if (nameColumn == null && identifierColumn == null && foundCustomIdentifiers.size() == 0
&& elementIdentifierColumn == null) { && elementIdentifierColumn == null) {
throw new InvalidColorSchemaException( throw new InvalidColorSchemaException(
"One of these columns is obligatory: " + ColorSchemaColumn.NAME.getTitle() + "," "One of these columns is obligatory: " + ColorSchemaColumn.NAME.getColumnName() + ","
+ ColorSchemaColumn.IDENTIFIER.getTitle() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getTitle()); + ColorSchemaColumn.IDENTIFIER.getColumnName() + "," + ColorSchemaColumn.ELEMENT_IDENTIFIER.getColumnName());
} }
if (valueColumn == null && colorColumn == null) { if (valueColumn == null && colorColumn == null) {
......
...@@ -19,41 +19,41 @@ public enum ColorSchemaColumn { ...@@ -19,41 +19,41 @@ public enum ColorSchemaColumn {
/** /**
* Name of the element. * 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. * 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. * Value that will be transformed into new color.
* *
* @see ColorSchemaColumn#COLOR * @see ColorSchemaColumn#COLOR
*/ */
VALUE("value", new ColorSchemaType[] { ColorSchemaType.GENERIC }), VALUE(new ColorSchemaType[] { ColorSchemaType.GENERIC }),
/** /**
* In which compartment the element should be located. * 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. * 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. * 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 of the element.
*/ */
IDENTIFIER("identifier", new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }), IDENTIFIER(new ColorSchemaType[] { ColorSchemaType.GENERIC, ColorSchemaType.GENETIC_VARIANT }),
/** /**
* Element identifier. * Element identifier.
...@@ -74,69 +74,85 @@ public enum ColorSchemaColumn { ...@@ -74,69 +74,85 @@ public enum ColorSchemaColumn {
/** /**
* Position where gene variants starts. * 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 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 of the variant.
*/ */
ALTERNATIVE_DNA("alternative_dna", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), ALTERNATIVE_DNA(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/** /**
* Short description of the entry. * Short description of the entry.
*/ */
DESCRIPTION("description", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT, ColorSchemaType.GENERIC }), DESCRIPTION(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT, ColorSchemaType.GENERIC }),
/** /**
* Variant references. * Variant references.
*/ */
REFERENCES("references", new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }), REFERENCES(new ColorSchemaType[] { ColorSchemaType.GENETIC_VARIANT }),
/** /**
* What's the {@link ReferenceGenomeType}. * 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. * {@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 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 }), 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. * Should the direction of reaction be reversed.
*/ */
REVERSE_REACTION("reverseReaction", new ColorSchemaType[] { ColorSchemaType.GENERIC }), REVERSE_REACTION("reverseReaction", new ColorSchemaType[] { ColorSchemaType.GENERIC }),
/** /**
* Optional amino acid change in the variant. * 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. * Default constructor that creates enum entry.
* *
* @param title * @param deprecatedColumnName
* {@link #title} * {@link #deprecatedColumnName}
* @param types * @param types
* list of {@link ColorSchemaType types} where this column is allowed * list of {@link ColorSchemaType types} where this column is allowed
*/ */
ColorSchemaColumn(String title, ColorSchemaType[] types) { ColorSchemaColumn(ColorSchemaType[] types) {
this.title = title;
for (ColorSchemaType colorSchemaType : types) { for (ColorSchemaType colorSchemaType : types) {
this.types.add(colorSchemaType); this.types.add(colorSchemaType);
} }
...@@ -145,7 +161,7 @@ public enum ColorSchemaColumn { ...@@ -145,7 +161,7 @@ public enum ColorSchemaColumn {
/** /**
* Human readable title used in input file. * Human readable title used in input file.
*/ */
private String title; private String deprecatedColumnName;
/** /**
* Set of types where column is allowed. * Set of types where column is allowed.
...@@ -154,10 +170,16 @@ public enum ColorSchemaColumn { ...@@ -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() { @Deprecated
return title; 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