<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> <%-- Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole and hasPrincipalInvestigatorRole. This is intended to create a set of statements like: ?person core:hasPrincipalInvestigatorRole ?newRole. ?newRole rdf:type core:PrincipalInvestigatorRole ; core:relatedRole ?someGrant . --%> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Arrays" %> <%@ 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.controller.freemarker.UrlBuilder.JavaScript" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.StartYearBeforeEndYear"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> <% VitroRequest vreq = new VitroRequest(request); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); String intDatatypeUri = XSD.xint.toString(); vreq.setAttribute("intDatatypeUri", intDatatypeUri); vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri)); vreq.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); String predicateUri = (String)request.getAttribute("predicateUri"); ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri ); if( op != null && op.getURIInverse() != null ){ %> <%=op.getURIInverse()%> <% }else{ %> <% } %> <%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty"%> <% // set role type based on predicate String subjectName = ((Individual) request.getAttribute("subject")).getName(); if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %> http://vivoweb.org/ontology/core#PrincipalInvestigatorRole Principal Investigator principal investigator entry for <%= subjectName %> <% }else if ( ((String)request.getAttribute("predicateUri")).endsWith("hasCo-PrincipalInvestigatorRole") ) { %> http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole Co-Principal Investigator co-principal investigator entry for <%= subjectName %> <% }else { %> http://vivoweb.org/ontology/core#InvestigatorRole Investigator investigator entry for <%= subjectName %> <% } %> "> ?role <${startYearUri}> ?startYear . ?role <${endYearUri}> ?endYear . @prefix core: <${vivoCore}> . @prefix rdf: <${rdf}> . ?person ?rolePredicate ?role. ?role rdf:type ?roleType . ?role core:roleIn ?grant . ?grant core:relatedRole ?role . ?role ?inverseRolePredicate ?person. @prefix core: <${vivoCore}> . @prefix rdf: <${rdf}> . ?grant rdf:type core:Grant . @prefix rdfs: <${rdfs}> . ?grant rdfs:label ?grantLabel . PREFIX core: <${vivoCore}> PREFIX rdfs: <${rdfs}> SELECT ?existingGrantLabel WHERE { ?role core:roleIn ?existingGrant . ?existingGrant rdfs:label ?existingGrantLabel . } PREFIX core: <${vivoCore}> SELECT ?existingStartYear WHERE { ?role core:startYear ?existingStartYear .} PREFIX core: <${vivoCore}> SELECT ?existingStartYear WHERE { ?role core:endYear ?existingStartYear .} PREFIX core: <${vivoCore}> SELECT ?existingGrant WHERE { ?role core:roleIn ?existingGrant . } ${vivoOnt}#Grant { "formUrl" : "${formUrl}", "editKey" : "${editKey}", "urlPatternToReturnTo" : "/individual", "subject" : ["person", "${subjectUriJson}" ], "predicate" : ["rolePredicate", "${predicateUriJson}" ], "object" : ["role", "${objectUriJson}", "URI" ], "n3required" : [ "${n3ForGrantRole}", "${startYearAssertion}" ], "n3optional" : [ "${n3ForGrantType}", "${n3ForGrantLabel}", "${n3ForInverse}", "${endYearAssertion}" ], "newResources" : { "role" : "${defaultNamespace}", "grant" : "${defaultNamespace}" }, "urisInScope" : { "roleType" : "${roleType}", "inverseRolePredicate" : "${inversePredicate}" }, "literalsInScope": { }, "urisOnForm" : [ "grant" ], "literalsOnForm" : [ "grantLabel", "startYear", "endYear", "existingGrantLabel" ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, "sparqlForUris" : { }, "sparqlForExistingLiterals" : { "grantLabel":"${grantLabelQuery}" , "startYear":"${startYearQuery}", "endYear":"${endYearQuery}" }, "sparqlForExistingUris" : { "grant":"${grantQuery}" }, "fields" : { "grant" : { "newResource" : "false", "validators" : [ ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "${grantTypeUriJson}", "rangeDatatypeUri" : "", "rangeLang" : "", "assertions" : [ ] }, "grantLabel" : { "newResource" : "false", "validators" : [ ${labelRequired} "datatype:${stringDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "${stringDatatypeUriJson}", "rangeLang" : "", "assertions" : ["${n3ForGrantLabel}"] }, "existingGrantLabel" : { /* Needed iff we return from an invalid submission */ "newResource" : "false", "validators" : [ ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "", "rangeLang" : "", "assertions" : [ ] }, "startYear" : { "newResource" : "false", "validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "${gYearDatatypeUriJson}", "rangeLang" : "", "assertions" : ["${startYearAssertion}"] }, "endYear" : { "newResource" : "false", "validators" : [ "datatype:${gYearDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "${gYearDatatypeUriJson}", "rangeLang" : "", "assertions" : ["${endYearAssertion}"] } } } <% EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); if (editConfig == null) { editConfig = new EditConfiguration((String) request.getAttribute("editjson")); EditConfiguration.putConfigInSession(editConfig,session); } editConfig.addValidator(new StartYearBeforeEndYear("startYear","endYear") ); Model model = (Model) application.getAttribute("jenaOntModel"); String objectUri = (String) request.getAttribute("objectUri"); if (objectUri != null) { editConfig.prepareForObjPropUpdate(model); // Return browser to person individual after editing an existing role. } else { editConfig.prepareForNonUpdate(model); // NIHVIVO-1014 Return browser to person individual after editing an existing role. // Return the browser to the new activity entity after adding a new role. // editConfig.setEntityToReturnTo("?grant"); } String subjectUri = vreq.getParameter("subjectUri"); List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), JavaScript.CUSTOM_FORM_UTILS.path(), "/js/browserUtils.js", "/edit/forms/js/customFormWithAutocomplete.js" )); request.setAttribute("customJs", customJs); List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), Css.CUSTOM_FORM.path(), "/edit/forms/css/customFormWithAutocomplete.css" )); request.setAttribute("customCss", customCss); %>

${formHeading}

<%@ include file="unsupportedBrowserMessage.jsp" %> <%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
" >

<%-- Store this value in a hidden field, because the displayed field is disabled and don't submit. This ensures that when returning from a validation error, we retain the value. --%>

(Verify this match)

<%-- Field value populated by JavaScript --%> <%-- Needed iff we return from an invalid submission --%>

Years of Participation in Grant

* required fields

<%-- Must be all one line for JavaScript. --%> PREFIX core: <${vivoCore}> SELECT ?grantUri WHERE {<${subjectUri}> <${predicateUri}> ?grantRole . ?grantRole core:roleIn ?grantUri .}