Changeset 1640


Ignore:
Timestamp:
May 9, 2012, 2:59:48 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #390: Search for subtype and annotation type among proper main item type

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Annotationtype.java

    r1639 r1640  
    1818import net.sf.basedb.core.ItemQuery;
    1919import net.sf.basedb.core.Type;
     20import net.sf.basedb.core.query.Expression;
    2021import net.sf.basedb.core.query.Expressions;
    2122import net.sf.basedb.core.query.Hql;
     
    424425   
    425426  /**
    426     List all annotation types registered in BASE with a name matching this annotation
    427     type definition. Normally, only a single annotation type should be returned.
     427    List all annotation types registered in BASE with a name and main item type
     428    matching this annotation type definition. Normally, only a single annotation
     429    type should be returned.
    428430  */
    429431  public List<AnnotationType> list(DbControl dc)
     
    431433    ItemQuery<AnnotationType> query = AnnotationType.getQuery(null);
    432434    query.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING)));
     435    query.joinPermanent(Hql.innerJoin("itemTypes", "it"));
     436   
     437    Item[] mt = getMainType();
     438    Expression[] mainTypes = new Expression[mt.length];
     439    for (int i = 0; i < mainTypes.length; ++i)
     440    {
     441      mainTypes[i] = Expressions.integer(mt[i].getValue());
     442    }
     443    query.restrictPermanent(Restrictions.in(Hql.alias("it"), mainTypes));
     444
    433445    query.include(Include.ALL);
     446    query.setDistinct(true);
    434447    return query.list(dc);
    435448  }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r1639 r1640  
    259259 
    260260  /**
    261     List all subtypes registered in BASE with a name matching this subtype
    262     definition. Normally, only a single subtype should be returned.
     261    List all subtypes registered in BASE with a name and main item type
     262    matching this subtype definition. Normally, only a single subtype
     263    should be returned.
    263264  */
    264265  public List<ItemSubtype> list(DbControl dc)
    265266  {
    266     ItemQuery<ItemSubtype> query = ItemSubtype.getQuery(null);
     267    ItemQuery<ItemSubtype> query = ItemSubtype.getQuery(getMainType());
    267268    query.restrict(
    268269      Restrictions.eq(
Note: See TracChangeset for help on using the changeset viewer.