NIHVIVO-630 Use role name instead of the individual's moniker in role short view

This commit is contained in:
rjy7 2010-07-15 14:02:44 +00:00
parent 7f06f68af6
commit 7a2d09dce6
14 changed files with 12 additions and 335 deletions

View file

@ -335,7 +335,7 @@
<input type="hidden" id="roleActivityURI" name="roleActivity" class="acReceiver" value="" /> <!-- Field value populated by JavaScript -->
</div>
<p><v:input type="text" id="newIndLabel" name="roleLabel" label="Role Name ${requiredHint}" size="50" /></p>
<p><v:input type="text" id="newIndLabel" name="roleLabel" label="Role ${requiredHint}" size="50" /></p>
<h4>Dates of Participation</h4>
<v:input type="text" label="Start Year ${requiredHint} ${yearHint}" id="startYear" size="7"/>

View file

@ -1,310 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for research, teaching, service, and outreach activities --%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
<%@ page import="com.hp.hpl.jena.rdf.model.Model"%>
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.TitleCase" %>
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.StartDateBeforeEndDate"%>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
<%!
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.personHasActivity.jsp");
%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
request.setAttribute("gYearMonthDatatypeUriJson", MiscWebUtils.escape(XSD.gYearMonth.toString()));
%>
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
<c:set var="vitroNs" value="<%= VitroVocabulary.vitroURI %>" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="labelUri" value="${rdfs}label" />
<c:set var="researchActivityUri" value="${vivoCore}hasResearchActivity" />
<c:set var="teachingActivityUri" value="${vivoCore}hasTeachingActivity" />
<c:set var="serviceActivityUri" value="${vivoCore}hasProfessionalServiceActivity" />
<c:set var="outreachActivityUri" value="${vivoCore}hasOutreachActivity" />
<c:choose>
<c:when test="${predicateUri == researchActivityUri}">
<c:set var="inverseUri" value="${vivoCore}researchActivityBy" />
<c:set var="activityClass" value="${vivoCore}ResearchActivity" />
</c:when>
<c:when test="${predicateUri == teachingActivityUri}">
<c:set var="inverseUri" value="${vivoCore}teachingActivityBy" />
<c:set var="activityClass" value="${vivoCore}TeachingActivity" />
</c:when>
<c:when test="${predicateUri == serviceActivityUri}">
<c:set var="inverseUri" value="${vivoCore}professionalServiceActivityBy" />
<c:set var="activityClass" value="${vivoCore}ServiceActivity" />
</c:when>
<c:when test="${predicateUri == outreachActivityUri}">
<c:set var="inverseUri" value="${vivoCore}outreachActivityBy" />
<c:set var="activityClass" value="${vivoCore}OutreachActivity" />
</c:when>
</c:choose>
<c:set var="activitySuperClass" value="${vivoCore}Activity" />
<c:set var="superPropertyUri" value="${vivoCore}hasActivity" />
<c:set var="inverseSuperPropertyUri" value="${vivoCore}activityBy" />
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing"
to convey that the expression is used to retrieve any existing value for the field in an existing individual.
Each of these must then be referenced in the sparqlForExistingLiterals section of the JSON block below
and in the literalsOnForm --%>
<v:jsonset var="labelExisting" >
SELECT ?existingLabel WHERE {
?activityUri <${labelUri}> ?existingLabel }
</v:jsonset>
<%-- Pair the "existing" query with the skeleton of what will be asserted for a new statement involving this field.
The actual assertion inserted in the model will be created via string substitution into the ? variables.
NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
<v:jsonset var="labelAssertion" >
?activityUri <${labelUri}> ?label .
</v:jsonset>
<c:set var="descriptionUri" value="${vitroNs}description" />
<v:jsonset var="descriptionExisting" >
SELECT ?existingDescription WHERE {
?activityUri <${descriptionUri}> ?existingDescription }
</v:jsonset>
<v:jsonset var="descriptionAssertion" >
?activityUri <${descriptionUri}> ?description .
</v:jsonset>
<c:set var="roleUri" value="${vivoCore}role" />
<v:jsonset var="roleExisting" >
SELECT ?existingRole WHERE {
?activityUri <${roleUri}> ?existingRole }
</v:jsonset>
<v:jsonset var="roleAssertion" >
?activityUri <${roleUri}> ?role .
</v:jsonset>
<c:set var="startYearMonthUri" value="${vivoCore}startYearMonth" />
<v:jsonset var="startYearMonthExisting" >
SELECT ?existingStartYearMonth WHERE {
?activityUri <${startYearMonthUri}> ?existingStartYearMonth }
</v:jsonset>
<v:jsonset var="startYearMonthAssertion" >
?activityUri <${startYearMonthUri}> ?startYearMonth .
</v:jsonset>
<c:set var="endYearMonthUri" value="${vivoCore}endYearMonth" />
<v:jsonset var="endYearMonthExisting">
SELECT ?existingEndYearMonth WHERE {
?activityUri <${endYearMonthUri}> ?existingEndYearMonth }
</v:jsonset>
<v:jsonset var="endYearMonthAssertion" >
?activityUri <${endYearMonthUri}> ?endYearMonth .
</v:jsonset>
<v:jsonset var="n3ForStmtToPerson">
?activityUri <${labelUri}> ?label ;
a <${activityClass}> ;
a <${activitySuperClass}> ;
<${inverseUri}> ?person ;
<${inverseSuperPropertyUri}> ?person .
?person <${predicateUri}> ?activityUri ;
<${superPropertyUri}> ?activityUri .
</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/entity",
"subject" : ["person", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["activityUri", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForStmtToPerson}", "${labelAssertion}", "${descriptionAssertion}", "${roleAssertion}" ],
"n3optional" : [ "${startYearMonthAssertion}", "${endYearMonthAssertion}" ],
"newResources" : { "activityUri" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ ],
"literalsOnForm" : [ "label", "description", "role", "startYearMonth", "endYearMonth" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"label" : "${labelExisting}",
"description" : "${descriptionExisting}",
"role" : "${roleExisting}",
"startYearMonth" : "${startYearMonthExisting}",
"endYearMonth" : "${endYearMonthExisting}",
},
"sparqlForExistingUris" : { },
"fields" : {
"label" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${labelAssertion}" ]
},
"description" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${descriptionAssertion}" ]
},
"role" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${roleAssertion}" ]
},
"startYearMonth" : {
"newResource" : "false",
"validators" : [ "datatype:${gYearMonthDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${gYearMonthDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${startYearMonthAssertion}"]
},
"endYearMonth" : {
"newResource" : "false",
"validators" : [ "datatype:${gYearMonthDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${gYearMonthDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${endYearMonthAssertion}"]
}
}
}
</c:set>
<%
log.debug(request.getAttribute("editjson"));
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig,session);
}
editConfig.addValidator(new StartDateBeforeEndDate("startYearMonth","endYearMonth") );
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) { // editing existing
editConfig.prepareForObjPropUpdate(model);
} else { // adding new
editConfig.prepareForNonUpdate(model);
}
String subjectName = ((Individual) request.getAttribute("subject")).getName();
%>
<c:set var="subjectName" value="<%= subjectName %>" />
<c:choose>
<c:when test="${predicateUri == researchActivityUri}">
<c:set var="propertyName" value="research focus and activity" scope="request" />
</c:when>
<c:when test="${predicateUri == teachingActivityUri}">
<c:set var="propertyName" value="teaching focus and activity" scope="request" />
</c:when>
<c:when test="${predicateUri == serviceActivityUri}">
<c:set var="propertyName" value="professional service" scope="request" />
</c:when>
<c:when test="${predicateUri == outreachActivityUri}">
<c:set var="propertyName" value="outreach and community service" scope="request" />
</c:when>
</c:choose>
<%
// RY put propertyName in page context instead, and get a PageContext object
String propName = (String)request.getAttribute("propertyName");
vreq.setAttribute("submitPropertyName", TitleCase.toTitleCase(propName));
if (objectUri != null) { // editing existing entry
%>
<c:set var="title" value="Edit ${propertyName} entry for ${subjectName}" />
<c:set var="submitLabel" value="Save Changes" />
<%
} else { // adding new entry
%>
<c:set var="title" value="Create a new ${propertyName} entry for ${subjectName}" />
<c:set var="submitLabel" value="Create New ${submitPropertyName}" />
<% }
List<String> customCss = new ArrayList<String>(Arrays.asList("/edit/forms/css/customForm.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearMonthHint" value="<span class='hint'>(YYYY-MM)</span>" />
<jsp:include page="${preForm}"/>
<h2>${title}</h2>
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<v:input type="text" label="Activity Name ${requiredHint}" id="label" size="30" />
<v:input type="textarea" label="Description ${requiredHint}" id="description" rows="5" cols="20" />
<v:input type="text" label="Role ${requiredHint}" id="role" size="30" />
<v:input type="text" label="Start Year and Month ${yearMonthHint}" id="startYearMonth" size="7"/>
<v:input type="text" label="End Year and Month ${yearMonthHint}" id="endYearMonth" size="7"/>
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true"/></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<jsp:include page="${postForm}"/>

View file

@ -4,6 +4,4 @@
<jsp:param name="personToRolePredicate" value="http://vivoweb.org/ontology/core#hasClinicalRole"/>
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#clinicianRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="clinical role"/>
<jsp:param name="roleLabelForPerson" value="USE_MONIKER"/>
</jsp:include>

View file

@ -5,5 +5,5 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#co-PrincipalInvestigatorRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="grant"/>
<jsp:param name="roleLabelForPerson" value="co-principal investigator"/>
<jsp:param name="roleLabelForPerson" value="Co-Principal Investigator"/>
</jsp:include>

View file

@ -5,5 +5,5 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#principalInvestigatorRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="grant"/>
<jsp:param name="roleLabelForPerson" value="principal investigator"/>
<jsp:param name="roleLabelForPerson" value="Principal Investigator"/>
</jsp:include>

View file

@ -5,5 +5,5 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#investigatorRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="grant"/>
<jsp:param name="roleLabelForPerson" value="investigator"/>
<jsp:param name="roleLabelForPerson" value="Investigator"/>
</jsp:include>

View file

@ -5,5 +5,4 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#leaderRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="leadership role"/>
<jsp:param name="roleLabelForPerson" value="leader"/>
</jsp:include>

View file

@ -5,5 +5,4 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#memberRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="member role"/>
<jsp:param name="roleLabelForPerson" value="member"/>
</jsp:include>

View file

@ -5,5 +5,4 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#outreachProviderRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="outreach role"/>
<jsp:param name="roleLabelForPerson" value="USE_MONIKER"/>
</jsp:include>

View file

@ -5,6 +5,5 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#presenterRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="presenter role"/>
<jsp:param name="roleLabelForPerson" value="presenter"/>
</jsp:include>

View file

@ -5,5 +5,4 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#researcherRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="researcher role"/>
<jsp:param name="roleLabelForPerson" value="USE_MONIKER"/>
</jsp:include>

View file

@ -11,7 +11,8 @@
personToRolePredicate: URI of the person to role predicate.
roleToPersonPredicate: URI of the role to person predicate.
roleActivityToRolePredicate: URI of the activity to role predicate.
roleLabelForPerson: human readable label for person when viewing from non-person side of role
roleLabelForPerson: human readable label for person when viewing from non-person side of role. Some short views
don't specify this value because the role name is displayed instead.
roleActivityLabel: human readable label of activity used for error messages
--%>
@ -20,7 +21,7 @@
<c:choose>
<c:when test="${!empty predicateUri}">
<c:set var="roleLabel" value="${individual.name}"/>
<c:set var="roleLabel" value="${! empty params.roleLabelForPerson ? params.roleLabelForPerson : individual.name}"/>
<%-- get years off role --%>
<c:set var="startYear" value="${individual.dataPropertyMap['http://vivoweb.org/ontology/core#startYear'].dataPropertyStatements[0].data}"/>
@ -38,10 +39,10 @@
<c:when test="${!empty individual.objectPropertyMap['http://vivoweb.org/ontology/core#roleIn']}">
<c:set var="roleActivity" value="${individual.objectPropertyMap['http://vivoweb.org/ontology/core#roleIn'].objectPropertyStatements[0].object}" />
<c:set var="name" value="${roleActivity.name}"/>
<c:set var="label" value="${roleActivity.moniker}"/>
<c:set var="label" value="${roleLabel}" />
<c:set var="uri" value="${roleActivity.URI}"/>
</c:when>
<c:otherwise><%-- this Role is not linked to a anything yet; use name as a placeholder and add link to the Role so user can add more information --%>
<c:otherwise><%-- this Role is not linked to anything yet; use name as a placeholder and add link to the Role so user can add more information --%>
<c:choose>
<c:when test="${!empty individual.name}">
<c:set var="name" value="${individual.name}"/>
@ -64,12 +65,7 @@
<c:when test="${!empty individual.objectPropertyMap[ param.roleToPersonPredicate ]}">
<c:set var="person" value="${individual.objectPropertyMap[ param.roleToPersonPredicate ].objectPropertyStatements[0].object}" />
<c:set var="name" value="${person.name}"/>
<c:if test="${param.roleLabelForPerson == 'USE_MONIKER'}">
<c:set var="label" value="${person.moniker}" />
</c:if>
<c:if test="${param.roleLabelForPerson != 'USE_MONIKER'}">
<c:set var="label" value="${param.roleLabelForPerson}" />
</c:if>
<c:set var="label" value="${roleLabel}" />
<c:set var="uri" value="${person.URI}"/>
</c:when>
@ -96,7 +92,7 @@
<c:choose>
<c:when test="${!empty uri}">
<c:url var="olink" value="/entity"><c:param name="uri" value="${uri}"/></c:url>
<a href="<c:out value="${olink}"/>">${name}</a> ${roleLabel}&nbsp;${label}&nbsp;${startYear}${endYear}
<a href="<c:out value="${olink}"/>">${name}</a>&nbsp;${label}&nbsp;${startYear}${endYear}
</c:when>
<c:otherwise>
<p:process><strong>${name}</strong> ${label}</p:process>

View file

@ -5,5 +5,4 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#serviceProviderRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="service to profession role"/>
<jsp:param name="roleLabelForPerson" value="provider of service"/>
</jsp:include>

View file

@ -5,5 +5,4 @@
<jsp:param name="roleToPersonPredicate" value="http://vivoweb.org/ontology/core#teacherRoleOf"/>
<jsp:param name="roleActivityToRolePredicate" value="http://vivoweb.org/ontology/core#relatedRole"/>
<jsp:param name="roleActivityLabel" value="teaching role"/>
<jsp:param name="roleLabelForPerson" value="teacher"/>
</jsp:include>