import java.util.HashSet;
import java.util.Set;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
-import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
/** @see #getGeneticAccessionNumber()*/
@XmlElement(name = "GeneticAccessionNumber")
- @Size(max=20)
+ @Column(length=20)
private String geneticAccessionNumber;
/** @see #getBoldProcessId() */
@XmlElement(name = "BoldProcessId")
- @Size(max=20)
+ @Column(length=20)
private String boldProcessId;
@XmlElementWrapper(name = "SingleReadAlignments")
@XmlElement(name = "SingleReadAlignment")
@XmlIDREF
@XmlSchemaType(name = "IDREF")
- @OneToMany(mappedBy="consensusAlignment", fetch = FetchType.LAZY)
+ @OneToMany(mappedBy="consensusAlignment", fetch = FetchType.LAZY, orphanRemoval=true)
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
private Set<SingleReadAlignment> singleReadAlignments = new HashSet<SingleReadAlignment>();
/** @see #getHaplotype() */
@XmlElement(name = "Haplotype")
- @Size(max=100)
+ @Column(length=100)
private String haplotype;
/** @see #getCitations() */
this.singleReadAlignments.remove(singleReadAlignment);
if (this.equals(singleReadAlignment.getConsensusSequence())){
singleReadAlignment.setConsensusAlignment(null);
+ singleReadAlignment.setSingleRead(null);
}
}
// /**
// private void setSingleReadAlignments(Set<SingleReadAlignment> singleReadAlignments) {
// this.singleReadAlignments = singleReadAlignments;
// }
-
+
// *********************** CONVENIENCE ***********************************/
-
+
/**
* Convenience method to add a single read to a consensus sequence
* by creating a {@link SingleReadAlignment}.
SingleReadAlignment alignment = SingleReadAlignment.NewInstance(this, singleRead);
return alignment;
}
-
+
public void removeSingleRead(SingleRead singleRead) {
Set<SingleReadAlignment> toRemove = new HashSet<SingleReadAlignment>();
for (SingleReadAlignment align : this.singleReadAlignments){
}
return;
}
-
+
/**
* Convenience method that returns all single reads this consensus sequence
* is based on via {@link SingleReadAlignment}s.