Commit 89227162 authored by Matija Obreza's avatar Matija Obreza
Browse files

Metadata (experiments), Methods

parent e3fb08f8
...@@ -2,6 +2,8 @@ eclipse.preferences.version=1 ...@@ -2,6 +2,8 @@ eclipse.preferences.version=1
encoding//src/main/resources=UTF-8 encoding//src/main/resources=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/country/data.jsp=UTF-8 encoding//src/main/webapp/WEB-INF/jsp/country/data.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/login.jsp=UTF-8 encoding//src/main/webapp/WEB-INF/jsp/login.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/metadata/index.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/metadata/view.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/wiews/data.jsp=UTF-8 encoding//src/main/webapp/WEB-INF/jsp/wiews/data.jsp=UTF-8
encoding//src/main/webapp/WEB-INF/jsp/wiews/index.jsp=UTF-8 encoding//src/main/webapp/WEB-INF/jsp/wiews/index.jsp=UTF-8
encoding//src/test/resources=UTF-8 encoding//src/test/resources=UTF-8
......
...@@ -23,13 +23,10 @@ import javax.persistence.GenerationType; ...@@ -23,13 +23,10 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
@SuppressWarnings("serial")
@MappedSuperclass @MappedSuperclass
public abstract class BusinessModel implements HibernateModel { public abstract class BusinessModel implements HibernateModel {
/**
*
*/
private static final long serialVersionUID = -7550280319451806328L;
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false, length = 20) @Column(name = "id", unique = true, nullable = false, length = 20)
......
package org.crophub.rest.common.model.genesys;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "accessiontrait")
public class AccessionTrait implements Serializable {
private static final long serialVersionUID = -240056837800843686L;
private Long id;
private Accession accession;
private Metadata metadata;
private Method method;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "accessionId")
public Accession getAccession() {
return accession;
}
public void setAccession(Accession accession) {
this.accession = accession;
}
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "metadataId")
public Metadata getMetadata() {
return metadata;
}
public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "methodId")
public Method getMethod() {
return method;
}
public void setMethod(Method method) {
this.method = method;
}
}
...@@ -59,10 +59,8 @@ public class Metadata implements java.io.Serializable { ...@@ -59,10 +59,8 @@ public class Metadata implements java.io.Serializable {
this.title = title; this.title = title;
} }
public Metadata(final String institute, final String title, final String SDate, final String EDate, public Metadata(final String institute, final String title, final String SDate, final String EDate, final String location, final Double long_,
final String location, final Double lat, final Double alt, final String citation, final String description) {
final Double long_, final Double lat, final Double alt,
final String citation, final String description) {
this.institute = institute; this.institute = institute;
this.title = title; this.title = title;
this.SDate = SDate; this.SDate = SDate;
...@@ -77,6 +75,7 @@ public class Metadata implements java.io.Serializable { ...@@ -77,6 +75,7 @@ public class Metadata implements java.io.Serializable {
@Id @Id
@GeneratedValue(strategy = IDENTITY) @GeneratedValue(strategy = IDENTITY)
@Column(name = "Meta_id")
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
...@@ -103,7 +102,7 @@ public class Metadata implements java.io.Serializable { ...@@ -103,7 +102,7 @@ public class Metadata implements java.io.Serializable {
this.title = title; this.title = title;
} }
@Column(length = 10) @Column(name = "S_Date", length = 10)
public String getSDate() { public String getSDate() {
return this.SDate; return this.SDate;
} }
...@@ -112,7 +111,7 @@ public class Metadata implements java.io.Serializable { ...@@ -112,7 +111,7 @@ public class Metadata implements java.io.Serializable {
this.SDate = SDate; this.SDate = SDate;
} }
@Column(length = 10) @Column(name = "E_Date", length = 10)
public String getEDate() { public String getEDate() {
return this.EDate; return this.EDate;
} }
...@@ -130,6 +129,7 @@ public class Metadata implements java.io.Serializable { ...@@ -130,6 +129,7 @@ public class Metadata implements java.io.Serializable {
this.location = location; this.location = location;
} }
@Column(name = "Long")
public Double getLongitude() { public Double getLongitude() {
return this.longitude; return this.longitude;
} }
...@@ -138,6 +138,7 @@ public class Metadata implements java.io.Serializable { ...@@ -138,6 +138,7 @@ public class Metadata implements java.io.Serializable {
this.longitude = longitude; this.longitude = longitude;
} }
@Column(name = "Lat")
public Double getLatitude() { public Double getLatitude() {
return this.latitude; return this.latitude;
} }
...@@ -146,6 +147,7 @@ public class Metadata implements java.io.Serializable { ...@@ -146,6 +147,7 @@ public class Metadata implements java.io.Serializable {
this.latitude = latitude; this.latitude = latitude;
} }
@Column(name = "Alt")
public Double getAltitude() { public Double getAltitude() {
return this.altitude; return this.altitude;
} }
...@@ -174,9 +176,7 @@ public class Metadata implements java.io.Serializable { ...@@ -174,9 +176,7 @@ public class Metadata implements java.io.Serializable {
@Override @Override
public String toString() { public String toString() {
return MessageFormat return MessageFormat.format("Metadata id={0,number,#} inst={2} title={1}", id, title, institute);
.format("Metadata id={0,number,#} inst={2} title={1}",
id, title, institute);
} }
} }
...@@ -28,7 +28,7 @@ import javax.persistence.Table; ...@@ -28,7 +28,7 @@ import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
@Entity @Entity
@Table(name = "method") @Table(name = "methods")
public class Method implements java.io.Serializable { public class Method implements java.io.Serializable {
/** /**
...@@ -51,6 +51,7 @@ public class Method implements java.io.Serializable { ...@@ -51,6 +51,7 @@ public class Method implements java.io.Serializable {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="Method_Id")
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
...@@ -70,7 +71,7 @@ public class Method implements java.io.Serializable { ...@@ -70,7 +71,7 @@ public class Method implements java.io.Serializable {
// } // }
@ManyToOne(cascade = {}, optional = false) @ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "parameterId", nullable = false) @JoinColumn(name = "Par_Id", nullable = false)
public Parameter getParameter() { public Parameter getParameter() {
return this.parameter; return this.parameter;
} }
...@@ -187,7 +188,7 @@ public class Method implements java.io.Serializable { ...@@ -187,7 +188,7 @@ public class Method implements java.io.Serializable {
// return TraitCode.parseOptionsMap(this.options); // return TraitCode.parseOptionsMap(this.options);
// } // }
@Column(name = "dataRange", length = 32) @Column(name = "Range", length = 32)
public String getRange() { public String getRange() {
return this.range; return this.range;
} }
......
...@@ -24,7 +24,7 @@ import javax.persistence.Id; ...@@ -24,7 +24,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
@Entity @Entity
@Table(name = "parameter") @Table(name = "parameters")
public class Parameter implements java.io.Serializable { public class Parameter implements java.io.Serializable {
/** /**
...@@ -32,17 +32,17 @@ public class Parameter implements java.io.Serializable { ...@@ -32,17 +32,17 @@ public class Parameter implements java.io.Serializable {
*/ */
private static final long serialVersionUID = -4831244149317371274L; private static final long serialVersionUID = -4831244149317371274L;
private Long id; private Long id;
// private Language language; // private Language language;
// private Crop crop; // private Crop crop;
// private Category category; // private Category category;
private String title; private String title;
public Parameter() { public Parameter() {
} }
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "Par_Id")
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
...@@ -51,35 +51,35 @@ public class Parameter implements java.io.Serializable { ...@@ -51,35 +51,35 @@ public class Parameter implements java.io.Serializable {
this.id = parId; this.id = parId;
} }
// @ManyToOne(cascade = {}, optional = false) // @ManyToOne(cascade = {}, optional = false)
// @JoinColumn(name = "languageId") // @JoinColumn(name = "languageId")
// public Language getLanguage() { // public Language getLanguage() {
// return this.language; // return this.language;
// } // }
// //
// public void setLanguage(final Language language) { // public void setLanguage(final Language language) {
// this.language = language; // this.language = language;
// } // }
// //
// @ManyToOne(cascade = {}, optional = false) // @ManyToOne(cascade = {}, optional = false)
// @JoinColumn(name = "cropId") // @JoinColumn(name = "cropId")
// public Crop getCrop() { // public Crop getCrop() {
// return this.crop; // return this.crop;
// } // }
// //
// public void setCrop(final Crop crop) { // public void setCrop(final Crop crop) {
// this.crop = crop; // this.crop = crop;
// } // }
// //
// @ManyToOne(cascade = {}, optional = false) // @ManyToOne(cascade = {}, optional = false)
// @JoinColumn(name = "categoryId", nullable = false) // @JoinColumn(name = "categoryId", nullable = false)
// public Category getCategory() { // public Category getCategory() {
// return this.category; // return this.category;
// } // }
// //
// public void setCategory(final Category category) { // public void setCategory(final Category category) {
// this.category = category; // this.category = category;
// } // }
@Column(nullable = false, length = 32) @Column(nullable = false, length = 32)
public String getTitle() { public String getTitle() {
...@@ -90,12 +90,12 @@ public class Parameter implements java.io.Serializable { ...@@ -90,12 +90,12 @@ public class Parameter implements java.io.Serializable {
this.title = title; this.title = title;
} }
// @Override // @Override
// public String toString() { // public String toString() {
// return MessageFormat // return MessageFormat
// .format("Parameter id={0,number,#} title={1} lang={2} crop={3} cat={4}", // .format("Parameter id={0,number,#} title={1} lang={2} crop={3} cat={4}",
// id, title, language.getId(), crop.getName(), // id, title, language.getId(), crop.getName(),
// category.getTitle()); // category.getTitle());
// } // }
} }
/**
* 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.crophub.rest.common.persistence.domain;
import java.util.List;
import org.crophub.rest.common.model.genesys.Accession;
import org.crophub.rest.common.model.genesys.AccessionTrait;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface AccessionTraitRepository extends JpaRepository<AccessionTrait, Long> {
List<AccessionTrait> findByAccession(Accession accession);
List<AccessionTrait> findByMetadata(Metadata metadata);
List<AccessionTrait> findByMethod(Method method);
@Query("select distinct at.metadata from AccessionTrait at where at.accession = ?1")
List<Metadata> listMetadata(Accession accession);
@Query("select distinct at.method from AccessionTrait at where at.accession = ?1")
List<Method> listMethods(Accession accession);
@Query("select distinct at.accession from AccessionTrait at where at.metadata = ?1")
Page<Accession> listMetadataAccessions(Metadata metadata, Pageable pageable);
@Query("select distinct at.method from AccessionTrait at where at.metadata = ?1")
List<Method> listMetadataMethods(Metadata metadata);
}
...@@ -7,9 +7,12 @@ import org.crophub.rest.common.model.genesys.AllAccnames; ...@@ -7,9 +7,12 @@ import org.crophub.rest.common.model.genesys.AllAccnames;
import org.crophub.rest.common.model.genesys.AllAcqBreeding; import org.crophub.rest.common.model.genesys.AllAcqBreeding;
import org.crophub.rest.common.model.genesys.AllAcqCollect; import org.crophub.rest.common.model.genesys.AllAcqCollect;
import org.crophub.rest.common.model.genesys.AllAcqExchange; import org.crophub.rest.common.model.genesys.AllAcqExchange;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
import org.crophub.rest.common.model.impl.Country; import org.crophub.rest.common.model.impl.Country;
import org.crophub.rest.common.model.impl.FaoInstitute; import org.crophub.rest.common.model.impl.FaoInstitute;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
public interface GenesysService { public interface GenesysService {
...@@ -36,4 +39,14 @@ public interface GenesysService { ...@@ -36,4 +39,14 @@ public interface GenesysService {
List<AllAcqBreeding> listAccessionBreeding(Accession accession); List<AllAcqBreeding> listAccessionBreeding(Accession accession);
List<Metadata> listMetadata(Accession accession);
Page<Metadata> listMetadata(PageRequest pageRequest);
Metadata getMetadata(long metadataId);
List<Method> listMethods(Metadata metadata);
Page<Accession> listMetadataAccessions(Metadata metadata, PageRequest pageRequest);
} }
...@@ -7,96 +7,128 @@ import org.crophub.rest.common.model.genesys.AllAccnames; ...@@ -7,96 +7,128 @@ import org.crophub.rest.common.model.genesys.AllAccnames;
import org.crophub.rest.common.model.genesys.AllAcqBreeding; import org.crophub.rest.common.model.genesys.AllAcqBreeding;
import org.crophub.rest.common.model.genesys.AllAcqCollect; import org.crophub.rest.common.model.genesys.AllAcqCollect;
import org.crophub.rest.common.model.genesys.AllAcqExchange; import org.crophub.rest.common.model.genesys.AllAcqExchange;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
import org.crophub.rest.common.model.impl.Country; import org.crophub.rest.common.model.impl.Country;
import org.crophub.rest.common.model.impl.FaoInstitute; import org.crophub.rest.common.model.impl.FaoInstitute;
import org.crophub.rest.common.persistence.domain.AccessionBreedingRepository; import org.crophub.rest.common.persistence.domain.AccessionBreedingRepository;
import org.crophub.rest.common.persistence.domain.AccessionCollectRepository; import org.crophub.rest.common.persistence.domain.AccessionCollectRepository;
import org.crophub.rest.common.persistence.domain.AccessionNameRepository; import org.crophub.rest.common.persistence.domain.AccessionNameRepository;
import org.crophub.rest.common.persistence.domain.AccessionRepository; import org.crophub.rest.common.persistence.domain.AccessionRepository;
import org.crophub.rest.common.persistence.domain.AccessionTraitRepository;
import org.crophub.rest.common.persistence.domain.MetadataRepository;
import org.crophub.rest.common.persistence.domain.MethodRepository; import org.crophub.rest.common.persistence.domain.MethodRepository;
import org.crophub.rest.common.service.GenesysService; import org.crophub.rest.common.service.GenesysService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@Transactional(readOnly=true) @Transactional(readOnly = true)
public class GenesysServiceImpl implements GenesysService { public class GenesysServiceImpl implements GenesysService {
@Autowired @Autowired
private AccessionRepository accessionRepository; private AccessionRepository accessionRepository;
@Autowired @Autowired
private AccessionBreedingRepository accessionBreedingRepository; private AccessionBreedingRepository accessionBreedingRepository;
@Autowired @Autowired
private AccessionCollectRepository accessionCollectRepository; private AccessionCollectRepository accessionCollectRepository;
@Autowired @Autowired
private AccessionNameRepository accessionNamesRepository; private AccessionNameRepository accessionNamesRepository;
@Autowired
private AccessionTraitRepository accessionTraitRepository;
@Autowired
private MetadataRepository metadataRepository;
@Autowired @Autowired
private MethodRepository methodRepository; private MethodRepository methodRepository;
@Override @Override
public long countByInstitute(FaoInstitute institute) { public long countByInstitute(FaoInstitute institute) {
return accessionRepository.countByInstitute(institute); return accessionRepository.countByInstitute(institute);
} }
@Override @Override
public long countByOrigin(String isoCode3) { public long countByOrigin(String isoCode3) {
return accessionRepository.countByOrigin(isoCode3); return accessionRepository.countByOrigin(isoCode3);
} }
@Override @Override
public long countByLocation(String isoCode3) { public long countByLocation(String isoCode3) {
return accessionRepository.countByLocation(isoCode3); return accessionRepository.countByLocation(isoCode3);
} }
@Override @Override
public Page<Accession> listAccessionsByOrigin(Country country, Pageable pageable) { public Page<Accession> listAccessionsByOrigin(Country country, Pageable pageable) {
return accessionRepository.findByOrigin(country.getCode3(), pageable); return accessionRepository.findByOrigin(country.getCode3(), pageable);
} }