From: <rv...@us...> - 2010-06-15 17:24:29
|
Revision: 720 http://treebase.svn.sourceforge.net/treebase/?rev=720&view=rev Author: rvos Date: 2010-06-15 17:24:23 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Adding functionality to fix bug 3014899. This commit makes it possible to: * attach TreeBASE1 matrix ids to NeXML (and RDF) serializations. This involves an addition to NexmlMatrixConverter (to add the annotation during serialization) and to treebase.owl (to add the identifier.matrix.tb1 predicate to the treebase terms vocabulary). * allow searching on TreeBASE1 matrix ids by the core. This involves extending the MatrixService and MatrixHome interfaces, and implementing in MatrixServiceImpl which dispatches to the specified MatrixHome implementation, i.e. MatrixDAO, which does the actual searching. * using identifier.matrix.tb1 as a CQL search predicate. This involves some modification to the predicate handling in the MatrixSearchController so that the right search method is dispatched. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/matrix/MatrixDAO.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixHome.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixService.java trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/MatrixServiceImpl.java trunk/treebase-core/src/main/resources/treebase.owl trunk/treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/dao/matrix/MatrixDAO.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/dao/matrix/MatrixDAO.java 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/dao/matrix/MatrixDAO.java 2010-06-15 17:24:23 UTC (rev 720) @@ -28,6 +28,7 @@ import org.cipres.treebase.domain.study.Study; import org.cipres.treebase.domain.study.Submission; import org.cipres.treebase.domain.study.SubmissionHome; +import org.cipres.treebase.domain.taxon.Taxon; import org.cipres.treebase.domain.taxon.TaxonLabel; import org.cipres.treebase.domain.taxon.TaxonLabelHome; import org.cipres.treebase.domain.taxon.TaxonLabelSet; @@ -36,6 +37,7 @@ import org.hibernate.Criteria; import org.hibernate.Hibernate; import org.hibernate.Query; +import org.hibernate.criterion.Expression; /** * MatrixDAO.java @@ -614,4 +616,14 @@ returnVal = (MatrixKind) c.uniqueResult(); return returnVal; } + + /* + * (non-Javadoc) + * @see org.cipres.treebase.domain.matrix.MatrixHome#findByTB1StudyID(java.lang.String) + */ + public Matrix findByTB1StudyID(String pTB1MatrixID) { + Criteria c = getSession().createCriteria(Matrix.class); + c.add(Expression.eq("TB_MatrixID", pTB1MatrixID)); + return (Matrix) c.uniqueResult(); + } } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixHome.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixHome.java 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixHome.java 2010-06-15 17:24:23 UTC (rev 720) @@ -168,5 +168,14 @@ * @return MatrixKind */ MatrixKind findKindByDescription(String pDescription); + + /** + * Return a Matrix object by its legacy TreeBASE1 id. The Matrix object is fully inflated + * with colum, row and elements data + * + * @param pTB1MatrixID + * @return + */ + Matrix findByTB1StudyID(String pTB1MatrixID); } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixService.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixService.java 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixService.java 2010-06-15 17:24:23 UTC (rev 720) @@ -26,6 +26,15 @@ * @return */ Matrix findByID(Long pMatrixID); + + /** + * Return a Matrix object by its legacy TreeBASE1 id. The Matrix object is fully inflated + * with colum, row and elements data + * + * @param pTB1MatrixID + * @return + */ + Matrix findByTB1StudyID(String pTB1MatrixID); /** * Delete a matrix and its assoicated objects. Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixConverter.java 2010-06-15 17:24:23 UTC (rev 720) @@ -276,6 +276,10 @@ } xmlMatrix.setLabel(tbMatrix.getTitle()); attachTreeBaseID((Annotatable)xmlMatrix, tbMatrix,Matrix.class); + String tb1MatrixID = tbMatrix.getTB1MatrixID(); + if ( null != tb1MatrixID ) { + ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix.tb1", Constants.TBTermsURI, tb1MatrixID); + } return xmlMatrix; } Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/MatrixServiceImpl.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/MatrixServiceImpl.java 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/matrix/MatrixServiceImpl.java 2010-06-15 17:24:23 UTC (rev 720) @@ -145,4 +145,8 @@ public Class defaultResultClass() { return Matrix.class; } + + public Matrix findByTB1StudyID(String pTB1MatrixID) { + return getMatrixHome().findByTB1StudyID(pTB1MatrixID); + } } Modified: trunk/treebase-core/src/main/resources/treebase.owl =================================================================== --- trunk/treebase-core/src/main/resources/treebase.owl 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/main/resources/treebase.owl 2010-06-15 17:24:23 UTC (rev 720) @@ -68,6 +68,14 @@ + <!-- http://purl.org/phylo/treebase/2.0/terms#identifier.matrix.tb1 --> + + <owl:ObjectProperty rdf:about="identifier.matrix.tb1"> + <rdfs:subPropertyOf rdf:resource="http://purl.org/dc/elements/1.1/identifier"/> + </owl:ObjectProperty> + + + <!-- http://purl.org/phylo/treebase/2.0/terms#identifier.ncbi --> <owl:ObjectProperty rdf:about="identifier.ncbi"> 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 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-core/src/test/java/org/cipres/treebase/auxdata/AuxDataTest.java 2010-06-15 17:24:23 UTC (rev 720) @@ -212,6 +212,11 @@ Boolean caseSensitive) { // TODO Auto-generated method stub return null; + } + + public Matrix findByTB1StudyID(String pTB1MatrixID) { + // TODO Auto-generated method stub + return null; } } Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java 2010-06-15 16:05:56 UTC (rev 719) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/MatrixSearchController.java 2010-06-15 17:24:23 UTC (rev 720) @@ -56,6 +56,7 @@ byType, byNTAX, byNCHAR, + byTB1ID } protected ModelAndView onSubmit( @@ -153,8 +154,10 @@ String index = term.getIndex(); if ( index.startsWith("tb.title") ) { results.addAll(doSearch(request, response, SearchType.byTitle, errors, term.getTerm())); - } else if ( index.startsWith("tb.identifier") ) { + } else if ( index.equals("tb.identifier.matrix") ) { results.addAll(doSearch(request, response, SearchType.byID, errors, term.getTerm())); + } else if ( index.equals("tb.identifier.matrix.tb1") ) { + results.addAll(doSearch(request, response, SearchType.byTB1ID, errors, term.getTerm())); } else if ( index.startsWith("tb.type") ) { results.addAll(doSearch(request, response, SearchType.byType, errors, term.getTerm())); } else if ( index.startsWith("tb.ntax") ) { @@ -185,7 +188,12 @@ case byID: matches = (Collection<Matrix>) doSearchByIDString(request, matrixService, Matrix.class, searchTerm); break; - + + case byTB1ID: + matches = new HashSet<Matrix>(); + matches.add(matrixService.findByTB1StudyID(searchTerm)); + break; + case byTitle: matches = matrixService .findSomethingBySubstring(Matrix.class, "title", searchTerm); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |