Changeset 6700


Ignore:
Timestamp:
Jan 30, 2015, 1:31:02 PM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1912: Add more filter rows in list pages

Added support for dynamic queries and implemented filter rows on bioassay sets and other list pages inside an experiment (including experiment explorer).

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r6698 r6700  
    15241524          {
    15251525            Restriction r = filter.getRestriction(dc, query);
    1526             int rowIndex = filter.getRowIndex();
    15271526            if (r != null)
    15281527            {
     1528              int rowIndex = filter.getRowIndex();
    15291529              List<Restriction> rowRestrictions = allRestrictions.get(rowIndex);
    15301530              if (rowRestrictions == null)
     
    17471747    if (propertyFilters != null)
    17481748    {
    1749       Restriction[] restrictions = new Restriction[propertyFilters.values().size()];
    1750       int i = 0;
     1749      Map<Integer, List<Restriction>> allRestrictions = new HashMap<Integer, List<Restriction>>();
    17511750      for (PropertyFilterPair filterPair : propertyFilters.values())
    17521751      {
     
    17591758            if (r != null)
    17601759            {
    1761               restrictions[i] = r;
    1762               i++;
     1760              int rowIndex = filter.getRowIndex();
     1761              List<Restriction> rowRestrictions = allRestrictions.get(rowIndex);
     1762              if (rowRestrictions == null)
     1763              {
     1764                rowRestrictions = new ArrayList<Restriction>();
     1765                allRestrictions.put(rowIndex, rowRestrictions);
     1766              }
     1767              rowRestrictions.add(r);
     1768
    17631769            }
    17641770          }
     
    17701776        }
    17711777      }
    1772       if (i > 0)
    1773       {
    1774         Restriction[] r2 = new Restriction[i];
    1775         System.arraycopy(restrictions, 0, r2, 0, i);
    1776         query.restrict(Restrictions.and(r2));
     1778      if (allRestrictions.size() > 0)
     1779      {
     1780        Restriction[] rows = new Restriction[allRestrictions.size()];
     1781        int rowNo = 0;
     1782        for (List<Restriction> rowRestrictions : allRestrictions.values())
     1783        {
     1784          rows[rowNo] = Restrictions.nullSafeAnd(rowRestrictions);
     1785          rowNo++;
     1786        }
     1787        query.restrict(Restrictions.or(rows));
    17771788      }
    17781789    }
  • trunk/www/views/experiments/bioassays/list_bioassays.jsp

    r6691 r6700  
    196196      sc="<%=sc%>"
    197197      item="<%=itemType%>"
     198      filterrows="<%=cc.getFilterRows()%>"
    198199      subclass="fulltable"
    199200      data-inherited-annotations="true"
     
    410411            <tbl:columnheaders />
    411412          </tbl:headerrow>
    412           <tbl:headerrow>
    413             <tbl:header subclass="index" />
    414             <tbl:header
    415               subclass="check"
    416               visible="<%=mode.hasCheck()%>"
    417               ><base:icon
    418                 id="check.uncheck"
    419                 image="check_uncheck.png"
    420                 tooltip="Check/uncheck all"
    421                  
    422               /></tbl:header>
    423             <tbl:header
    424               subclass="check"
    425               visible="<%=mode.hasRadio()%>"
    426               />
    427             <tbl:header
    428               subclass="icons"
    429               visible="<%=mode.hasIcons()%>"
    430               />
    431             <tbl:propertyfilter />
    432           </tbl:headerrow>
     413          <%
     414          int numFilters = cc.getNumPropertyFilters();
     415          int numRows = cc.getFilterRows();
     416          for (int filterNo = 0; filterNo < numRows; filterNo++)
     417          {
     418            boolean lastRow = filterNo == numRows-1;
     419            %>
     420            <tbl:headerrow>
     421              <tbl:header subclass="index" />
     422              <tbl:header
     423                subclass="check"
     424                visible="<%=mode.hasCheck()%>"
     425                ><base:icon
     426                  id="check.uncheck"
     427                  image="check_uncheck.png"
     428                  tooltip="Check/uncheck all"
     429                  visible="<%=lastRow%>"
     430                /></tbl:header>
     431              <tbl:header
     432                subclass="check"
     433                visible="<%=mode.hasRadio()%>"
     434                />
     435              <tbl:header
     436                subclass="icons"
     437                visible="<%=mode.hasIcons()%>"
     438                >
     439                <base:icon
     440                  subclass="link table-filter-row-action"
     441                  image="add.png"
     442                  tooltip="Add extra filter row"
     443                  visible="<%=lastRow%>"
     444                /><base:icon
     445                  subclass="link table-filter-row-action"
     446                  image="remove.png"
     447                  tooltip="Remove this filter row"
     448                  visible="<%=numRows > 1 || numFilters > 0 %>"
     449                  data-remove-row="<%=filterNo%>"
     450                />
     451              </tbl:header>
     452              <tbl:propertyfilter row="<%=filterNo%>" />
     453            </tbl:headerrow>
     454            <%
     455          }
     456          %>
    433457        </tbl:headers>
    434458        <tbl:rows>
  • trunk/www/views/experiments/bioassaysets/analysis_tree.jsp

    r6604 r6700  
    367367      sc="<%=sc%>"
    368368      item="<%=itemType%>"
     369      filterrows="<%=cc.getFilterRows()%>"
    369370      subclass="<%=root == null ? "fulltable" : "" %>"
    370371      >
     
    516517      <tbl:toolbar
    517518        visible="<%=mode.hasToolbar()%>"
    518         subclass="<%=root == null ? "bottomborder" : "topborder leftborder rightborder" %>"
     519        subclass="<%=root == null ? "bottomborder bg-filled-50" : "topborder leftborder rightborder bg-filled-50" %>"
    519520        >
    520521        <tbl:button
     
    584585            <tbl:columnheaders />
    585586          </tbl:headerrow>
    586           <tbl:headerrow>
    587             <tbl:header subclass="index" />
    588             <tbl:header
    589               subclass="check"
    590               visible="<%=mode.hasCheck()%>"
    591               ><base:icon
    592                 id="check.uncheck"
    593                 image="check_uncheck.png"
    594                 tooltip="Check/uncheck all"
    595                  
    596               /></tbl:header>
    597             <tbl:header
    598               subclass="check"
    599               visible="<%=mode.hasRadio()%>"
    600               />
    601             <tbl:header
    602               subclass="icons"
    603               visible="<%=mode.hasIcons()%>"
    604               />
    605             <tbl:propertyfilter />
    606           </tbl:headerrow>
     587          <%
     588          int numFilters = cc.getNumPropertyFilters();
     589          int numRows = cc.getFilterRows();
     590          for (int filterNo = 0; filterNo < numRows; filterNo++)
     591          {
     592            boolean lastRow = filterNo == numRows-1;
     593            %>
     594            <tbl:headerrow>
     595              <tbl:header subclass="index" />
     596              <tbl:header
     597                subclass="check"
     598                visible="<%=mode.hasCheck()%>"
     599                ><base:icon
     600                  id="check.uncheck"
     601                  image="check_uncheck.png"
     602                  tooltip="Check/uncheck all"
     603                  visible="<%=lastRow%>"
     604                /></tbl:header>
     605              <tbl:header
     606                subclass="check"
     607                visible="<%=mode.hasRadio()%>"
     608                />
     609              <tbl:header
     610                subclass="icons"
     611                visible="<%=mode.hasIcons()%>"
     612                >
     613                <base:icon
     614                  subclass="link table-filter-row-action"
     615                  image="add.png"
     616                  tooltip="Add extra filter row"
     617                  visible="<%=lastRow%>"
     618                /><base:icon
     619                  subclass="link table-filter-row-action"
     620                  image="remove.png"
     621                  tooltip="Remove this filter row"
     622                  visible="<%=numRows > 1 || numFilters > 0 %>"
     623                  data-remove-row="<%=filterNo%>"
     624                />
     625              </tbl:header>
     626              <tbl:propertyfilter row="<%=filterNo%>" />
     627            </tbl:headerrow>
     628            <%
     629          }
     630          %>
    607631        </tbl:headers>
    608632        <tbl:rows>
  • trunk/www/views/experiments/explorer/search/list.jsp

    r6612 r6700  
    133133      item="<%=itemType%>"
    134134      subcontext="<%=subContext%>"
     135      filterrows="<%=cc.getFilterRows()%>"
    135136      subclass="fulltable"
    136137      >
     
    199200            <tbl:columnheaders />
    200201          </tbl:headerrow>
    201           <tbl:headerrow>
    202             <tbl:header clazz="icons"/>
    203             <tbl:propertyfilter />
    204           </tbl:headerrow>
     202          <%
     203          int numFilters = cc.getNumPropertyFilters();
     204          int numRows = cc.getFilterRows();
     205          for (int filterNo = 0; filterNo < numRows; filterNo++)
     206          {
     207            boolean lastRow = filterNo == numRows-1;
     208            %>
     209            <tbl:headerrow>
     210              <tbl:header subclass="icons">
     211                <base:icon
     212                  subclass="link table-filter-row-action"
     213                  image="add.png"
     214                  tooltip="Add extra filter row"
     215                  visible="<%=lastRow%>"
     216                /><base:icon
     217                  subclass="link table-filter-row-action"
     218                  image="remove.png"
     219                  tooltip="Remove this filter row"
     220                  visible="<%=numRows > 1 || numFilters > 0 %>"
     221                  data-remove-row="<%=filterNo%>"
     222                />
     223              </tbl:header>
     224              <tbl:propertyfilter row="<%=filterNo%>" />
     225            </tbl:headerrow>
     226            <%
     227          }
     228          %>
    205229        </tbl:headers>
    206230        <tbl:rows>
  • trunk/www/views/experiments/explorer/view/view.jsp

    r6621 r6700  
    8181  import="java.util.Map"
    8282  import="java.util.HashMap"
     83  import="java.util.TreeMap"
    8384  import="org.json.simple.JSONObject"
    8485  import="org.json.simple.JSONArray"
     
    235236    <t:tab id="view" title="Reporter view">
    236237    <%
    237     Collection<PropertyFilter> filters = reporterContext.getPropertyFilters();
    238     String filter = filters != null && filters.size() > 0 ?
    239       Values.getString(filters, " AND ", true).replaceAll("@|�", "") : "- none -";
     238    Map<Integer, List<PropertyFilter>> filters = new TreeMap<Integer, List<PropertyFilter>>();
     239    for (PropertyFilter filter : reporterContext.getPropertyFilters())
     240    {
     241      List<PropertyFilter> rowFilters = filters.get(filter.getRowIndex());
     242      if (rowFilters == null)
     243      {
     244        rowFilters = new ArrayList<PropertyFilter>();
     245        filters.put(filter.getRowIndex(), rowFilters);
     246      }
     247      rowFilters.add(filter);
     248    }
     249    StringBuilder filter = new StringBuilder();
     250    for (List<PropertyFilter> rowFilter : filters.values())
     251    {
     252      if (filter.length() > 0) filter.append(" OR ");
     253      StringBuilder sb = new StringBuilder();
     254      for (PropertyFilter pf : rowFilter)
     255      {
     256        if (sb.length() > 0) sb.append(" AND ");
     257        sb.append(pf.getProperty()+" "+pf.getOperator()+" "+pf.getValue());
     258      }
     259      filter.append(sb.toString().replaceAll("@|£", ""));
     260    }
    240261    if (reporter == null)
    241262    {
     
    244265      <tr>
    245266        <th>Filter</th>
    246         <td><%=HTML.encodeTags(filter)%></td>
     267        <td><%=HTML.encodeTags(filter.toString())%></td>
    247268      </tr>
    248269      <tr>
     
    352373        %>
    353374        <tbl:form width="2" clazz="fullform special">
    354           <tbl:cell column="filter"><%=HTML.encodeTags(filter)%></tbl:cell>
     375          <tbl:cell column="filter"><%=HTML.encodeTags(filter.toString())%></tbl:cell>
    355376          <tbl:cell column="id"><%=reporter.getId()%></tbl:cell>
    356377          <tbl:cell column="version"><%=reporter.getVersion()%></tbl:cell>
  • trunk/www/views/experiments/reporters/list_reporters.jsp

    r6604 r6700  
    153153      item="<%=itemType%>"
    154154      subcontext="<%=subContext%>"
     155      filterrows="<%=cc.getFilterRows()%>"
    155156      subclass="fulltable"
    156157      >
     
    260261        <tbl:headers>
    261262          <tbl:headerrow>
    262             <tbl:header colspan="2" />
     263            <tbl:header colspan="3" />
    263264            <tbl:columnheaders />
    264265          </tbl:headerrow>
    265           <tbl:headerrow>
    266             <tbl:header subclass="index" />
    267             <tbl:header
    268               subclass="check"
    269               visible="<%=mode.hasCheck()%>"
    270               ><base:icon
    271                 id="check.uncheck"
    272                 image="check_uncheck.png"
    273                 tooltip="Check/uncheck all"
    274                  
    275               /></tbl:header>
    276             <tbl:propertyfilter />
    277           </tbl:headerrow>
     266          <%
     267          int numFilters = cc.getNumPropertyFilters();
     268          int numRows = cc.getFilterRows();
     269          for (int filterNo = 0; filterNo < numRows; filterNo++)
     270          {
     271            boolean lastRow = filterNo == numRows-1;
     272            %>
     273            <tbl:headerrow>
     274              <tbl:header subclass="index" />
     275              <tbl:header
     276                subclass="check"
     277                visible="<%=mode.hasCheck()%>"
     278                ><base:icon
     279                  id="check.uncheck"
     280                  image="check_uncheck.png"
     281                  tooltip="Check/uncheck all"
     282                  visible="<%=lastRow%>"
     283                /></tbl:header>
     284              <tbl:header
     285                subclass="check"
     286                visible="<%=mode.hasRadio()%>"
     287                />
     288              <tbl:header
     289                subclass="icons"
     290                visible="<%=mode.hasIcons()%>"
     291                >
     292                <base:icon
     293                  subclass="link table-filter-row-action"
     294                  image="add.png"
     295                  tooltip="Add extra filter row"
     296                  visible="<%=lastRow%>"
     297                /><base:icon
     298                  subclass="link table-filter-row-action"
     299                  image="remove.png"
     300                  tooltip="Remove this filter row"
     301                  visible="<%=numRows > 1 || numFilters > 0 %>"
     302                  data-remove-row="<%=filterNo%>"
     303                />
     304              </tbl:header>
     305              <tbl:propertyfilter row="<%=filterNo%>" />
     306            </tbl:headerrow>
     307            <%
     308          }
     309          %>
    278310        </tbl:headers>
    279311        <tbl:rows>
     
    319351                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%>
    320352                  ></tbl:header>
     353                <tbl:header clazz="icons" visible="<%=mode.hasIcons()%>" />
    321354
    322355                <tbl:cell column="upToDate" visible="<%=hasUpToDateColumn %>">
  • trunk/www/views/experiments/spotdata/list_spotdata.jsp

    r6604 r6700  
    194194      item="<%=itemType%>"
    195195      subcontext="<%=subContext%>"
     196      filterrows="<%=cc.getFilterRows()%>"
    196197      subclass="fulltable"
    197198      >
     
    318319            <tbl:columnheaders />
    319320          </tbl:headerrow>
    320           <tbl:headerrow>
    321             <tbl:header
    322               clazz="index"
    323               colspan="2"
    324             />
    325             <tbl:propertyfilter />
    326           </tbl:headerrow>
     321          <%
     322          int numFilters = cc.getNumPropertyFilters();
     323          int numRows = cc.getFilterRows();
     324          for (int filterNo = 0; filterNo < numRows; filterNo++)
     325          {
     326            boolean lastRow = filterNo == numRows-1;
     327            %>
     328            <tbl:headerrow>
     329              <tbl:header subclass="index" />
     330              <tbl:header
     331                subclass="icons"
     332                visible="<%=mode.hasIcons()%>"
     333                >
     334                <base:icon
     335                  subclass="link table-filter-row-action"
     336                  image="add.png"
     337                  tooltip="Add extra filter row"
     338                  visible="<%=lastRow%>"
     339                /><base:icon
     340                  subclass="link table-filter-row-action"
     341                  image="remove.png"
     342                  tooltip="Remove this filter row"
     343                  visible="<%=numRows > 1 || numFilters > 0 %>"
     344                  data-remove-row="<%=filterNo%>"
     345                />
     346              </tbl:header>
     347              <tbl:propertyfilter row="<%=filterNo%>" />
     348            </tbl:headerrow>
     349            <%
     350          }
     351          %>
    327352        </tbl:headers>
    328353        <tbl:rows>
Note: See TracChangeset for help on using the changeset viewer.