From: <rv...@us...> - 2012-02-17 18:17:23
|
Revision: 1072 http://treebase.svn.sourceforge.net/treebase/?rev=1072&view=rev Author: rvos Date: 2012-02-17 18:17:16 +0000 (Fri, 17 Feb 2012) Log Message: ----------- We want to be able to find studies by their DOIs. To make this possible, the interfaces for CitationService and StudyService have been expanded with a findByDoi(String doi) method, the idea being that the StudyService will delegate the query to the CitationService, then get the associated study from the returned citation. This is how it has been implemented in the *Impl classes, and the AuxDataTest needed to be expanded with another method stub to satisfy the interface for the inner class that is used there. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/CitationService.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/StudyService.java trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/CitationServiceImpl.java trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/StudyServiceImpl.java trunk/treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/CitationService.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/CitationService.java 2012-02-17 18:13:28 UTC (rev 1071) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/CitationService.java 2012-02-17 18:17:16 UTC (rev 1072) @@ -44,5 +44,12 @@ * @param pCitation */ void replaceCitation(Study pStudy, Citation pCitation); + + /** + * Find the citation with the provided doi + * @param doi + * @return + */ + Citation findByDOI(String doi); } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/StudyService.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/StudyService.java 2012-02-17 18:13:28 UTC (rev 1071) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/StudyService.java 2012-02-17 18:17:16 UTC (rev 1072) @@ -204,4 +204,11 @@ * @author mjd 20080813 */ Collection<Study> findByTaxonLabelName(String taxonLabel); + + /** + * Return the study for publication with provided DOI + * @param doi + * @return + */ + Study findByDOI(String doi); } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/CitationServiceImpl.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/CitationServiceImpl.java 2012-02-17 18:13:28 UTC (rev 1071) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/CitationServiceImpl.java 2012-02-17 18:17:16 UTC (rev 1072) @@ -2,6 +2,7 @@ package org.cipres.treebase.service.study; import java.util.Calendar; +import java.util.Collection; import org.cipres.treebase.domain.DomainHome; import org.cipres.treebase.domain.study.Citation; @@ -161,4 +162,18 @@ return Citation.class; } + /* + * (non-Javadoc) + * @see org.cipres.treebase.domain.study.CitationService#findByDOI(java.lang.String) + */ + public Citation findByDOI(String doi) { + Collection<Citation> results = findSomethingByString(Citation.class, "doi", doi); + if ( null != results && ! results.isEmpty() ) { + return results.iterator().next(); + } + else { + return null; + } + } + } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/StudyServiceImpl.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/StudyServiceImpl.java 2012-02-17 18:13:28 UTC (rev 1071) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/StudyServiceImpl.java 2012-02-17 18:17:16 UTC (rev 1072) @@ -19,6 +19,7 @@ import org.cipres.treebase.domain.matrix.Matrix; import org.cipres.treebase.domain.matrix.MatrixHome; import org.cipres.treebase.domain.study.AnalysisService; +import org.cipres.treebase.domain.study.Citation; import org.cipres.treebase.domain.study.CitationService; import org.cipres.treebase.domain.study.Study; import org.cipres.treebase.domain.study.StudyCriteria; @@ -533,4 +534,14 @@ public Collection<Study> findByPublicationDateRange(Date from, Date until) { return getStudyHome().findByPublicationDateRange(from, until); } + + public Study findByDOI(String doi) { + Citation citation = getCitationService().findByDOI(doi); + if ( null != citation ) { + return citation.getStudy(); + } + else { + return null; + } + } } Modified: trunk/treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java =================================================================== --- trunk/treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java 2012-02-17 18:13:28 UTC (rev 1071) +++ trunk/treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java 2012-02-17 18:17:16 UTC (rev 1072) @@ -368,6 +368,11 @@ // TODO Auto-generated method stub return null; } + + public Study findByDOI(String doi) { + // TODO Auto-generated method stub + return null; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |