merging r10004 to the trunk

This commit is contained in:
tworrall 2012-08-07 19:54:50 +00:00
parent 71cdc0ae52
commit 4f56554901
2 changed files with 5 additions and 94 deletions

View file

@ -87,9 +87,6 @@ class IndividualResponseBuilder {
* into the data model: no real data can be modified.
*/
// body.put("individual", wrap(itm, BeansWrapper.EXPOSE_SAFE));
body.put("publicationCount", getPublicationCount(itm.getUri(), vreq));
body.put("grantCount", getGrantCount(itm.getUri(), vreq));
body.put("peopleCount", getPeopleCount(itm.getUri(), vreq));
body.put("labelCount", getLabelCount(itm.getUri(), vreq));
body.put("individual", wrap(itm, new ReadOnlyBeansWrapper()));
@ -249,30 +246,8 @@ class IndividualResponseBuilder {
+ " ?subject rdfs:label ?label \n"
+ " FILTER isLiteral(?label) \n"
+ "}" ;
private static String PUB_COUNT_QUERY = ""
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
+ "SELECT ( str(COUNT(?authorship)) AS ?authorshipCount ) WHERE { \n"
+ " ?subject core:authorInAuthorship ?authorship \n"
+ "}" ;
private static String GRANT_COUNT_QUERY = ""
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
+ "SELECT ( str(COUNT(?role)) AS ?roleCount ) WHERE { \n"
+ " { ?subject core:hasInvestigatorRole ?role } UNION \n"
+ " { ?subject core:hasPrincipalInvestigatorRole ?role } UNION \n"
+ " { ?subject core:hasCo-PrincipalInvestigatorRole ?role } UNION \n"
+ " { ?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);
log.debug("queryStr = " + queryStr);
int theCount = 0;
@ -288,56 +263,4 @@ class IndividualResponseBuilder {
}
return theCount;
}
private static Integer getPublicationCount(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(PUB_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("authorshipCount").toString();
theCount = Integer.parseInt(countStr);
}
} catch (Exception e) {
log.error(e, e);
}
return theCount;
}
private static Integer getGrantCount(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(GRANT_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("roleCount").toString();
theCount = Integer.parseInt(countStr);
}
} catch (Exception e) {
log.error(e, e);
}
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,34 +25,22 @@
</#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 && (pubCount > 0) >
<#if property.localName == "authorInAuthorship" && editable >
<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> >
<a id="managePubLink" 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 && (researchCount! > 0) >
<#elseif property.localName == "hasResearcherRole" && editable >
<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) >
<#elseif property.localName == "organizationForPosition" && editable >
<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