<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %> <%@ page import="com.hp.hpl.jena.rdf.model.Literal" %> <%@ page import="com.hp.hpl.jena.rdf.model.Model" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> <% Individual subject = (Individual)request.getAttribute("subject"); ObjectProperty prop = (ObjectProperty)request.getAttribute("predicate"); if (prop == null) throw new Error("no object property specified via incoming predicate attribute in defaultAddMissingIndividualForm.jsp"); String propDomainPublic = (prop.getDomainPublic() == null) ? "affiliation" : prop.getDomainPublic(); VitroRequest vreq = new VitroRequest(request); //String contextPath = vreq.getContextPath(); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); if( prop.getRangeVClassURI() == null )throw new Error("Property has null for its range class URI"); VClass rangeClass = wdf.getVClassDao().getVClassByURI(prop.getRangeVClassURI()); if( rangeClass == null ) throw new Error ("Cannot find class for range for property. Looking for " + prop.getRangeVClassURI() ); //vreq.setAttribute("rangeClassLocalName",rangeClass.getLocalName()); //vreq.setAttribute("rangeClassNamespace",rangeClass.getNamespace()); vreq.setAttribute("rangeClassUri",prop.getRangeVClassURI()); vreq.setAttribute("curatorReviewUri","http://vivo.library.cornell.edu/ns/0.1#CuratorReview"); //get the current portal and make this new individual a member of that portal vreq.setAttribute("portalUri", vreq.getPortal().getTypeUri()); %> PREFIX owl: SELECT ?inverse_property WHERE { ?inverse_property owl:inverseOf ?predicate } <%-- Enter here the class names to be used for constructing MONIKERS_VIA_VCLASS pick lists These are then referenced in the field's ObjectClassUri but not elsewhere. Note that you can't reference a jsonset variable inside another jsonset expression or you get double escaping problems --%> ${rangeClassUri} <%-- 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 --%> PREFIX rdfs: SELECT ?existingName WHERE { ?newIndividual rdfs:label ?existingName } <%-- 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) --%> @prefix vivo: . ?newIndividual rdfs:label ?name . PREFIX rdfs: SELECT ?existingMoniker WHERE { ?newIndividual vitro:moniker ?existingMoniker } @prefix vivo: . ?newIndividual vitro:moniker ?moniker . PREFIX vitro: SELECT ?existingLinkUrl WHERE { ?newIndividual vitro:primaryLink ?newLink ; ?newLink vitro:linkURL ?existingLinkUrl . } @prefix vitro: . ?newLink vitro:linkURL ?linkUrl . @prefix rdf: . @prefix rdfs: . @prefix vivo: . @prefix vitro: . ?newIndividual rdf:type <${curatorReviewUri}> . ?newIndividual rdf:type <${rangeClassUri}> . ?subject ?predicate ?newIndividual . ?newIndividual rdfs:label ?name . ?newIndividual ?inverseProp ?subject . <%-- make sure you have all the @prefix entries to cover the statements in each block --%> @prefix vitro: . ?newIndividual vitro:moniker ?moniker . <%-- set the portal of the new individual to the current portal. --%> @prefix rdf: . ?newIndividual rdf:type <${portalUri}> . <%-- note that it's safer to have multiple distinct optional blocks so that a failure in one will not prevent correct sections from being inserted --%> @prefix rdf: . @prefix vitro: . ?newLink rdf:type vitro:Link ; vitro:linkURL ?linkUrl ; vitro:linkAnchor ?name ; vitro:linkDisplayRank "1" . ?newIndividual vitro:primaryLink ?newLink . { "formUrl" : "${formUrl}", "editKey" : "${editKey}", "urlPatternToReturnTo" : "/entity", "subject" : [ "subject", "${subjectUriJson}" ], "predicate" : [ "predicate", "${predicateUriJson}" ], "object" : [ "newIndividual", "${objectUriJson}", "URI" ], "n3required" : [ "${n3ForEdit}" ], "n3optional" : [ "${n3optional}", "${n3Inverse}", "${n3link}", "${n3portal}" ], "newResources" : { "newIndividual" : "http://vivo.library.cornell.edu/ns/0.1#individual", "newLink" : "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#Link" }, "urisInScope" : { }, "literalsInScope" : { }, "urisOnForm" : [ ], "literalsOnForm" : [ "name","moniker","linkUrl" ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, "sparqlForUris" : { "inverseProp" : "${queryForInverse}" }, "sparqlForExistingLiterals" : { "name" : "${nameExisting}", "moniker" : "${monikerExisting}", "linkUrl" : "${linkUrlExisting}" }, "sparqlForExistingUris" : { }, "fields" : { "name" : { "newResource" : "false", "validators" : [ "nonempty" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "", "rangeLang" : "", "assertions" : [ "${nameAssertion}" ] }, "moniker" : { "newResource" : "false", "validators" : [ ], "optionsType" : "MONIKERS_VIA_VCLASS", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "${newIndividualVClassUri}", "rangeDatatypeUri" : "", "rangeLang" : "", "assertions" : [ "${monikerAssertion}" ] }, "linkUrl" : { "newResource" : "false", "validators" : [], "optionsType" : "UNDEFINED", "literalOptions" : [], "predicateUri" : "", "objectClassUri" : "", "rangeDatatypeUri" : "", "rangeLang" : "", "assertions" : [ "${linkUrlAssertion}" ] } } } <% EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); if( editConfig == null ){ editConfig = new EditConfiguration((String)request.getAttribute("editjson")); EditConfiguration.putConfigInSession(editConfig, session); } Model model = (Model)application.getAttribute("jenaOntModel"); String objectUri = (String)request.getAttribute("objectUri"); if( objectUri != null ){ editConfig.prepareForObjPropUpdate(model); }else{ editConfig.prepareForNonUpdate(model); } String submitButtonLabel=""; // don't put local variables into the request /* title is used by pre and post form fragments */ if (objectUri != null) { request.setAttribute("title", "Edit \""+propDomainPublic+"\" entry for " + subject.getName()); submitButtonLabel = "Save changes"; } else { request.setAttribute("title","Create a new \""+propDomainPublic+"\" entry for " + subject.getName()); submitButtonLabel = "Create new \""+propDomainPublic+"\" entry"; } %>

${title}

" >
start typing to see existing choices, or add a new label