diff --git a/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf b/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf index 681c8731..fe62e356 100644 --- a/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf +++ b/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf @@ -985,6 +985,7 @@ 25 5 + addGrantRoleToPerson.jsp true true @@ -3345,6 +3346,7 @@ display level 5 true + addGrantRoleToPerson.jsp 25 diff --git a/productMods/edit/forms/addGrantRoleToPerson.jsp b/productMods/edit/forms/addGrantRoleToPerson.jsp new file mode 100644 index 00000000..1a7bf54c --- /dev/null +++ b/productMods/edit/forms/addGrantRoleToPerson.jsp @@ -0,0 +1,213 @@ +<%-- $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.edit.n3editing.PersonHasPublicationValidator" %> +<%@ 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="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.addAuthorsToInformationResource.jsp"); +%> +<% + 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)); + +%> + + + + + + + +<% // set role type based on predicate +if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %> + ${vivoOnt}#PrincipalInvestigatorRole + <% }else{ %> + ${vivoOnt}#hasCo-PrincipalInvestigatorRole + <% } %> + + + @prefix core: <${vivoCore}> . + @prefix rdf: <${rdf}> . + + ?person ?rolePredicate ?role. + ?role rdf:type ?roleType ; + core:relatedRole ?grant . + + + + @prefix core: <${vivoCore}> . + @prefix rdf: <${rdf}> . + @prefix rdfs: <${rdfs}> . + + ?grant rdf:type core:Grant . + ?grant rdfs:label ?grantLabel . + + +<%-- Must be all one line for JavaScript. --%> + +PREFIX core: <${vivoCore}> SELECT ?grantURI WHERE {<${subjectUri}> core:hasPrincipalInvestigatorRole ?grantRole .?grantRole core:relatedRole ?grantURI .} + + +${vivoOnt}#Grant + +{ + "formUrl" : "${formUrl}", + "editKey" : "${editKey}", + "urlPatternToReturnTo" : "/individual", + + "subject" : ["person", "${subjectUriJson}" ], + "predicate" : ["rolePredicate", "${predicateUriJson}" ], + "object" : ["role", "${objectUriJson}", "URI" ], + + "n3required" : [ "${n3ForGrantRole}" ], + + "n3optional" : [ "${n3ForNewGrant}" ], + + "newResources" : { "role" : "${defaultNamespace}", + "grant" : "${defaultNamespace}" }, + + "urisInScope" : { "roleType" : "${roleType}" }, + "literalsInScope": { }, + "urisOnForm" : [ "grant" ], + "literalsOnForm" : [ "grantLabel" ], + "filesOnForm" : [ ], + "sparqlForLiterals" : { }, + "sparqlForUris" : { }, + "sparqlForExistingLiterals" : { }, + "sparqlForExistingUris" : { }, + "fields" : { + "grant" : { + "newResource" : "true", + "validators" : [ ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "${grantTypeUriJson}", + "rangeDatatypeUri" : "", + "rangeLang" : "", + "assertions" : [ ] + }, + "grantLabel" : { + "newResource" : "false", + "validators" : [ "datatype:${stringDatatypeUriJson}" ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "${personClassUriJson}", + "rangeDatatypeUri" : "${stringDatatypeUriJson}", + "rangeLang" : "", + "assertions" : ["${n3ForExistingPub}"] + } + } +} + + +<% + 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); + } + + //validator for addGrantRoleToPerson.jsp? + //editConfig.addValidator(new AddGrantRoleToPersonValidator()); + + Model model = (Model) application.getAttribute("jenaOntModel"); + editConfig.prepareForNonUpdate(model); + + //this will return the browser to the new grant entity after an edit. + editConfig.setEntityToReturnTo("?grant"); + + String subjectUri = vreq.getParameter("subjectUri"); + String predicateUri = vreq.getParameter("predicateUri"); + String subjectName = ((Individual) request.getAttribute("subject")).getName(); + + List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), + JavaScript.UTILS.path(), + JavaScript.CUSTOM_FORM_UTILS.path(), + "/edit/forms/js/customFormWithAdvanceTypeSelection.js" + )); + request.setAttribute("customJs", customJs); + + List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), + Css.CUSTOM_FORM.path(), + "/edit/forms/css/autocomplete.css", + "/edit/forms/css/customFormWithAdvanceTypeSelection.css" + )); + request.setAttribute("customCss", customCss); +%> + + + + + + + + + +Create a new principal investigator entry for <%= subjectName %> + +" > + + + + + <%-- RY maybe make this a label and input field. See what looks best. --%> + + <%-- bdc34: for some odd reason id and name should not be grant in this input element. --%> + + + + + + * required fields + + + \ No newline at end of file
* required fields