NIHVIVO-1491 Display of overview and research areas on person profile page
This commit is contained in:
parent
fb7e71ab9d
commit
675adfab19
9 changed files with 102 additions and 66 deletions
|
@ -325,6 +325,12 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
return map;
|
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.
|
// 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.
|
// 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.
|
// 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.put("currentPage", vreq.getServletPath().replaceFirst("/", ""));
|
||||||
|
|
||||||
map.putAll(getDirectives());
|
map.putAll(getDirectives());
|
||||||
|
map.putAll(getMethods());
|
||||||
|
|
||||||
map.put("tabMenu", getTabMenu(vreq));
|
map.put("tabMenu", getTabMenu(vreq));
|
||||||
map.put("menu", getDisplayModelMenu(vreq));
|
map.put("menu", getDisplayModelMenu(vreq));
|
||||||
|
|
|
@ -128,8 +128,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
||||||
* into the data model: no real data can be modified.
|
* into the data model: no real data can be modified.
|
||||||
*/
|
*/
|
||||||
body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(ind));
|
body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(ind));
|
||||||
|
|
||||||
body.put("url", new IndividualProfileUrlMethod());
|
|
||||||
body.put("localName", new IndividualLocalNameMethod());
|
body.put("localName", new IndividualLocalNameMethod());
|
||||||
|
|
||||||
String template = getIndividualTemplate(individual);
|
String template = getIndividualTemplate(individual);
|
||||||
|
|
|
@ -63,5 +63,11 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
public List<DataPropertyStatementTemplateModel> getStatements() {
|
public List<DataPropertyStatementTemplateModel> getStatements() {
|
||||||
return statements;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
/*
|
/*
|
||||||
public class GroupedPropertyList extends ArrayList<PropertyGroupTemplateModel> {
|
public class GroupedPropertyList extends ArrayList<PropertyGroupTemplateModel> {
|
||||||
If this class extends a List type, Freemarker does not let the templates call methods
|
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 {
|
public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
|
|
||||||
|
@ -385,43 +389,35 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyTemplateModel getProperty(String propertyUri) {
|
public PropertyTemplateModel getProperty(String propertyUri) {
|
||||||
|
|
||||||
PropertyTemplateModel propertyTemplateModel = null;
|
for (PropertyGroupTemplateModel pgtm : groups) {
|
||||||
|
|
||||||
groupLoop: for (PropertyGroupTemplateModel pgtm : groups) {
|
|
||||||
List<PropertyTemplateModel> properties = pgtm.getProperties();
|
List<PropertyTemplateModel> properties = pgtm.getProperties();
|
||||||
for (PropertyTemplateModel ptm : properties) {
|
for (PropertyTemplateModel ptm : properties) {
|
||||||
if (propertyUri.equals(ptm.getUri())) {
|
if (propertyUri.equals(ptm.getUri())) {
|
||||||
propertyTemplateModel = ptm;
|
return ptm;
|
||||||
break groupLoop;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return propertyTemplateModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyTemplateModel getPropertyAndRemoveFromList(String propertyUri) {
|
public PropertyTemplateModel getPropertyAndRemoveFromList(String propertyUri) {
|
||||||
|
|
||||||
PropertyTemplateModel propertyTemplateModel = null;
|
for (PropertyGroupTemplateModel pgtm : groups) {
|
||||||
|
|
||||||
groupLoop: for (PropertyGroupTemplateModel pgtm : groups) {
|
|
||||||
List<PropertyTemplateModel> properties = pgtm.getProperties();
|
List<PropertyTemplateModel> properties = pgtm.getProperties();
|
||||||
for (PropertyTemplateModel ptm : properties) {
|
for (PropertyTemplateModel ptm : properties) {
|
||||||
if (propertyUri.equals(ptm.getUri())) {
|
if (propertyUri.equals(ptm.getUri())) {
|
||||||
propertyTemplateModel = ptm;
|
|
||||||
// Remove the property from the group
|
// Remove the property from the group
|
||||||
properties.remove(ptm);
|
properties.remove(ptm);
|
||||||
// If this is the only property in the group, remove the group as well
|
// If this is the only property in the group, remove the group as well
|
||||||
if (properties.size() == 0) {
|
if (properties.size() == 0) {
|
||||||
groups.remove(pgtm);
|
groups.remove(pgtm);
|
||||||
}
|
}
|
||||||
break groupLoop;
|
return ptm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return propertyTemplateModel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
protected Individual individual;
|
protected Individual individual;
|
||||||
protected VitroRequest vreq;
|
protected VitroRequest vreq;
|
||||||
protected UrlBuilder urlBuilder;
|
protected UrlBuilder urlBuilder;
|
||||||
|
protected GroupedPropertyList propertyList = null;
|
||||||
|
|
||||||
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
public IndividualTemplateModel(Individual individual, VitroRequest vreq) {
|
||||||
this.individual = individual;
|
this.individual = individual;
|
||||||
|
@ -123,7 +124,10 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupedPropertyList getPropertyList() {
|
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
|
/* These methods simply forward to the methods of the wrapped individual. It would be desirable to
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
|
|
||||||
<#-- Template for individual profile page -->
|
<#-- Template for individual profile page -->
|
||||||
|
|
||||||
|
<#-- RY This is actually the person profile page, but we cannot move it to its proper location until selection of template by
|
||||||
|
annotaiton has been implemented. -->
|
||||||
|
|
||||||
<#import "lib-list.ftl" as l>
|
<#import "lib-list.ftl" as l>
|
||||||
|
<#import "lib-properties.ftl" as p>
|
||||||
|
|
||||||
<#assign editingClass>
|
<#assign editingClass>
|
||||||
<#if editStatus.showEditLinks>editing<#else></#if>
|
<#if editStatus.showEditLinks>editing<#else></#if>
|
||||||
|
@ -70,15 +74,22 @@
|
||||||
</ul>
|
</ul>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<p class="individual-overview">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed est erat, tristique non bibendum eu, mollis non est. Cras vehicula velit quis elit porta vel molestie tellus blandit. Donec eget magna dolor. Phasellus faucibus mollis lorem at dapibus. Sed ultricies lobortis mauris in volutpat. Cras mattis neque ut sapien pellentesque fringilla. Mauris posuere dui quis massa mattis id mollis nibh accumsan. [+]</p>
|
<#-- Overview -->
|
||||||
|
<#assign overview = propertyGroups.getPropertyAndRemoveFromList("http://vivoweb.org/ontology/core#overview")>
|
||||||
|
<#if overview?has_content>
|
||||||
|
<p class="individual-overview">${overview.value}</p>
|
||||||
|
</#if>
|
||||||
|
|
||||||
<h2>Research Areas</h2>
|
<#-- Research Areas -->
|
||||||
|
<#assign researchAreas = propertyGroups.getPropertyAndRemoveFromList("http://vivoweb.org/ontology/core#hasResearchArea")>
|
||||||
<ul id ="individual-areas" role="list">
|
<#if researchAreas?has_content>
|
||||||
<li role="listitem"><a href="#">Researcher (5)</a></li>
|
<h2>Research Areas</h2>
|
||||||
<li role="listitem"><a href="#">Principal Investigator (3)</a></li>
|
|
||||||
<li role="listitem"><a href="#">Teacher (2)</a></li>
|
<ul id="individual-areas" role="list">
|
||||||
</ul>
|
<@p.objectProperty researchAreas />
|
||||||
|
</ul>
|
||||||
|
</#if>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
<#-- Template for property listing on individual profile page -->
|
<#-- Template for property listing on individual profile page -->
|
||||||
|
|
||||||
|
<#import "lib-properties.ftl" as p>
|
||||||
|
|
||||||
<#list propertyGroups.all as group>
|
<#list propertyGroups.all as group>
|
||||||
|
|
||||||
<#assign groupname = group.name(nameForOtherGroup)>
|
<#assign groupname = group.name(nameForOtherGroup)>
|
||||||
|
@ -28,13 +30,13 @@
|
||||||
<ul class="property-list" role="list">
|
<ul class="property-list" role="list">
|
||||||
<#-- data property -->
|
<#-- data property -->
|
||||||
<#if property.type == "data">
|
<#if property.type == "data">
|
||||||
<@dataPropertyList property.statements />
|
<@p.dataPropertyList property.statements />
|
||||||
|
|
||||||
<#-- object property -->
|
<#-- object property -->
|
||||||
<#elseif property.collatedBySubclass> <#-- collated -->
|
<#elseif property.collatedBySubclass> <#-- collated -->
|
||||||
<@collatedObjectPropertyList property />
|
<@p.collatedObjectPropertyList property />
|
||||||
<#else> <#-- uncollated -->
|
<#else> <#-- uncollated -->
|
||||||
<@objectPropertyList property.statements property.template />
|
<@p.objectPropertyList property.statements property.template />
|
||||||
</#if>
|
</#if>
|
||||||
</ul>
|
</ul>
|
||||||
</article> <!-- end property -->
|
</article> <!-- end property -->
|
||||||
|
@ -42,34 +44,3 @@
|
||||||
</section> <!-- end property-group -->
|
</section> <!-- end property-group -->
|
||||||
</#list>
|
</#list>
|
||||||
|
|
||||||
<#-----------------------------------------------------------------------------
|
|
||||||
Macros for generating property lists
|
|
||||||
------------------------------------------------------------------------------>
|
|
||||||
|
|
||||||
<#macro dataPropertyList statements>
|
|
||||||
<#list statements as statement>
|
|
||||||
<@propertyListItem>${statement.value}</@propertyListItem>
|
|
||||||
</#list>
|
|
||||||
</#macro>
|
|
||||||
|
|
||||||
<#macro collatedObjectPropertyList property>
|
|
||||||
<#assign subclasses = property.subclasses>
|
|
||||||
<#list subclasses?keys as subclass>
|
|
||||||
<li class="subclass">
|
|
||||||
<h3>${subclass?lower_case}</h3>
|
|
||||||
<ul class="subclass-property-list">
|
|
||||||
<@objectPropertyList subclasses[subclass] property.template />
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</#list>
|
|
||||||
</#macro>
|
|
||||||
|
|
||||||
<#macro objectPropertyList statements template>
|
|
||||||
<#list statements as statement>
|
|
||||||
<@propertyListItem><#include "${template}"></@propertyListItem>
|
|
||||||
</#list>
|
|
||||||
</#macro>
|
|
||||||
|
|
||||||
<#macro propertyListItem>
|
|
||||||
<li role="listitem"><#nested></li>
|
|
||||||
</#macro>
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-----------------------------------------------------------------------------
|
||||||
|
Macros for generating property lists
|
||||||
|
------------------------------------------------------------------------------>
|
||||||
|
|
||||||
|
<#macro dataPropertyList statements>
|
||||||
|
<#list statements as statement>
|
||||||
|
<@propertyListItem>${statement.value}</@propertyListItem>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro collatedObjectPropertyList property>
|
||||||
|
<#assign subclasses = property.subclasses>
|
||||||
|
<#list subclasses?keys as subclass>
|
||||||
|
<li class="subclass">
|
||||||
|
<h3>${subclass?lower_case}</h3>
|
||||||
|
<ul class="subclass-property-list">
|
||||||
|
<@objectPropertyList subclasses[subclass] property.template />
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro objectProperty property>
|
||||||
|
<@objectPropertyList property.statements "propStatement-simple.ftl" />
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro objectPropertyList statements template>
|
||||||
|
<#list statements as statement>
|
||||||
|
<@propertyListItem><#include "${template}"></@propertyListItem>
|
||||||
|
</#list>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro propertyListItem>
|
||||||
|
<li role="listitem"><#nested></li>
|
||||||
|
</#macro>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||||
|
|
||||||
|
<#-- Simple object property statement template -->
|
||||||
|
|
||||||
|
<a href="${url(statement.object)}">${statement.name!}</a>
|
Loading…
Add table
Add a link
Reference in a new issue