Changeset 7799


Ignore:
Timestamp:
Apr 30, 2020, 9:01:24 AM (21 months ago)
Author:
Nicklas Nordborg
Message:

Fixes #2207: Allow multiple item lists to be selected when filtering

Location:
branches/3.16-stable
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/3.16-stable/src/core/net/sf/basedb/core/PropertyFilter.java

    r7770 r7799  
    365365    @since 2.9
    366366  */
    367   public Object getValueAsObject(Unit unit, boolean asDouble)
     367  public <T> T getValueAsObject(Unit unit, boolean asDouble)
    368368  {
    369369    return getValueAsObject(value, unit, asDouble);
     
    408408    @since 2.5
    409409   */
    410   public List<Object> getValuesAsObjects()
     410  public <T> List<T> getValuesAsObjects()
    411411  {
    412412    return getValuesAsObjects(value, unit, false);
     
    426426    @since 2.9
    427427  */
    428   public List<Object> getValuesAsObjects(Unit unit, boolean asDouble)
     428  public <T> List<T> getValuesAsObjects(Unit unit, boolean asDouble)
    429429  {
    430430    return getValuesAsObjects(value, unit, asDouble);
    431431  }
    432432 
    433   private List<Object> getValuesAsObjects(String value, Unit unit, boolean asDouble)
     433  @SuppressWarnings("unchecked")
     434  private <T> List<T> getValuesAsObjects(String value, Unit unit, boolean asDouble)
    434435  {
    435436    if (value == null) return Collections.emptyList();
     
    476477      if (newSession && session != null) HibernateUtil.close(session);
    477478    }
    478     return Arrays.asList(objects);
     479    return (List<T>)Arrays.asList(objects);
    479480  }
    480481
     
    754755      // The value is the ID of the item list to filter on
    755756      // We support a single selection and either EQ or NEQ operator
    756       Integer listId = (Integer)getValueAsObject();
     757      // or multi-selection with either IN or NOTIN operator
    757758      String prefix = alias == null ? "$id" : alias + ".id";
    758       if (operator == Operator.NEQ)
    759       {
    760         restriction = Hql.restriction(prefix+" NOT IN (SELECT mmb FROM ItemListData lst INNER JOIN lst.members mmb WHERE lst.id=" +listId+")", "$");
    761       }
    762       else
    763       {
    764         restriction = Hql.restriction(prefix+" IN (SELECT mmb FROM ItemListData lst INNER JOIN lst.members mmb WHERE lst.id=" +listId+")", "$");
    765       }
     759      String listId = net.sf.basedb.util.Values.getString(getValuesAsObjects(), ",", true);
     760      String listOp = operator.isNegationOperator() ? "NOT IN" : "IN";
     761      String where = operator.isListOperator() ? "lst.id IN (" + listId + ")" : "lst.id="+listId;
     762      restriction = Hql.restriction(prefix+" "+listOp+" (SELECT mmb FROM ItemListData lst INNER JOIN lst.members mmb WHERE "+where+")", "$");
    766763    }
    767764   
  • branches/3.16-stable/www/biomaterials/bioplates/wells/list_biowells.jsp

    r7605 r7799  
    360360        filterable="true"
    361361        enumeration="<%=Base.getItemListsEnum(dc, bioMaterialType, cc.getInclude())%>"
    362         multiple="false"
    363362      />
    364363      <tbl:columndef
  • branches/3.16-stable/www/biomaterials/biosources/list_biosources.jsp

    r7798 r7799  
    255255        filterable="true"
    256256        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    257         multiple="false"
    258257      />
    259258      <%
  • branches/3.16-stable/www/biomaterials/extracts/list_extracts.jsp

    r7773 r7799  
    479479        filterable="true"
    480480        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    481         multiple="false"
    482481      />
    483482      <%
  • branches/3.16-stable/www/biomaterials/samples/list_samples.jsp

    r7773 r7799  
    429429        filterable="true"
    430430        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    431         multiple="false"
    432431      />
    433432      <%
  • branches/3.16-stable/www/views/derivedbioassays/list_bioassays.jsp

    r7773 r7799  
    361361        filterable="true"
    362362        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    363         multiple="false"
    364363      />
    365364      <%
  • branches/3.16-stable/www/views/itemlists/members/list_members.jsp

    r7605 r7799  
    289289        filterable="true"
    290290        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    291         multiple="false"
    292291      />
    293292      <%
  • branches/3.16-stable/www/views/physicalbioassays/list_bioassays.jsp

    r7773 r7799  
    324324        filterable="true"
    325325        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    326         multiple="false"
    327326      />
    328327      <%
  • branches/3.16-stable/www/views/rawbioassays/list_rawbioassays.jsp

    r7773 r7799  
    426426        filterable="true"
    427427        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
    428         multiple="false"
    429428      />
    430429      <%
Note: See TracChangeset for help on using the changeset viewer.