NIHVIVO-2449 Display preferred title on individuallist page
This commit is contained in:
parent
1c52d91b08
commit
0347b682c7
18 changed files with 145 additions and 177 deletions
|
@ -12,7 +12,6 @@ import java.util.regex.Pattern;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -59,7 +58,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.jena.ExtendedLinkedDataUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.jena.ExtendedLinkedDataUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
|
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividual;
|
||||||
import freemarker.ext.beans.BeansWrapper;
|
import freemarker.ext.beans.BeansWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,7 +226,8 @@ public class IndividualController extends FreemarkerHttpServlet {
|
||||||
if (relatedSubjectInd != null) {
|
if (relatedSubjectInd != null) {
|
||||||
map = new HashMap<String, Object>();
|
map = new HashMap<String, Object>();
|
||||||
map.put("name", relatedSubjectInd.getName());
|
map.put("name", relatedSubjectInd.getName());
|
||||||
map.put("url", (new ListedIndividualTemplateModel(relatedSubjectInd, vreq)).getProfileUrl());
|
map.put("url", UrlBuilder.getIndividualProfileUrl(relatedSubjectInd, vreq));
|
||||||
|
map.put("url", (new ListedIndividual(relatedSubjectInd, vreq)).getProfileUrl());
|
||||||
String relatingPredicateUri = vreq.getParameter("relatingPredicateUri");
|
String relatingPredicateUri = vreq.getParameter("relatingPredicateUri");
|
||||||
if (relatingPredicateUri != null) {
|
if (relatingPredicateUri != null) {
|
||||||
ObjectProperty relatingPredicateProp = opDao.getObjectPropertyByURI(relatingPredicateUri);
|
ObjectProperty relatingPredicateProp = opDao.getObjectPropertyByURI(relatingPredicateUri);
|
||||||
|
|
|
@ -27,9 +27,13 @@ import org.apache.lucene.search.ScoreDoc;
|
||||||
import org.apache.lucene.search.Sort;
|
import org.apache.lucene.search.Sort;
|
||||||
import org.apache.lucene.search.TermQuery;
|
import org.apache.lucene.search.TermQuery;
|
||||||
import org.apache.lucene.search.TopDocs;
|
import org.apache.lucene.search.TopDocs;
|
||||||
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
|
import org.apache.solr.client.solrj.SolrServer;
|
||||||
|
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
|
import org.apache.solr.common.SolrDocument;
|
||||||
|
import org.apache.solr.common.SolrDocumentList;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -38,17 +42,13 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc;
|
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames;
|
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividual;
|
||||||
import freemarker.ext.beans.BeansWrapper;
|
import freemarker.ext.beans.BeansWrapper;
|
||||||
import freemarker.template.TemplateModel;
|
import freemarker.template.TemplateModel;
|
||||||
import org.apache.solr.client.solrj.SolrQuery;
|
|
||||||
import org.apache.solr.client.solrj.SolrServer;
|
|
||||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
|
||||||
import org.apache.solr.common.SolrDocument;
|
|
||||||
import org.apache.solr.common.SolrDocumentList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a list of individuals for display in a template
|
* Generates a list of individuals for display in a template
|
||||||
|
@ -109,9 +109,9 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
body.putAll(map);
|
body.putAll(map);
|
||||||
|
|
||||||
List<Individual> inds = (List<Individual>)map.get("entities");
|
List<Individual> inds = (List<Individual>)map.get("entities");
|
||||||
List<ListedIndividualTemplateModel> indsTm = new ArrayList<ListedIndividualTemplateModel>();
|
List<BaseListedIndividual> indsTm = new ArrayList<BaseListedIndividual>();
|
||||||
for(Individual ind : inds ){
|
for(Individual ind : inds ){
|
||||||
indsTm.add(new ListedIndividualTemplateModel(ind,vreq));
|
indsTm.add(new ListedIndividual(ind,vreq));
|
||||||
}
|
}
|
||||||
body.put("individuals", indsTm);
|
body.put("individuals", indsTm);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividual;
|
||||||
import freemarker.ext.beans.BeansWrapper;
|
import freemarker.ext.beans.BeansWrapper;
|
||||||
import freemarker.template.TemplateModel;
|
import freemarker.template.TemplateModel;
|
||||||
|
|
||||||
|
@ -95,9 +96,9 @@ public class SolrIndividualListController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Individual> inds = (List<Individual>)map.get("entities");
|
List<Individual> inds = (List<Individual>)map.get("entities");
|
||||||
List<ListedIndividualTemplateModel> indsTm = new ArrayList<ListedIndividualTemplateModel>();
|
List<BaseListedIndividual> indsTm = new ArrayList<BaseListedIndividual>();
|
||||||
for ( Individual ind : inds ) {
|
for ( Individual ind : inds ) {
|
||||||
indsTm.add(new ListedIndividualTemplateModel(ind,vreq));
|
indsTm.add(new ListedIndividual(ind,vreq));
|
||||||
}
|
}
|
||||||
body.put("individuals", indsTm);
|
body.put("individuals", indsTm);
|
||||||
|
|
||||||
|
|
|
@ -271,37 +271,18 @@ public class UrlBuilder {
|
||||||
public static String getPath(Route route, ParamMap params) {
|
public static String getPath(Route route, ParamMap params) {
|
||||||
return getPath(route.path(), params);
|
return getPath(route.path(), params);
|
||||||
}
|
}
|
||||||
//Adding method to allow for checking for special parameters
|
|
||||||
|
public static String getIndividualProfileUrl(Individual individual, VitroRequest vreq) {
|
||||||
|
return getIndividualProfileUrl(individual, individual.getURI(),vreq);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getIndividualProfileUrl(String individualUri, VitroRequest vreq) {
|
public static String getIndividualProfileUrl(String individualUri, VitroRequest vreq) {
|
||||||
Individual individual = new IndividualImpl(individualUri);
|
Individual individual = new IndividualImpl(individualUri);
|
||||||
return getIndividualProfileUrl(individual, individualUri, vreq);
|
return getIndividualProfileUrl(individual, individualUri, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getIndividualProfileUrl(String individualUri, WebappDaoFactory wadf) {
|
|
||||||
Individual individual = new IndividualImpl(individualUri);
|
|
||||||
return getIndividualProfileUrl(individual, individualUri, wadf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getIndividualProfileUrl(Individual individual, WebappDaoFactory wadf) {
|
|
||||||
String individualUri = individual.getURI();
|
|
||||||
return getIndividualProfileUrl(individual, individualUri, wadf);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Trying first with using a form of the method that includes the vitro request
|
|
||||||
private static String getIndividualProfileUrl(Individual individual, String individualUri, VitroRequest vreq) {
|
private static String getIndividualProfileUrl(Individual individual, String individualUri, VitroRequest vreq) {
|
||||||
WebappDaoFactory wadf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wadf = vreq.getWebappDaoFactory();
|
||||||
String profileUrl = getIndividualProfileUrl(individual, individualUri, wadf);
|
|
||||||
if(profileUrl != null) {
|
|
||||||
HashMap<String, String> specialParams = getSpecialParams(vreq);
|
|
||||||
if(specialParams.size() != 0) {
|
|
||||||
profileUrl = addParams(profileUrl, new ParamMap(specialParams));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return profileUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getIndividualProfileUrl(Individual individual, String individualUri, WebappDaoFactory wadf) {
|
|
||||||
String profileUrl = null;
|
String profileUrl = null;
|
||||||
try {
|
try {
|
||||||
URI uri = new URIImpl(individualUri); // throws exception if individualUri is invalid
|
URI uri = new URIImpl(individualUri); // throws exception if individualUri is invalid
|
||||||
|
@ -324,10 +305,18 @@ public class UrlBuilder {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn(e);
|
log.warn(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return profileUrl;
|
|
||||||
|
if (profileUrl != null) {
|
||||||
|
HashMap<String, String> specialParams = getSpecialParams(vreq);
|
||||||
|
if(specialParams.size() != 0) {
|
||||||
|
profileUrl = addParams(profileUrl, new ParamMap(specialParams));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return profileUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUriInDefaultNamespace(String individualUri, VitroRequest vreq) {
|
public static boolean isUriInDefaultNamespace(String individualUri, VitroRequest vreq) {
|
||||||
return isUriInDefaultNamespace(individualUri, vreq.getWebappDaoFactory());
|
return isUriInDefaultNamespace(individualUri, vreq.getWebappDaoFactory());
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames;
|
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.LinkTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.LinkTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -357,7 +357,7 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert search result individuals to template model objects
|
// Convert search result individuals to template model objects
|
||||||
body.put("individuals", ListedIndividualTemplateModel
|
body.put("individuals", BaseListedIndividual
|
||||||
.getIndividualTemplateModels(beans, vreq));
|
.getIndividualTemplateModels(beans, vreq));
|
||||||
|
|
||||||
body.put("querytext", qtxt);
|
body.put("querytext", qtxt);
|
||||||
|
|
|
@ -53,7 +53,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
|
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.LinkTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualSearchResult;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualSearchResult;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.JSONtoFmModel;
|
import edu.cornell.mannlib.vitro.webapp.utils.JSONtoFmModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
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.VClassTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividual;
|
||||||
|
|
||||||
public class BrowseDataGetter implements PageDataGetter {
|
public class BrowseDataGetter implements PageDataGetter {
|
||||||
final static Log log = LogFactory.getLog(BrowseDataGetter.class);
|
final static Log log = LogFactory.getLog(BrowseDataGetter.class);
|
||||||
|
@ -145,9 +146,9 @@ public class BrowseDataGetter implements PageDataGetter {
|
||||||
List<Individual> inds = vreq.getWebappDaoFactory().getIndividualDao()
|
List<Individual> inds = vreq.getWebappDaoFactory().getIndividualDao()
|
||||||
.getIndividualsByVClass(vclass);
|
.getIndividualsByVClass(vclass);
|
||||||
|
|
||||||
List<ListedIndividualTemplateModel> tInds = new ArrayList<ListedIndividualTemplateModel>(inds.size());
|
List<BaseListedIndividual> tInds = new ArrayList<BaseListedIndividual>(inds.size());
|
||||||
for( Individual ind : inds){
|
for( Individual ind : inds){
|
||||||
tInds.add(new ListedIndividualTemplateModel(ind, vreq));
|
tInds.add(new ListedIndividual(ind, vreq));
|
||||||
}
|
}
|
||||||
map.put("individualsInClass", tInds);
|
map.put("individualsInClass", tInds);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
import freemarker.ext.beans.BeansWrapper;
|
import freemarker.ext.beans.BeansWrapper;
|
||||||
import freemarker.template.TemplateModel;
|
import freemarker.template.TemplateModel;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ public class DataGetterUtils {
|
||||||
jo.put("name",ind.getName());
|
jo.put("name",ind.getName());
|
||||||
jo.put("thumbUrl", ind.getThumbUrl());
|
jo.put("thumbUrl", ind.getThumbUrl());
|
||||||
jo.put("imageUrl", ind.getImageUrl());
|
jo.put("imageUrl", ind.getImageUrl());
|
||||||
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq.getWebappDaoFactory()));
|
jo.put("profileUrl", UrlBuilder.getIndividualProfileUrl(ind, vreq));
|
||||||
|
|
||||||
String moniker = JSONServlet.getDataPropertyValue(ind, monikerDp, fullWdf);
|
String moniker = JSONServlet.getDataPropertyValue(ind, monikerDp, fullWdf);
|
||||||
jo.put("moniker", moniker);
|
jo.put("moniker", moniker);
|
||||||
|
|
|
@ -33,7 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.JSONServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.JSONServlet;
|
||||||
import freemarker.ext.beans.BeansWrapper;
|
import freemarker.ext.beans.BeansWrapper;
|
||||||
import freemarker.template.TemplateModel;
|
import freemarker.template.TemplateModel;
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -74,7 +70,7 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
||||||
/* These methods perform some manipulation of the data returned by the Individual methods */
|
/* These methods perform some manipulation of the data returned by the Individual methods */
|
||||||
|
|
||||||
public String getProfileUrl() {
|
public String getProfileUrl() {
|
||||||
return UrlBuilder.getIndividualProfileUrl(individual, vreq.getWebappDaoFactory());
|
return UrlBuilder.getIndividualProfileUrl(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For image, we use the default list view and Individual methods to reconstruct the image
|
// For image, we use the default list view and Individual methods to reconstruct the image
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* $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.lang.StringUtils;
|
||||||
|
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.beans.Link;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||||
|
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 abstract class BaseListedIndividual extends BaseTemplateModel {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(BaseListedIndividual.class);
|
||||||
|
|
||||||
|
protected Individual individual;
|
||||||
|
protected VitroRequest vreq;
|
||||||
|
|
||||||
|
public BaseListedIndividual(Individual individual, VitroRequest vreq) {
|
||||||
|
this.individual = individual;
|
||||||
|
this.vreq = vreq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ListedIndividual> getIndividualTemplateModels(List<Individual> individuals, VitroRequest vreq) {
|
||||||
|
List<ListedIndividual> models = new ArrayList<ListedIndividual>(individuals.size());
|
||||||
|
for (Individual individual : individuals) {
|
||||||
|
models.add(new ListedIndividual(individual, vreq));
|
||||||
|
}
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Access methods for templates */
|
||||||
|
|
||||||
|
public String getProfileUrl() {
|
||||||
|
return UrlBuilder.getIndividualProfileUrl(individual, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageUrl() {
|
||||||
|
String imageUrl = individual.getImageUrl();
|
||||||
|
return imageUrl == null ? null : getUrl(imageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getThumbUrl() {
|
||||||
|
String thumbUrl = individual.getThumbUrl();
|
||||||
|
return thumbUrl == null ? null : getUrl(thumbUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return individual.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUri() {
|
||||||
|
return individual.getURI();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ public class IndividualSearchResult extends BaseTemplateModel {
|
||||||
/* Access methods for templates */
|
/* Access methods for templates */
|
||||||
|
|
||||||
public String getProfileUrl() {
|
public String getProfileUrl() {
|
||||||
return UrlBuilder.getIndividualProfileUrl(individual, vreq.getWebappDaoFactory());
|
return UrlBuilder.getIndividualProfileUrl(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class ListedIndividual extends BaseListedIndividual {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(ListedIndividual.class);
|
||||||
|
|
||||||
|
public ListedIndividual(Individual individual, VitroRequest vreq) {
|
||||||
|
super(individual, vreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Access methods for templates */
|
||||||
|
|
||||||
|
}
|
|
@ -1,101 +0,0 @@
|
||||||
/* $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.lang.StringUtils;
|
|
||||||
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.beans.Link;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
|
||||||
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 ListedIndividualTemplateModel extends BaseTemplateModel {
|
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ListedIndividualTemplateModel.class);
|
|
||||||
|
|
||||||
protected Individual individual;
|
|
||||||
protected VitroRequest vreq;
|
|
||||||
|
|
||||||
public ListedIndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
|
||||||
this.individual = individual;
|
|
||||||
this.vreq = 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));
|
|
||||||
}
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Access methods for templates */
|
|
||||||
|
|
||||||
public String getProfileUrl() {
|
|
||||||
return UrlBuilder.getIndividualProfileUrl(individual, vreq.getWebappDaoFactory());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImageUrl() {
|
|
||||||
String imageUrl = individual.getImageUrl();
|
|
||||||
return imageUrl == null ? null : getUrl(imageUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getThumbUrl() {
|
|
||||||
String thumbUrl = individual.getThumbUrl();
|
|
||||||
return thumbUrl == null ? null : getUrl(thumbUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Link getPrimaryLink() {
|
|
||||||
// Link primaryLink = null;
|
|
||||||
// String anchor = individual.getAnchor();
|
|
||||||
// String url = individual.getUrl();
|
|
||||||
// if ( !(StringUtils.isEmpty(anchor)) && !(StringUtils.isEmpty(url)) ) {
|
|
||||||
// primaryLink = new Link();
|
|
||||||
// primaryLink.setAnchor(anchor);
|
|
||||||
// primaryLink.setUrl(url);
|
|
||||||
// }
|
|
||||||
// return primaryLink;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public List<Link> getAdditionalLinks() {
|
|
||||||
// return individual.getLinksList(); // returns an empty list, but not null
|
|
||||||
return new ArrayList<Link>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Link> getLinks() {
|
|
||||||
List<Link> additionalLinks = getAdditionalLinks(); // returns an empty list, but not null
|
|
||||||
List<Link> links = new ArrayList<Link>(additionalLinks.size()+1);
|
|
||||||
Link primaryLink = getPrimaryLink();
|
|
||||||
if (primaryLink != null) {
|
|
||||||
links.add(primaryLink);
|
|
||||||
}
|
|
||||||
for (Link link : additionalLinks) {
|
|
||||||
// Hide malformed links from the template to make things easier
|
|
||||||
if ( !(StringUtils.isEmpty(link.getAnchor())) && !(StringUtils.isEmpty(link.getUrl())) ) {
|
|
||||||
links.add(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return links; // returns an empty list, but not null
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return individual.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return individual.getURI();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -26,7 +26,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.JSONtoFmModel;
|
import edu.cornell.mannlib.vitro.webapp.utils.JSONtoFmModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel;
|
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.VClassTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.BaseListedIndividual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividual;
|
||||||
import freemarker.core.Environment;
|
import freemarker.core.Environment;
|
||||||
import freemarker.template.TemplateModelException;
|
import freemarker.template.TemplateModelException;
|
||||||
|
|
||||||
|
@ -161,9 +162,9 @@ public class BrowseWidget extends Widget {
|
||||||
List<Individual> inds = vreq.getWebappDaoFactory().getIndividualDao()
|
List<Individual> inds = vreq.getWebappDaoFactory().getIndividualDao()
|
||||||
.getIndividualsByVClass(vclass);
|
.getIndividualsByVClass(vclass);
|
||||||
|
|
||||||
List<ListedIndividualTemplateModel> tInds = new ArrayList<ListedIndividualTemplateModel>(inds.size());
|
List<BaseListedIndividual> tInds = new ArrayList<BaseListedIndividual>(inds.size());
|
||||||
for( Individual ind : inds){
|
for( Individual ind : inds){
|
||||||
tInds.add(new ListedIndividualTemplateModel(ind, vreq));
|
tInds.add(new ListedIndividual(ind, vreq));
|
||||||
}
|
}
|
||||||
map.put("individualsInClass", tInds);
|
map.put("individualsInClass", tInds);
|
||||||
|
|
||||||
|
|
|
@ -35,19 +35,8 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/browseIndex.css
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<#list individuals as individual>
|
<#list individuals as individual>
|
||||||
<li>
|
<li>
|
||||||
<a href="${individual.profileUrl}">${individual.name}</a>
|
<#include "listedIndividual.ftl">
|
||||||
<#-- <#if individual.moniker?has_content> <span class="moniker">${individual.moniker}</span></#if> -->
|
|
||||||
<#assign links = individual.links>
|
|
||||||
<#if links?has_content>
|
|
||||||
<ul class="individualData">
|
|
||||||
<@l.firstLastList>
|
|
||||||
<#list links as link>
|
|
||||||
<li><a class="externalLink" href="${link.url}">${link.anchor}</a></li>
|
|
||||||
</#list>
|
|
||||||
</@l.firstLastList>
|
|
||||||
</ul>
|
|
||||||
</#if>
|
|
||||||
</li>
|
</li>
|
||||||
</#list>
|
</#list>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Display of an individual in a list (/individuallist). -->
|
||||||
|
|
||||||
|
<a href="${individual.profileUrl}">${individual.name}</a>
|
Loading…
Add table
Add a link
Reference in a new issue