Changeset 20740


Ignore:
Timestamp:
26/02/10 16:15:13 (2 years ago)
Author:
julie
Message:

refactor portal to use new method that returns list of object IDs instead of webresults. remove obsolete section of code referring to collapsed item collection. remove references to PORTAL_QUERY_FLAG, it's not used anymore either. refactor main method into several smaller ones.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bio/webapp/src/org/intermine/bio/web/logic/OrthologueConverter.java

    r20728 r20740  
    1515import java.util.ArrayList; 
    1616import java.util.List; 
    17 import java.util.regex.Matcher; 
    1817import java.util.regex.Pattern; 
    1918 
    20 import javax.servlet.ServletContext; 
    21 import javax.servlet.http.HttpSession; 
    22  
    2319import org.apache.commons.lang.StringUtils; 
    24 import org.apache.log4j.Logger; 
    2520import org.apache.struts.action.ActionMessage; 
    26 import org.directwebremoting.WebContextFactory; 
    2721import org.intermine.api.InterMineAPI; 
    2822import org.intermine.api.profile.Profile; 
    2923import org.intermine.api.query.PathQueryExecutor; 
    30 import org.intermine.api.query.WebResultsExecutor; 
    3124import org.intermine.api.results.ExportResultsIterator; 
    3225import org.intermine.api.results.ResultElement; 
    3326import org.intermine.api.results.WebResults; 
    3427import org.intermine.metadata.Model; 
    35 import org.intermine.model.InterMineObject; 
    36 import org.intermine.objectstore.ObjectStore; 
    37 import org.intermine.objectstore.ObjectStoreException; 
    3828import org.intermine.pathquery.Constraints; 
    39 import org.intermine.pathquery.Path; 
    40 import org.intermine.pathquery.PathException; 
    4129import org.intermine.pathquery.PathQuery; 
    4230import org.intermine.web.logic.bag.BagConverter; 
    4331import org.intermine.web.logic.config.WebConfig; 
    44 import org.intermine.web.logic.pathqueryresult.PathQueryResultHelper; 
    45 import org.intermine.web.logic.session.SessionMethods; 
    4632 
    4733/** 
     
    5238{ 
    5339 
    54     private static final Logger LOG = Logger.getLogger(OrthologueConverter.class); 
     40     
    5541    // D. melanogaster, C. lupus familiaris 
    5642    private static final Pattern ORGANISM_SHORTNAME_MATCHER = Pattern.compile("([a-zA-Z]\\..+)"); 
    57     private static InterMineAPI im; 
    58     private static Model model; 
    59     private static WebConfig webConfig; 
    60     private static ObjectStore os; 
     43    private Model model; 
     44     
    6145 
    62     public OrthologueConverter() { 
    63         super(); 
    64         ServletContext servletContext = WebContextFactory.get().getServletContext(); 
    65         HttpSession session = WebContextFactory.get().getSession(); 
    66         im = SessionMethods.getInterMineAPI(session); 
    67         webConfig = SessionMethods.getWebConfig(servletContext); 
     46    /** 
     47     * @param im intermine api 
     48     * @param webConfig the webconfig 
     49     */ 
     50    public OrthologueConverter(InterMineAPI im, WebConfig webConfig) { 
     51        super(im, webConfig); 
    6852        model = im.getModel(); 
    69         os = im.getObjectStore(); 
    70     } 
    71      
    72     /** 
    73      * {@inheritDoc} 
    74      * @throws PathException 
    75      */ 
    76     public WebResults getConvertedObjects (Profile profile, List<Integer> fromList, String type, 
    77             String ... parameters) throws ObjectStoreException, PathException { 
    78         String organism = null, dataset = null; 
    7953 
    80         for (String param : parameters) { 
    81             if (StringUtils.isEmpty(param)) { 
    82                 continue; 
    83             } 
    84             Matcher m = ORGANISM_SHORTNAME_MATCHER.matcher(param); 
    85             if (m.matches()) { 
    86                 organism = param; 
    87             } else { 
    88                 dataset = param; 
    89             } 
    90         } 
    91         List<InterMineObject> objectList = os.getObjectsByIds(fromList); 
    92         PathQuery q = generateQuery(objectList, type, organism, dataset); 
    93  
    94         LOG.info("PATH QUERY:" + q.toXml(PathQuery.USERPROFILE_VERSION)); 
    95         WebResultsExecutor executor = im.getWebResultsExecutor(profile); 
    96  
    97         return executor.execute(q); 
    9854    } 
    9955 
    100     private static PathQuery constructPathQuery(String organism, String dataset) { 
     56    private PathQuery constructPathQuery(String bagType, String bagName, String organismName) { 
    10157        PathQuery q = new PathQuery(model); 
    10258 
    10359        // organism 
    104         q.addConstraint("Gene.homologues.homologue.organism", Constraints.lookup(organism)); 
     60        q.addConstraint("Gene.homologues.homologue.organism.shortName",  
     61                Constraints.eq(organismName)); 
    10562 
    10663        // homologue.type = "orthologue" 
    10764        q.addConstraint("Gene.homologues.type", Constraints.eq("orthologue")); 
    10865 
    109         if (StringUtils.isNotEmpty(dataset)) { 
    110             // homologue.dataSets = dataset 
    111             q.addConstraint("Gene.homologues.dataSets.title", Constraints.eq(dataset)); 
    112         } 
     66        q.addConstraint(bagType, Constraints.in(bagName)); 
    11367        return q; 
    11468    } 
    11569 
    116     private PathQuery generateQuery(List<InterMineObject> objectList, String type, String organism, 
    117             String dataset) 
    118     throws PathException { 
    119         PathQuery q = constructPathQuery(organism, dataset); 
    120  
    121         List<Path> view = PathQueryResultHelper.getDefaultView(type, model, webConfig, 
    122                         "Gene.homologues.homologue", false); 
    123         view = getFixedView(view); 
    124         q.setViewPaths(view); 
    125  
    126         q.addConstraint(type, Constraints.in(objectList)); 
    127  
    128         q.syncLogicExpression("and"); 
    129         return q; 
    130     } 
    131  
    132  
    133     private static PathQuery generateQuery(String bagType, String bagName, String organismName) { 
    134         PathQuery q = constructPathQuery(organismName, null); 
    135         q.setView("Gene.homologues.homologue.primaryIdentifier"); 
    136         q.addConstraint(bagType, Constraints.in(bagName)); 
    137         q.syncLogicExpression("and"); 
    138         return q; 
    139     } 
    140  
    141     public String getFieldsFromConvertedObjects(Profile profile, String bagType, 
     70    /** 
     71     * runs the orthologue conversion pathquery and returns a comma-delimited list of identifiers 
     72     * @param profile the user's profile 
     73     * @param bagType the class of the list, has to be gene I think 
     74     * @param bagName name of list 
     75     * @param organismName name of homologue's organism 
     76     * @return commadelimited list of identifiers, eg. eve,zen 
     77     */ 
     78    public String getConvertedObjectFields(Profile profile, String bagType, 
    14279            String bagName, String organismName) { 
    143         String orthologues = ""; 
    144         PathQuery pathQuery = generateQuery(bagType, bagName, organismName); 
     80        StringBuffer orthologues = null; 
     81        PathQuery pathQuery = constructPathQuery(bagType, bagName, organismName); 
     82        pathQuery.setView("Gene.homologues.homologue.primaryIdentifier"); 
     83        pathQuery.syncLogicExpression("and"); 
    14584        PathQueryExecutor executor = im.getPathQueryExecutor(profile); 
    14685        ExportResultsIterator it = executor.execute(pathQuery); 
    147          
     86 
    14887        while (it.hasNext()) { 
    14988            List<ResultElement> row = it.next(); 
    15089            String orthologue = row.get(0).getField().toString(); 
    151             if (StringUtils.isNotEmpty(orthologues)) { 
    152                 orthologues += ","; 
     90            if (orthologues != null) { 
     91                orthologues.append(","); 
    15392            } 
    154             orthologues += orthologue; 
     93            orthologues.append(orthologue); 
    15594        } 
    156  
    157         return orthologues; 
     95        if (orthologues == null) { 
     96            return null; 
     97        } 
     98        return orthologues.toString(); 
    15899    } 
    159  
     100     
    160101    /** 
    161      * If view contains joined organism, this will make sure, that 
    162      * organism is joined as a inner join. Else constraint on organism doesn't work. 
    163      * @param pathQuery 
    164      * @param joinPath 
    165      * @throws PathException 
     102     * runs the orthologue conversion pathquery and returns list of intermine IDs 
     103     * @param profile the user's profile 
     104     * @param bagType the class of the list, has to be gene I think 
     105     * @param bagName name of list 
     106     * @param organismName name of homologue's organism 
     107     * @return list of intermine IDs 
    166108     */ 
    167     private List<Path> getFixedView(List<Path> view) throws PathException { 
    168         String invalidPath = "Gene.homologues.homologue:organism"; 
    169         String validPath = "Gene.homologues.homologue.organism"; 
    170         List<Path> ret = new ArrayList<Path>(); 
    171         for (Path path : view) { 
    172             if (path.toString().contains(invalidPath)) { 
    173                 String newPathString = path.toString().replace(invalidPath, validPath); 
    174                 path = new Path(path.getModel(), newPathString); 
    175             } 
    176             ret.add(path); 
     109    public List<Integer> getConvertedObjectIds(Profile profile, String bagType, 
     110            String bagName, String organismName) { 
     111        PathQuery pathQuery = constructPathQuery(bagType, bagName, organismName); 
     112        pathQuery.setView(bagType + ".id"); 
     113        PathQueryExecutor executor = im.getPathQueryExecutor(profile); 
     114        ExportResultsIterator it = executor.execute(pathQuery); 
     115        List<Integer> ids = new ArrayList(); 
     116        while (it.hasNext()) { 
     117            List<ResultElement> row = it.next(); 
     118            ids.add((Integer) row.get(0).getField()); 
    177119        } 
    178         return ret; 
     120        return ids; 
    179121    } 
    180122 
     
    241183        return am; 
    242184    } 
     185 
     186    @Override 
     187    public WebResults getConvertedObjects(Profile profile, List<Integer> fromList, String type, 
     188            String... parameters) { 
     189        // TODO Auto-generated method stub 
     190        return null; 
     191    } 
    243192} 
  • trunk/intermine/web/main/src/org/intermine/dwr/AjaxServices.java

    r20728 r20740  
    13641364                Constructor constructor = clazz.getConstructor(); 
    13651365                BagConverter bagConverter = (BagConverter) constructor.newInstance(); 
    1366                 return bagConverter.getFieldsFromConvertedObjects(profile, bagType, bagName,  
     1366                return bagConverter.getConvertedObjectFields(profile, bagType, bagName,  
    13671367                        selectedValue); 
    13681368            } 
  • trunk/intermine/web/main/src/org/intermine/web/logic/Constants.java

    r20646 r20740  
    105105 
    106106    /** 
    107      * The name of the property that is set to TRUE in the PortalQueryAction Action to indicate 
    108      * to the ObjectDetailsController that we have come from a portal page. 
    109      */ 
    110     public static final String PORTAL_QUERY_FLAG = "PORTAL_QUERY_FLAG"; 
    111  
    112     /** 
    113107     * The name of the property to look up to find the maximum size of an inline table. 
    114108     */ 
  • trunk/intermine/web/main/src/org/intermine/web/logic/bag/BagConverter.java

    r20728 r20740  
    1414import java.util.List; 
    1515 
    16 import javax.servlet.ServletContext; 
    17 import javax.servlet.http.HttpSession; 
    18  
    1916import org.apache.struts.action.ActionMessage; 
    20 import org.directwebremoting.WebContextFactory; 
    2117import org.intermine.api.InterMineAPI; 
    2218import org.intermine.api.profile.Profile; 
    2319import org.intermine.api.results.WebResults; 
    24 import org.intermine.metadata.Model; 
    25 import org.intermine.objectstore.ObjectStore; 
    2620import org.intermine.objectstore.ObjectStoreException; 
    2721import org.intermine.pathquery.PathException; 
    2822import org.intermine.web.logic.config.WebConfig; 
    29 import org.intermine.web.logic.session.SessionMethods; 
    3023 
    3124 
     
    3528 * 
    3629 */ 
    37 public abstract class BagConverter { 
    38      
    39     private static InterMineAPI im = null; 
    40     private static Model model = null; 
    41     private static WebConfig webConfig = null; 
    42     private static ObjectStore os = null; 
    43      
    44      
     30public abstract class BagConverter 
     31{ 
     32 
     33    protected InterMineAPI im = null; 
     34    protected WebConfig webConfig = null; 
     35 
     36    /** 
     37     * 
     38     * @param im intermine API 
     39     * @param webConfig the webconfig 
     40     */ 
     41    public BagConverter(InterMineAPI im, WebConfig webConfig) { 
     42        this.im = im; 
     43        this.webConfig = webConfig; 
     44    } 
     45 
    4546    /** 
    4647     * Returns a List<ResultRows> of converted objects 
     48     * @param profile user's profile 
    4749     * @param parameters the parameters 
    4850     * @param fromList the list to convert 
     
    5355     * @throws PathException bad path 
    5456     */ 
    55     public abstract WebResults getConvertedObjects(Profile profile, List<Integer> fromList, String type,  
    56             String ... parameters) 
     57    public abstract WebResults getConvertedObjects(Profile profile, List<Integer> fromList, 
     58            String type, String ... parameters) 
    5759        throws ClassNotFoundException, ObjectStoreException, PathException; 
    5860 
     
    6769     * @throws UnsupportedEncodingException exception 
    6870     */ 
    69     public abstract ActionMessage getActionMessage(String externalids, int convertedSize, String type,  
    70             String ... parameters)  
     71    public abstract ActionMessage getActionMessage(String externalids, int convertedSize, 
     72            String type, String ... parameters) 
    7173    throws ObjectStoreException, UnsupportedEncodingException; 
    72      
    73     public abstract String getFieldsFromConvertedObjects(Profile profile, String bagType, 
     74 
     75    /** 
     76     * 
     77     * @param profile user's profile 
     78     * @param bagType class of list 
     79     * @param bagName name of list 
     80     * @param constraintValue value of constraint 
     81     * @return string of comma delimited identifiers 
     82     */ 
     83    public abstract String getConvertedObjectFields(Profile profile, String bagType, 
     84            String bagName, String constraintValue); 
     85 
     86    /** 
     87    * 
     88    * @param profile user's profile 
     89    * @param bagType class of list 
     90    * @param bagName name of list 
     91    * @param constraintValue value of constraint 
     92    * @return list of intermine IDs 
     93    */ 
     94    public abstract List<Integer> getConvertedObjectIds(Profile profile, String bagType, 
    7495            String bagName, String constraintValue); 
    7596} 
  • trunk/intermine/web/main/src/org/intermine/web/struts/ObjectDetailsController.java

    r20462 r20740  
    8888        request.setAttribute("object", dobj); 
    8989 
    90         if (session.getAttribute(Constants.PORTAL_QUERY_FLAG) != null) { 
    91             session.removeAttribute(Constants.PORTAL_QUERY_FLAG); 
    92             // FIXME see #1911 
    93             // setVerboseCollections(session, dobj); 
    94         } 
    95  
    9690        Map<String, Map> placementRefsAndCollections = new TreeMap<String, Map>(); 
    9791        Set<String> aspects = new HashSet<String>(SessionMethods.getCategories(servletContext)); 
  • trunk/intermine/web/main/src/org/intermine/web/struts/PortalQueryAction.java

    r20728 r20740  
    1111 */ 
    1212 
     13import java.io.UnsupportedEncodingException; 
    1314import java.lang.reflect.Constructor; 
    1415import java.net.URLDecoder; 
     
    3637import org.intermine.api.profile.Profile; 
    3738import org.intermine.api.query.WebResultsExecutor; 
    38 import org.intermine.api.results.ResultElement; 
    3939import org.intermine.api.results.WebResults; 
    40 import org.intermine.api.results.flatouterjoins.MultiRow; 
    41 import org.intermine.api.results.flatouterjoins.MultiRowValue; 
    4240import org.intermine.api.template.TemplateManager; 
    4341import org.intermine.api.template.TemplatePopulator; 
     
    4543import org.intermine.api.util.NameUtil; 
    4644import org.intermine.metadata.Model; 
    47 import org.intermine.model.InterMineObject; 
    4845import org.intermine.objectstore.ObjectStoreException; 
    4946import org.intermine.objectstore.query.ConstraintOp; 
    50 import org.intermine.objectstore.query.ResultsRow; 
    5147import org.intermine.pathquery.Constraints; 
    5248import org.intermine.pathquery.Path; 
    5349import org.intermine.pathquery.PathException; 
    5450import org.intermine.pathquery.PathQuery; 
    55 import org.intermine.util.StringUtil; 
    5651import org.intermine.web.logic.Constants; 
    5752import org.intermine.web.logic.bag.BagConverter; 
     
    7570    private static int index = 0; 
    7671//    private static final Logger LOG = Logger.getLogger(PortalQueryAction.class); 
     72    private Map<String, BagConverter> bagConverters = new HashMap(); 
     73 
     74 
    7775    /** 
    7876     * Link-ins from other sites end up here (after some redirection). 
     
    9593        final InterMineAPI im = SessionMethods.getInterMineAPI(session); 
    9694        ServletContext servletContext = session.getServletContext(); 
    97         String extId = request.getParameter("externalid"); 
     95 
    9896        String origin = request.getParameter("origin"); 
    9997        String className = request.getParameter("class"); 
    100         //String organism = request.getParameter("organism"); 
     98        String extId = request.getParameter("externalid"); 
    10199        if ((extId == null) || (extId.length() <= 0)) { 
    102100            extId = request.getParameter("externalids"); 
    103101        } 
     102 
    104103        // Add a message to welcome the user 
    105104        Properties properties = SessionMethods.getWebProperties(servletContext); 
    106105        String welcomeMsg = properties.getProperty("portal.welcome." + origin); 
    107         if (StringUtil.isEmpty(welcomeMsg)) { 
     106        if (StringUtils.isEmpty(welcomeMsg)) { 
    108107            welcomeMsg = properties.getProperty("portal.welcome"); 
    109108        } 
     
    115114        } 
    116115 
    117         session.setAttribute(Constants.PORTAL_QUERY_FLAG, Boolean.TRUE); 
    118  
    119         // Set collapsed/uncollapsed state of object details UI 
    120         // TODO This might not be used anymore 
    121         Map<String, Boolean> collapsed = SessionMethods.getCollapsedMap(session); 
    122         collapsed.put("fields", Boolean.TRUE); 
    123         collapsed.put("further", Boolean.FALSE); 
    124         collapsed.put("summary", Boolean.FALSE); 
    125  
    126         Profile profile = SessionMethods.getProfile(session); 
     116 
    127117        String[] idList = extId.split(","); 
    128118 
     
    139129        BagQueryConfig bagQueryConfig = im.getBagQueryConfig(); 
    140130 
    141         // If the class is not in the model, we can't continue 
    142         try { 
    143             className = StringUtil.capitalise(className); 
    144             Class.forName(model.getPackageName() + "." + className); 
    145         } catch (ClassNotFoundException clse) { 
     131        // If the class is not in the model, we can't continue         
     132        if (model.getClassDescriptorByName(className) == null) {  
    146133            recordError(new ActionMessage("errors.badportalclass"), request); 
    147134            return goToNoResults(mapping, session); 
    148135        } 
    149         String bagName = NameUtil.generateNewName(profile.getSavedBags().keySet(), "link"); 
    150  
     136              
    151137        PathQuery pathQuery = new PathQuery(model); 
    152138        List<Path> view = PathQueryResultHelper.getDefaultView(className, model, webConfig, null, 
     
    157143 
    158144        Map<String, BagQueryResult> returnBagQueryResults = new HashMap(); 
     145        Profile profile = SessionMethods.getProfile(session); 
    159146        WebResultsExecutor executor = im.getWebResultsExecutor(profile); 
    160147        WebResults webResults = executor.execute(pathQuery, returnBagQueryResults); 
    161  
     148         
     149        String bagName = NameUtil.generateNewName(profile.getSavedBags().keySet(), "link"); 
    162150        InterMineBag imBag = profile.createBag(bagName, className, ""); 
    163151        List<Integer> bagList = new ArrayList(); 
     
    177165        if (additionalConverters != null) { 
    178166            for (String converterClassName : additionalConverters.keySet()) { 
    179                 Class clazz = Class.forName(converterClassName); 
    180                 Constructor constructor = clazz.getConstructor(); 
    181                 String[] paramArray = additionalConverters.get(converterClassName); 
    182                 String[] urlFields = paramArray[0].split(","); 
    183                 String[] addparameters = new String[urlFields.length]; 
    184                 int i = 0; 
    185                 for (String urlField : urlFields) { 
    186                     // if one of the request vars matches the variables listed in the bagquery 
    187                     // config, add the variable to be passed to the custom converter 
    188                     String param = request.getParameter(urlField); 
    189                     if (StringUtils.isNotEmpty(param)) { 
    190                         // the spaces in organisms, eg. D.%20rerio, need to be handled 
    191                         addparameters[i] = URLDecoder.decode(param, "UTF-8"); 
    192                     } 
    193                 } 
     167 
     168                String[] addparameters = getAdditionalParameters(request, 
     169                        additionalConverters.get(converterClassName)); 
     170 
    194171                if (addparameters.length > 0) { 
    195                     BagConverter bagConverter = (BagConverter) constructor.newInstance(); 
    196                     WebResults convertedWebResult = bagConverter.getConvertedObjects(profile, 
    197                             bagList, className, addparameters); 
     172 
     173                    BagConverter bagConverter = getBagConverter(converterClassName); 
     174 
    198175                    imBag = profile.createBag(bagName, className, ""); 
    199                     List<Integer> converted = new ArrayList<Integer>(); 
    200                     for (MultiRow<ResultsRow<MultiRowValue<ResultElement>>> resRow 
    201                             : convertedWebResult) { 
    202                         ResultElement resElement = resRow.get(0).get(0).getValue(); 
    203                         Object obj = resElement.getObject(); 
    204                         if (obj instanceof InterMineObject) { 
    205                             converted.add(((InterMineObject) obj).getId()); 
    206                         } 
    207                     } 
     176                    List<Integer> converted = bagConverter.getConvertedObjectIds(profile,  
     177                            className, bagName, addparameters[0]); 
    208178                    // No matches 
    209179                    if (converted.size() <= 0) { 
     
    224194            } 
    225195        } 
    226         // Attach messages 
    227         if (bagList.size() == 0 && bagQueryResult.getMatches().size() == 1) { 
    228             ActionMessage msg = new ActionMessage("results.lookup.noresults.one", 
    229                                                   new Integer(bagQueryResult.getMatches().size()), 
    230                                                   className); 
    231             actionMessages.add(Constants.PORTAL_MSG, msg); 
    232         } else if (bagList.size() == 0 && bagQueryResult.getMatches().size() > 1) { 
    233             ActionMessage msg = new ActionMessage("results.lookup.noresults.many", 
    234                                                   new Integer(bagQueryResult.getMatches().size()), 
    235                                                   className); 
    236             actionMessages.add(Constants.PORTAL_MSG, msg); 
    237         } else if (bagList.size() > 0) { 
    238             ActionMessage msg = new ActionMessage("results.lookup.matches.many", 
    239                                                   new Integer(bagList.size())); 
    240             actionMessages.add(Constants.PORTAL_MSG, msg); 
    241         } else if (bagList.size() == 0) { 
    242             ActionMessage msg = new ActionMessage("portal.nomatches", extId); 
    243             actionMessages.add(Constants.PORTAL_MSG, msg); 
    244         } 
     196 
     197        attachMessages(actionMessages, className, bagQueryResult.getMatches().size(), 
     198                bagList.size(), extId); 
     199 
    245200        session.setAttribute(Constants.PORTAL_MSG, actionMessages); 
    246201 
     
    260215    } 
    261216 
     217    private BagConverter getBagConverter(String converterClassName) { 
     218 
     219        BagConverter bagConverter = bagConverters.get(converterClassName); 
     220 
     221        if (bagConverter == null) { 
     222            try { 
     223                Class clazz = Class.forName(converterClassName); 
     224                Constructor constructor = clazz.getConstructor(); 
     225                bagConverter = (BagConverter) constructor.newInstance(); 
     226            } catch (Exception e) { 
     227                throw new RuntimeException("Failed to construct bagconverter for " 
     228                        + converterClassName, e); 
     229            } 
     230            bagConverters.put(converterClassName, bagConverter); 
     231        } 
     232        return bagConverter; 
     233    } 
     234 
     235    private String[] getAdditionalParameters(HttpServletRequest request, String[] paramArray) 
     236    throws UnsupportedEncodingException { 
     237 
     238    String[] urlFields = paramArray[0].split(","); 
     239    String[] addparameters = new String[urlFields.length]; 
     240    int i = 0; 
     241    for (String urlField : urlFields) { 
     242        // if one of the request vars matches the variables listed in the bagquery 
     243        // config, add the variable to be passed to the custom converter 
     244        String param = request.getParameter(urlField); 
     245        if (StringUtils.isNotEmpty(param)) { 
     246            // the spaces in organisms, eg. D.%20rerio, need to be handled 
     247            addparameters[i] = URLDecoder.decode(param, "UTF-8"); 
     248        } 
     249    } 
     250    return addparameters; 
     251    } 
     252 
    262253    private ActionForward goToResults(ActionMapping mapping, 
    263254                                      HttpSession session, WebResults webResults) { 
     
    287278    } 
    288279 
     280    private void attachMessages(ActionMessages actionMessages, String className, 
     281            int bagQueryResultSize, 
     282            int bagListSize, String extId) { 
     283        // Attach messages 
     284        if (bagListSize == 0 && bagQueryResultSize == 1) { 
     285            ActionMessage msg = new ActionMessage("results.lookup.noresults.one", 
     286                    new Integer(bagQueryResultSize), 
     287                    className); 
     288            actionMessages.add(Constants.PORTAL_MSG, msg); 
     289        } else if (bagListSize == 0 && bagQueryResultSize > 1) { 
     290            ActionMessage msg = new ActionMessage("results.lookup.noresults.many", 
     291                    new Integer(bagQueryResultSize), 
     292                    className); 
     293            actionMessages.add(Constants.PORTAL_MSG, msg); 
     294        } else if (bagListSize > 0) { 
     295            ActionMessage msg = new ActionMessage("results.lookup.matches.many", 
     296                    new Integer(bagListSize)); 
     297            actionMessages.add(Constants.PORTAL_MSG, msg); 
     298        } else if (bagListSize == 0) { 
     299            ActionMessage msg = new ActionMessage("portal.nomatches", extId); 
     300            actionMessages.add(Constants.PORTAL_MSG, msg); 
     301        } 
     302    } 
     303 
    289304    /** 
    290      * @deprecated Use the BagQueryRunner instead 
     305     * @deprecated Use the quicksearch action instead 
    291306     */ 
    292307    private String loadObjectDetails(ServletContext servletContext, HttpSession session, 
Note: See TracChangeset for help on using the changeset viewer.