%-- $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" %> <%@ 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)); 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 Create a new principal investigator entry for <%= subjectName %> <% }else{ %> http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole Co-Principal Investigator Create a new co-principal investigator entry for <%= subjectName %> <% } %> @prefix core: <${vivoCore}> . @prefix rdf: <${rdf}> . ?person ?rolePredicate ?role. ?role rdf:type ?roleType . ?role core:relatedRole ?grant . ?grant core:inRole ?role . ?role ?inverseRolePredicate ?person. @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. Must use ?individual since Javascript will look for that property in the data returned. --%> PREFIX core: <${vivoCore}> SELECT ?individual WHERE {<${subjectUri}> core:hasPrincipalInvestigatorRole ?grantRole .?grantRole core:relatedRole ?individual .} ${vivoOnt}#Grant { "formUrl" : "${formUrl}", "editKey" : "${editKey}", "urlPatternToReturnTo" : "/individual", "subject" : ["person", "${subjectUriJson}" ], "predicate" : ["rolePredicate", "${predicateUriJson}" ], "object" : ["role", "${objectUriJson}", "URI" ], "n3required" : [ "${n3ForGrantRole}" ], "n3optional" : [ "${n3ForNewGrant}" , "${n3ForInverse}" ], "newResources" : { "role" : "${defaultNamespace}", "grant" : "${defaultNamespace}" }, "urisInScope" : { "roleType" : "${roleType}", "inverseRolePredicate" : "${inversePredicate}" }, "literalsInScope": { }, "urisOnForm" : [ "grant" ], "literalsOnForm" : [ "grantLabel" ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, "sparqlForUris" : { }, "sparqlForExistingLiterals" : { }, "sparqlForExistingUris" : { }, "fields" : { "grant" : { "newResource" : "false", "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}"] } } } <% 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"); List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.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); %> ${formHeading} " > <%-- bdc34: for some odd reason id and name should not be grant in this input element. --%> * required fields
* required fields