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

hibernate required the structuralState to be present in the species (not protein/complex)

parent 3379b6dc
......@@ -41,12 +41,6 @@ public class Complex extends Species {
@OneToMany(fetch = FetchType.EAGER, mappedBy = "complex")
private List<Species> elements = new ArrayList<>();
/**
* State of the complex species.
*/
@OneToOne
private StructuralState structuralState = null;
/**
* Empty constructor required by hibernate.
*/
......@@ -67,7 +61,6 @@ public class Complex extends Species {
for (Species element : original.getElements()) {
addSpecies(element.copy());
}
this.structuralState = original.getStructuralState();
}
/**
......@@ -176,15 +169,4 @@ public class Complex extends Species {
return "Complex";
}
public StructuralState getStructuralState() {
return structuralState;
}
public void setStructuralState(StructuralState structuralState) {
this.structuralState = structuralState;
if (structuralState != null) {
structuralState.setSpecies(this);
}
}
}
......@@ -26,12 +26,6 @@ public abstract class Protein extends Species implements SpeciesWithBindingRegio
*/
private static final long serialVersionUID = 1L;
/**
* State of the protein.
*/
@OneToOne
private StructuralState structuralState = null;
/**
* List of modifications for the Protein.
*/
......@@ -54,7 +48,6 @@ public abstract class Protein extends Species implements SpeciesWithBindingRegio
*/
protected Protein(Protein original) {
super(original);
this.structuralState = original.getStructuralState();
for (ModificationResidue mr : original.getModificationResidues()) {
addModificationResidue(mr.copy());
}
......@@ -113,15 +106,4 @@ public abstract class Protein extends Species implements SpeciesWithBindingRegio
return "Protein";
}
public StructuralState getStructuralState() {
return structuralState;
}
public void setStructuralState(StructuralState structuralState) {
this.structuralState = structuralState;
if (structuralState != null) {
structuralState.setSpecies(this);
}
}
}
......@@ -12,8 +12,7 @@ import org.hibernate.annotations.CascadeType;
import lcsb.mapviewer.model.map.kinetics.SbmlUnit;
import lcsb.mapviewer.model.map.kinetics.SbmlUnitType;
import lcsb.mapviewer.model.map.species.field.PositionToCompartment;
import lcsb.mapviewer.model.map.species.field.UniprotRecord;
import lcsb.mapviewer.model.map.species.field.*;
/**
* Structure used for representing information about single element.
......@@ -139,6 +138,15 @@ public abstract class Species extends Element {
@Cascade({ CascadeType.ALL })
private SbmlUnit substanceUnitComlexType;
/**
* State of the complex/protein species.
*/
// it should be in protein/complex, but due to hibernate reversed mappedBy
// property it
// must be in species.
@OneToOne(orphanRemoval = true, cascade = javax.persistence.CascadeType.ALL)
private StructuralState structuralState = null;
/**
* Constructor that set element identifier.
*
......@@ -191,6 +199,7 @@ public abstract class Species extends Element {
substanceUnitRawType = original.substanceUnitRawType;
uniprots = original.getUniprots();
structuralState = original.structuralState;
// don't copy reaction nodes
}
......@@ -511,4 +520,15 @@ public abstract class Species extends Element {
this.substanceUnitRawType = null;
}
public StructuralState getStructuralState() {
return structuralState;
}
public void setStructuralState(StructuralState structuralState) {
this.structuralState = structuralState;
if (structuralState != null) {
structuralState.setSpecies(this);
}
}
}
......@@ -8,6 +8,8 @@ import javax.persistence.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -48,8 +50,7 @@ public class StructuralState implements Serializable {
@Column(nullable = false)
private Double fontSize;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(nullable = false)
@OneToOne(fetch = FetchType.LAZY, cascade = javax.persistence.CascadeType.ALL, mappedBy = "structuralState", optional = false)
private Species species;
public StructuralState() {
......
alter table structural_state_table alter column species_id drop not null;
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