Commit 368d1867 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

data overlay entry name must not be null

parent 35346e80
Pipeline #51087 failed with stage
in 11 minutes and 7 seconds
......@@ -2,9 +2,25 @@ package lcsb.mapviewer.model.overlay;
import java.awt.Color;
import java.io.Serializable;
import java.util.*;
import javax.persistence.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
......@@ -30,9 +46,11 @@ public abstract class DataOverlayEntry implements Serializable {
private int id;
/**
* Name of the {@link Element Element}. If null then this field will be skipped.
* Name of the {@link Element Element}. If empty then this field will be
* skipped.
*/
private String name = null;
@Column(nullable = false)
private String name = "";
/**
* Name of the {@link Model} to which this schema should be limited. If null
......@@ -93,7 +111,8 @@ public abstract class DataOverlayEntry implements Serializable {
@Cascade({ CascadeType.ALL })
@ManyToMany()
@JoinTable(name = "data_overlay_entry_miriam_table", joinColumns = {
@JoinColumn(name = "data_overlay_entry_id", referencedColumnName = "id", nullable = false, updatable = false) }, inverseJoinColumns = {
@JoinColumn(name = "data_overlay_entry_id", referencedColumnName = "id", nullable = false, updatable = false) },
inverseJoinColumns = {
@JoinColumn(name = "miriam_id", referencedColumnName = "id", nullable = true, updatable = true) })
private Set<MiriamData> miriamData = new HashSet<>();
......@@ -117,7 +136,7 @@ public abstract class DataOverlayEntry implements Serializable {
* @param original
* original object used for initialization
*/
protected DataOverlayEntry(DataOverlayEntry original) {
protected DataOverlayEntry(final DataOverlayEntry original) {
this.setName(original.getName());
this.setElementId(original.getElementId());
this.setReverseReaction(original.getReverseReaction());
......@@ -136,7 +155,7 @@ public abstract class DataOverlayEntry implements Serializable {
* @param types2
* list of classes to add
*/
public void addTypes(Collection<Class<? extends BioEntity>> types2) {
public void addTypes(final Collection<Class<? extends BioEntity>> types2) {
for (Class<? extends BioEntity> clazz : types2) {
addType(clazz);
}
......@@ -148,7 +167,7 @@ public abstract class DataOverlayEntry implements Serializable {
* @param compartments2
* elements to add
*/
public void addCompartments(String[] compartments2) {
public void addCompartments(final String[] compartments2) {
for (String string : compartments2) {
compartments.add(string);
}
......@@ -160,7 +179,7 @@ public abstract class DataOverlayEntry implements Serializable {
* @param compartments2
* elements to add
*/
public void addCompartments(Collection<String> compartments2) {
public void addCompartments(final Collection<String> compartments2) {
for (String string : compartments2) {
compartments.add(string);
}
......@@ -211,9 +230,9 @@ public abstract class DataOverlayEntry implements Serializable {
* the name to set
* @see #name
*/
public void setName(String name) {
public void setName(final String name) {
if (name == null) {
this.name = null;
this.name = "";
} else {
this.name = name.trim();
}
......@@ -232,7 +251,7 @@ public abstract class DataOverlayEntry implements Serializable {
* the compartments to set
* @see #compartments
*/
public void setCompartments(Set<String> compartments) {
public void setCompartments(final Set<String> compartments) {
this.compartments = compartments;
}
......@@ -257,7 +276,7 @@ public abstract class DataOverlayEntry implements Serializable {
* the value to set
* @see #value
*/
public void setValue(Double value) {
public void setValue(final Double value) {
this.value = value;
}
......@@ -274,7 +293,7 @@ public abstract class DataOverlayEntry implements Serializable {
* the color to set
* @see #color
*/
public void setColor(Color color) {
public void setColor(final Color color) {
this.color = color;
}
......@@ -282,7 +301,7 @@ public abstract class DataOverlayEntry implements Serializable {
* Adds identifier to {@link #miriamData} set.
*
*/
public void addMiriamData(MiriamData md) {
public void addMiriamData(final MiriamData md) {
miriamData.add(md);
}
......@@ -299,7 +318,7 @@ public abstract class DataOverlayEntry implements Serializable {
* the lineWidth to set
* @see #lineWidth
*/
public void setLineWidth(Double lineWidth) {
public void setLineWidth(final Double lineWidth) {
this.lineWidth = lineWidth;
}
......@@ -316,7 +335,7 @@ public abstract class DataOverlayEntry implements Serializable {
* the reverseReaction to set
* @see #reverseReaction
*/
public void setReverseReaction(Boolean reverseReaction) {
public void setReverseReaction(final Boolean reverseReaction) {
this.reverseReaction = reverseReaction;
}
......@@ -326,7 +345,7 @@ public abstract class DataOverlayEntry implements Serializable {
* @param name
* compartment name
*/
public void addCompartment(String name) {
public void addCompartment(final String name) {
compartments.add(name);
}
......@@ -336,7 +355,7 @@ public abstract class DataOverlayEntry implements Serializable {
* @param clazz
* class to add
*/
public void addType(Class<? extends BioEntity> clazz) {
public void addType(final Class<? extends BioEntity> clazz) {
this.types.add(clazz);
}
......@@ -353,7 +372,7 @@ public abstract class DataOverlayEntry implements Serializable {
* the description to set
* @see #description
*/
public void setDescription(String description) {
public void setDescription(final String description) {
this.description = description;
}
......@@ -368,7 +387,7 @@ public abstract class DataOverlayEntry implements Serializable {
return modelName;
}
public void setModelName(String modelName) {
public void setModelName(final String modelName) {
this.modelName = modelName;
}
......@@ -376,7 +395,7 @@ public abstract class DataOverlayEntry implements Serializable {
return elementId;
}
public void setElementId(String elementId) {
public void setElementId(final String elementId) {
this.elementId = elementId;
}
......@@ -388,7 +407,7 @@ public abstract class DataOverlayEntry implements Serializable {
return id;
}
public void setDataOverlay(DataOverlay dataOverlay) {
public void setDataOverlay(final DataOverlay dataOverlay) {
this.dataOverlay = dataOverlay;
}
}
......@@ -101,10 +101,7 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
+ " entry left join entry.compartments compartment left join entry.miriamData entry_miriam, "
+ Element.class.getSimpleName() + " element left join element.miriamData element_miriam"
+ " where element.model in :maps and entry.dataOverlay.id = :overlayId "
// "not entry.name <>''" is equivalent to
// "dataoverla0_.name='' or dataoverla0_.name is null"
// but faster
+ " and (lower(element.name) = lower(entry.name) or not entry.name <>'') "
+ " and (lower(element.name) = lower(entry.name) or entry.name ='') "
+ " and (lower(element.model.name) = lower(entry.modelName) or entry.modelName='' or entry.modelName is null) "
+ " and (entry_miriam is null or (entry_miriam.dataType = element_miriam.dataType and lower(entry_miriam.resource) = lower(element_miriam.resource)) ) "
+ " and (compartment is null or"
......@@ -164,10 +161,7 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
+ " entry left join entry.compartments compartment left join entry.miriamData entry_miriam, "
+ Reaction.class.getSimpleName() + " reaction left join reaction.miriamData reaction_miriam"
+ " where reaction.model in :maps and entry.dataOverlay.id = :overlayId "
// "not entry.name <>''" is equivalent to
// "dataoverla0_.name='' or dataoverla0_.name is null"
// but faster
+ " and (lower(reaction.name) = lower(entry.name) or not entry.name <>'') "
+ " and (lower(reaction.name) = lower(entry.name) or entry.name ='') "
+ " and (lower(reaction.model.name) = lower(entry.modelName) or entry.modelName='' or entry.modelName is null) "
+ " and (entry_miriam is null or (entry_miriam.dataType = reaction_miriam.dataType and lower(entry_miriam.resource) = lower(reaction_miriam.resource)) ) "
+ " and (lower(reaction.idReaction) = lower(entry.elementId) or entry.elementId='' or entry.elementId is null) ";
......
update data_overlay_entry_table set name ='' where name is null;
alter table data_overlay_entry_table ALTER COLUMN name SET NOT NULL;
\ No newline at end of file
update data_overlay_entry_table set name ='' where name is null;
alter table data_overlay_entry_table ALTER COLUMN name SET NOT NULL;
\ No newline at end of file
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