Ignore:
Timestamp:
Dec 4, 2015, 12:55:19 PM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #1976: Improve filtering in "All items" list

The list now uses conditional query elements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/views/items/list_items.jsp

    r6834 r7037  
    4444  import="net.sf.basedb.core.query.Restriction"
    4545  import="net.sf.basedb.core.query.Restrictions"
     46  import="net.sf.basedb.core.query.ReturnClassFilter"
    4647  import="net.sf.basedb.util.Enumeration"
    4748  import="net.sf.basedb.util.ShareableUtil"
     
    9899      }
    99100    }
    100     Restriction sharedTo = cc.getFilterRestriction("!sharedTo.name", dc, null);
    101     Restriction name = cc.getFilterRestriction("name", dc, null);
    102     Restriction description = cc.getFilterRestriction("description", dc, null);
    103101    Restriction id = cc.getFilterRestriction("id", dc, null);
     102    Restriction sharedTo = Restrictions.conditionalRestriction(new ReturnClassFilter(Shareable.class),
     103      cc.getFilterRestriction("!sharedTo.name", dc, null), null, true);
     104    Restriction name = Restrictions.conditionalRestriction(new ReturnClassFilter(Nameable.class),
     105      cc.getFilterRestriction("name", dc, null), null, true);
     106    Restriction description = Restrictions.conditionalRestriction(new ReturnClassFilter(Nameable.class),
     107      cc.getFilterRestriction("description", dc, null), null, true);
    104108    Restriction restriction = Restrictions.nullSafeAnd(sharedTo, name, description, id);
    105     if (sharedTo != null)
    106     {
    107       // If we filter on "Shared to" we must make sure to only
    108       // include Shareable items in the query
    109       if (itemTypes != null)
    110       {
    111         itemTypes.retainAll(Metadata.getShareableItems());
    112       }
    113       else
    114       {
    115         itemTypes = Metadata.getShareableItems();
    116       }
    117     }
     109
    118110    User loggedInUser = User.getById(dc, sc.getLoggedInUserId());
    119111    if (itemTypes == null || itemTypes.size() > 0)
Note: See TracChangeset for help on using the changeset viewer.