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