merging r9990 into the trunk

This commit is contained in:
tworrall 2012-08-01 14:07:08 +00:00
parent cadff5e548
commit 1b75b2a93f
3 changed files with 52 additions and 4 deletions

View file

@ -38,6 +38,7 @@ log4j.logger.edu.cornell.mannlib.vitro.webapp.startup.StartupStatus=WARN
log4j.logger.edu.cornell.mannlib.vitro.webapp.controller.freemarker.BrowseController=WARN
log4j.logger.edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener=WARN
log4j.logger.edu.cornell.mannlib.vitro.webapp.dao.jena.RDBGraphGenerator=WARN
log4j.logger.edu.cornell.mannlib.vitro.webapp.servlet.setup.UpdateKnowledgeBase=DEBUG
# Spring as a whole is too chatty to display INFO messages.
log4j.logger.org.springframework=WARN

View file

@ -87,9 +87,14 @@ class IndividualResponseBuilder {
* into the data model: no real data can be modified.
*/
// body.put("individual", wrap(itm, BeansWrapper.EXPOSE_SAFE));
if ( itm.person() ) {
body.put("publicationCount", getPublicationCount(itm.getUri(), vreq));
body.put("grantCount", getGrantCount(itm.getUri(), vreq));
}
if ( itm.organization() ) {
body.put("peopleCount", getPeopleCount(itm.getUri(), vreq));
}
body.put("labelCount", getLabelCount(itm.getUri(), vreq));
body.put("publicationCount", getPublicationCount(itm.getUri(), vreq));
body.put("grantCount", getGrantCount(itm.getUri(), vreq));
body.put("individual", wrap(itm, new ReadOnlyBeansWrapper()));
body.put("headContent", getRdfLinkTag(itm));
@ -264,6 +269,12 @@ class IndividualResponseBuilder {
+ " { ?subject core:hasResearcherRole ?role } \n"
+ "}" ;
private static String PEOPLE_COUNT_QUERY = ""
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
+ "SELECT ( str(COUNT(?position)) AS ?positionCount ) WHERE { \n"
+ " ?subject core:organizationForPosition ?position \n"
+ "}" ;
private static Integer getLabelCount(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(LABEL_COUNT_QUERY, "subject", subjectUri);
@ -315,4 +326,22 @@ class IndividualResponseBuilder {
}
return theCount;
}
private static Integer getPeopleCount(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(PEOPLE_COUNT_QUERY, "subject", subjectUri);
log.debug("queryStr = " + queryStr);
int theCount = 0;
try {
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
if (results.hasNext()) {
QuerySolution soln = results.nextSolution();
String countStr = soln.get("positionCount").toString();
theCount = Integer.parseInt(countStr);
}
} catch (Exception e) {
log.error(e, e);
}
return theCount;
}
}

View file

@ -25,21 +25,39 @@
</#if>
<#-- List the properties in the group -->
<#assign pubCount = 0 >
<#assign researchCount = 0 >
<#assign peepsCount = 0 >
<#if publicationCount?? >
<#assign pubCount = publicationCount >
</#if>
<#if grantCount?? >
<#assign researchCount = grantCount >
</#if>
<#if peopleCount?? >
<#assign peepsCount = peopleCount >
</#if>
<#list group.properties as property>
<article class="property" role="article">
<#-- Property display name -->
<#if property.localName == "authorInAuthorship" && editable && (publicationCount > 0) >
<#if property.localName == "authorInAuthorship" && editable && (pubCount > 0) >
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property />
<a id="managePropLink" class="manageLinks" href="${urls.base}/managePublications?subjectUri=${subjectUri[1]!}" title="manage publications" <#if verbose>style="padding-top:10px"</#if> >
manage publications
</a>
</h3>
<#elseif property.localName == "hasResearcherRole" && editable && (grantCount > 0) >
<#elseif property.localName == "hasResearcherRole" && editable && (researchCount! > 0) >
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property />
<a id="manageGrantLink" class="manageLinks" href="${urls.base}/manageGrants?subjectUri=${subjectUri[1]!}" title="manage grants & projects" <#if verbose>style="padding-top:10px"</#if> >
manage grants & projects
</a>
</h3>
<#elseif property.localName == "organizationForPosition" && editable && (peepsCount! > 0) >
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property />
<a id="managePeopleLink" class="manageLinks" href="${urls.base}/managePeople?subjectUri=${subjectUri[1]!}" title="manage people" <#if verbose>style="padding-top:10px"</#if> >
manage affiliated people
</a>
</h3>
<#else>
<h3 id="${property.localName}">${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> </h3>
</#if>