%-- $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.configuration.EditConfiguration" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ModelChangePreprocessor"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.DefaultAddMissingIndividualFormModelPreprocessor"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena"%>
<%@ 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);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
if( prop.getRangeVClassURI() == null ) {
// If property has no explicit range, we will use e.g. owl:Thing.
// Typically an allValuesFrom restriction will come into play later.
VClass top = wdf.getVClassDao().getTopConcept();
prop.setRangeVClassURI(top.getURI());
}
String objectUri = (String)request.getAttribute("objectUri");
String predicateUri = (String)request.getAttribute("predicateUri");
boolean isForwardToCreateNew = request.getAttribute("isForwardToCreateNew") != null &&
(Boolean)request.getAttribute("isForwardToCreateNew") == true;
// If this request is the first forward to this form we need to create a new
// edit key because the request will be coming from a defaultObjPropForm and
// will have an edit key that will be reused by the EditConfiguration that
// is being created below. This also preserves back button functionality to
// the form this request is coming from. If the edit key was not cleared
// the new editConfig below would overwrite the previous form's editConfig
// in the Session.
if( isForwardToCreateNew )
request.setAttribute("editKey", EditConfiguration.newEditKey(session));
//If a objectProperty is both provideSelect and offerCreateNewOption
// then when the user gos to a default ObjectProperty edit for an existing
// object property statement then the user can create a new Individual,
// and replace the object in the existing objectPropertyStatement with
// this new individual.
boolean isReplaceWithNew = request.getAttribute("isReplaceWithNew") != null &&
(Boolean)request.getAttribute("isReplaceWithNew") == true;
// If an objectProperty is selectFromExisitng==false and offerCreateNewOption == true
// the we want to forward to the create new form but edit the existing object
// of the objPropStmt.
boolean isForwardToCreateButEdit = request.getAttribute("isForwardToCreateButEdit") != null
&& (Boolean)request.getAttribute("isForwardToCreateButEdit") == true;
vreq.setAttribute("defaultNamespace",wdf.getDefaultNamespace());
StringBuffer n3AssertedTypesUnescapedBuffer = new StringBuffer();
// TODO: redo to query restrictions directly. getVClassesForProperty returns the subclasses, which we don't want.
//for ( VClass vclass : assertionsWdf.getVClassDao().getVClassesForProperty(subject.getVClassURI(),prop.getURI()) ) {
// if (vclass.getURI()!=null) {
// n3AssertedTypesUnescapedBuffer.append("?newIndividual ").append(" rdf:type <")
// .append(vclass.getURI()).append("> .\n");
// }
//}
vreq.setAttribute("n3AssertedTypesUnescaped",n3AssertedTypesUnescapedBuffer.toString());
String flagURI = wdf.getVClassDao().getTopConcept().getURI();
vreq.setAttribute("flagURI",flagURI);
VClass rangeClass = null;
String typeOfNew = (String)vreq.getAttribute("typeOfNew");
if(typeOfNew != null )
rangeClass = wdf.getVClassDao().getVClassByURI( typeOfNew );
if( rangeClass == null ){
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",rangeClass.getURI());
//todo: set additional ranges using allValuesFrom.
//vreq.setAttribute("curatorReviewUri","http://vivo.library.cornell.edu/ns/0.1#CuratorReview");
%>