Commit 068020fe authored by Matija Obreza's avatar Matija Obreza
Browse files

Bring back Accession#taxGenus

parent 74ad400e
......@@ -31,6 +31,7 @@ import javax.persistence.OrderBy;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys2.server.model.impl.Country;
......@@ -38,10 +39,7 @@ import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.util.MCPDUtil;
@Entity
@Table(name = "accession")
// TODO FIXME Reenable
// @Table(name = "accession", uniqueConstraints = {
// @UniqueConstraint(columnNames = { "instCode", "acceNumb", "taxGenus" }) })
@Table(name = "accession", uniqueConstraints = { @UniqueConstraint(name="UQ_accession_genus_inst", columnNames = { "instituteId", "taxGenus", "acceNumb" }) })
public class Accession extends VersionedAuditedModel {
private static final long serialVersionUID = -7630113633534038876L;
......@@ -94,6 +92,9 @@ public class Accession extends VersionedAuditedModel {
@Column(name = "mlsStat")
private Boolean mlsStatus;
@Column(name = "taxGenus", nullable = false)
private long taxGenus;
@Column(name = "storage", nullable = false)
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "accessionstorage", joinColumns = @JoinColumn(name = "accessionId"))
......@@ -231,6 +232,14 @@ public class Accession extends VersionedAuditedModel {
this.mlsStatus = mlsStatus;
}
public long getTaxGenus() {
return taxGenus;
}
public void setTaxGenus(long taxGenus) {
this.taxGenus = taxGenus;
}
public void setTaxonomy(Taxonomy2 taxonomy2) {
this.taxonomy = taxonomy2;
}
......@@ -261,6 +270,6 @@ public class Accession extends VersionedAuditedModel {
@Override
public String toString() {
return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, "N/A", accessionName);
return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, taxGenus, accessionName);
}
}
......@@ -659,6 +659,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
if (!ensuredTaxonomy.sameAs(taxonomy)) {
accession.setTaxonomy(ensuredTaxonomy);
accession.setTaxGenus(ensuredTaxonomy.getTaxGenus());
updated = true;
}
......
......@@ -240,6 +240,7 @@ public class BatchRESTServiceTest {
assertTrue(accession.getTaxonomy() != null);
final Taxonomy2 tax = accession.getTaxonomy();
System.err.println(tax);
System.err.println(accession.getTaxGenus());
// Modify taxonomy
json.put("genus", "Hordeum");
......@@ -257,6 +258,7 @@ public class BatchRESTServiceTest {
final Taxonomy2 tax2 = accession.getTaxonomy();
System.err.println(tax2);
assertFalse(tax2.getId().equals(tax.getId()));
System.err.println(accession.getTaxGenus());
// test nothing
try {
......
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