Commit 12860fb1 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'master' into emailvalidation

parents 6f55cdba 01f76b17
ALTER TABLE `accession` ADD COLUMN `version` BIGINT NOT NULL DEFAULT 0 AFTER `id` ,
ADD COLUMN `uuid` VARCHAR(36) NULL DEFAULT NULL AFTER `Institute` ;
-- Availability
select Availability, count(*) from accession group by availability;
-- select Availability, count(*) from accession group by availability;
update accession set Availability=0 where Availability='N';
update accession set Availability=1 where Availability='Y';
......@@ -9,7 +9,7 @@ ALTER TABLE `accession` CHANGE COLUMN `Availability` `Availability` BIT NULL DEF
-- MLS_Status
select MLS_Status, count(*) from accession group by MLS_Status;
-- select MLS_Status, count(*) from accession group by MLS_Status;
ALTER TABLE `accession` CHANGE COLUMN `MLS_Status` `MLS_Status` char(1) NULL DEFAULT NULL COMMENT 'In MLS' ;
......@@ -20,7 +20,7 @@ update accession set MLS_Status=null where MLS_Status not in ('0', '1');
ALTER TABLE `accession` CHANGE COLUMN `MLS_Status` `MLS_Status` BIT NULL DEFAULT NULL COMMENT 'In MLS' ;
-- In_Svalbard
select In_Svalbard, count(*) from accession group by In_Svalbard;
-- select In_Svalbard, count(*) from accession group by In_Svalbard;
ALTER TABLE `accession` CHANGE COLUMN `In_Svalbard` `In_Svalbard` char(1) NULL DEFAULT NULL COMMENT 'In Svalbard' ;
......@@ -32,7 +32,7 @@ ALTER TABLE `accession` CHANGE COLUMN `In_Svalbard` `In_Svalbard` BIT NULL DEFAU
-- In_Trust
select In_Trust, count(*) from accession group by In_Trust;
-- select In_Trust, count(*) from accession group by In_Trust;
ALTER TABLE `accession` CHANGE COLUMN `In_Trust` `In_Trust` char(1) NULL DEFAULT NULL COMMENT 'Article 15 accession' ;
......
update accession set ACC_Numb_HI=concat('ICG ', ACC_Numb_HI) where Institute='IND002' and Genuss='Arachis';
update accession set ACC_Numb_HI=concat('ICP ', ACC_Numb_HI) where Institute='IND002' and Genuss='Cajanus';
update accession set ACC_Numb_HI=concat('ICC ', ACC_Numb_HI) where Institute='IND002' and Genuss='Cicer';
update accession set ACC_Numb_HI=concat('IEc ', ACC_Numb_HI) where Institute='IND002' and Genuss='Echinochloa';
update accession set ACC_Numb_HI=concat('IE ', ACC_Numb_HI) where Institute='IND002' and Genuss='Eleusine';
update accession set ACC_Numb_HI=concat('IPs ', ACC_Numb_HI) where Institute='IND002' and Genuss='Paspalum';
update accession set ACC_Numb_HI=concat('IP ', ACC_Numb_HI) where Institute='IND002' and Genuss='Pennisetum';
update accession set ACC_Numb_HI=concat('ISe ', ACC_Numb_HI) where Institute='IND002' and Genuss='Setaria';
update accession set ACC_Numb_HI=concat('IS ', ACC_Numb_HI) where Institute='IND002' and Genuss='Sorghum';
update accession set ACC_Numb_HI=concat('IPmr ', ACC_Numb_HI) where Institute='IND002' and Taxon_Code in (select Taxon_Code from taxonomy where genus='Panicum' and species='sumatrense');
update accession set ACC_Numb_HI=concat('IPm ', ACC_Numb_HI) where Institute='IND002' and Taxon_Code in (select Taxon_Code from taxonomy where genus='Panicum' and species='miliaceum');
-- Add @Id, @Version to acq_collect, ...
ALTER TABLE `all_accnames` RENAME TO `accnames` ;
ALTER TABLE `all_acq_breeding` RENAME TO `acq_breeding` ;
ALTER TABLE `all_acq_collect` RENAME TO `acq_collect` ;
ALTER TABLE `all_acq_exchange` RENAME TO `acq_exchange` ;
ALTER TABLE `all_environment` RENAME TO `environment` ;
ALTER TABLE `acq_breeding` ADD COLUMN `version` BIGINT NOT NULL DEFAULT 0,
CHANGE COLUMN `ALIS_Id` `ALIS_Id` BIGINT NOT NULL ,
ADD COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT FIRST ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`id`) ,
ADD UNIQUE INDEX `ALIS_Id_UNIQUE` (`ALIS_Id` ASC) ;
ALTER TABLE `acq_collect` ADD COLUMN `version` BIGINT NOT NULL DEFAULT 0,
CHANGE COLUMN `ALIS_Id` `ALIS_Id` BIGINT NOT NULL ,
ADD COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT FIRST ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`id`) ,
ADD UNIQUE INDEX `ALIS_Id_UNIQUE` (`ALIS_Id` ASC) ;
ALTER TABLE `acq_exchange` ADD COLUMN `version` BIGINT NOT NULL DEFAULT 0,
CHANGE COLUMN `ALIS_Id` `ALIS_Id` BIGINT NOT NULL ,
ADD COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT FIRST ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`id`) ,
ADD UNIQUE INDEX `ALIS_Id_UNIQUE` (`ALIS_Id` ASC) ;
ALTER TABLE `environment` ADD COLUMN `version` BIGINT NOT NULL DEFAULT 0,
CHANGE COLUMN `ALIS_Id` `ALIS_Id` BIGINT NOT NULL ,
ADD COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT FIRST ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`id`) ,
ADD UNIQUE INDEX `ALIS_Id_UNIQUE` (`ALIS_Id` ASC) ;
ALTER TABLE `accnames` ADD COLUMN `version` BIGINT NOT NULL DEFAULT 0,
CHANGE COLUMN `ALIS_Id` `ALIS_Id` BIGINT NOT NULL ,
ADD COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT FIRST ,
DROP PRIMARY KEY ,
ADD PRIMARY KEY (`id`) ,
ADD UNIQUE INDEX `ALIS_Id_UNIQUE` (`ALIS_Id` ASC) ;
-- Create acq_geo table
create table acq_geo as select id, ALIS_Id, version, LatitudeD as lat, LongitudeD as lng, Altitude as alt from environment;
ALTER TABLE `acq_geo` CHANGE COLUMN `id` `id` BIGINT(20) NOT NULL AUTO_INCREMENT, modify column alt double null, ADD PRIMARY KEY (`id`) ;
-- alter table environment drop column LatitudeD, drop column LongitudeD, drop column Altitude;
ALTER TABLE `accession` DROP COLUMN `dataSource` , CHANGE COLUMN `ACC_Numb_HI` `ACC_Numb_HI` VARCHAR(36) NOT NULL COMMENT 'Accession Number at Holding Institute' , CHANGE COLUMN `Taxon_Code` `Taxon_Code` BIGINT NOT NULL COMMENT 'Taxon Code' , CHANGE COLUMN `Acquisition_Source` `Acquisition_Source` VARCHAR(3) NULL COMMENT 'Acquisition Source Code' , CHANGE COLUMN `Acquisition_Date` `Acquisition_Date` VARCHAR(8) NULL COMMENT 'Acquisition Date' , CHANGE COLUMN `Origin` `Origin` VARCHAR(3) NULL COMMENT 'Country of Origin ISO Code' , CHANGE COLUMN `Dubl_Inst` `Dubl_Inst` VARCHAR(8) NULL COMMENT 'Duplicate Institute' , CHANGE COLUMN `Sample_Status` `Sample_Status` VARCHAR(3) NULL COMMENT 'Sample Status Code' , CHANGE COLUMN `Storage` `Storage` VARCHAR(12) NULL COMMENT 'Storage Type Code' , CHANGE COLUMN `Genuss` `Genuss` VARCHAR(32) NOT NULL ;
......@@ -67,10 +67,10 @@
<name>ibiblio.mirrors</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
</repository>
<repository>
<!-- <repository>
<id>sonatype mirror</id>
<url>http://search.maven.org/remotecontent?filepath=</url>
</repository>
</repository> -->
</repositories>
<dependencies>
......
......@@ -22,10 +22,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AllAccnames;
import org.genesys2.server.model.genesys.AllAcqBreeding;
import org.genesys2.server.model.genesys.AllAcqCollect;
import org.genesys2.server.model.genesys.AllAcqExchange;
import org.genesys2.server.model.genesys.Taxonomy;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute;
......@@ -68,31 +64,31 @@ public class AccessionBridge implements FieldBridge {
if (institute.getCountry() != null)
sd.append(institute.getCountry().getName());
}
AllAccnames accNames = accession.getAccessionNames();
if (accNames != null) {
sd.append(accNames.getOtherIds());
sd.append(accNames.getAccNames());
}
AllAcqBreeding accBreeding = accession.getAccessionBreeding();
if (accBreeding != null) {
sd.append(accBreeding.getPedigree());
sd.append(accBreeding.getBreederCode());
}
AllAcqCollect accCollect = accession.getAccessionCollection();
if (accCollect != null) {
sd.append(accCollect.getCollectSite());
sd.append(accCollect.getCollectorsNumb());
sd.append(accCollect.getCollectingInstitute());
}
AllAcqExchange accExchange = accession.getAccessionExchange();
if (accExchange != null) {
sd.append(accExchange.getDonorInstitute());
sd.append(accExchange.getAccNumbDonor());
}
// AllAccnames accNames = accession.getAccessionNames();
// if (accNames != null) {
// sd.append(accNames.getOtherIds());
// sd.append(accNames.getAccNames());
// }
//
// AllAcqBreeding accBreeding = accession.getAccessionBreeding();
// if (accBreeding != null) {
// sd.append(accBreeding.getPedigree());
// sd.append(accBreeding.getBreederCode());
// }
//
// AllAcqCollect accCollect = accession.getAccessionCollection();
// if (accCollect != null) {
// sd.append(accCollect.getCollectSite());
// sd.append(accCollect.getCollectorsNumb());
// sd.append(accCollect.getCollectingInstitute());
// }
//
// AllAcqExchange accExchange = accession.getAccessionExchange();
// if (accExchange != null) {
// sd.append(accExchange.getDonorInstitute());
// sd.append(accExchange.getAccNumbDonor());
// }
//
LOG.debug("IDX." + name + " = " + sd.toString());
Field field = new Field(name, sd.toString(), luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
field.setBoost(luceneOptions.getBoost());
......
......@@ -20,16 +20,15 @@ package org.genesys2.server.model.genesys;
import java.text.MessageFormat;
import javax.persistence.CascadeType;
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.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import org.genesys2.server.lucene.genesys.AccessionBridge;
import org.genesys2.server.model.impl.Country;
......@@ -46,6 +45,8 @@ import org.hibernate.search.annotations.Indexed;
public class Accession implements java.io.Serializable {
private static final long serialVersionUID = -7630113633534038876L;
private Long id;
private long version = 0;
private String uuid;
private String instituteCode;
private FaoInstitute institute;
private String accNumbHi;
......@@ -62,13 +63,6 @@ public class Accession implements java.io.Serializable {
private Boolean availability;
private Boolean mlsStatus;
private String genus;
private String dataSource;
private AllAccnames accessionNames;
private AllAcqBreeding accessionBreeding;
private AllAcqCollect accessionCollection;
private AllAcqExchange accessionExchange;
private AllEnvironment accessionEnvironment;
private SvalbardData svalbardData;
public Accession() {
}
......@@ -85,6 +79,24 @@ public class Accession implements java.io.Serializable {
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;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "instituteId")
public FaoInstitute getInstitute() {
......@@ -232,75 +244,6 @@ public class Accession implements java.io.Serializable {
this.genus = genuss;
}
@OneToOne
@JoinColumn(name = "id", referencedColumnName = "ALIS_Id")
public AllAccnames getAccessionNames() {
return accessionNames;
}
public void setAccessionNames(AllAccnames accessionNames) {
this.accessionNames = accessionNames;
}
@OneToOne
@JoinColumn(name = "id", referencedColumnName = "ALIS_Id")
public AllAcqBreeding getAccessionBreeding() {
return accessionBreeding;
}
public void setAccessionBreeding(AllAcqBreeding accessionBreeding) {
this.accessionBreeding = accessionBreeding;
}
@OneToOne
@JoinColumn(name = "id", referencedColumnName = "ALIS_Id")
public AllAcqCollect getAccessionCollection() {
return accessionCollection;
}
public void setAccessionCollection(AllAcqCollect accessionCollection) {
this.accessionCollection = accessionCollection;
}
@OneToOne
@JoinColumn(name = "id", referencedColumnName = "ALIS_Id")
public AllAcqExchange getAccessionExchange() {
return accessionExchange;
}
public void setAccessionExchange(AllAcqExchange accessionExchange) {
this.accessionExchange = accessionExchange;
}
@OneToOne
@JoinColumn(name = "id", referencedColumnName = "ALIS_Id")
public AllEnvironment getAccessionEnvironment() {
return accessionEnvironment;
}
public void setAccessionEnvironment(AllEnvironment accessionEnvironment) {
this.accessionEnvironment = accessionEnvironment;
}
@OneToOne(orphanRemoval = true, cascade = CascadeType.REMOVE, optional = true)
@JoinColumn(name = "id", referencedColumnName = "id")
public SvalbardData getSvalbardData() {
return svalbardData;
}
public void setSvalbardData(SvalbardData svalbardData) {
this.svalbardData = svalbardData;
}
@Column(name = "dataSource", length = 45)
public String getDataSource() {
return dataSource;
}
public void setDataSource(String dataSource) {
this.dataSource = dataSource;
}
@Override
public String toString() {
return MessageFormat.format("Accession id={0,number,#} A={3} inst={1} genus={2}", id, instituteCode, genus, accNumbHi);
......
/**
* 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 = "acq_geo")
public class AccessionGeo 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 = "lng")
private Double longitude;
@Column(name = "lat")
private Double latitude;
@Column(name = "alt")
private Double altitude;
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
public Accession getAccession() {
return accession;
}
public void setAccession(Accession accession) {
this.accession = accession;
}
public Double getLongitude() {
return this.longitude;
}
public void setLongitude(final Double longitudeD) {
this.longitude = longitudeD;
}
public Double getLatitude() {
return this.latitude;
}
public void setLatitude(final Double latitudeD) {
this.latitude = latitudeD;
}
public Double getAltitude() {
return this.altitude;
}
public void setAltitude(final Double altitude) {
this.altitude = altitude;
}
}
......@@ -16,54 +16,58 @@
package org.genesys2.server.model.genesys;
// Generated Apr 24, 2013 10:08:59 AM by Hibernate Tools 4.0.0
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
/**
* AllAccnames generated by hbm2java
*/
@Entity
@Table(name = "accnames")
public class AllAccnames implements java.io.Serializable {
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)
private Accession accession;
/**
*
*/
private static final long serialVersionUID = -2785898802497223245L;
private long alisId;
@Column(name = "AccNames")
@Lob
private String accNames;
@Column(name = "OtherIds")
@Lob
private String otherIds;
public AllAccnames() {
}
public AllAccnames(final int alisId) {
this.alisId = alisId;
public long getVersion() {
return version;
}
public AllAccnames(final int alisId, final String accNames, final String otherIds) {
this.alisId = alisId;
this.accNames = accNames;
this.otherIds = otherIds;
public void setVersion(long version) {
this.version = version;
}
@Id
@Column(name = "ALIS_Id", unique = true, nullable = false)
public long getAlisId() {
return this.alisId;
public Accession getAccession() {
return accession;
}
public void setAlisId(final long alisId) {
this.alisId = alisId;
public void setAccession(Accession accession) {
this.accession = accession;
}
@Column(name = "AccNames")
@Lob
public String getAccNames() {
return this.accNames;
}
......@@ -72,8 +76,6 @@ public class AllAccnames implements java.io.Serializable {
this.accNames = accNames;
}
@Column(name = "OtherIds")
@Lob
public String getOtherIds() {
return this.otherIds;
}
......
......@@ -16,53 +16,57 @@
package org.genesys2.server.model.genesys;
// Generated Apr 24, 2013 10:08:59 AM by Hibernate Tools 4.0.0
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
/**
* AllAcqBreeding generated by hbm2java
*/
@Entity
@Table(name = "acq_breeding")
public class AllAcqBreeding implements java.io.Serializable {
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)
private Accession accession;
/**
*
*/
private static final long serialVersionUID = 2762545036218363406L;
private long alisId;
@Column(name = "Breeder_Code", length = 8)
private String breederCode;
@Column(name = "Pedigree")
@Lob
private String pedigree;
public AllAcqBreeding() {
}
public AllAcqBreeding(final int alisId) {
this.alisId = alisId;
public long getVersion() {
return version;
}
public AllAcqBreeding(final int alisId, final String breederCode, final String pedigree) {
this.alisId = alisId;
this.breederCode = breederCode;
this.pedigree = pedigree;
public void setVersion(long version) {
this.version = version;
}
@Id
@Column(name = "ALIS_Id", unique = true, nullable = false)
public long getAlisId() {
return this.alisId;
public Accession getAccession() {
return accession;
}
public void setAlisId(final long alisId) {
this.alisId = alisId;
public void setAccession(Accession accession) {
this.accession = accession;
}
@Column(name = "Breeder_Code", length = 8)
public String getBreederCode() {
return this.breederCode;