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 a32cb40e6..640bbb712 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 @@ -50,16 +50,15 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission; import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo; -import edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep; import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQuery; import edu.cornell.mannlib.vitro.webapp.search.beans.VitroQueryWrapper; import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper; import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory; import edu.cornell.mannlib.vitro.webapp.web.ContentType; import edu.cornell.mannlib.vitro.webapp.web.functions.IndividualLocalNameMethod; -import edu.cornell.mannlib.vitro.webapp.web.functions.IndividualProfileUrlMethod; import edu.cornell.mannlib.vitro.webapp.web.jsptags.StringProcessorTag; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel; import freemarker.ext.beans.BeansWrapper; /** @@ -165,7 +164,7 @@ public class IndividualController extends FreemarkerHttpServlet { if (relatedSubjectInd != null) { map = new HashMap(); map.put("name", relatedSubjectInd.getName()); - map.put("url", (new IndividualTemplateModel(relatedSubjectInd, vreq)).getProfileUrl()); + map.put("url", (new ListedIndividualTemplateModel(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 d5d692eca..95004b520 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 @@ -14,13 +14,13 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.controller.EntityListController; -import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.utils.StringUtils; -import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel; import freemarker.ext.beans.BeansWrapper; import freemarker.template.TemplateModel; @@ -82,9 +82,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 IndividualTemplateModel(ind,vreq)); + indsTm.add(new ListedIndividualTemplateModel(ind,vreq)); } body.put("individuals", indsTm); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/FreemarkerPagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/FreemarkerPagedSearchController.java index 508e13295..5e5f2c593 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/FreemarkerPagedSearchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/FreemarkerPagedSearchController.java @@ -74,7 +74,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.FlagMathUtils; import edu.cornell.mannlib.vitro.webapp.utils.Html2Text; import edu.cornell.mannlib.vitro.webapp.utils.StringUtils; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.LinkTemplateModel; -import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel; import freemarker.template.Configuration; /** @@ -334,7 +334,7 @@ public class FreemarkerPagedSearchController extends FreemarkerHttpServlet imple } // Convert search result individuals to template model objects - body.put("individuals", IndividualTemplateModel + body.put("individuals", ListedIndividualTemplateModel .getIndividualTemplateModelList(beans, vreq)); body.put("querytext", qtxt); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java index e28475a8f..e58499c7c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java @@ -155,9 +155,6 @@ public class PropertyEditLinks extends TagSupport{ if (data == null) { // link to add a new value links = doObjProp( subjectUri, predicateUri, policyToAccess(ids, policy, subjectUri, predicateUri), contextPath ); } else { // links to edit or delete an existing value - // RY **** May need new policyToAccess which gets the specific obj prop statement using the data as well as subject and predicate - // This is NOT the correct object property statement - we need the link individual uri in data, instead of the link URL - // Then we can combine this with doObjPropStmt ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(subjectUri, predicateUri, data); links = doObjPropStmt( prop, policyToAccess(ids, policy, prop), contextPath ); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java index 68edc5e08..303f5147c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java @@ -32,13 +32,6 @@ public class IndividualTemplateModel extends BaseTemplateModel { protected GroupedPropertyList propertyList = null; protected LoginStatusBean loginStatusBean = null; private EditingPolicyHelper policyHelper = null; - - public IndividualTemplateModel(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.getPortal()); - } public IndividualTemplateModel(Individual individual, VitroRequest vreq, LoginStatusBean loginStatusBean) { this.individual = individual; @@ -114,19 +107,6 @@ public class IndividualTemplateModel extends BaseTemplateModel { return individual.isVClass("http://xmlns.com/foaf/0.1/Organization"); } - public String getSearchView() { - return getView(ClassView.SEARCH); - } - - public String getDisplayView() { - return getView(ClassView.DISPLAY); - } - - private String getView(ClassView view) { - ViewFinder vf = new ViewFinder(view); - return vf.findClassView(individual, vreq); - } - public Link getPrimaryLink() { Link primaryLink = null; String anchor = individual.getAnchor(); @@ -139,8 +119,12 @@ public class IndividualTemplateModel extends BaseTemplateModel { return primaryLink; } + public List getAdditionalLinks() { + return individual.getLinksList(); + } + public List getLinks() { - List additionalLinks = individual.getLinksList(); + List additionalLinks = getAdditionalLinks(); List links = new ArrayList(additionalLinks.size()+1); Link primaryLink = getPrimaryLink(); if (primaryLink != null) { @@ -150,14 +134,6 @@ public class IndividualTemplateModel extends BaseTemplateModel { return links; } - public static List getIndividualTemplateModelList(List individuals, VitroRequest vreq) { - List models = new ArrayList(individuals.size()); - for (Individual individual : individuals) { - models.add(new IndividualTemplateModel(individual, vreq)); - } - return models; - } - public GroupedPropertyList getPropertyList() { if (propertyList == null) { propertyList = new GroupedPropertyList(individual, vreq, policyHelper); 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 new file mode 100644 index 000000000..fdfb9025d --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ListedIndividualTemplateModel.java @@ -0,0 +1,104 @@ +/* $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.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); + + private static final String PATH = Route.INDIVIDUAL.path(); + + protected Individual individual; + protected VitroRequest vreq; + protected UrlBuilder urlBuilder; + + + 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.getPortal()); + } + + public static List getIndividualTemplateModelList(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 Link getPrimaryLink() { + Link primaryLink = null; + String anchor = individual.getAnchor(); + String url = individual.getUrl(); + if (anchor != null && url != null) { + primaryLink = new Link(); + primaryLink.setAnchor(individual.getAnchor()); + primaryLink.setUrl(individual.getUrl()); + } + return primaryLink; + } + + public List getAdditionalLinks() { + return individual.getLinksList(); + } + + public List getLinks() { + List additionalLinks = getAdditionalLinks(); + List links = new ArrayList(additionalLinks.size()+1); + Link primaryLink = getPrimaryLink(); + if (primaryLink != null) { + links.add(primaryLink); + } + links.addAll(additionalLinks); + return links; + } + + public String getName() { + return individual.getName(); + } + + public String getMoniker() { + return individual.getMoniker(); + } + + public String getUri() { + return individual.getURI(); + } + + public String getSearchView() { + return getView(ClassView.SEARCH); + } + + public String getDisplayView() { + return getView(ClassView.DISPLAY); + } + + private String getView(ClassView view) { + ViewFinder vf = new ViewFinder(view); + return vf.findClassView(individual, vreq); + } + +} 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 1ba9cbdd4..fed238260 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 @@ -21,7 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; 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.VClassTemplateModel; -import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel; import freemarker.core.Environment; import freemarker.template.TemplateModelException; @@ -125,9 +125,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 IndividualTemplateModel(ind, vreq)); + tInds.add(new ListedIndividualTemplateModel(ind, vreq)); } map.put("individualsInClass", tInds); diff --git a/webapp/web/edit/editDatapropStmtRequestDispatch.jsp b/webapp/web/edit/editDatapropStmtRequestDispatch.jsp index ca1db6949..55c9d695c 100644 --- a/webapp/web/edit/editDatapropStmtRequestDispatch.jsp +++ b/webapp/web/edit/editDatapropStmtRequestDispatch.jsp @@ -61,6 +61,7 @@ String vitroNsProp = (String) vreq.getParameter("vitroNsProp"); boolean isVitroNsProp = false; + // On new Freemarker individual page, the editing link for rdfs:label doesn't get this url param attached if ( "true".equals(vitroNsProp) || predicateUri.equals(VitroVocabulary.LABEL) ) { isVitroNsProp = true; } diff --git a/webapp/web/templates/freemarker/body/individual/individual.ftl b/webapp/web/templates/freemarker/body/individual/individual.ftl index f1f502e2c..2425c4826 100644 --- a/webapp/web/templates/freemarker/body/individual/individual.ftl +++ b/webapp/web/templates/freemarker/body/individual/individual.ftl @@ -63,13 +63,7 @@ <#-- Links --> - + <#include "individual-links.ftl"> diff --git a/webapp/web/templates/freemarker/body/partials/individual/individual-links.ftl b/webapp/web/templates/freemarker/body/partials/individual/individual-links.ftl new file mode 100644 index 000000000..d29d6b508 --- /dev/null +++ b/webapp/web/templates/freemarker/body/partials/individual/individual-links.ftl @@ -0,0 +1,15 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Template for links on individual profile + + Currently the page displays the vitro namespace links properties. Future versions + will use the vivo core ontology links property, eliminating the need for special handling. +--> + + \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl b/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl index e9829530b..f6a00d158 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl @@ -76,4 +76,6 @@ we need to also show the property label. --> <#if url?has_content> delete - \ No newline at end of file + + +<#-- Macros for specific properties --> \ No newline at end of file