id is the id of the entity to query for. netid also works.
"); - out.println(""); - } - - private void doNotFound(HttpServletRequest req, HttpServletResponse res) - throws IOException, ServletException { - VitroRequest vreq = new VitroRequest(req); - Portal portal = vreq.getPortal(); - ApplicationBean appBean = ApplicationBean.getAppBean(getServletContext()); - int allPortalId = appBean.getAllPortalFlagNumeric(); - - //If an Individual is not found, there is possibility that it - //was requested from a portal where it was not visible. - //In this case redirect to the all portal. - try{ - Portal allPortal = - vreq.getWebappDaoFactory().getPortalDao().getPortal(allPortalId); - // there must be a portal defined with the ID of the all portal - // for this to work - if( portal.getPortalId() != allPortalId && allPortal != null ) { - - //bdc34: - // this is hard coded to get the all portal - // I didn't find a way to get the id of the all portal - // it is likely that redirecting will not work in non VIVO clones - String portalPrefix = null; - String portalParam = null; - if( allPortal != null && allPortal.getUrlprefix() != null ) - portalPrefix = allPortal.getUrlprefix(); - else - portalParam = "home=" + allPortalId; - - String queryStr = req.getQueryString(); - if( queryStr == null && portalParam != null && !"".equals(portalParam)){ - queryStr = portalParam; - } else { - if( portalParam != null && !"".equals(portalParam)) - queryStr = queryStr + "&" + portalParam; - } - if( queryStr != null && !queryStr.startsWith("?") ) - queryStr = "?" + queryStr; - - StringBuilder url = new StringBuilder(); - url.append( req.getContextPath() ); - if( req.getContextPath() != null && !req.getContextPath().endsWith("/")) - url.append('/'); - - if( portalPrefix != null && !"".equals(portalPrefix)) - url.append( portalPrefix ).append('/'); - - String servletPath = req.getServletPath(); - String spath = ""; - if( servletPath != null ){ - if( servletPath.startsWith("/") ) - spath = servletPath.substring(1); - else - spath = servletPath; - } - - if( spath != null && !"".equals(spath)) - url.append( spath ); - - if( req.getPathInfo() != null ) - url.append( req.getPathInfo() ); - - if( queryStr != null && !"".equals(queryStr )) - url.append( queryStr ); - - res.sendRedirect(url.toString()); - return; - } - }catch(Throwable th){ - log.error("could not do a redirect", th); - } - - //set title before we do the highlighting so we don't get markup in it. - req.setAttribute("title","not found"); - res.setStatus(HttpServletResponse.SC_NOT_FOUND); - - String css = "" - + ""; - req.setAttribute("css",css); - - req.setAttribute("bodyJsp","/"+Controllers.ENTITY_NOT_FOUND_JSP); - - RequestDispatcher rd = req.getRequestDispatcher(Controllers.BASIC_JSP); - rd.forward(req,res); - } - - private String forURL(String frag) - { - String result = null; - try - { - result = URLEncoder.encode(frag, "UTF-8"); - } catch (UnsupportedEncodingException ex) { - throw new RuntimeException("UTF-8 not supported", ex); - } - return result; - } - - private class HelpException extends Throwable{} - private class EntityNotFoundException extends Throwable{} -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityListController.java deleted file mode 100644 index 3c0901b27..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityListController.java +++ /dev/null @@ -1,321 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.lucene.document.Document; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.PrefixQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TopDocs; - -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.Portal; -import edu.cornell.mannlib.vitro.webapp.beans.VClass; -import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; -import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord; -import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; -import edu.cornell.mannlib.vitro.webapp.flags.FlagException; -import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc; -import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory; -import edu.cornell.mannlib.vitro.webapp.utils.FlagMathUtils; - -public class EntityListController extends VitroHttpServlet { - - public static final int ENTITY_LIST_CONTROLLER_MAX_RESULTS = 30000; - public static final int INDIVIDUALS_PER_PAGE = 30; - - long startTime = -1; - - private static final Log log = LogFactory.getLog(EntityListController.class.getName()); - - /** - * This generates a list of entities and then sends that - * off to a jsp to be displayed. - * - * Expected parameters: - * - * Expected Attributes: - * entity - set to entity to display properties for. - * - * @author bdc34 - */ - public void doGet( HttpServletRequest req, HttpServletResponse res ) - throws IOException, ServletException { - startTime = System.currentTimeMillis(); // TODO: remove - try { - super.doGet(req, res); - VitroRequest vreq = new VitroRequest(req); - Object obj = req.getAttribute("vclass"); - VClass vclass=null; - if( obj == null ) { // look for vitroclass id parameter - String vitroClassIdStr=req.getParameter("vclassId"); - if (vitroClassIdStr!=null && !vitroClassIdStr.equals("")) { - try { - vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vitroClassIdStr); - if (vclass == null) { - log.error("Couldn't retrieve vclass "+vitroClassIdStr); - res.sendRedirect(Controllers.BROWSE_CONTROLLER+"?"+req.getQueryString()); - } - } catch (Exception ex) { - throw new HelpException("EntityListController: request parameter 'vclassId' must be a URI string"); - } - } - } else if (obj instanceof VClass) { - vclass = (VClass)obj; - } else { - throw new HelpException("EntityListController: attribute 'vclass' must be of type " - + VClass.class.getName() ); - } - - if (vclass!=null) - doVClass(vreq, res, vclass); - else - log.debug("no vclass found for " + obj); - - } catch (HelpException help){ - doHelp(res); - } catch (Throwable e) { - req.setAttribute("javax.servlet.jsp.jspException",e); - RequestDispatcher rd = req.getRequestDispatcher("/error.jsp"); - rd.forward(req, res); - } - } - - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException,IOException { - doGet(request, response); - } - - /** - * Perform the actions needed for the entity list jsp. - * @param request - * @param res - * @param vclass - * @throws ServletException - * @throws IOException - */ - private void doVClass(VitroRequest request, HttpServletResponse res, VClass vclass) - throws ServletException, IOException, FlagException { - - Maprequest.attributes 'entities' must be set by servlet before calling." - +" It must be a List of Entity objects
"); - out.println(""); - } - - private class HelpException extends Throwable{ - public HelpException(String string) { - super(string); - } - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityMergedPropertyListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityMergedPropertyListController.java deleted file mode 100644 index 259dea21c..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/EntityMergedPropertyListController.java +++ /dev/null @@ -1,823 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import net.sf.jga.fn.UnaryFunctor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; -import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty; -import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; -import edu.cornell.mannlib.vitro.webapp.beans.Property; -import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup; -import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; -import edu.cornell.mannlib.vitro.webapp.beans.VClass; -import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; -import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; -import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao; -import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; -import edu.cornell.mannlib.vitro.webapp.servlet.setup.PropertyMaskingSetup; - -public class EntityMergedPropertyListController extends VitroHttpServlet { - - /** - * This gets the Entity object in the requestScope "entity" and - * sets up a merged property list for it. This merged list includes - * Object and Data properties. - * - * After that a jsp is called to draw the data. - * - * Expected parameters: - * - * Expected Attributes: - * entity - set to entity to display properties for. - * - * @author jc55 forked this file from EntityPropertyListController - */ - - private static final Log log = LogFactory.getLog(EntityMergedPropertyListController.class.getName()); - private static final int MAX_GROUP_DISPLAY_RANK = 99; - private static final String VIVO_CORE_NAMESPACE = "http://vivoweb.org/ontology/core#"; - - /** Don't include these properties in the list. */ - private static final Collectionrequest.attributes 'entity' must be set by Entity servlet before calling." - +" It should already be 'filled out.'
"); - out.println(""); - } - - private class HelpException extends Throwable{ - - public HelpException(String string) { - super(string); - } - } - - private class PropertyRanker implements Comparator { - VitroRequest vreq; - WebappDaoFactory wdf; - PropertyGroupDao pgDao; - - - private PropertyRanker(VitroRequest vreq) { - this.vreq = vreq; - this.wdf = vreq.getWebappDaoFactory(); - this.pgDao = wdf.getPropertyGroupDao(); - } - - public int compare (Object o1, Object o2) { - Property p1 = (Property) o1; - Property p2 = (Property) o2; - - // sort first by property group rank; if the same, then sort by property rank - final int MAX_GROUP_RANK=99; - - int p1GroupRank=MAX_GROUP_RANK; - try { - if (p1.getGroupURI()!=null) { - PropertyGroup pg1 = pgDao.getGroupByURI(p1.getGroupURI()); - if (pg1!=null) { - p1GroupRank=pg1.getDisplayRank(); - } - } - } catch (Exception ex) { - log.error("Cannot retrieve p1GroupRank for group "+p1.getLabel()); - } - - int p2GroupRank=MAX_GROUP_RANK; - try { - if (p2.getGroupURI()!=null) { - PropertyGroup pg2 = pgDao.getGroupByURI(p2.getGroupURI()); - if (pg2!=null) { - p2GroupRank=pg2.getDisplayRank(); - } - } - } catch (Exception ex) { - log.error("Cannot retrieve p2GroupRank for group "+p2.getLabel()); - } - - // int diff = pgDao.getGroupByURI(p1.getGroupURI()).getDisplayRank() - pgDao.getGroupByURI(p2.getGroupURI()).getDisplayRank(); - int diff=p1GroupRank - p2GroupRank; - if (diff==0) { - diff = determineDisplayRank(p1) - determineDisplayRank(p2); - if (diff==0) { - return p1.getLabel().compareTo(p2.getLabel()); - } else { - return diff; - } - } - return diff; - } - - private int determineDisplayRank(Property p) { - if (p instanceof DataProperty) { - DataProperty dp = (DataProperty)p; - return dp.getDisplayTier(); - } else if (p instanceof ObjectProperty) { - ObjectProperty op = (ObjectProperty)p; - String tierStr = op.getDomainDisplayTier(); // no longer used: p.isSubjectSide() ? op.getDomainDisplayTier() : op.getRangeDisplayTier(); - try { - return Integer.parseInt(tierStr); - } catch (NumberFormatException ex) { - log.error("Cannot decode object property display tier value "+tierStr+" as an integer"); - } - } else { - log.error("Property is of unknown class in PropertyRanker()"); - } - return 0; - } - } - - private Listrequest.attributes 'entity' must be set by Entity servlet before calling." - +" It should already be 'filled out.'
"); - out.println(""); - } - - private class HelpException extends Throwable{ - - public HelpException(String string) { - super(string); - }} -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java index a864f2396..697a7e905 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/JSONServlet.java @@ -8,7 +8,6 @@ import java.io.Writer; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Enumeration; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -35,6 +34,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; @@ -43,8 +43,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.SelectListGenerator; import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch; -import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel; -import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassTemplateModel; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; /** @@ -222,9 +220,9 @@ public class JSONServlet extends VitroHttpServlet { .put("name",vclass.getName())); if (vclass != null) { - String alpha = EntityListController.getAlphaParamter(vreq); - int page = EntityListController.getPageParameter(vreq); - MapThe search request contained errors.
"; - doFailedSearch(request, response, msg, qtxt); - return; - } - } - - if( topDocs == null || topDocs.scoreDocs == null){ - log.error("topDocs for a search was null"); - String msg = "The search request contained errors.
"; - doFailedSearch(request, response, msg, qtxt); - return; - } - - int hitsLength = topDocs.scoreDocs.length; - if ( hitsLength < 1 ){ - doFailedSearch(request, response, NORESULT_MSG, qtxt); - return; - } - log.debug("found "+hitsLength+" hits"); - - int lastHitToShow = 0; - if((startIndex + hitsPerPage) > hitsLength ) - lastHitToShow = hitsLength; - else - lastHitToShow = startIndex + hitsPerPage - 1; - - ListThe search request contained errors.
"; - doFailedSearch(request, response, msg, query); - return; - } - } - - long end = System.currentTimeMillis(); - long time=end-start; - - if (hits == null || hits.size() < 1) { - doFailedSearch(request, response, NORESULT_MSG, query); - return; - } - log.debug("found "+hits+" hits"); - - // now we have hits which are only entity ids - // so convert the hits to usable entity beans - List beans = makeUsableBeans(hits,vreq); - log.debug("makeUsableBeans() succeeded"); - - //sort by ClassGroup and the sort the ClassGroups - Map collatedListOfLists = null; - if (beans != null && beans.size() > 0) { // collate entities - collatedListOfLists = collate(beans,vreq); // sort each classgroup - // list by a default - // setting if available - // sort each class group - collatedListOfLists = sortClassGroups(collatedListOfLists); - } - log.debug("sort by classgroups succeeded"); - - VClassGroup.removeEmptyClassGroups(collatedListOfLists); - log.debug("empty classgroups removed"); - collateClassGroupsByVClass(collatedListOfLists.values()); - log.debug("classgroups collated"); - - //Now collatedLitOfLists has Map of VCLassGroups - //and each VClassGroup has a list of VCLassList, each with a list of entities. - - //attempt to do highlighting - try { - beans = highlightBeans( beans , searcher.getHighlighter(query) ); - } catch (Exception e) { - log.error("Error highlighting search result beans", e); - } - log.debug("beans highlighted"); - - // //////////////////////////////////////////////////////////////////// - // stick the data in the requestScope and sessionScope - - // stick the results in the requestScope: - request.setAttribute("collatedResultsLists", collatedListOfLists); - request.setAttribute("collatedGroupNames", collatedListOfLists - .keySet()); - - String terms = query.getTerms(); - - request.setAttribute("title", terms+" - "+portal.getAppName()+" Search Results" ); - request.setAttribute("bodyJsp", Controllers.SEARCH_BASIC_JSP); - request.setAttribute("css", Controllers.TOGGLE_SCRIPT_ELEMENT); - request.setAttribute("querytext", terms); - - VitroQueryWrapper queryWrapper = - new VitroQueryWrapper(query, - (VitroHighlighter)searcher.getHighlighter(query), - 2, time); - request.getSession(true).setAttribute("LastQuery", queryWrapper); - - log.debug("query wrapper created"); - - // //////////////////////////////////////////////////////////////////// - // FINALLY: send off to the BASIC_JSP to get turned into html - - RequestDispatcher rd = request - .getRequestDispatcher(Controllers.BASIC_JSP); - rd.forward(request, response); - } catch (Throwable e) { - log.error("SearchController.doGet(): " + e); - doSearchError(request, response, e.getMessage(), null); - return; - } - } - - private void doSearchError(HttpServletRequest request, - HttpServletResponse response, String message, Object object) - throws ServletException, IOException { - Portal portal = (new VitroRequest(request)).getPortal(); - - request.setAttribute("bodyJsp", Controllers.SEARCH_ERROR_JSP); - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - rd.forward(request, response); - } - - private List highlightBeans(List beans, VitroHighlighter highlighter) { - Iterator it = beans.iterator(); - while(it.hasNext()){ - Object obj = it.next(); - if( obj instanceof Individual){ - Individual ent = (Individual)obj; - highlighter.fragmentHighlight(ent); - } - } - return beans; - } - - private void doNoQuery(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, IOException { - Portal portal = (new VitroRequest(request)).getPortal(); - request.setAttribute("title", "Search "+portal.getAppName()); - request.setAttribute("bodyJsp", Controllers.SEARCH_FORM_JSP); - - RequestDispatcher rd = request - .getRequestDispatcher(Controllers.BASIC_JSP); - rd.forward(request, response); - } - - private void doFailedSearch(HttpServletRequest request, - HttpServletResponse response, String message, VitroQuery query) - throws ServletException, IOException { - Portal portal = (new VitroRequest(request)).getPortal(); - if( query != null ){ - String terms = query.getTerms(); - request.setAttribute("querytext", terms); - request.setAttribute("title", terms+" - "+portal.getAppName()+" Search" ); - }else{ - request.setAttribute("title", portal.getAppName()+" Search" ); - request.setAttribute("querytext", ""); - } - if( message != null && message.length() > 0) - request.setAttribute("message", message); - - request.setAttribute("bodyJsp", Controllers.SEARCH_FAILED_JSP); - RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); - rd.forward(request, response); - } - - - /** - * Makes a message to display to user for a bad search term. - * @param query - * @param exceptionMsg - */ - private String makeBadSearchMessage(VitroQuery query, String exceptionMsg){ - String term = query.getTerms(); - String rv = ""; - try{ - //try to get the column in the search term that is causing the problems - int coli = exceptionMsg.indexOf("column"); - if( coli == -1) return ""; - int numi = exceptionMsg.indexOf(".", coli+7); - if( numi == -1 ) return ""; - String part = exceptionMsg.substring(coli+7,numi ); - int i = Integer.parseInt(part) - 1; - - // figure out where to cut preview and post-view - int errorWindow = 5; - int pre = i - errorWindow; - if (pre < 0) - pre = 0; - int post = i + errorWindow; - if (post > term.length()) - post = term.length(); - // log.warn("pre: " + pre + " post: " + post + " term len: - // " + term.length()); - - // get part of the search term before the error and after - String before = term.substring(pre, i); - String after = ""; - if (post > i) - after = term.substring(i + 1, post); - - rv = "The search term had an error near " - + before + "" + term.charAt(i) - + "" + after + ""; - } catch (Throwable ex) { - return ""; - } - return rv; - } - - /** - * Upgrades beans using individual entity upgrade(). - * - * @param hits - * @return - */ - @SuppressWarnings("unchecked") - private List makeUsableBeans(List hits,VitroRequest vreq) { - if (hits == null || hits.size() == 0) { - return new ArrayList(); - } - LinkedList beans = new LinkedList(); - Iterator it = hits.iterator(); - while (it.hasNext()) { - try { - Object obj = it.next(); - if (obj != null) { - obj = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(((Individual)obj).getURI()); - //null would indicate that the entity that was found in - //the search index is no longer in the system. - if( obj != null ) { - beans.add(obj); - } - } - } catch (Exception e) { - log.error(e.getStackTrace()); - } - } - return beans; - } - - public static final String NO_GRP_FOUND = "others"; - - public static final String TABS = "tabs"; - - /** - * Make a map of VClassGroup objs to Lists of entites. There will also be a - * map from TABS -> a List of tabs and NO_CLASSGRP_FOUND -> a list of - * Entities where the class or classgroup could not be found. - * - * @param beans - * @return - */ - private Map /* of List */collate(List beans, VitroRequest vreq) { - if (beans == null || beans.size() == 0) { - return new HashMap(); - } - /* make a hash map of VClassGroup -> List[ ent, ent , ent ... ] */ - Map groups = vreq.getWebappDaoFactory().getVClassGroupDao().getClassGroupMap(); - Map groupsByURI = makeGroupURIBasedMap(groups); - - VClass vclass = null; - VClassGroup tabs = null, other = null; - Iterator it = beans.iterator(); - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof Individual){ - vclass = (VClass)((Individual) obj).getVClass(); - if( vclass != null && vclass.getGroupURI() != null ){ - putInGroupsList(groupsByURI, vclass.getGroupURI(), obj); - } else { /* didn't find a group */ - if( !groupsByURI.containsKey("vitro://NullClassGroup") ){ - other = new VClassGroup("vitro://NullClassGroup",NO_GRP_FOUND); - groupsByURI.put("vitro://NullClassGroup", other); - groups.put(NO_GRP_FOUND,other); - } - putInGroupsList(groupsByURI, "vitro://NullClassGroup", obj); - } - } else if (obj instanceof Tab) { - if( !groupsByURI.containsKey("vitro://NullTabGroup") ){ - tabs = new VClassGroup("vitro://NullTabGroup",TABS); - groupsByURI.put(0, tabs ); - groups.put(TABS,tabs); - } - putInGroupsList(groupsByURI, null, obj); - } - } - return groups; - } - - private void putInGroupsList(Map groupsById, String key, Object obj) { - List classList = (List) groupsById.get(key); - if (classList == null) {/* make new list if this is a new grp */ - classList = new LinkedList(); - groupsById.put(key, classList); - } - classList.add(obj); - } - - /** - * Make a new map from the Integer() -> VClassGroup. - * @param groups - * @return - */ - private Map makeGroupURIBasedMap( Map groups){ - LinkedHashMap