NIHVIVO-2449 Display mostSpecificTypes in search results in place of moniker. Create new template model class for individual in search results, since the display increasingly diverges from the individualList display.

This commit is contained in:
ryounes 2011-07-05 22:00:10 +00:00
parent 1d1edb17b8
commit 1c52d91b08
9 changed files with 95 additions and 41 deletions

View file

@ -414,9 +414,10 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qexec = null;
try {
QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
qexec = QueryExecutionFactory.create(query, dataset);
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
@ -431,6 +432,9 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
} finally {
dataset.getLock().leaveCriticalSection();
if (qexec != null) {
qexec.close();
}
w.close();
}

View file

@ -358,7 +358,7 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear
// Convert search result individuals to template model objects
body.put("individuals", ListedIndividualTemplateModel
.getIndividualTemplateModelList(beans, vreq));
.getIndividualTemplateModels(beans, vreq));
body.put("querytext", qtxt);
body.put("title", qtxt + " - " + appBean.getApplicationName()

View file

@ -52,6 +52,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery;
import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.LinkTemplateModel;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualSearchResult;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
import freemarker.template.Configuration;
@ -301,11 +302,8 @@ public class SolrPagedSearchController extends FreemarkerHttpServlet {
}
}
// Convert search result individuals to template model objects
// RY If this diverges significantly from what's used on the index page,
// create a different template model.
body.put("individuals", ListedIndividualTemplateModel
.getIndividualTemplateModelList(individuals, vreq));
body.put("individuals", IndividualSearchResult
.getIndividualTemplateModels(individuals, vreq));
body.put("querytext", qtxt);
body.put("title", qtxt + " - " + appBean.getApplicationName()

View file

@ -154,7 +154,6 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
return opsDao.getMostSpecificTypesForIndividual(getUri());
}
public String getUri() {
return individual.getURI();
}

View file

@ -0,0 +1,64 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder;
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder.ClassView;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
public class IndividualSearchResult extends BaseTemplateModel {
private static final Log log = LogFactory.getLog(IndividualSearchResult.class);
protected Individual individual;
protected VitroRequest vreq;
public IndividualSearchResult(Individual individual, VitroRequest vreq) {
this.individual = individual;
this.vreq = vreq;
}
private String getView(ClassView view) {
ViewFinder vf = new ViewFinder(view);
return vf.findClassView(individual, vreq);
}
public static List<IndividualSearchResult> getIndividualTemplateModels(List<Individual> individuals, VitroRequest vreq) {
List<IndividualSearchResult> models = new ArrayList<IndividualSearchResult>(individuals.size());
for (Individual individual : individuals) {
models.add(new IndividualSearchResult(individual, vreq));
}
return models;
}
/* Access methods for templates */
public String getProfileUrl() {
return UrlBuilder.getIndividualProfileUrl(individual, vreq.getWebappDaoFactory());
}
public String getName() {
return individual.getName();
}
public List<String> getMostSpecificTypes() {
ObjectPropertyStatementDao opsDao = vreq.getWebappDaoFactory().getObjectPropertyStatementDao();
return opsDao.getMostSpecificTypesForIndividual(individual.getURI());
}
public String getSearchView() {
return getView(ClassView.SEARCH);
}
}

View file

@ -21,22 +21,16 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
public class ListedIndividualTemplateModel extends BaseTemplateModel {
private static final Log log = LogFactory.getLog(ListedIndividualTemplateModel.class);
private static final String PATH = Route.INDIVIDUAL.path();
protected Individual individual;
protected VitroRequest vreq;
protected UrlBuilder urlBuilder;
protected VitroRequest vreq;
public ListedIndividualTemplateModel(Individual individual, VitroRequest vreq) {
this.individual = individual;
this.vreq = vreq;
// Needed for getting portal-sensitive urls. Remove if multi-portal support is removed.
this.urlBuilder = new UrlBuilder(vreq.getAppBean());
}
public static List<ListedIndividualTemplateModel> getIndividualTemplateModelList(List<Individual> individuals, VitroRequest vreq) {
public static List<ListedIndividualTemplateModel> getIndividualTemplateModels(List<Individual> individuals, VitroRequest vreq) {
List<ListedIndividualTemplateModel> models = new ArrayList<ListedIndividualTemplateModel>(individuals.size());
for (Individual individual : individuals) {
models.add(new ListedIndividualTemplateModel(individual, vreq));
@ -44,11 +38,6 @@ public class ListedIndividualTemplateModel extends BaseTemplateModel {
return models;
}
private String getView(ClassView view) {
ViewFinder vf = new ViewFinder(view);
return vf.findClassView(individual, vreq);
}
/* Access methods for templates */
public String getProfileUrl() {
@ -105,18 +94,8 @@ public class ListedIndividualTemplateModel extends BaseTemplateModel {
return individual.getName();
}
@Deprecated
public String getMoniker() {
return "";
// return individual.getMoniker();
}
public String getUri() {
return individual.getURI();
}
public String getSearchView() {
return getView(ClassView.SEARCH);
}
}
}