/** * Makes a flag based query clause. This is where searches can filtered by portal. * * <p>If you think that search is not working correctly with protals and all that kruft then this * is a method you want to look at. * * <p>It only takes into account "the portal flag" and flag1Exclusive must be set. Where does that * stuff get set? Look in vitro.flags.PortalFlag * * <p>One thing to keep in mind with portal filtering and search is that if you want to search a * portal that is different then the portal the user is 'in' then the home parameter should be set * to force the user into the new portal. * * <p>Ex. Bob requests the search page for vivo in portal 3. You want to have a drop down menu so * bob can search the all CALS protal, id 60. You need to have a home=60 on your search form. If * you don't set home=60 with your search query, then the search will not be in the all portal AND * the WebappDaoFactory will be filtered to only show things in portal 3. * * <p>Notice: flag1 as a parameter is ignored. bdc34 2009-05-22. */ @SuppressWarnings("static-access") private Query makeFlagQuery(PortalFlag flag) { if (flag == null || !flag.isFilteringActive() || flag.getFlag1DisplayStatus() == flag.SHOW_ALL_PORTALS) return null; // make one term for each bit in the numeric flag that is set Collection<TermQuery> terms = new LinkedList<TermQuery>(); int portalNumericId = flag.getFlag1Numeric(); Long[] bits = FlagMathUtils.numeric2numerics(portalNumericId); for (Long bit : bits) { terms.add(new TermQuery(new Term(Entity2LuceneDoc.term.PORTAL, Long.toString(bit)))); } // make a boolean OR query for all of those terms BooleanQuery boolQuery = new BooleanQuery(); if (terms.size() > 0) { for (TermQuery term : terms) { boolQuery.add(term, BooleanClause.Occur.SHOULD); } return boolQuery; } else { // we have no flags set, so no flag filtering return null; } }
/** Filter the entities based on the specifications of the tab. */ protected static UnaryFunctor<Individual, Boolean> getPortalFilter(Tab tab) { ApplicationBean appBean = new ApplicationBean(); if (tab.getPortalId() == appBean.getSharedPortalFlagNumeric()) { return VitroFilterUtils.getCalsPortalFilter().getIndividualFilter(); // } else if (tab.getPortalId() == appBean.getAllPortalFlagNumeric()){ } else if (tab.getPortalId() == 65535) { return VitroFilterUtils.t; } else { return VitroFilterUtils.getFlag1ExclusiveFilter( FlagMathUtils.portalId2Numeric(tab.getPortalId())); } }