diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java index d8385f854..65a008a26 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java @@ -12,7 +12,6 @@ import java.util.regex.Pattern; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; 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.web.ContentType; 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; /** @@ -227,7 +226,8 @@ public class IndividualController extends FreemarkerHttpServlet { if (relatedSubjectInd != null) { map = new HashMap(); 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"); if (relatingPredicateUri != null) { ObjectProperty relatingPredicateProp = opDao.getObjectPropertyByURI(relatingPredicateUri); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java index 6e229ef7f..6509575c2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java @@ -27,9 +27,13 @@ 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 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.IndividualImpl; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; 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.dao.IndividualDao; 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.LuceneIndexFactory; 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.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 @@ -109,9 +109,9 @@ public class IndividualListController extends FreemarkerHttpServlet { body.putAll(map); List inds = (List)map.get("entities"); - List indsTm = new ArrayList(); + List indsTm = new ArrayList(); for(Individual ind : inds ){ - indsTm.add(new ListedIndividualTemplateModel(ind,vreq)); + indsTm.add(new ListedIndividual(ind,vreq)); } body.put("individuals", indsTm); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SolrIndividualListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SolrIndividualListController.java index bf095ca43..c2d7bae6f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SolrIndividualListController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SolrIndividualListController.java @@ -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.search.VitroSearchTermNames; 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.template.TemplateModel; @@ -95,9 +96,9 @@ public class SolrIndividualListController extends FreemarkerHttpServlet { @SuppressWarnings("unchecked") List inds = (List)map.get("entities"); - List indsTm = new ArrayList(); + List indsTm = new ArrayList(); for ( Individual ind : inds ) { - indsTm.add(new ListedIndividualTemplateModel(ind,vreq)); + indsTm.add(new ListedIndividual(ind,vreq)); } body.put("individuals", indsTm); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java index 81bcc110e..77b4ab612 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java @@ -271,37 +271,18 @@ public class UrlBuilder { public static String getPath(Route route, ParamMap 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) { Individual individual = new IndividualImpl(individualUri); 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) { - WebappDaoFactory wadf = vreq.getWebappDaoFactory(); - String profileUrl = getIndividualProfileUrl(individual, individualUri, wadf); - if(profileUrl != null) { - HashMap 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) { + WebappDaoFactory wadf = vreq.getWebappDaoFactory(); String profileUrl = null; try { URI uri = new URIImpl(individualUri); // throws exception if individualUri is invalid @@ -324,10 +305,18 @@ public class UrlBuilder { } catch (Exception e) { log.warn(e); return null; - } - return profileUrl; + } + + if (profileUrl != null) { + HashMap specialParams = getSpecialParams(vreq); + if(specialParams.size() != 0) { + profileUrl = addParams(profileUrl, new ParamMap(specialParams)); + } + } + + return profileUrl; } - + public static boolean isUriInDefaultNamespace(String individualUri, VitroRequest vreq) { return isUriInDefaultNamespace(individualUri, vreq.getWebappDaoFactory()); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java index 0f904f00a..2a77c8b6a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java @@ -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.LuceneIndexFactory; 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; /** @@ -357,7 +357,7 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear } // Convert search result individuals to template model objects - body.put("individuals", ListedIndividualTemplateModel + body.put("individuals", BaseListedIndividual .getIndividualTemplateModels(beans, vreq)); body.put("querytext", qtxt); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SolrPagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SolrPagedSearchController.java index 6ca136107..ba6cac08e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SolrPagedSearchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/SolrPagedSearchController.java @@ -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.web.templatemodels.LinkTemplateModel; 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; /** diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/BrowseDataGetter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/BrowseDataGetter.java index 05483aa1a..1282e0c0d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/BrowseDataGetter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/BrowseDataGetter.java @@ -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.web.templatemodels.VClassGroupTemplateModel; 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 { final static Log log = LogFactory.getLog(BrowseDataGetter.class); @@ -145,9 +146,9 @@ public class BrowseDataGetter implements PageDataGetter { List inds = vreq.getWebappDaoFactory().getIndividualDao() .getIndividualsByVClass(vclass); - List tInds = new ArrayList(inds.size()); + List tInds = new ArrayList(inds.size()); for( Individual ind : inds){ - tInds.add(new ListedIndividualTemplateModel(ind, vreq)); + tInds.add(new ListedIndividual(ind, vreq)); } map.put("individualsInClass", tInds); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java index 0b0256b5d..164a067b9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java @@ -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.jena.VClassGroupCache; 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.template.TemplateModel; @@ -239,7 +239,7 @@ public class DataGetterUtils { jo.put("name",ind.getName()); jo.put("thumbUrl", ind.getThumbUrl()); 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); jo.put("moniker", moniker); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java index 877b0a7e2..a76908e54 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java @@ -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.jena.VClassGroupCache; 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 freemarker.ext.beans.BeansWrapper; import freemarker.template.TemplateModel; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java index d68f8c7eb..f47c708db 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java @@ -2,11 +2,7 @@ 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.Map; import org.apache.commons.logging.Log; 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 */ 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 diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseListedIndividual.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseListedIndividual.java new file mode 100644 index 000000000..43bfea0b4 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseListedIndividual.java @@ -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 getIndividualTemplateModels(List individuals, VitroRequest vreq) { + List models = new ArrayList(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(); + } + + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualSearchResult.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualSearchResult.java index e076a8eb6..8b6e70772 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualSearchResult.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualSearchResult.java @@ -45,7 +45,7 @@ public class IndividualSearchResult extends BaseTemplateModel { /* Access methods for templates */ public String getProfileUrl() { - return UrlBuilder.getIndividualProfileUrl(individual, vreq.getWebappDaoFactory()); + return UrlBuilder.getIndividualProfileUrl(individual, vreq); } public String getName() { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividual.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividual.java new file mode 100644 index 000000000..e18225d26 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividual.java @@ -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 */ + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividualTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividualTemplateModel.java deleted file mode 100644 index 3cffb0307..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividualTemplateModel.java +++ /dev/null @@ -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 getIndividualTemplateModels(List individuals, VitroRequest vreq) { - List models = new ArrayList(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 getAdditionalLinks() { -// return individual.getLinksList(); // returns an empty list, but not null - return new ArrayList(); - } - - public List getLinks() { - List additionalLinks = getAdditionalLinks(); // returns an empty list, but not null - List links = new ArrayList(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(); - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/BrowseWidget.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/BrowseWidget.java index fc7506b25..052d13636 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/BrowseWidget.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/BrowseWidget.java @@ -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.web.templatemodels.VClassGroupTemplateModel; 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.template.TemplateModelException; @@ -161,9 +162,9 @@ public class BrowseWidget extends Widget { List inds = vreq.getWebappDaoFactory().getIndividualDao() .getIndividualsByVClass(vclass); - List tInds = new ArrayList(inds.size()); + List tInds = new ArrayList(inds.size()); for( Individual ind : inds){ - tInds.add(new ListedIndividualTemplateModel(ind, vreq)); + tInds.add(new ListedIndividual(ind, vreq)); } map.put("individualsInClass", tInds); diff --git a/webapp/web/templates/freemarker/body/individualList.ftl b/webapp/web/templates/freemarker/body/individualList.ftl index 31e72afb0..a0db63e6f 100644 --- a/webapp/web/templates/freemarker/body/individualList.ftl +++ b/webapp/web/templates/freemarker/body/individualList.ftl @@ -35,19 +35,8 @@ ${stylesheets.add('${individual.name} - <#-- <#if individual.moniker?has_content> ${individual.moniker} --> - <#assign links = individual.links> - <#if links?has_content> - - +
  • + <#include "listedIndividual.ftl">
  • diff --git a/webapp/web/templates/freemarker/body/partials/listedIndividual.ftl b/webapp/web/templates/freemarker/body/partials/listedIndividual.ftl new file mode 100644 index 000000000..bb294d383 --- /dev/null +++ b/webapp/web/templates/freemarker/body/partials/listedIndividual.ftl @@ -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). --> + +${individual.name} \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl b/webapp/web/templates/freemarker/lib/lib-properties.ftl similarity index 100% rename from webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl rename to webapp/web/templates/freemarker/lib/lib-properties.ftl