From e64e1bcb962c51220f07414c6061201321c8ad62 Mon Sep 17 00:00:00 2001 From: "ben.clark" Date: Sat, 13 Dec 2008 16:43:15 +0000 Subject: [PATCH] Partially implemented new methods for DescriptionDaoHibernateImpl, but need to change mapping of DescriptionBase -> DescriptionElementBase to bidirectional first --- .gitattributes | 3 + .../dao/description/IDescriptionDao.java | 25 + .../description/IDescriptionElementDao.java | 45 + .../description/DescriptionDaoImpl.java | 50 + .../DescriptionDaoHibernateImplTest.java | 18 + .../description/TaxonDaoHibernateImplTest.xml | 1802 +++++++++++++++++ 6 files changed, 1943 insertions(+) create mode 100644 cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionElementDao.java create mode 100644 cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java create mode 100644 cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/description/TaxonDaoHibernateImplTest.xml diff --git a/.gitattributes b/.gitattributes index 647ca8806f..fd0bc751ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -986,6 +986,7 @@ cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/IRepres cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ITermVocabularyDao.java -text cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ITitledDao.java -text cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java -text +cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionElementDao.java -text cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IFeatureDao.java -text cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IFeatureNodeDao.java -text cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IFeatureTreeDao.java -text @@ -1048,6 +1049,7 @@ cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/comm cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DaoBaseTest.java -text cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DefinedTermDaoImplTest.java -text cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBaseTest.java -text +cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java -text cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java -text cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java -text cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/test/function/TestCdmApplicationUtils.java -text @@ -1075,6 +1077,7 @@ cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DefinedTermDaoImplTest.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBaseTest.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/dataset.xsd -text +cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/description/TaxonDaoHibernateImplTest.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.xml -text cdmlib-persistence/src/test/resources/unitils.properties -text cdmlib-remote/LICENSE.TXT -text diff --git a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java index 9e87fa413b..5d4898f1d5 100644 --- a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java +++ b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionDao.java @@ -9,8 +9,33 @@ package eu.etaxonomy.cdm.persistence.dao.description; +import java.util.List; +import java.util.Set; + import eu.etaxonomy.cdm.model.description.DescriptionBase; +import eu.etaxonomy.cdm.model.description.DescriptionElementBase; +import eu.etaxonomy.cdm.model.description.Feature; +import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase; +import eu.etaxonomy.cdm.model.description.Scope; +import eu.etaxonomy.cdm.model.description.TaxonDescription; +import eu.etaxonomy.cdm.model.location.NamedArea; +import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao; public interface IDescriptionDao extends IIdentifiableDao { + List listDescriptions(Class type, Boolean hasImages, Boolean hasText, Set feature, Integer pageSize, Integer pageNumber); + + int countDescriptions(Class type, Boolean hasImages, Boolean hasText, Set feature); + + List getDescriptionElements(DescriptionBase description, List features, Class type, Integer pageSize, Integer pageNumber); + + int countDescriptionElements(DescriptionBase description, List features, Class type); + + List getTaxonDescriptions(Taxon taxon, Set scopes, Set geographicalScope, Integer pageSize, Integer pageNumber); + + int countTaxonDescriptions(Taxon taxon, Set scopes, Set geographicalScope); + + List searchDescriptionByDistribution(Set namedAreas, PresenceAbsenceTermBase presence, Integer pageSize, Integer pageNumber); + + int countDescriptionByDistribution(Set namedAreas, PresenceAbsenceTermBase presence); } diff --git a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionElementDao.java b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionElementDao.java new file mode 100644 index 0000000000..2170a39f5d --- /dev/null +++ b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IDescriptionElementDao.java @@ -0,0 +1,45 @@ +package eu.etaxonomy.cdm.persistence.dao.description; + +import java.util.List; + +import eu.etaxonomy.cdm.model.description.DescriptionElementBase; +import eu.etaxonomy.cdm.model.description.TextData; +import eu.etaxonomy.cdm.model.media.Media; +import eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao; + +public interface IDescriptionElementDao extends ICdmEntityDao { + /** + * This query is designed to search the the descriptions. + * This is complicated somewhat by the 1 ... n relation between + * Descriptions and their descriptionElements, and also by the language aspect + * (i.e. that every feature can be written in many languages). + * + * What we do here is return a list of TextData objects where + * the partOfDescription property is hydrated + * + * If the description is a TaxonDescription, then the Taxon and + * is hydrated too. If the description is a TaxonNameDescription + * the TaxonName is hydrated. If the description is a SpecimenDescription, the + * specimens are hydrated + * + * HOWEVER, until hibernate search changes the way it handles subclasses + * (i.e. indexing the properties of subclasses when the entitiy is only + * typed as a superclass), we'll not be able to sort by a property of the TaxonDescription without + * a pretty nasty performance penalty (remember, we're potentially searching + * all of the textual content here, so sorting this one-to-n by description.taxon or description. + * name is a bit of a no go). + * + * @param queryString + * @param pageSize + * @param pageNumber + * @return + * @throws QueryParseException + */ + public List searchTextData(String queryString, Integer pageSize, Integer pageNumber); + + public int countTextData(String queryString); + + public List getMedia(DescriptionElementBase descriptionElement, Integer pageSize, Integer pageNumber); + + public int countMedia(DescriptionElementBase descriptionElement); +} diff --git a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java index 35e779e090..35974bd4ac 100644 --- a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java +++ b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoImpl.java @@ -9,10 +9,20 @@ package eu.etaxonomy.cdm.persistence.dao.hibernate.description; +import java.util.List; +import java.util.Set; + import org.apache.log4j.Logger; import org.springframework.stereotype.Repository; import eu.etaxonomy.cdm.model.description.DescriptionBase; +import eu.etaxonomy.cdm.model.description.DescriptionElementBase; +import eu.etaxonomy.cdm.model.description.Feature; +import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase; +import eu.etaxonomy.cdm.model.description.Scope; +import eu.etaxonomy.cdm.model.description.TaxonDescription; +import eu.etaxonomy.cdm.model.location.NamedArea; +import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao; import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase; @@ -24,5 +34,45 @@ public class DescriptionDaoImpl extends IdentifiableDaoBase imp public DescriptionDaoImpl() { super(DescriptionBase.class); } + + public int countDescriptionByDistribution(Set namedAreas, PresenceAbsenceTermBase presence) { + // TODO Auto-generated method stub + return 0; + } + + public int countDescriptionElements(DescriptionBase description, List features, Class type) { + // TODO Auto-generated method stub + return 0; + } + + public int countDescriptions(Class type, Boolean hasImages, Boolean hasText, Set feature) { + // TODO Auto-generated method stub + return 0; + } + + public int countTaxonDescriptions(Taxon taxon, Set scopes,Set geographicalScope) { + // TODO Auto-generated method stub + return 0; + } + + public List getDescriptionElements(DescriptionBase description, List features, Class type, Integer pageSize, Integer pageNumber) { + // TODO Auto-generated method stub + return null; + } + + public List getTaxonDescriptions(Taxon taxon, Set scopes, Set geographicalScope,Integer pageSize, Integer pageNumber) { + // TODO Auto-generated method stub + return null; + } + + public List listDescriptions(Class type, Boolean hasImages, Boolean hasText, Set feature, Integer pageSize, Integer pageNumber) { + // TODO Auto-generated method stub + return null; + } + + public List searchDescriptionByDistribution(Set namedAreas, PresenceAbsenceTermBase presence, Integer pageSize, Integer pageNumber) { + // TODO Auto-generated method stub + return null; + } } diff --git a/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java b/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java new file mode 100644 index 0000000000..c4519e13f9 --- /dev/null +++ b/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionDaoHibernateImplTest.java @@ -0,0 +1,18 @@ +package eu.etaxonomy.cdm.persistence.dao.hibernate.description; + +import org.junit.Test; +import org.unitils.spring.annotation.SpringBeanByType; + +import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao; +import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest; + +public class DescriptionDaoHibernateImplTest extends CdmIntegrationTest { + + @SpringBeanByType + IDescriptionDao descriptionDao; + + @Test + public void test() { + // Will finish once I've altered the DescriptionBase -> DescriptionElementBase mapping + } +} diff --git a/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/description/TaxonDaoHibernateImplTest.xml b/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/description/TaxonDaoHibernateImplTest.xml new file mode 100644 index 0000000000..a0d116e637 --- /dev/null +++ b/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/description/TaxonDaoHibernateImplTest.xml @@ -0,0 +1,1802 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.34.1