NIHVIVO-294 Corrections to custom short view for missing role, missing start date. Merge from /branches/rel-1.0-maint

This commit is contained in:
rjy7 2010-04-07 20:57:35 +00:00
parent 9b1429db43
commit 967c53284d

View file

@ -6,11 +6,10 @@
PREDICATE - predicateUri PREDICATE - predicateUri
OBJECT - individual OBJECT - individual
Predicates: on Person page: Person professionalServiceActivity ServiceActivity
--%> --%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.DisplayUtils" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
@ -29,16 +28,22 @@
predicateUri == teachingActivityUri || predicateUri == teachingActivityUri ||
predicateUri == serviceActivityUri || predicateUri == serviceActivityUri ||
predicateUri == outreachActivityUri}" /> predicateUri == outreachActivityUri}" />
<c:choose> <c:choose>
<c:when test="${!empty individual}"><%-- individual is the OBJECT of the property referenced - in this case, the Activity object --%> <c:when test="${!empty individual}"><%-- individual is the OBJECT of the property referenced - in this case, the Activity object --%>
<c:choose> <c:choose>
<c:when test="${!empty predicateUri}"> <c:when test="${!empty predicateUri}">
<%-- RY may need another branch in here; predicateIsActivity vs predicate is something else...
depends if this would display on something other than a person page. --%>
<c:set var="activity" value="${individual}" />
<c:set var="activity" value="${individual}" />
<%-- Get the Activity label --%> <%-- Get the Activity label --%>
<c:set var="activityLabel" value=" ${activity.name}"/> <c:set var="activityLabel" value=" ${activity.name}"/>
<%-- Create an html link element to the activity --%>
<c:url var="activityUrl" value="/individual"><c:param name="uri" value="${activity.URI}"/></c:url>
<c:set var="activityLink" ><a href='${activityUrl}'><p:process>${activityLabel}</p:process></a></c:set>
<c:if test="${!empty activityLink}" >
<c:set var="activityLink" value="<strong>${activityLink}</strong> " />
</c:if>
<%-- Get the role of the person in the activity --%> <%-- Get the role of the person in the activity --%>
<c:set var="role" value="${activity.dataPropertyMap['http://vivoweb.org/ontology/core#role'].dataPropertyStatements[0].data}"/> <c:set var="role" value="${activity.dataPropertyMap['http://vivoweb.org/ontology/core#role'].dataPropertyStatements[0].data}"/>
@ -46,28 +51,36 @@
<%-- Get the time span of the service activity --%> <%-- Get the time span of the service activity --%>
<c:set var="startYearMonth" value="${activity.dataPropertyMap['http://vivoweb.org/ontology/core#startYearMonth'].dataPropertyStatements[0].data}"/> <c:set var="startYearMonth" value="${activity.dataPropertyMap['http://vivoweb.org/ontology/core#startYearMonth'].dataPropertyStatements[0].data}"/>
<c:set var="endYearMonth" value="${activity.dataPropertyMap['http://vivoweb.org/ontology/core#endYearMonth'].dataPropertyStatements[0].data}"/> <c:set var="endYearMonth" value="${activity.dataPropertyMap['http://vivoweb.org/ontology/core#endYearMonth'].dataPropertyStatements[0].data}"/>
<c:set var="timeSpan" value="" />
<c:if test="${!empty startYearMonth || !empty endYearMonth}" >
<c:if test="${!empty startYearMonth}" > <c:if test="${!empty startYearMonth}" >
<%-- RY Don't know whether we should display just the year, or month and year.
Latter looks like too much info, but why collect it if we aren't going to display it?
Needs reformatting, otherwise we get e.g., "2008-10 - 2009-12"
<c:set var="startDate" value="${fn:substring(startYearMonth, 0, 4)}" /> --%>
<c:set var="start" value="${fn:split(startYearMonth, '-')}" /> <c:set var="start" value="${fn:split(startYearMonth, '-')}" />
<c:set var="startDate" value="${start[1]}/${start[0]}" /> <c:set var="startDate" value="${start[1]}/${start[0]}" />
<c:set var="timeSpan" value=", ${startDate} - "/> <c:set var="timeSpan" value="${startDate}" />
</c:if>
<c:set var="timeSpan" value="${timeSpan} - " />
<c:if test="${!empty endYearMonth}"> <c:if test="${!empty endYearMonth}">
<%-- <c:set var="endDate" value="${fn:substring(endYearMonth, 0, 4)}" /> --%>
<c:set var="end" value="${fn:split(endYearMonth, '-')}" /> <c:set var="end" value="${fn:split(endYearMonth, '-')}" />
<c:set var="endDate" value="${end[1]}/${end[0]}" /> <c:set var="endDate" value="${end[1]}/${end[0]}" />
<c:set var="timeSpan" value="${timeSpan}${endDate}" /> <c:set var="timeSpan" value="${timeSpan}${endDate}" />
</c:if> </c:if>
</c:if> </c:if>
<%-- Create an html link element to the activity --%> <%-- Construct the final output --%>
<c:url var="activityUrl" value="/individual"><c:param name="uri" value="${activity.URI}"/></c:url> <p:process>${activityLink} </p:process>
<c:set var="activityLink" ><a href='${activityUrl}'><p:process>${activityLabel}</p:process></a></c:set>
<%-- Final output --%> <%-- We need a join but we have to keep getting variables in and out of JSTL/EL/Java. Do this for now even though it's ugly. --%>
<strong>${activityLink}</strong> <p:process>${role} ${timeSpan}</p:process> <c:choose>
<c:when test="${!empty role && !empty timeSpan}">
<p:process>${role}, ${timeSpan}</p:process>
</c:when>
<c:when test="${!empty role}">
<p:process>${role}</p:process>
</c:when>
<c:when test="${!empty timeSpan}">
<p:process>${timeSpan}</p:process>
</c:when>
</c:choose>
</c:when> </c:when>
<c:otherwise> <%-- no predicate --%> <c:otherwise> <%-- no predicate --%>