%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> <%@ 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.beans.ObjectProperty" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %> <%@ 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.edit.n3editing.EditConfiguration" %> <%@ page import="org.apache.commons.logging.Log" %> <%@ page import="java.util.List" %> <%@ 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.defaultObjPropForm.jsp"); %> <% Individual subject = (Individual)request.getAttribute("subject"); ObjectProperty prop = (ObjectProperty)request.getAttribute("predicate"); VitroRequest vreq = new VitroRequest(request); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); %> <%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.SelectListGenerator"%> <%@page import="java.util.Map"%> <%@page import="com.hp.hpl.jena.ontology.OntModel"%> <%@page import="edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch"%> <%@page import="edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary"%> PREFIX owl: SELECT ?inverse_property WHERE { ?inverse_property owl:inverseOf ?predicate } ?subject ?predicate ?objectVar. ?objectVar ?inverseProp ?subject. { "formUrl" : "${formUrl}", "editKey" : "${editKey}", "urlPatternToReturnTo" : "/entity", "subject" : [ "subject", "${subjectUriJson}" ] , "predicate" : [ "predicate", "${predicateUriJson}" ], "object" : [ "objectVar" , "${objectUriJson}" , "URI"], "n3required" : [ "${n3ForEdit}" ], "n3optional" : [ "${n3Inverse}" ], "newResources" : { }, "urisInScope" : { }, "literalsInScope" : { }, "urisOnForm" : ["objectVar"], "literalsOnForm" : [ ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, "sparqlForUris" : {"inverseProp" : "${queryForInverse}" }, "sparqlForExistingLiterals" : { }, "sparqlForExistingUris" : { }, "fields" : { "objectVar" : { "newResource" : "false", "queryForExisting" : { }, "validators" : [ "nonempty" ], "optionsType" : "INDIVIDUALS_VIA_OBJECT_PROPERTY", "subjectUri" : "${subjectUriJson}", "subjectClassUri" : "", "predicateUri" : "${predicateUriJson}", "objectClassUri" : "", "rangeDatatypeUri" : "", "rangeLang" : "", "literalOptions" : [ ] , "assertions" : ["${n3ForEdit}", "${n3Inverse}"] } } } <% log.debug(request.getAttribute("editjson")); /* now put edit configuration Json object into session */ EditConfiguration editConfig = new EditConfiguration((String)request.getAttribute("editjson")); EditConfiguration.putConfigInSession(editConfig, session); String formTitle =""; String submitLabel =""; Model model = (Model)application.getAttribute("jenaOntModel"); if( request.getAttribute("object") != null ){//this block is for an edit of an existing object property statement editConfig.prepareForObjPropUpdate( model ); formTitle = "Change entry for: "+prop.getDomainPublic()+""; submitLabel = "save change"; } else { editConfig.prepareForNonUpdate( model ); if ( prop.getOfferCreateNewOption() ) { //Try to get the name of the class to select from VClass classOfObjectFillers = null; if( prop.getRangeVClassURI() == null ) { // If property has no explicit range, try to get classes List classes = wdf.getVClassDao().getVClassesForProperty(subject.getVClassURI(), prop.getURI()); if( classes == null || classes.size() == 0 || classes.get(0) == null ){ // If property has no explicit range, we will use e.g. owl:Thing. // Typically an allValuesFrom restriction will come into play later. classOfObjectFillers = wdf.getVClassDao().getTopConcept(); } else { if( classes.size() > 1 ) log.debug("Found multiple classes when attempting to get range vclass."); classOfObjectFillers = classes.get(0); } }else{ classOfObjectFillers = wdf.getVClassDao().getVClassByURI(prop.getRangeVClassURI()); if( classOfObjectFillers == null ) classOfObjectFillers = wdf.getVClassDao().getTopConcept(); } log.debug("property set to offer \"create new\" option; custom form: ["+prop.getCustomEntryForm()+"]"); formTitle = "Select an existing "+classOfObjectFillers.getName()+" for "+subject.getName(); submitLabel = "select existing"; } else { formTitle = "Add an entry to: "+prop.getDomainPublic()+""; submitLabel = "save entry"; } } if( prop.getSelectFromExisting() ){ // set ProhibitedFromSearch object so picklist doesn't show // individuals from classes that should be hidden from list views OntModel displayOntModel = (OntModel) pageContext.getServletContext() .getAttribute("displayOntModel"); if (displayOntModel != null) { ProhibitedFromSearch pfs = new ProhibitedFromSearch( DisplayVocabulary.PRIMARY_LUCENE_INDEX_URI, displayOntModel); if( editConfig != null ) editConfig.setProhibitedFromSearch(pfs); } Map rangeOptions = SelectListGenerator.getOptions(editConfig, "objectVar" , wdf); if( rangeOptions != null && rangeOptions.size() > 0 ) { request.setAttribute("rangeOptionsExist", true); request.setAttribute("rangeOptions.objectVar", rangeOptions); } else { request.setAttribute("rangeOptionsExist",false); } } %> <%=formTitle%> " > ${predicate.publicDescription} There are no entries in the system to select from. If you don't find the appropriate entry on the selection list: Please create a new entry. This property is currently configured to prohibit editing. Delete this entry?
${predicate.publicDescription}
There are no entries in the system to select from.
If you don't find the appropriate entry on the selection list:
Please create a new entry.
This property is currently configured to prohibit editing.