Commit 7d056d0e authored by Matija Obreza's avatar Matija Obreza

Database model overhaul

parent 7c8c22a5
......@@ -19,11 +19,8 @@ package org.genesys2.server.model;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import org.genesys2.server.model.impl.User;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
......@@ -34,28 +31,26 @@ public abstract class AuditedModel extends BusinessModel {
private static final long serialVersionUID = -5927214471682331909L;
@CreatedBy
@ManyToOne(optional = true)
@JoinColumn(name = "createdBy")
private User createdBy;
@Column(length = 36)
private String createdBy;
@CreatedDate
@Column(name = "createdDate")
private Date createdDate;
@LastModifiedBy
@ManyToOne(optional = true)
@JoinColumn(name = "lastModifiedBy")
private User lastModifiedBy;
@Column(length = 36)
private String lastModifiedBy;
@LastModifiedDate
@Column(name = "lastModifiedDate")
private Date lastModifiedDate;
public User getCreatedBy() {
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(User createdBy) {
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
......@@ -67,11 +62,11 @@ public abstract class AuditedModel extends BusinessModel {
this.createdDate = createdDate;
}
public User getLastModifiedBy() {
public String getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(User lastModifiedBy) {
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
......
......@@ -16,79 +16,86 @@
package org.genesys2.server.model.genesys;
// Generated Apr 24, 2013 10:08:59 AM by Hibernate Tools 4.0.0
import java.text.MessageFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import org.genesys2.server.lucene.genesys.AccessionBridge;
import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute;
import org.hibernate.search.annotations.ClassBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Indexed;
@Entity
// @Table(name = "accession")
@Table(name = "accession", uniqueConstraints = { @UniqueConstraint(columnNames = { "Institute", "ACC_Numb_HI", "Genuss" }) })
@Table(name = "accession", uniqueConstraints = { @UniqueConstraint(columnNames = { "instCode", "acceNumb", "genus" }) })
@Indexed
@ClassBridge(name = "body", impl = AccessionBridge.class)
public class Accession implements java.io.Serializable {
public class Accession extends VersionedAuditedModel {
private static final long serialVersionUID = -7630113633534038876L;
private Long id;
private long version = 0;
@Column(length = 36)
private String uuid;
@Column(name = "instCode", length = 6)
private String instituteCode;
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "instituteId")
private FaoInstitute institute;
private String accNumbHi;
@Column(name = "acceNumb", nullable = false, length = 128)
private String accessionName;
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "taxonomyId")
private Taxonomy taxonomy;
@Column(name = "acqSrc", length = 3)
private String acquisitionSource;
@Column(name = "acqDate", length = 8)
private String acquisitionDate;
@Column(name = "orgCty", length = 3)
private String origin;
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "orgCtyId", nullable = true)
private Country countryOfOrigin;
@Column(name = "dublInst", length = 8)
private String dublInst;
@Column(name = "sampStat", length = 3)
private String sampleStatus;
@Column(name = "storage", length = 12)
private String storage;
@Column(name = "inSGSV")
private Boolean inSvalbard;
@Column(name = "inTrust")
private Boolean inTrust;
@Column(name = "available")
private Boolean availability;
@Column(name = "mlsStat")
private Boolean mlsStatus;
@Column(name = "genus", nullable = false, length = 64)
private String genus;
public Accession() {
}
@Id
@GeneratedValue
@Column(name = "id", unique = true, nullable = false)
@DocumentId
public Long getId() {
return this.id;
}
public void setId(final Long alisId) {
this.id = alisId;
}
@Version
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
@Column(length = 36)
public String getUuid() {
return uuid;
}
......@@ -97,8 +104,6 @@ public class Accession implements java.io.Serializable {
this.uuid = uuid;
}
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "instituteId")
public FaoInstitute getInstitute() {
return this.institute;
}
......@@ -107,7 +112,6 @@ public class Accession implements java.io.Serializable {
this.institute = institute;
}
@Column(name = "Institute", length = 6)
public String getInstituteCode() {
return instituteCode;
}
......@@ -116,17 +120,14 @@ public class Accession implements java.io.Serializable {
this.instituteCode = instituteCode;
}
@Column(name = "ACC_Numb_HI", nullable = false, length = 128)
public String getAccessionName() {
return this.accNumbHi;
return this.accessionName;
}
public void setAccessionName(final String accNumbHi) {
this.accNumbHi = accNumbHi;
public void setAccessionName(final String accessionName) {
this.accessionName = accessionName;
}
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "Taxon_Code")
public Taxonomy getTaxonomy() {
return this.taxonomy;
}
......@@ -135,7 +136,6 @@ public class Accession implements java.io.Serializable {
this.taxonomy = taxonomy;
}
@Column(name = "Acquisition_Source", length = 3)
public String getAcquisitionSource() {
return this.acquisitionSource;
}
......@@ -144,7 +144,6 @@ public class Accession implements java.io.Serializable {
this.acquisitionSource = acquisitionSource;
}
@Column(name = "Acquisition_Date", length = 8)
public String getAcquisitionDate() {
return this.acquisitionDate;
}
......@@ -153,7 +152,6 @@ public class Accession implements java.io.Serializable {
this.acquisitionDate = acquisitionDate;
}
@Column(name = "Origin", length = 3)
public String getOrigin() {
return this.origin;
}
......@@ -162,8 +160,6 @@ public class Accession implements java.io.Serializable {
this.origin = origin;
}
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "originId", nullable = true)
public Country getCountryOfOrigin() {
return countryOfOrigin;
}
......@@ -172,7 +168,6 @@ public class Accession implements java.io.Serializable {
this.countryOfOrigin = countryOfOrigin;
}
@Column(name = "Dubl_Inst", length = 8)
public String getDublInst() {
return this.dublInst;
}
......@@ -181,7 +176,6 @@ public class Accession implements java.io.Serializable {
this.dublInst = dublInst;
}
@Column(name = "Sample_Status", length = 3)
public String getSampleStatus() {
return this.sampleStatus;
}
......@@ -190,7 +184,6 @@ public class Accession implements java.io.Serializable {
this.sampleStatus = sampleStatus;
}
@Column(name = "Storage", length = 12)
public String getStorage() {
return this.storage;
}
......@@ -199,7 +192,6 @@ public class Accession implements java.io.Serializable {
this.storage = storage;
}
@Column(name = "In_Svalbard")
public Boolean getInSvalbard() {
return this.inSvalbard;
}
......@@ -208,7 +200,6 @@ public class Accession implements java.io.Serializable {
this.inSvalbard = inSvalbard;
}
@Column(name = "In_Trust")
public Boolean getInTrust() {
return this.inTrust;
}
......@@ -217,7 +208,6 @@ public class Accession implements java.io.Serializable {
this.inTrust = inTrust;
}
@Column(name = "Availability")
public Boolean getAvailability() {
return this.availability;
}
......@@ -226,7 +216,6 @@ public class Accession implements java.io.Serializable {
this.availability = availability;
}
@Column(name = "MLS_Status")
public Boolean getMlsStatus() {
return this.mlsStatus;
}
......@@ -235,7 +224,6 @@ public class Accession implements java.io.Serializable {
this.mlsStatus = mlsStatus;
}
@Column(name = "Genuss", nullable = false, length = 64)
public String getGenus() {
return this.genus;
}
......@@ -246,6 +234,6 @@ public class Accession implements java.io.Serializable {
@Override
public String toString() {
return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, genus, accNumbHi);
return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, genus, accessionName);
}
}
......@@ -25,23 +25,24 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
import org.genesys2.server.model.impl.GeoReferencedEntity;
@Entity
@Table(name = "acq_geo")
public class AccessionGeo extends BusinessModel {
@Table(name = "accessiongeo")
public class AccessionGeo extends BusinessModel implements GeoReferencedEntity {
@Version
private long version = 0;
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "ALIS_Id", unique = true, nullable = false, updatable = false)
@JoinColumn(name = "accessionId", unique = true, nullable = false, updatable = false)
private Accession accession;
@Column(name = "lng")
@Column(name = "longitude")
private Double longitude;
@Column(name = "lat")
@Column(name = "latitude")
private Double latitude;
@Column(name = "alt")
@Column(name = "altitude")
private Double altitude;
public long getVersion() {
......
......@@ -31,21 +31,21 @@ import org.genesys2.server.model.BusinessModel;
* AllAccnames generated by hbm2java
*/
@Entity
@Table(name = "accnames")
@Table(name = "accessionname")
public class AllAccnames extends BusinessModel{
@Version
private long version = 0;
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "ALIS_Id", unique = true, nullable = false, updatable = false)
@JoinColumn(name = "accessionId", unique = true, nullable = false, updatable = false)
private Accession accession;
@Column(name = "AccNames")
@Column(name = "names")
@Lob
private String accNames;
@Column(name = "OtherIds")
@Column(name = "otherIds")
@Lob
private String otherIds;
......
......@@ -31,20 +31,20 @@ import org.genesys2.server.model.BusinessModel;
* AllAcqBreeding generated by hbm2java
*/
@Entity
@Table(name = "acq_breeding")
@Table(name = "accessionbreeding")
public class AllAcqBreeding extends BusinessModel{
@Version
private long version = 0;
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "ALIS_Id", unique = true, nullable = false, updatable = false)
@JoinColumn(name = "accessionId", unique = true, nullable = false, updatable = false)
private Accession accession;
@Column(name = "Breeder_Code", length = 8)
@Column(name = "breederCode", length = 8)
private String breederCode;
@Column(name = "Pedigree")
@Column(name = "pedigree")
@Lob
private String pedigree;
......
......@@ -33,26 +33,26 @@ import org.genesys2.server.model.BusinessModel;
* AllAcqCollect generated by hbm2java
*/
@Entity
@Table(name = "acq_collect")
@Table(name = "accessioncollect")
public class AllAcqCollect extends BusinessModel {
@Version
private long version = 0;
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "ALIS_Id", unique = true, nullable = false, updatable = false)
@JoinColumn(name = "accessionId", unique = true, nullable = false, updatable = false)
private Accession accession;
@Column(name = "Collect_Date", length = 8)
@Column(name = "date", length = 8)
private String collectDate;
@Column(name = "Collectors_Numb", length = 24)
@Column(name = "collNumb", length = 24)
private String collectorsNumb;
@Column(name = "Collecting_Institute", length = 8)
@Column(name = "instCode", length = 8)
private String collectingInstitute;
@Column(name = "Collect_Site")
@Column(name = "site")
@Lob
private String collectSite;
......
......@@ -30,20 +30,20 @@ import org.genesys2.server.model.BusinessModel;
* AllAcqExchange generated by hbm2java
*/
@Entity
@Table(name = "acq_exchange")
@Table(name = "accessionexchange")
public class AllAcqExchange extends BusinessModel{
@Version
private long version = 0;
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "ALIS_Id", unique = true, nullable = false, updatable = false)
@JoinColumn(name = "accessionId", unique = true, nullable = false, updatable = false)
private Accession accession;
@Column(name = "Donor_Institute", length = 8)
@Column(name = "donorInst", length = 8)
private String donorInstitute;
@Column(name = "Acc_Numb_Donor", length = 36)
@Column(name = "acceNumb", length = 36)
private String accNumbDonor;
public AllAcqExchange() {
......
/**
* Copyright 2013 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 javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
@Entity
@Table(name = "environment")
public class AllEnvironment extends BusinessModel{
@Version
private long version = 0;
@OneToOne(optional = false, fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "ALIS_Id", unique = true, nullable = false, updatable = false)
private Accession accession;
@Column(name = "T_Min_Jan")
private Float TMinJan;
@Column(name = "T_Min_Feb")
private Float TMinFeb;
@Column(name = "T_Min_Mar")
private Float TMinMar;
@Column(name = "T_Min_Apr")
private Float TMinApr;
@Column(name = "T_Min_May")
private Float TMinMay;
@Column(name = "T_Min_Jun")
private Float TMinJun;
@Column(name = "T_Min_Jul")
private Float TMinJul;
@Column(name = "T_Min_Aug")
private Float TMinAug;
@Column(name = "T_Min_Sep")
private Float TMinSep;
@Column(name = "T_Min_Oct")
private Float TMinOct;
@Column(name = "T_Min_Nov")
private Float TMinNov;
@Column(name = "T_Min_Dec")
private Float TMinDec;
@Column(name = "T_Max_Jan")
private Float TMaxJan;
@Column(name = "T_Max_Feb")
private Float TMaxFeb;
@Column(name = "T_Max_Mar")
private Float TMaxMar;
@Column(name = "T_Max_Apr")
private Float TMaxApr;
@Column(name = "T_Max_May")
private Float TMaxMay;
@Column(name = "T_Max_Jun")
private Float TMaxJun;
@Column(name = "T_Max_Jul")
private Float TMaxJul;
@Column(name = "T_Max_Aug")
private Float TMaxAug;
@Column(name = "T_Max_Sep")
private Float TMaxSep;
@Column(name = "T_Max_Oct")
private Float TMaxOct;
@Column(name = "T_Max_Nov")
private Float TMaxNov;
@Column(name = "T_Max_Dec")
private Float TMaxDec;
@Column(name = "P_Jan")
private Float PJan;
@Column(name = "P_Feb")
private Float PFeb;
@Column(name = "P_Mar")
private Float PMar;
@Column(name = "P_Apr")
private Float PApr;
@Column(name = "P_May")
private Float PMay;
@Column(name = "P_Jun")
private Float PJun;
@Column(name = "P_Jul")
private Float PJul;
@Column(name = "P_Aug")
private Float PAug;
@Column(name = "P_Sep")
private Float PSep;
@Column(name = "P_Oct")
private Float POct;
@Column(name = "P_Nov")
private Float PNov;
@Column(name = "P_Dec")
private Float PDec;
@Column(name = "T_Min_Annual")
private Float TMinAnnual;
@Column(name = "T_Max_Annual")
private Float TMaxAnnual;
@Column(name = "P_Max_Annual")
private Float PMaxAnnual;
@Column(name = "Bio_1")
private Float bio1;
@Column(name = "Bio_2")
private Float bio2;
@Column(name = "Bio_3")
private Float bio3;
@Column(name = "Bio_4")
private Float bio4;
@Column(name = "Bio_5")
private Float bio5;