Commit 78fdb4b0 authored by Matija Obreza's avatar Matija Obreza

Taxonomy2 model

parent 0a7b4ecf
...@@ -56,6 +56,10 @@ public class Accession extends VersionedAuditedModel { ...@@ -56,6 +56,10 @@ public class Accession extends VersionedAuditedModel {
@JoinColumn(name = "taxonomyId") @JoinColumn(name = "taxonomyId")
private Taxonomy taxonomy; private Taxonomy taxonomy;
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "taxonomyId2")
private Taxonomy2 taxonomy2;
@Column(name = "acqSrc", length = 3) @Column(name = "acqSrc", length = 3)
private String acquisitionSource; private String acquisitionSource;
...@@ -90,8 +94,11 @@ public class Accession extends VersionedAuditedModel { ...@@ -90,8 +94,11 @@ public class Accession extends VersionedAuditedModel {
@Column(name = "mlsStat") @Column(name = "mlsStat")
private Boolean mlsStatus; private Boolean mlsStatus;
@Column(name = "genus", nullable = false, length = 64) @Column(name = "taxGenus", nullable = true)
private String genus; private long taxGenus;
@Column(name = "taxSpecies", nullable = true)
private Long taxSpecies;
public Accession() { public Accession() {
} }
...@@ -132,6 +139,10 @@ public class Accession extends VersionedAuditedModel { ...@@ -132,6 +139,10 @@ public class Accession extends VersionedAuditedModel {
return this.taxonomy; return this.taxonomy;
} }
public Taxonomy2 getTaxonomy2() {
return this.taxonomy2;
}
public void setTaxonomy(final Taxonomy taxonomy) { public void setTaxonomy(final Taxonomy taxonomy) {
this.taxonomy = taxonomy; this.taxonomy = taxonomy;
} }
...@@ -224,16 +235,29 @@ public class Accession extends VersionedAuditedModel { ...@@ -224,16 +235,29 @@ public class Accession extends VersionedAuditedModel {
this.mlsStatus = mlsStatus; this.mlsStatus = mlsStatus;
} }
public String getGenus() {
return this.genus; public long getTaxGenus() {
return taxGenus;
}
public void setTaxGenus(long taxGenus) {
this.taxGenus = taxGenus;
}
public Long getTaxSpecies() {
return taxSpecies;
}
public void setTaxSpecies(Long taxSpecies) {
this.taxSpecies = taxSpecies;
} }
public void setGenus(final String genuss) { public void setTaxonomy2(Taxonomy2 taxonomy2) {
this.genus = genuss; this.taxonomy2 = taxonomy2;
} }
@Override @Override
public String toString() { public String toString() {
return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, genus, accessionName); return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, taxGenus, accessionName);
} }
} }
/**
* Copyright 2014 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.genesys2.server.model.genesys;
import java.text.MessageFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.GlobalVersionedAuditedModel;
import org.hibernate.search.annotations.Indexed;
@Entity
// Add index on all fields
@Table(name = "taxonomy2", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species", "spAuthor", "subtaxa", "subtAuthor" }) })
@Indexed
public class Taxonomy2 extends GlobalVersionedAuditedModel {
private static final long serialVersionUID = 8881324404490162933L;
@Column(nullable = false, length = 100)
private String genus;
@Column(nullable = false, length = 100)
private String species;
@Column(nullable = true, length = 100)
private String spAuthor;
@Column(nullable = true, length = 100)
private String subtaxa;
@Column(nullable = true, length = 100)
private String subtAuthor;
// @OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "taxonomy")
// private List<CropTaxonomy> cropTaxonomies;
public String getGenus() {
return this.genus;
}
public void setGenus(final String genus) {
this.genus = genus;
}
public String getSpecies() {
return this.species;
}
public void setSpecies(final String species) {
this.species = species;
}
public String getTaxonName() {
StringBuilder sb = new StringBuilder();
sb.append(genus).append(" ").append(species);
if (spAuthor != null)
sb.append(" ").append(spAuthor);
if (subtaxa != null)
sb.append(" ").append(subtaxa);
if (subtAuthor != null)
sb.append(" ").append(subtAuthor);
return sb.toString();
}
// public List<CropTaxonomy> getCropTaxonomies() {
// return cropTaxonomies;
// }
//
// public void setCropTaxonomies(List<CropTaxonomy> cropTaxonomies) {
// this.cropTaxonomies = cropTaxonomies;
// }
@Override
public String toString() {
return MessageFormat.format("Tax id={0} taxonName=", id, getTaxonName());
}
public boolean sameAs(Taxonomy2 taxonomy) {
return taxonomy == null ? false : taxonomy.getId().equals(id);
}
}
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