Changeset 4728


Ignore:
Timestamp:
Jan 14, 2009, 9:25:34 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1192: Use biomaterial lists as filters

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r4711 r4728  
    2525
    2626import net.sf.basedb.core.AnnotatableProxy;
     27import net.sf.basedb.core.BioMaterialList;
    2728import net.sf.basedb.core.Coloring;
    2829import net.sf.basedb.core.DataFileType;
     
    7879import java.awt.Color;
    7980import java.util.ArrayList;
     81import java.util.Collection;
    8082import java.util.Date;
    8183import java.util.List;
     
    11171119    return lists;
    11181120  }
     1121
     1122  /**
     1123    Get available biomaterial lists as an Enumeration that is
     1124    suitable to use in a column definition for a table.
     1125    @param dc The DbControl to use
     1126    @param memberType Only load lists with this member type, or null
     1127      to load any lists
     1128    @param include Include options
     1129    @return The found lists as an enumeration, empty if no lists are
     1130      found
     1131    @since 2.10
     1132  */
     1133  public static net.sf.basedb.util.Enumeration<String, String>
     1134    getBioMaterialListsEnum(DbControl dc, Item memberType, Collection<Include> include)
     1135  {
     1136    ItemQuery<BioMaterialList> query = BioMaterialList.getQuery();
     1137    query.include(include == null ? Include.ALL : include);
     1138    if (memberType != null)
     1139    {
     1140      query.restrict(
     1141        Restrictions.eq(
     1142          Hql.property("memberType"),
     1143          Expressions.integer(memberType.getValue())
     1144        )
     1145      );
     1146    }
     1147    query.order(Orders.asc(Hql.property("name")));
     1148    query.setCacheResult(true);
     1149   
     1150    net.sf.basedb.util.Enumeration<String, String> lists =
     1151      new net.sf.basedb.util.Enumeration<String, String>();
     1152    for (BioMaterialList list : query.list(dc))
     1153    {
     1154      lists.add(Integer.toString(list.getId()), HTML.encodeTags(list.getName()));
     1155    }
     1156    return lists;
     1157  }
     1158
    11191159 
    11201160  private static final Float defaultScale = 1.0f;
  • trunk/src/core/net/sf/basedb/core/PropertyFilter.java

    r4711 r4728  
    543543      if (property != null && property.startsWith("@"))
    544544      {
    545         // Property is a collection - we only support equality tests
     545        // Property is a collection - we only support equal and not-equal tests
    546546        property = property.substring(1);
    547547        Expression elements = Hql.elements(alias, property);
     
    574574          // filter for a single element in a collection
    575575          restriction = Restrictions.in(parameter, elements);
     576          if (operator == Operator.NEQ)
     577          {
     578            restriction = Restrictions.not(restriction);
     579          }
    576580        }
    577581        else
     
    579583          // filter that returns items with empty collections
    580584          restriction = isEmpty;
     585          if (operator == Operator.NEQ)
     586          {
     587            restriction = Restrictions.not(restriction);
     588          }
    581589        }
    582590      }
  • trunk/www/biomaterials/bioplates/wells/list_biowells.jsp

    r4704 r4728  
    2828  import="net.sf.basedb.core.DbControl"
    2929  import="net.sf.basedb.core.Item"
     30  import="net.sf.basedb.core.Include"
    3031  import="net.sf.basedb.core.ItemContext"
    3132  import="net.sf.basedb.core.BioPlate"
     
    265266        formatter="<%=dateFormatter%>"
    266267      />
    267 
    268      
     268      <tbl:columndef
     269        id="bioMaterialList"
     270        property="@bioMaterial.bioMaterialLists"
     271        datatype="int"
     272        title="Biomaterial list"
     273        filterable="true"
     274        enumeration="<%=Base.getBioMaterialListsEnum(dc, null, Include.ALL)%>"
     275        multiple="false"
     276      />
    269277      <tbl:columndef
    270278        id="permission"
  • trunk/www/biomaterials/biosources/list_biosources.jsp

    r4712 r4728  
    288288        exportable="true"
    289289      />     
     290      <tbl:columndef
     291        id="bioMaterialList"
     292        property="@bioMaterialLists"
     293        datatype="int"
     294        title="Biomaterial list"
     295        filterable="true"
     296        enumeration="<%=Base.getBioMaterialListsEnum(dc, itemType, cc.getInclude())%>"
     297        multiple="false"
     298      />
    290299      <%
    291300      for (AnnotationType at : annotationTypes)
  • trunk/www/biomaterials/extracts/list_extracts.jsp

    r4712 r4728  
    356356        exportable="true"
    357357      />     
     358      <tbl:columndef
     359        id="bioMaterialList"
     360        property="@bioMaterialLists"
     361        datatype="int"
     362        title="Biomaterial list"
     363        filterable="true"
     364        enumeration="<%=Base.getBioMaterialListsEnum(dc, itemType, cc.getInclude())%>"
     365        multiple="false"
     366      />
    358367      <%
    359368      for (AnnotationType at : annotationTypes)
  • trunk/www/biomaterials/labeledextracts/list_labeledextracts.jsp

    r4712 r4728  
    364364        exportable="true"
    365365      />     
     366      <tbl:columndef
     367        id="bioMaterialList"
     368        property="@bioMaterialLists"
     369        datatype="int"
     370        title="Biomaterial list"
     371        filterable="true"
     372        enumeration="<%=Base.getBioMaterialListsEnum(dc, itemType, cc.getInclude())%>"
     373        multiple="false"
     374      />
    366375      <%
    367376      for (AnnotationType at : annotationTypes)
  • trunk/www/biomaterials/samples/list_samples.jsp

    r4712 r4728  
    366366        exportable="true"
    367367      />     
     368      <tbl:columndef
     369        id="bioMaterialList"
     370        property="@bioMaterialLists"
     371        datatype="int"
     372        title="Biomaterial list"
     373        filterable="true"
     374        enumeration="<%=Base.getBioMaterialListsEnum(dc, itemType, cc.getInclude())%>"
     375        multiple="false"
     376      />
    368377      <%
    369378      for (AnnotationType at : annotationTypes)
Note: See TracChangeset for help on using the changeset viewer.