I have two different functions, one to return annotations with a  
given type and a given value, another to return all annotations with  
a given value (of any annotation type).
the code for the first is below:

>       ItemQuery<AnnotationType> typeIq = AnnotationType.getQuery 
> (Item.SAMPLE);
>       typeIq.include(Include.SHARED); typeIq.setDistinct(true);               
>       ItemResultIterator<AnnotationType> typeIt = typeIq.iterate(dc);
>       ArrayList<AnnotationSimpleRestriction> restArray = new ArrayList();
>
>       while (typeIt.hasNext()) {
>               AnnotationType at = typeIt.next();
>               try {
>                       restArray.add(new AnnotationSimpleRestriction("ann", 
> at,  
> Operator.EQ, annotation, false));
>                       }
>               catch (InvalidDataException ex) {
>                       try {
>                               restArray.add(new 
> AnnotationSimpleRestriction("ann", at,  
> Operator.EQ, Integer.parseInt(annotation), false));
>                               }
>                       catch (NumberFormatException ex2) {
>                               // System.out.println(ex.getMessage());
>                               }
>                       }
>               }
>
>
>       AnnotationSimpleRestriction[] restrictions = restArray.toArray(new  
> AnnotationSimpleRestriction[restArray.size()]);
>
>       ItemQuery<net.sf.basedb.core.Annotation> annoQuery =  
> Annotation.getQuery();
>       annoQuery.include(Include.SHARED); annoQuery.setDistinct(true);
>
> // restrict to one annotation type
>       annoQuery.join(Hql.innerJoin("annotationType",  
> Item.ANNOTATIONTYPE.getAlias()));
>       annoQuery.restrict(
>               Restrictions.eq(
>                       Hql.property(Item.ANNOTATIONTYPE.getAlias(), "name"),
>                       Expressions.string(type)
>                       )
>               );
>
>       annoQuery.restrict(
>               Restrictions.or(restrictions)
>               );
>
>
>       ItemResultList<net.sf.basedb.core.Annotation> eList =  
> annoQuery.list(dc);



The code for the second is identical apart from the join and the  
extra restriction on annotationtype.name, however whilst the first  
returns what I expect, the second brings back all the annotations  
with the relevant value, as well as all others in the annotationSet.  
Can anyone point out what I'm doing wrong?

thanks

-s


-- 
Seth Redmond
   Scientific Programmer, VectorBase
   Kafatos / Christophides Groups
   Div. Cell and Molecular Biology
   Imperial College, London
[EMAIL PROTECTED]
--


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
basedb-devel mailing list
basedb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/basedb-devel

Reply via email to