From 4f56554901bd2dc5127641c7b127571e05e50a91 Mon Sep 17 00:00:00 2001 From: tworrall Date: Tue, 7 Aug 2012 19:54:50 +0000 Subject: [PATCH] merging r10004 to the trunk --- .../individual/IndividualResponseBuilder.java | 79 +------------------ .../individual/individual-properties.ftl | 20 +---- 2 files changed, 5 insertions(+), 94 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java index bfcd0c7a3..7e5855582 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java @@ -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: \n" - + "SELECT ( str(COUNT(?authorship)) AS ?authorshipCount ) WHERE { \n" - + " ?subject core:authorInAuthorship ?authorship \n" - + "}" ; - - private static String GRANT_COUNT_QUERY = "" - + "PREFIX 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: \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; - } } diff --git a/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl b/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl index e31d92f22..dd48a75ca 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/individual-properties.ftl @@ -25,34 +25,22 @@ <#-- List the properties in the group --> - <#assign pubCount = 0 > - <#assign researchCount = 0 > - <#assign peepsCount = 0 > - <#if publicationCount?? > - <#assign pubCount = publicationCount > - - <#if grantCount?? > - <#assign researchCount = grantCount > - - <#if peopleCount?? > - <#assign peepsCount = peopleCount > - <#list group.properties as property>
<#-- Property display name --> - <#if property.localName == "authorInAuthorship" && editable && (pubCount > 0) > + <#if property.localName == "authorInAuthorship" && editable >

${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> - style="padding-top:10px" > + style="padding-top:10px" > manage publications

- <#elseif property.localName == "hasResearcherRole" && editable && (researchCount! > 0) > + <#elseif property.localName == "hasResearcherRole" && editable >

${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> style="padding-top:10px" > manage grants & projects

- <#elseif property.localName == "organizationForPosition" && editable && (peepsCount! > 0) > + <#elseif property.localName == "organizationForPosition" && editable >

${property.name} <@p.addLink property editable /> <@p.verboseDisplay property /> style="padding-top:10px" > manage affiliated people