NIHVIVO-1491 Display of overview and research areas on person profile page

This commit is contained in:
rjy7 2011-01-03 22:34:17 +00:00
parent fb7e71ab9d
commit 675adfab19
9 changed files with 102 additions and 66 deletions

View file

@ -325,6 +325,12 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
return map;
}
protected Map<String, Object> getMethods() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", new edu.cornell.mannlib.vitro.webapp.web.functions.IndividualProfileUrlMethod());
return map;
}
// Add variables that should be available only to the page's root map, not to the body.
// RY This is protected instead of private so FreeMarkerComponentGenerator can access.
// Once we don't need that (i.e., jsps have been eliminated) we can make it private.
@ -356,6 +362,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
map.put("currentPage", vreq.getServletPath().replaceFirst("/", ""));
map.putAll(getDirectives());
map.putAll(getMethods());
map.put("tabMenu", getTabMenu(vreq));
map.put("menu", getDisplayModelMenu(vreq));

View file

@ -128,8 +128,7 @@ public class IndividualController extends FreemarkerHttpServlet {
* into the data model: no real data can be modified.
*/
body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(ind));
body.put("url", new IndividualProfileUrlMethod());
body.put("localName", new IndividualLocalNameMethod());
String template = getIndividualTemplate(individual);

View file

@ -63,5 +63,11 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
public List<DataPropertyStatementTemplateModel> getStatements() {
return statements;
}
// Allows the template to display a data value for a single property, when there is expected to be
// only a single value for the property.
public String getValue() {
return statements.get(0).getValue();
}
}

View file

@ -30,7 +30,11 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
/*
public class GroupedPropertyList extends ArrayList<PropertyGroupTemplateModel> {
If this class extends a List type, Freemarker does not let the templates call methods
on it.
on it. Since the class must then contain a list rather than be a list, the template
syntax is less idiomatic: e.g., groups.all rather than simply groups. An alternative
is to make the get methods (getProperty and getPropertyAndRemoveFromList) methods
of the IndividualTemplateModel. Then this class doesn't need methods, and can extend
a List type.
*/
public class GroupedPropertyList extends BaseTemplateModel {
@ -385,43 +389,35 @@ public class GroupedPropertyList extends BaseTemplateModel {
}
public PropertyTemplateModel getProperty(String propertyUri) {
PropertyTemplateModel propertyTemplateModel = null;
groupLoop: for (PropertyGroupTemplateModel pgtm : groups) {
for (PropertyGroupTemplateModel pgtm : groups) {
List<PropertyTemplateModel> properties = pgtm.getProperties();
for (PropertyTemplateModel ptm : properties) {
if (propertyUri.equals(ptm.getUri())) {
propertyTemplateModel = ptm;
break groupLoop;
return ptm;
}
}
}
return propertyTemplateModel;
}
return null;
}
public PropertyTemplateModel getPropertyAndRemoveFromList(String propertyUri) {
PropertyTemplateModel propertyTemplateModel = null;
groupLoop: for (PropertyGroupTemplateModel pgtm : groups) {
for (PropertyGroupTemplateModel pgtm : groups) {
List<PropertyTemplateModel> properties = pgtm.getProperties();
for (PropertyTemplateModel ptm : properties) {
if (propertyUri.equals(ptm.getUri())) {
propertyTemplateModel = ptm;
if (propertyUri.equals(ptm.getUri())) {
// Remove the property from the group
properties.remove(ptm);
// If this is the only property in the group, remove the group as well
if (properties.size() == 0) {
groups.remove(pgtm);
groups.remove(pgtm);
}
break groupLoop;
return ptm;
}
}
}
return propertyTemplateModel;
}
return null;
}
}

View file

@ -31,6 +31,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
protected Individual individual;
protected VitroRequest vreq;
protected UrlBuilder urlBuilder;
protected GroupedPropertyList propertyList = null;
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
this.individual = individual;
@ -123,7 +124,10 @@ public class IndividualTemplateModel extends BaseTemplateModel {
}
public GroupedPropertyList getPropertyList() {
return new GroupedPropertyList(individual, vreq);
if (propertyList == null) {
propertyList = new GroupedPropertyList(individual, vreq);
}
return propertyList;
}
/* These methods simply forward to the methods of the wrapped individual. It would be desirable to