NIHVIVO-3530: Removed custom forms jsp files from VITRO
This commit is contained in:
parent
597ed286bd
commit
2214336f65
11 changed files with 0 additions and 2078 deletions
|
@ -1,181 +0,0 @@
|
||||||
<%-- $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.DataProperty" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %>
|
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
|
||||||
|
|
||||||
<%
|
|
||||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.autoCompleteDatapropForm.jsp");
|
|
||||||
log.debug("Starting autoCompleteDatapropForm.jsp");
|
|
||||||
|
|
||||||
String subjectUri = request.getParameter("subjectUri");
|
|
||||||
String predicateUri = request.getParameter("predicateUri");
|
|
||||||
|
|
||||||
DataPropertyStatement dps = (DataPropertyStatement)request.getAttribute("dataprop");
|
|
||||||
|
|
||||||
String datapropKeyStr = request.getParameter("datapropKey");
|
|
||||||
int dataHash=0;
|
|
||||||
|
|
||||||
DataProperty prop = (DataProperty)request.getAttribute("predicate");
|
|
||||||
if( prop == null ) throw new Error("In autoCompleteDatapropForm.jsp, could not find predicate " + predicateUri);
|
|
||||||
request.setAttribute("propertyName",prop.getPublicName());
|
|
||||||
|
|
||||||
Individual subject = (Individual)request.getAttribute("subject");
|
|
||||||
if( subject == null ) throw new Error("In autoCompleteDatapropForm.jsp, could not find subject " + subjectUri);
|
|
||||||
request.setAttribute("subjectName",subject.getName());
|
|
||||||
|
|
||||||
String rangeDatatypeUri = prop.getRangeDatatypeURI();
|
|
||||||
request.setAttribute("rangeDatatypeUriJson", MiscWebUtils.escape(rangeDatatypeUri));
|
|
||||||
|
|
||||||
if( dps != null ){
|
|
||||||
try {
|
|
||||||
dataHash = Integer.parseInt(datapropKeyStr);
|
|
||||||
log.debug("dataHash is " + dataHash);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
log.debug("could not parse dataprop hash "+
|
|
||||||
"but there was a dataproperty; hash: '"+datapropKeyStr+"'");
|
|
||||||
}
|
|
||||||
|
|
||||||
String rangeDatatype = dps.getDatatypeURI();
|
|
||||||
if( rangeDatatype == null ){
|
|
||||||
log.debug("no range datatype uri set on data property statement when property's range datatype is "+prop.getRangeDatatypeURI()+" in autoCompleteDatapropForm.jsp");
|
|
||||||
request.setAttribute("rangeDatatypeUriJson","");
|
|
||||||
}else{
|
|
||||||
log.debug("range datatype uri of ["+rangeDatatype+"] on data property statement in autoCompleteDatapropForm.jsp");
|
|
||||||
request.setAttribute("rangeDatatypeUriJson",rangeDatatype);
|
|
||||||
}
|
|
||||||
String rangeLang = dps.getLanguage();
|
|
||||||
if( rangeLang == null ) {
|
|
||||||
log.debug("no language attribute on data property statement in autoCompleteDatapropForm.jsp");
|
|
||||||
request.setAttribute("rangeLangJson","");
|
|
||||||
}else{
|
|
||||||
log.debug("language attribute of ["+rangeLang+"] on data property statement in autoCompleteDatapropForm.jsp");
|
|
||||||
request.setAttribute("rangeLangJson", rangeLang);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("No incoming dataproperty statement attribute in autoCompleteDatapropForm.jsp");
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<c:set var="dataLiteral" value="<%=prop.getLocalName()%>"/>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForEdit" >
|
|
||||||
?subject ?predicate ?${dataLiteral}.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"datapropKey" : "<%=datapropKeyStr==null?"":datapropKeyStr%>",
|
|
||||||
"urlPatternToReturnTo" : "/entity",
|
|
||||||
|
|
||||||
"subject" : ["subject", "${subjectUriJson}" ],
|
|
||||||
"predicate" : ["predicate", "${predicateUriJson}"],
|
|
||||||
"object" : ["${dataLiteral}","","DATAPROPHASH"],
|
|
||||||
|
|
||||||
"n3required" : ["${n3ForEdit}"],
|
|
||||||
"n3optional" : [ ],
|
|
||||||
"newResources" : { },
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope" : { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : ["${dataLiteral}"],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { },
|
|
||||||
"sparqlForExistingLiterals" : { },
|
|
||||||
"sparqlForExistingUris" : { },
|
|
||||||
"optionsForFields" : { },
|
|
||||||
"fields" : { "${dataLiteral}" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : ["nonempty"],
|
|
||||||
"optionsType" : "STRINGS_VIA_DATATYPE_PROPERTY",
|
|
||||||
"literalOptions" : [],
|
|
||||||
"predicateUri" : "${predicateUriJson}",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "${rangeDatatypeUriJson}" ,
|
|
||||||
"rangeLang" : "${rangeLangJson}",
|
|
||||||
"assertions" : ["${n3ForEdit}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<%
|
|
||||||
if( log.isDebugEnabled()) log.debug(request.getAttribute("editjson"));
|
|
||||||
|
|
||||||
EditConfiguration editConfig = new EditConfiguration((String)request.getAttribute("editjson"));
|
|
||||||
EditConfiguration.putConfigInSession(editConfig, session);
|
|
||||||
|
|
||||||
String formTitle =""; // dont add local page variables to the request
|
|
||||||
String submitLabel ="";
|
|
||||||
|
|
||||||
if( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
|
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
|
||||||
editConfig.prepareForDataPropUpdate(model,dps);
|
|
||||||
formTitle = "Change text for: <em>"+prop.getPublicName()+"</em>";
|
|
||||||
submitLabel = "Save change";
|
|
||||||
} else {
|
|
||||||
formTitle = "Add new entry for: <em>"+prop.getPublicName()+"</em>";
|
|
||||||
submitLabel = "Save entry";
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}">
|
|
||||||
<jsp:param name="useTinyMCE" value="false"/>
|
|
||||||
<jsp:param name="useAutoComplete" value="true"/>
|
|
||||||
</jsp:include>
|
|
||||||
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
|
|
||||||
<script type="text/javascript" language="javascript">
|
|
||||||
$(this).load($(this).parent().children('a').attr('src')+" .editForm");
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var key = $("input[name='editKey']").attr("value");
|
|
||||||
$.getJSON("<c:url value="/dataservice"/>", {getN3EditOptionList:"1", field: "${dataLiteral}", editKey: key}, function(json){
|
|
||||||
|
|
||||||
$("select#${dataLiteral}").replaceWith("<input type='hidden' id='${dataLiteral}' name='${dataLiteral}' /><input type='text' id='${dataLiteral}-entry' name='${dataLiteral}-entry' />");
|
|
||||||
|
|
||||||
$("#${dataLiteral}-entry").autocomplete(json, {
|
|
||||||
minChars: 1,
|
|
||||||
width: 320,
|
|
||||||
matchContains: true,
|
|
||||||
mustMatch: 0,
|
|
||||||
autoFill: false,
|
|
||||||
// formatItem: function(row, i, max) {
|
|
||||||
// return row[0];
|
|
||||||
// },
|
|
||||||
// formatMatch: function(row, i, max) {
|
|
||||||
// return row[0];
|
|
||||||
// },
|
|
||||||
// formatResult: function(row) {
|
|
||||||
// return row[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
}).result(function(event, data, formatted) {
|
|
||||||
$("input#${dataLiteral}-entry").attr("value", data[0]); // dump the string into the text box
|
|
||||||
$("input#${dataLiteral}").attr("value", data[1]); // dump the uri into the hidden form input
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h2><%=formTitle%></h2>
|
|
||||||
<form class="editForm" action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
|
||||||
<c:if test="${!empty predicate.publicDescription}">
|
|
||||||
<p class="propEntryHelpText">${predicate.publicDescription}</p>
|
|
||||||
</c:if>
|
|
||||||
<v:input type="select" id="${dataLiteral}"/>
|
|
||||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
|
||||||
</form>
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,194 +0,0 @@
|
||||||
<%-- $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.configuration.EditConfiguration" %>
|
|
||||||
<%@ 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.autoCompleteObjPropForm.jsp");
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
log.warn("Starting autoCompleteObjPropForm.jsp");
|
|
||||||
Individual subject = (Individual)request.getAttribute("subject");
|
|
||||||
ObjectProperty prop = (ObjectProperty)request.getAttribute("predicate");
|
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
if( prop.getRangeVClassURI() == null ) {
|
|
||||||
log.debug("Property has null for its range class URI");
|
|
||||||
// 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());
|
|
||||||
log.debug("Using "+prop.getRangeVClassURI());
|
|
||||||
}
|
|
||||||
|
|
||||||
VClass rangeClass = wdf.getVClassDao().getVClassByURI( prop.getRangeVClassURI());
|
|
||||||
if( rangeClass == null ) log.debug("Cannot find class for range for property. Looking for " + prop.getRangeVClassURI() );
|
|
||||||
%>
|
|
||||||
|
|
||||||
<v:jsonset var="queryForInverse" >
|
|
||||||
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
|
||||||
SELECT ?inverse_property
|
|
||||||
WHERE {
|
|
||||||
?inverse_property owl:inverseOf ?predicate
|
|
||||||
}
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="objectVar" value="<%=prop.getLocalName()%>"/>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForEdit" >
|
|
||||||
?subject ?predicate ?${objectVar}.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3Inverse" >
|
|
||||||
?${objectVar} ?inverseProp ?subject.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"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" : [ ],
|
|
||||||
"optionsType" : "INDIVIDUALS_VIA_OBJECT_PROPERTY",
|
|
||||||
"subjectUri" : "${subjectUriJson}",
|
|
||||||
"subjectClassUri" : "",
|
|
||||||
"predicateUri" : "${predicateUriJson}",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "",
|
|
||||||
"rangeLang" : "",
|
|
||||||
"literalOptions" : [ ] ,
|
|
||||||
"assertions" : ["${n3ForEdit}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<% /* 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: <em>"+prop.getDomainPublic()+"</em>";
|
|
||||||
submitLabel = "save change";
|
|
||||||
} else {
|
|
||||||
editConfig.prepareForNonUpdate( model );
|
|
||||||
if ( prop.getOfferCreateNewOption() ) {
|
|
||||||
log.debug("property set to offer \"create new\" option; custom form: ["+prop.getCustomEntryForm()+"]");
|
|
||||||
formTitle = "Select an existing "+rangeClass.getName()+" for "+subject.getName();
|
|
||||||
submitLabel = "Select existing";
|
|
||||||
} else {
|
|
||||||
formTitle = "Add an entry to: <em>"+prop.getDomainPublic()+"</em>";
|
|
||||||
submitLabel = "Save entry";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<jsp:include page="${preForm}">
|
|
||||||
<jsp:param name="useTinyMCE" value="false"/>
|
|
||||||
<jsp:param name="useAutoComplete" value="true"/>
|
|
||||||
</jsp:include>
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
|
|
||||||
<script type="text/javascript" language="javascript">
|
|
||||||
$(this).load($(this).parent().children('a').attr('src')+" .editForm");
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var key = $("input[name='editKey']").attr("value");
|
|
||||||
$.getJSON("<c:url value="/dataservice"/>", {getN3EditOptionList:"1", field: "${objectVar}", editKey: key}, function(json){
|
|
||||||
|
|
||||||
$("select#${objectVar}").replaceWith("<input type='hidden' id='${objectVar}' name='${objectVar}' /><input type='text' id='${objectVar}-entry' name='${objectVar}-entry' />");
|
|
||||||
|
|
||||||
$("#${objectVar}-entry").autocomplete(json, {
|
|
||||||
minChars: 1,
|
|
||||||
width: 320,
|
|
||||||
matchContains: true,
|
|
||||||
mustMatch: 1,
|
|
||||||
autoFill: true,
|
|
||||||
// formatItem: function(row, i, max) {
|
|
||||||
// return row[0];
|
|
||||||
// },
|
|
||||||
// formatMatch: function(row, i, max) {
|
|
||||||
// return row[0];
|
|
||||||
// },
|
|
||||||
// formatResult: function(row) {
|
|
||||||
// return row[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
}).result(function(event, data, formatted) {
|
|
||||||
$("input#${objectVar}-entry").attr("value", data[0]); // dump the string into the text box
|
|
||||||
$("input#${objectVar}").attr("value", data[1]); // dump the uri into the hidden form input
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h2><%=formTitle%></h2>
|
|
||||||
<form class="editForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
||||||
<c:if test="${predicate.offerCreateNewOption == true}">
|
|
||||||
<c:url var="createNewUrl" value="/edit/editRequestDispatch.jsp">
|
|
||||||
<c:param name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<c:param name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<c:param name="clearEditConfig" value="true"/>
|
|
||||||
<c:param name="cmd" value="create"/>
|
|
||||||
</c:url>
|
|
||||||
</c:if>
|
|
||||||
<c:if test="${!empty predicate.publicDescription}">
|
|
||||||
<p>${predicate.publicDescription}</p>
|
|
||||||
</c:if>
|
|
||||||
<v:input type="select" id="${objectVar}" size="80" />
|
|
||||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
|
||||||
<c:if test="${predicate.offerCreateNewOption == true}">
|
|
||||||
<p>If you don't find the appropriate entry on the selection list,
|
|
||||||
<button type="button" onclick="javascript:document.location.href='${createNewUrl}'">Add a new item to this list</button>
|
|
||||||
</p>
|
|
||||||
</c:if>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<c:if test="${!empty param.objectUri}" >
|
|
||||||
<form class="deleteForm" action="editRequestDispatch.jsp" method="get">
|
|
||||||
<label for="delete"><h3>Delete this entry?</h3></label>
|
|
||||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<input type="hidden" name="objectUri" value="${param.objectUri}"/>
|
|
||||||
<input type="hidden" name="cmd" value="delete"/>
|
|
||||||
<v:input type="submit" id="delete" value="Delete" cancel="" />
|
|
||||||
</form>
|
|
||||||
</c:if>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,119 +0,0 @@
|
||||||
<%-- $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="com.hp.hpl.jena.rdf.model.Resource" %>
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Literal" %>
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Property" %>
|
|
||||||
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataProperty" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils"%>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
|
||||||
<%@ 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.processEdit.RdfLiteralHash" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.StandardModelSelector"%>
|
|
||||||
<%@ page import="com.hp.hpl.jena.shared.Lock"%>
|
|
||||||
<%@ page import="com.hp.hpl.jena.ontology.OntModel"%>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent"%>
|
|
||||||
|
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jstl/functions" %>
|
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
||||||
|
|
||||||
<%@taglib prefix="vitro" uri="/WEB-INF/tlds/VitroUtils.tld" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission" %>
|
|
||||||
<% request.setAttribute("requestedActions", SimplePermission.USE_MISCELLANEOUS_PAGES.ACTION); %>
|
|
||||||
<vitro:confirmAuthorization />
|
|
||||||
|
|
||||||
<%
|
|
||||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.datapropStmtDelete");
|
|
||||||
|
|
||||||
String subjectUri = request.getParameter("subjectUri");
|
|
||||||
String predicateUri = request.getParameter("predicateUri");
|
|
||||||
String datapropKeyStr = request.getParameter("datapropKey");
|
|
||||||
int dataHash = 0;
|
|
||||||
if (datapropKeyStr!=null && datapropKeyStr.trim().length()>0) {
|
|
||||||
try {
|
|
||||||
dataHash = Integer.parseInt(datapropKeyStr);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
throw new JspException("Cannot decode incoming datapropKey String value "+datapropKeyStr+" as an integer hash in datapropStmtDelete.jsp");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
String editorUri = EditN3Utils.getEditorUri(vreq);
|
|
||||||
wdf = wdf.getUserAwareDaoFactory(editorUri);
|
|
||||||
|
|
||||||
DataProperty prop = wdf.getDataPropertyDao().getDataPropertyByURI(predicateUri);
|
|
||||||
if( prop == null ) throw new Error("In datapropStmtDelete.jsp, could not find property " + predicateUri);
|
|
||||||
request.setAttribute("propertyName",prop.getPublicName());
|
|
||||||
|
|
||||||
Individual subject = wdf.getIndividualDao().getIndividualByURI(subjectUri);
|
|
||||||
if( subject == null ) throw new Error("could not find subject " + subjectUri);
|
|
||||||
request.setAttribute("subjectName",subject.getName());
|
|
||||||
|
|
||||||
String dataValue=null;
|
|
||||||
|
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
|
||||||
|
|
||||||
String vitroNsProp = vreq.getParameter("vitroNsProp");
|
|
||||||
|
|
||||||
DataPropertyStatement dps = RdfLiteralHash.getPropertyStmtByHash(subject.getURI(), predicateUri, dataHash, model);
|
|
||||||
|
|
||||||
if( log.isDebugEnabled() ){
|
|
||||||
log.debug("attempting to delete dataPropertyStatement: subjectURI <" + dps.getIndividualURI() +">");
|
|
||||||
log.debug( "predicateURI <" + dps.getDatapropURI() + ">");
|
|
||||||
log.debug( "literal \"" + dps.getData() + "\"" );
|
|
||||||
log.debug( "lang @" + (dps.getLanguage() == null ? "null" : dps.getLanguage()));
|
|
||||||
log.debug( "datatype ^^" + (dps.getDatatypeURI() == null ? "null" : dps.getDatatypeURI() ));
|
|
||||||
}
|
|
||||||
if( dps.getIndividualURI() == null || dps.getIndividualURI().trim().length() == 0){
|
|
||||||
log.debug("adding missing subjectURI to DataPropertyStatement" );
|
|
||||||
dps.setIndividualURI( subjectUri );
|
|
||||||
}
|
|
||||||
if( dps.getDatapropURI() == null || dps.getDatapropURI().trim().length() == 0){
|
|
||||||
log.debug("adding missing datapropUri to DataPropertyStatement");
|
|
||||||
dps.setDatapropURI( predicateUri );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dps!=null) {
|
|
||||||
dataValue = dps.getData().trim();
|
|
||||||
|
|
||||||
//do the delete
|
|
||||||
if( request.getParameter("y") != null ) {
|
|
||||||
|
|
||||||
wdf.getDataPropertyStatementDao().deleteDataPropertyStatement(dps);
|
|
||||||
%>
|
|
||||||
|
|
||||||
<%-- grab the predicate URI and trim it down to get the Local Name so we can send the user back to the appropriate property --%>
|
|
||||||
<c:set var="predicateUri" value="${param.predicateUri}" />
|
|
||||||
<c:set var="localName" value="${fn:substringAfter(predicateUri, '#')}" />
|
|
||||||
<c:url var="redirectUrl" value="../entity">
|
|
||||||
<c:param name="uri" value="${param.subjectUri}"/>
|
|
||||||
</c:url>
|
|
||||||
<c:redirect url="${redirectUrl}${'#'}${localName}"/>
|
|
||||||
|
|
||||||
<% } else { %>
|
|
||||||
<jsp:include page="${preForm}"/>
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
|
|
||||||
<form action="editDatapropStmtRequestDispatch.jsp" method="get">
|
|
||||||
<label for="submit"><h2>Are you sure you want to delete the following entry from <em>${propertyName}</em>?</h2></label>
|
|
||||||
<div class="toBeDeleted dataProp"><%=dataValue%></div>
|
|
||||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<input type="hidden" name="datapropKey" value="${param.datapropKey}"/>
|
|
||||||
<input type="hidden" name="y" value="1"/>
|
|
||||||
<input type="hidden" name="cmd" value="delete"/>
|
|
||||||
<input type="hidden" name="vitroNsProp" value="${param.vitroNsProp}" />
|
|
||||||
<v:input type="submit" id="submit" value="Delete" cancel="true" />
|
|
||||||
</form>
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
||||||
<% }
|
|
||||||
} else {
|
|
||||||
throw new Error("In datapropStmtDelete.jsp, no match via hashcode to existing data property "+predicateUri+" for subject "+subject.getName()+"\n");
|
|
||||||
}%>
|
|
|
@ -1,265 +0,0 @@
|
||||||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
||||||
|
|
||||||
<%@ page import="java.util.List" %>
|
|
||||||
<%@ page import="java.util.ArrayList" %>
|
|
||||||
<%@ page import="java.util.Arrays" %>
|
|
||||||
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
|
||||||
<%@ 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.configuration.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" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
|
|
||||||
|
|
||||||
<%@ 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.dateTimeIntervalForm");
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
|
||||||
%>
|
|
||||||
|
|
||||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
|
||||||
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
|
|
||||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
|
||||||
<c:set var="label" value="${rdfs}label" />
|
|
||||||
|
|
||||||
<c:set var="toDateTimeInterval" value="${vivoCore}dateTimeInterval"/>
|
|
||||||
<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/>
|
|
||||||
<c:set var="intervalToStart" value="${vivoCore}start"/>
|
|
||||||
<c:set var="intervalToEnd" value="${vivoCore}end"/>
|
|
||||||
|
|
||||||
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
|
|
||||||
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
|
|
||||||
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
|
|
||||||
|
|
||||||
<%-- Assertions for adding a new interval --%>
|
|
||||||
<v:jsonset var="n3ForStart">
|
|
||||||
?subject <${toDateTimeInterval}> ?intervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToStart}> ?startNode .
|
|
||||||
?startNode <${type}> <${dateTimeValueType}> .
|
|
||||||
?startNode <${dateTimeValue}> ?startField-value .
|
|
||||||
?startNode <${dateTimePrecision}> ?startField-precision .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForEnd">
|
|
||||||
?subject <${toDateTimeInterval}> ?intervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToEnd}> ?endNode .
|
|
||||||
?endNode <${type}> <${dateTimeValueType}> .
|
|
||||||
?endNode <${dateTimeValue}> ?endField-value .
|
|
||||||
?endNode <${dateTimePrecision}> ?endField-precision .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- Queries for editing an existing role --%>
|
|
||||||
|
|
||||||
<v:jsonset var="existingIntervalNodeQuery" >
|
|
||||||
SELECT ?existingIntervalNode WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?existingIntervalNode <${type}> <${intervalType}> . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingStartNodeQuery" >
|
|
||||||
SELECT ?existingStartNode WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToStart}> ?existingStartNode .
|
|
||||||
?existingStartNode <${type}> <${dateTimeValueType}> .}
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingStartDateQuery" >
|
|
||||||
SELECT ?existingDateStart WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToStart}> ?startNode .
|
|
||||||
?startNode <${type}> <${dateTimeValueType}> .
|
|
||||||
?startNode <${dateTimeValue}> ?existingDateStart . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingStartPrecisionQuery" >
|
|
||||||
SELECT ?existingStartPrecision WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToStart}> ?startNode .
|
|
||||||
?startNode <${type}> <${dateTimeValueType}> .
|
|
||||||
?startNode <${dateTimePrecision}> ?existingStartPrecision . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
|
|
||||||
<v:jsonset var="existingEndNodeQuery" >
|
|
||||||
SELECT ?existingEndNode WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToEnd}> ?existingEndNode .
|
|
||||||
?existingEndNode <${type}> <${dateTimeValueType}> .}
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingEndDateQuery" >
|
|
||||||
SELECT ?existingEndDate WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToEnd}> ?endNode .
|
|
||||||
?endNode <${type}> <${dateTimeValueType}> .
|
|
||||||
?endNode <${dateTimeValue}> ?existingEndDate . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingEndPrecisionQuery" >
|
|
||||||
SELECT ?existingEndPrecision WHERE {
|
|
||||||
?subject <${toDateTimeInterval}> ?existingIntervalNode .
|
|
||||||
?intervalNode <${type}> <${intervalType}> .
|
|
||||||
?intervalNode <${intervalToEnd}> ?endNode .
|
|
||||||
?endNode <${type}> <${dateTimeValueType}> .
|
|
||||||
?endNode <${dateTimePrecision}> ?existingEndPrecision . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- Configure add vs. edit --%>
|
|
||||||
<%
|
|
||||||
|
|
||||||
String objectUri = (String) request.getAttribute("objectUri");
|
|
||||||
if (objectUri != null) { // editing existing entry
|
|
||||||
%>
|
|
||||||
<c:set var="editMode" value="edit" />
|
|
||||||
<c:set var="titleVerb" value="Edit" />
|
|
||||||
<c:set var="submitButtonText" value="Edit Date/Time Interval" />
|
|
||||||
<c:set var="disabledVal" value="disabled" />
|
|
||||||
<%
|
|
||||||
} else { // adding new entry
|
|
||||||
%>
|
|
||||||
<c:set var="editMode" value="add" />
|
|
||||||
<c:set var="titleVerb" value="Create" />
|
|
||||||
<c:set var="submitButtonText" value="Create Date/Time Interval" />
|
|
||||||
<c:set var="disabledVal" value="" />
|
|
||||||
<% } %>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"urlPatternToReturnTo" : "/entity",
|
|
||||||
|
|
||||||
"subject" : ["subject", "${subjectUriJson}" ],
|
|
||||||
"predicate" : ["toDateTimeInterval", "${predicateUriJson}" ],
|
|
||||||
"object" : ["intervalNode", "${objectUriJson}", "URI" ],
|
|
||||||
|
|
||||||
"n3required" : [ ],
|
|
||||||
|
|
||||||
"n3optional" : [ "${n3ForStart}", "${n3ForEnd}" ],
|
|
||||||
|
|
||||||
"newResources" : { "intervalNode" : "${defaultNamespace}",
|
|
||||||
"startNode" : "${defaultNamespace}",
|
|
||||||
"endNode" : "${defaultNamespace}" },
|
|
||||||
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope": { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : [ ],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { },
|
|
||||||
"sparqlForExistingLiterals" : {
|
|
||||||
"startField-value" : "${existingStartDateQuery}",
|
|
||||||
"endField-value" : "${existingEndDateQuery}"
|
|
||||||
},
|
|
||||||
"sparqlForExistingUris" : {
|
|
||||||
"intervalNode" : "${existingIntervalNodeQuery}",
|
|
||||||
"startNode" : "${existingStartNodeQuery}",
|
|
||||||
"endNode" : "${existingEndNodeQuery}",
|
|
||||||
"startField-precision": "${existingStartPrecisionQuery}",
|
|
||||||
"endField-precision" : "${existingEndPrecisionQuery}"
|
|
||||||
},
|
|
||||||
"fields" : {
|
|
||||||
"startField" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : [ ],
|
|
||||||
"optionsType" : "UNDEFINED",
|
|
||||||
"literalOptions" : [ ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "",
|
|
||||||
"rangeLang" : "",
|
|
||||||
"assertions" : ["${n3ForStart}"]
|
|
||||||
},
|
|
||||||
"endField" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : [ ],
|
|
||||||
"optionsType" : "UNDEFINED",
|
|
||||||
"literalOptions" : [ ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "",
|
|
||||||
"rangeLang" : "",
|
|
||||||
"assertions" : ["${n3ForEnd}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<%
|
|
||||||
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);
|
|
||||||
|
|
||||||
//setup date time edit elements
|
|
||||||
Field startField = editConfig.getField("startField");
|
|
||||||
// arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel])
|
|
||||||
startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri()));
|
|
||||||
Field endField = editConfig.getField("endField");
|
|
||||||
endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri()));
|
|
||||||
}
|
|
||||||
|
|
||||||
editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") );
|
|
||||||
|
|
||||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
|
||||||
|
|
||||||
if (objectUri != null) { // editing existing
|
|
||||||
editConfig.prepareForObjPropUpdate(model);
|
|
||||||
} else { // adding new
|
|
||||||
editConfig.prepareForNonUpdate(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
|
||||||
JavaScript.CUSTOM_FORM_UTILS.path()
|
|
||||||
));
|
|
||||||
request.setAttribute("customJs", customJs);
|
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
|
||||||
Css.CUSTOM_FORM.path()
|
|
||||||
));
|
|
||||||
request.setAttribute("customCss", customCss);
|
|
||||||
|
|
||||||
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
|
||||||
%>
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}" />
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
<h2>${titleVerb} date time interval for <%= subjectName %></h2>
|
|
||||||
|
|
||||||
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
||||||
|
|
||||||
<v:input id="startField" label="Start" />
|
|
||||||
<v:input id="endField" label="End" />
|
|
||||||
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,190 +0,0 @@
|
||||||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
||||||
|
|
||||||
<%@ page import="java.util.List" %>
|
|
||||||
<%@ page import="java.util.ArrayList" %>
|
|
||||||
<%@ page import="java.util.Arrays" %>
|
|
||||||
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
|
||||||
<%@ 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.configuration.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" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
|
|
||||||
|
|
||||||
<%@ page import="org.apache.commons.logging.Log" %>
|
|
||||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
|
|
||||||
|
|
||||||
<%@ 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.dateTimeValueForm");
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
|
||||||
%>
|
|
||||||
|
|
||||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
|
||||||
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
|
|
||||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
|
||||||
<c:set var="label" value="${rdfs}label" />
|
|
||||||
|
|
||||||
<c:set var="toDateTimeValue" value="${vivoCore}dateTimeValue"/>
|
|
||||||
<c:set var="valueType" value="${vivoCore}DateTimeValue"/>
|
|
||||||
|
|
||||||
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
|
|
||||||
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
|
|
||||||
|
|
||||||
<%-- Assertions for adding a new date time value --%>
|
|
||||||
<v:jsonset var="n3ForValue">
|
|
||||||
?subject <${toDateTimeValue}> ?valueNode .
|
|
||||||
?valueNode <${type}> <${valueType}> .
|
|
||||||
?valueNode <${dateTimeValue}> ?dateTimeField-value .
|
|
||||||
?valueNode <${dateTimePrecision}> ?dateTimeField-precision .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- Queries for editing an existing role --%>
|
|
||||||
<v:jsonset var="existingNodeQuery" >
|
|
||||||
SELECT ?existingNode WHERE {
|
|
||||||
?subject <${toDateTimeValue}> ?existingNode .
|
|
||||||
?existingNode <${type}> <${valueType}> . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingDateTimeValueQuery" >
|
|
||||||
SELECT ?existingDateTimeValue WHERE {
|
|
||||||
?subject <${toDateTimeValue}> ?existingValueNode .
|
|
||||||
?existingValueNode <${type}> <${valueType}> .
|
|
||||||
?existingValueNode <${dateTimeValue}> ?existingDateTimeValue . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="existingPrecisionQuery" >
|
|
||||||
SELECT ?existingPrecision WHERE {
|
|
||||||
?subject <${toDateTimeValue}> ?existingValueNode .
|
|
||||||
?existingValueNode <${type}> <${valueType}> .
|
|
||||||
?existingValueNode <${dateTimePrecision}> ?existingPrecision . }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
|
|
||||||
<%-- Configure add vs. edit --%>
|
|
||||||
<%
|
|
||||||
|
|
||||||
String objectUri = (String) request.getAttribute("objectUri");
|
|
||||||
if (objectUri != null) { // editing existing entry
|
|
||||||
%>
|
|
||||||
<c:set var="editMode" value="edit" />
|
|
||||||
<c:set var="titleVerb" value="Edit" />
|
|
||||||
<c:set var="submitButtonText" value="Edit Date/Time Value" />
|
|
||||||
<c:set var="disabledVal" value="disabled" />
|
|
||||||
<%
|
|
||||||
} else { // adding new entry
|
|
||||||
%>
|
|
||||||
<c:set var="editMode" value="add" />
|
|
||||||
<c:set var="titleVerb" value="Create" />
|
|
||||||
<c:set var="submitButtonText" value="Create Date/Time Value" />
|
|
||||||
<c:set var="disabledVal" value="" />
|
|
||||||
<% } %>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"urlPatternToReturnTo" : "/individual",
|
|
||||||
|
|
||||||
"subject" : ["subject", "${subjectUriJson}" ],
|
|
||||||
"predicate" : ["toDateTimeValue", "${predicateUriJson}" ],
|
|
||||||
"object" : ["valueNode", "${objectUriJson}", "URI" ],
|
|
||||||
|
|
||||||
"n3required" : [ ],
|
|
||||||
|
|
||||||
"n3optional" : [ "${n3ForValue}" ],
|
|
||||||
|
|
||||||
"newResources" : { "valueNode" : "${defaultNamespace}" },
|
|
||||||
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope": { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : [ ],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { },
|
|
||||||
"sparqlForExistingLiterals" : {
|
|
||||||
"dateTimeField-value" : "${existingDateTimeValueQuery}",
|
|
||||||
},
|
|
||||||
"sparqlForExistingUris" : {
|
|
||||||
"valueNode" : "${existingNodeQuery}",
|
|
||||||
"dateTimeField-precision": "${existingPrecisionQuery}"
|
|
||||||
},
|
|
||||||
"fields" : {
|
|
||||||
"dateTimeField" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : [ ],
|
|
||||||
"optionsType" : "UNDEFINED",
|
|
||||||
"literalOptions" : [ ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "",
|
|
||||||
"rangeLang" : "",
|
|
||||||
"assertions" : ["${n3ForValue}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<%
|
|
||||||
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);
|
|
||||||
|
|
||||||
//setup date time edit elements
|
|
||||||
Field dateTimeField = editConfig.getField("dateTimeField");
|
|
||||||
// arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel])
|
|
||||||
dateTimeField.setEditElement(new DateTimeWithPrecision(dateTimeField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
|
||||||
|
|
||||||
if (objectUri != null) { // editing existing
|
|
||||||
editConfig.prepareForObjPropUpdate(model);
|
|
||||||
} else { // adding new
|
|
||||||
editConfig.prepareForNonUpdate(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
|
||||||
JavaScript.CUSTOM_FORM_UTILS.path()
|
|
||||||
));
|
|
||||||
request.setAttribute("customJs", customJs);
|
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
|
||||||
Css.CUSTOM_FORM.path()
|
|
||||||
));
|
|
||||||
request.setAttribute("customCss", customCss);
|
|
||||||
|
|
||||||
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
|
||||||
%>
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}" />
|
|
||||||
|
|
||||||
<h2>${titleVerb} date time value for <%= subjectName %></h2>
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
||||||
|
|
||||||
<v:input id="dateTimeField" />
|
|
||||||
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,250 +0,0 @@
|
||||||
<%-- $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");
|
|
||||||
%>
|
|
||||||
|
|
||||||
<v:jsonset var="queryForInverse" >
|
|
||||||
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
|
||||||
SELECT ?inverse_property
|
|
||||||
WHERE {
|
|
||||||
?inverse_property owl:inverseOf ?predicate
|
|
||||||
}
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- 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 --%>
|
|
||||||
<v:jsonset var="nameExisting" >
|
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
||||||
SELECT ?existingName
|
|
||||||
WHERE { ?newIndividual rdfs:label ?existingName }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- 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) --%>
|
|
||||||
<v:jsonset var="n3ForName" >
|
|
||||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
||||||
?newIndividual rdfs:label ?name .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForRelation" >
|
|
||||||
?subject ?predicate ?newIndividual .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForType" >
|
|
||||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
||||||
?newIndividual rdf:type <${rangeClassUri}> .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForFlag" >
|
|
||||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
||||||
?newIndividual rdf:type <${flagURI}> .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- using v:jsonset here so everything goes through the same JSON escaping --%>
|
|
||||||
<v:jsonset var="n3AssertedTypes">
|
|
||||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
||||||
${n3AssertedTypesUnescaped}
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3Inverse" >
|
|
||||||
?newIndividual ?inverseProp ?subject .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- 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 --%>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"urlPatternToReturnTo" : "/entity",
|
|
||||||
|
|
||||||
"subject" : [ "subject", "${subjectUriJson}" ],
|
|
||||||
"predicate" : [ "predicate", "${predicateUriJson}" ],
|
|
||||||
"object" : [ "newIndividual", "${objectUriJson}", "URI" ],
|
|
||||||
|
|
||||||
"n3required" : [ "${n3ForName}" , "${n3ForRelation}", "${n3ForType}"],
|
|
||||||
"n3optional" : [ "${n3Inverse}", "${n3AssertedTypes}", "${n3ForFlag}" ],
|
|
||||||
"newResources" : {
|
|
||||||
"newIndividual" : "${defaultNamespace}individual"
|
|
||||||
},
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope" : { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : [ "name" ],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { "inverseProp" : "${queryForInverse}" },
|
|
||||||
"sparqlForExistingLiterals" : {
|
|
||||||
"name" : "${nameExisting}"
|
|
||||||
},
|
|
||||||
"sparqlForExistingUris" : { },
|
|
||||||
"fields" : {
|
|
||||||
"name" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : ["nonempty"],
|
|
||||||
"optionsType" : "UNDEFINED",
|
|
||||||
"literalOptions" : [ ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "",
|
|
||||||
"rangeLang" : "",
|
|
||||||
"assertions" : [ "${n3ForName}" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
<%
|
|
||||||
EditConfiguration editConfig = null;
|
|
||||||
if( ! isForwardToCreateNew )
|
|
||||||
editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
||||||
//else
|
|
||||||
// don't want to get the editConfig because it was for the defaultObjPropForm
|
|
||||||
|
|
||||||
if( editConfig == null ){
|
|
||||||
editConfig = new EditConfiguration((String)request.getAttribute("editjson"));
|
|
||||||
EditConfiguration.putConfigInSession(editConfig, session);
|
|
||||||
}
|
|
||||||
|
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
|
||||||
|
|
||||||
if( isReplaceWithNew){
|
|
||||||
// this is very specialized for the defaultAddMissingIndividual.jsp
|
|
||||||
// to support objPropStmt edits where the user wants to
|
|
||||||
// create a new Individual. Here we trick the processRdfForm2 into
|
|
||||||
// creating a new Individual and use the preprocessor to do the
|
|
||||||
// removal of the old objPropStmt
|
|
||||||
editConfig.addModelChangePreprocessor(
|
|
||||||
new DefaultAddMissingIndividualFormModelPreprocessor(
|
|
||||||
subject.getURI(),predicateUri ,objectUri ) );
|
|
||||||
editConfig.setObject(null);
|
|
||||||
editConfig.prepareForNonUpdate(model);
|
|
||||||
}else if ( isForwardToCreateButEdit) {
|
|
||||||
editConfig.prepareForObjPropUpdate(model);
|
|
||||||
}else if(request.getAttribute("object") != null ){
|
|
||||||
editConfig.prepareForObjPropUpdate(model);
|
|
||||||
} else{
|
|
||||||
editConfig.prepareForNonUpdate(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
String submitButtonLabel="";
|
|
||||||
/* title is used by pre and post form fragments */
|
|
||||||
//set title to Edit to maintain functionality from 1.1.1 and avoid updates to Selenium tests
|
|
||||||
request.setAttribute("title", "Edit");
|
|
||||||
if (objectUri != null) {
|
|
||||||
request.setAttribute("formTitle", "Edit \""+propDomainPublic+"\" entry for " + subject.getName());
|
|
||||||
submitButtonLabel = "Save changes";
|
|
||||||
} else {
|
|
||||||
request.setAttribute("formTitle","Create \""+propDomainPublic+"\" entry for " + subject.getName());
|
|
||||||
submitButtonLabel = "Create \""+propDomainPublic+"\" entry";
|
|
||||||
}
|
|
||||||
|
|
||||||
%>
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}">
|
|
||||||
<jsp:param name="useTinyMCE" value="false"/>
|
|
||||||
<jsp:param name="useAutoComplete" value="false"/>
|
|
||||||
</jsp:include>
|
|
||||||
|
|
||||||
<h2>${formTitle}</h2>
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" ><br/>
|
|
||||||
<v:input type="text" label="name (required)" id="name" size="30"/><br/>
|
|
||||||
<v:input type="submit" id="submit" value="<%=submitButtonLabel%>" cancel="true"/>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,176 +0,0 @@
|
||||||
<%-- $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.DataProperty" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
|
||||||
<%@ page import="java.util.HashMap"%>
|
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %>
|
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
|
||||||
<%! private static HashMap<String,String> defaultsForXSDtypes ;
|
|
||||||
static {
|
|
||||||
defaultsForXSDtypes = new HashMap<String,String>();
|
|
||||||
//defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","2001-01-01T12:00:00");
|
|
||||||
defaultsForXSDtypes.put("http://www.w3.org/2001/XMLSchema#dateTime","#Unparseable datetime defaults to now");
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultDatapropForm.jsp");
|
|
||||||
log.debug("Starting defaultDatapropForm.jsp");
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
String subjectUri = vreq.getParameter("subjectUri");
|
|
||||||
String predicateUri = vreq.getParameter("predicateUri");
|
|
||||||
|
|
||||||
DataPropertyStatement dps = (DataPropertyStatement)vreq.getAttribute("dataprop");
|
|
||||||
|
|
||||||
String datapropKeyStr = vreq.getParameter("datapropKey");
|
|
||||||
int dataHash=0;
|
|
||||||
|
|
||||||
DataProperty prop = (DataProperty)vreq.getAttribute("predicate");
|
|
||||||
if( prop == null ) throw new Error("In defaultDatapropForm.jsp, could not find predicate " + predicateUri);
|
|
||||||
vreq.setAttribute("propertyName",prop.getPublicName());
|
|
||||||
|
|
||||||
Individual subject = (Individual)vreq.getAttribute("subject");
|
|
||||||
if( subject == null ) throw new Error("In defaultDatapropForm.jsp, could not find subject " + subjectUri);
|
|
||||||
vreq.setAttribute("subjectName",subject.getName());
|
|
||||||
|
|
||||||
String rangeDatatypeUri = vreq.getWebappDaoFactory().getDataPropertyDao().getRequiredDatatypeURI(subject, prop);
|
|
||||||
//String rangeDatatypeUri = prop.getRangeDatatypeURI();
|
|
||||||
vreq.setAttribute("rangeDatatypeUriJson", MiscWebUtils.escape(rangeDatatypeUri));
|
|
||||||
|
|
||||||
if( dps != null ){
|
|
||||||
try {
|
|
||||||
dataHash = Integer.parseInt(datapropKeyStr);
|
|
||||||
log.debug("dataHash is " + dataHash);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
log.debug("could not parse dataprop hash "+
|
|
||||||
"but there was a dataproperty; hash: '"+datapropKeyStr+"'");
|
|
||||||
}
|
|
||||||
|
|
||||||
String rangeDatatype = dps.getDatatypeURI();
|
|
||||||
if( rangeDatatype == null ){
|
|
||||||
log.debug("no range datatype uri set on data property statement when property's range datatype is "+prop.getRangeDatatypeURI()+" in defaultDatapropForm.jsp");
|
|
||||||
vreq.setAttribute("rangeDatatypeUriJson","");
|
|
||||||
} else {
|
|
||||||
log.debug("range datatype uri of ["+rangeDatatype+"] on data property statement in defaultDatapropForm.jsp");
|
|
||||||
vreq.setAttribute("rangeDatatypeUriJson",rangeDatatype);
|
|
||||||
}
|
|
||||||
String rangeLang = dps.getLanguage();
|
|
||||||
if( rangeLang == null ) {
|
|
||||||
log.debug("no language attribute on data property statement in defaultDatapropForm.jsp");
|
|
||||||
vreq.setAttribute("rangeLangJson","");
|
|
||||||
}else{
|
|
||||||
log.debug("language attribute of ["+rangeLang+"] on data property statement in defaultDatapropForm.jsp");
|
|
||||||
vreq.setAttribute("rangeLangJson", rangeLang);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.debug("No incoming dataproperty statement attribute for property "+prop.getPublicName()+"; adding a new statement");
|
|
||||||
if(rangeDatatypeUri != null && rangeDatatypeUri.length() > 0) {
|
|
||||||
String defaultVal = defaultsForXSDtypes.get(rangeDatatypeUri);
|
|
||||||
if( defaultVal == null )
|
|
||||||
vreq.setAttribute("rangeDefaultJson", "");
|
|
||||||
else
|
|
||||||
vreq.setAttribute("rangeDefaultJson", '"' + MiscWebUtils.escape(defaultVal) + '"' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
%>
|
|
||||||
<c:set var="localName" value="<%=prop.getLocalName()%>"/>
|
|
||||||
<c:set var="dataLiteral" value="${localName}Edited"/>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForEdit" >
|
|
||||||
?subject ?predicate ?${dataLiteral}.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"datapropKey" : "<%=datapropKeyStr==null?"":datapropKeyStr%>",
|
|
||||||
"urlPatternToReturnTo" : "/entity",
|
|
||||||
|
|
||||||
"subject" : ["subject", "${subjectUriJson}" ],
|
|
||||||
"predicate" : ["predicate", "${predicateUriJson}"],
|
|
||||||
"object" : ["${dataLiteral}","","DATAPROPHASH"],
|
|
||||||
|
|
||||||
"n3required" : ["${n3ForEdit}"],
|
|
||||||
"n3optional" : [ ],
|
|
||||||
"newResources" : { },
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope" : { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : ["${dataLiteral}"],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { },
|
|
||||||
"sparqlForExistingLiterals" : { },
|
|
||||||
"sparqlForExistingUris" : { },
|
|
||||||
"optionsForFields" : { },
|
|
||||||
"fields" : { "${dataLiteral}" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : ["datatype:${rangeDatatypeUriJson}"],
|
|
||||||
"optionsType" : "LITERALS",
|
|
||||||
"literalOptions" : [ ${rangeDefaultJson} ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "${rangeDatatypeUriJson}",
|
|
||||||
"rangeLang" : "${rangeLangJson}",
|
|
||||||
"assertions" : ["${n3ForEdit}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<%
|
|
||||||
if( log.isDebugEnabled()) log.debug(request.getAttribute("editjson"));
|
|
||||||
|
|
||||||
EditConfiguration editConfig = new EditConfiguration((String)vreq.getAttribute("editjson"));
|
|
||||||
EditConfiguration.putConfigInSession(editConfig, session);
|
|
||||||
|
|
||||||
String formTitle =""; // don't add local page variables to the request
|
|
||||||
String submitLabel ="";
|
|
||||||
|
|
||||||
if( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
|
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
|
||||||
editConfig.prepareForDataPropUpdate(model,dps);
|
|
||||||
formTitle = "Change text for: <em>"+prop.getPublicName()+"</em>";
|
|
||||||
submitLabel = "Save change";
|
|
||||||
} else {
|
|
||||||
formTitle ="Add new entry for: <em>"+prop.getPublicName()+"</em>";
|
|
||||||
submitLabel ="Save entry";
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
|
|
||||||
<%--the following parameters configure the tinymce textarea --%>
|
|
||||||
<jsp:include page="${preForm}">
|
|
||||||
<jsp:param name="useTinyMCE" value="true"/>
|
|
||||||
</jsp:include>
|
|
||||||
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
|
|
||||||
<h2><%=formTitle%></h2>
|
|
||||||
<form class="editForm" action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" method="post" > <%-- see VITRO-435 Jira issue: need POST, not GET --%>
|
|
||||||
<c:if test="${!empty predicate.publicDescription}">
|
|
||||||
<label for="${dataLiteral}"><p class="propEntryHelpText">${predicate.publicDescription}</p></label>
|
|
||||||
</c:if>
|
|
||||||
<v:input type="textarea" id="${dataLiteral}" rows="2"/>
|
|
||||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<c:if test="${ (!empty param.datapropKey) && (empty param.deleteProhibited) }">
|
|
||||||
<form class="deleteForm" action="editDatapropStmtRequestDispatch.jsp" method="post">
|
|
||||||
<label for="delete"><h3>Delete this entry?</h3></label>
|
|
||||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<input type="hidden" name="datapropKey" value="${param.datapropKey}"/>
|
|
||||||
<input type="hidden" name="cmd" value="delete"/>
|
|
||||||
<v:input type="submit" id="delete" value="Delete" cancel="" />
|
|
||||||
</form>
|
|
||||||
</c:if>
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,223 +0,0 @@
|
||||||
<%-- $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.configuration.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.configuration.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"%>
|
|
||||||
|
|
||||||
<v:jsonset var="queryForInverse" >
|
|
||||||
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
|
||||||
SELECT ?inverse_property
|
|
||||||
WHERE {
|
|
||||||
?inverse_property owl:inverseOf ?predicate
|
|
||||||
}
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForEdit" >
|
|
||||||
?subject ?predicate ?objectVar.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3Inverse" >
|
|
||||||
?objectVar ?inverseProp ?subject.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"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}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<%
|
|
||||||
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: <em>"+prop.getDomainPublic()+"</em>";
|
|
||||||
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<VClass> 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: <em>"+prop.getDomainPublic()+"</em>";
|
|
||||||
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.SEARCH_INDEX_URI, displayOntModel);
|
|
||||||
if( editConfig != null )
|
|
||||||
editConfig.setProhibitedFromSearch(pfs);
|
|
||||||
}
|
|
||||||
Map<String,String> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
<jsp:include page="${preForm}"/>
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
<h2><%=formTitle%></h2>
|
|
||||||
|
|
||||||
<c:if test="${requestScope.predicate.selectFromExisting == true }">
|
|
||||||
<c:if test="${requestScope.rangeOptionsExist == true }">
|
|
||||||
<form class="editForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
||||||
<c:if test="${!empty predicate.publicDescription}">
|
|
||||||
<p>${predicate.publicDescription}</p>
|
|
||||||
</c:if>
|
|
||||||
<v:input type="select" id="objectVar" size="80" />
|
|
||||||
<div style="margin-top: .2em">
|
|
||||||
<v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</c:if>
|
|
||||||
<c:set var="offerCancel" value="false"/>
|
|
||||||
<c:if test="${requestScope.rangeOptionsExist == false }">
|
|
||||||
<c:set var="offerCancel" value="true"/>
|
|
||||||
<p>There are no entries in the system to select from.</p>
|
|
||||||
</c:if>
|
|
||||||
</c:if>
|
|
||||||
|
|
||||||
<c:if test="${requestScope.predicate.offerCreateNewOption == true}">
|
|
||||||
<c:if test="${requestScope.rangeOptionsExist == true }">
|
|
||||||
<p style="margin-top: 2.2em">If you don't find the appropriate entry on the selection list above:</p>
|
|
||||||
</c:if>
|
|
||||||
<c:if test="${requestScope.rangeOptionsExist == false }">
|
|
||||||
<p style="margin-top: 5em">Please create a new entry.</p>
|
|
||||||
</c:if>
|
|
||||||
<c:url var="createNewUrl" value="/edit/editRequestDispatch.jsp"/>
|
|
||||||
<form class="editForm" action="${createNewUrl}">
|
|
||||||
<input type="hidden" value="${param.subjectUri}" name="subjectUri"/>
|
|
||||||
<input type="hidden" value="${param.predicateUri}" name="predicateUri"/>
|
|
||||||
<input type="hidden" value="${param.objectUri}" name="objectUri"/>
|
|
||||||
<input type="hidden" value="create" name="cmd"/>
|
|
||||||
<v:input type="typesForCreateNew" id="typeOfNew" />
|
|
||||||
<v:input type="submit" id="submit" value="Add a new item of this type" cancel="${offerCancel}"/>
|
|
||||||
</form>
|
|
||||||
</c:if>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<c:if test="${(requestScope.predicate.offerCreateNewOption == false) && (requestScope.predicate.selectFromExisting == false)}">
|
|
||||||
<p>This property is currently configured to prohibit editing. </p>
|
|
||||||
</c:if>
|
|
||||||
|
|
||||||
<c:if test="${ (!empty param.objectUri) && (empty param.deleteProhibited) }" >
|
|
||||||
<form class="deleteForm" action="editRequestDispatch.jsp" method="get">
|
|
||||||
<label for="delete"><h3 class="delete-entry">Delete this entry?</h3></label>
|
|
||||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<input type="hidden" name="objectUri" value="${param.objectUri}"/>
|
|
||||||
<input type="hidden" name="cmd" value="delete"/>
|
|
||||||
<c:if test="${(requestScope.predicate.offerCreateNewOption == false) && (requestScope.predicate.selectFromExisting == false)}">
|
|
||||||
<v:input type="submit" id="delete" value="Delete" cancel="cancel" />
|
|
||||||
</c:if>
|
|
||||||
<c:if test="${(requestScope.predicate.offerCreateNewOption == true) || (requestScope.predicate.selectFromExisting == true)}">
|
|
||||||
<v:input type="submit" id="delete" value="Delete" cancel="" />
|
|
||||||
</c:if>
|
|
||||||
</form>
|
|
||||||
</c:if>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,136 +0,0 @@
|
||||||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
||||||
|
|
||||||
<%-- Custom form for adding a new Individual from the siteAdmin page.
|
|
||||||
|
|
||||||
This form is not associated with an object property, it is reached because the
|
|
||||||
html:form on dataInput.jsp has an input element like:
|
|
||||||
<input type="hidden" name="editForm" value="newIndividualForm.jsp"/>
|
|
||||||
|
|
||||||
This form is intended to only do the addition of an individual. It is not configured with sparql
|
|
||||||
for existing so it cannot handle an update. It will not have a subject, predicate or object
|
|
||||||
parameter set up by editRequestDispatch.
|
|
||||||
|
|
||||||
--%>
|
|
||||||
|
|
||||||
<%@ page import="java.util.List" %>
|
|
||||||
<%@ page import="java.util.ArrayList" %>
|
|
||||||
<%@ page import="java.util.Arrays" %>
|
|
||||||
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
|
||||||
<%@ 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.VClass"%>
|
|
||||||
<%@ 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.configuration.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="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.newIndividualForm");
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
|
||||||
|
|
||||||
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
|
||||||
|
|
||||||
VClass type = wdf.getVClassDao().getVClassByURI(vreq.getParameter("typeOfNew"));
|
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList("/edit/forms/css/customForm.css"
|
|
||||||
));
|
|
||||||
request.setAttribute("customCss", customCss);
|
|
||||||
%>
|
|
||||||
|
|
||||||
<c:set var="typeName" ><%= type.getName() %></c:set>
|
|
||||||
|
|
||||||
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
|
||||||
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForType">
|
|
||||||
@prefix rdf: <${rdf}> .
|
|
||||||
?newInd rdf:type <${param.typeOfNew}> .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<v:jsonset var="n3ForRdfsLabel">
|
|
||||||
@prefix rdfs: <${rdfs}> .
|
|
||||||
?newInd rdfs:label ?label .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"urlPatternToReturnTo" : "/individual",
|
|
||||||
|
|
||||||
"subject" : ["subjectNotUsed", "" ],
|
|
||||||
"predicate" : ["predicateNotUsed", "" ],
|
|
||||||
"object" : ["objectNotUsed", "", "URI" ],
|
|
||||||
|
|
||||||
"n3required" : [ "${n3ForType}" ],
|
|
||||||
|
|
||||||
"n3optional" : [ "${n3ForRdfsLabel}" ],
|
|
||||||
|
|
||||||
"newResources" : { "newInd" : "${defaultNamespace}" },
|
|
||||||
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope": { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : [ "label", "firstName", "lastName" ],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { },
|
|
||||||
"sparqlForExistingLiterals" : { },
|
|
||||||
"sparqlForExistingUris" : { },
|
|
||||||
"fields" : {
|
|
||||||
"label" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : [ "nonempty" ],
|
|
||||||
"optionsType" : "UNDEFINED",
|
|
||||||
"literalOptions" : [ ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
|
||||||
"rangeLang" : "",
|
|
||||||
"assertions" : [ ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
<%
|
|
||||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
||||||
if (editConfig == null) {
|
|
||||||
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
|
|
||||||
EditConfiguration.putConfigInSession(editConfig,session);
|
|
||||||
}
|
|
||||||
editConfig.setEntityToReturnTo("?newInd");
|
|
||||||
|
|
||||||
//this form always is always doing a non-update:
|
|
||||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
|
||||||
editConfig.prepareForNonUpdate(model);
|
|
||||||
%>
|
|
||||||
|
|
||||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}" />
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
<h2>Create a new ${typeName}</h2>
|
|
||||||
|
|
||||||
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
||||||
<v:input type="text" label="Name ${requiredHint}" id="label" size="30" />
|
|
||||||
|
|
||||||
<c:set var="submitLabel" value="Create ${typeName}" />
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true" cancelUrl="/siteAdmin" /></p>
|
|
||||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,155 +0,0 @@
|
||||||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
||||||
|
|
||||||
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle"%>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.identifier.RoleIdentifier"%>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils"%>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement"%>
|
|
||||||
<%@ 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.dao.VitroVocabulary" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils" %>
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfigurationLoader"%>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfiguration" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet"%>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper"%>
|
|
||||||
|
|
||||||
<%@page import="freemarker.template.Configuration"%>
|
|
||||||
|
|
||||||
<%@ page import="java.util.List" %>
|
|
||||||
<%@ page import="java.util.Map" %>
|
|
||||||
<%@ page import="java.util.HashMap" %>
|
|
||||||
|
|
||||||
<%@ 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" %>
|
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jstl/functions" %>
|
|
||||||
|
|
||||||
<%@taglib prefix="vitro" uri="/WEB-INF/tlds/VitroUtils.tld" %>
|
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission" %>
|
|
||||||
<% request.setAttribute("requestedActions", SimplePermission.USE_MISCELLANEOUS_PAGES.ACTION); %>
|
|
||||||
<vitro:confirmAuthorization />
|
|
||||||
|
|
||||||
<%!
|
|
||||||
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.propDelete.jsp");
|
|
||||||
|
|
||||||
public WebappDaoFactory getUnfilteredDaoFactory() {
|
|
||||||
return (WebappDaoFactory) getServletContext().getAttribute("webappDaoFactory");
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
|
|
||||||
<%-- grab the predicate URI and trim it down to get the Local Name so we can send the user back to the appropriate property --%>
|
|
||||||
<c:set var="predicateUri" value="${param.predicateUri}" />
|
|
||||||
<c:set var="localName" value="${fn:substringAfter(predicateUri, '#')}" />
|
|
||||||
<c:url var="redirectUrl" value="../entity">
|
|
||||||
<c:param name="uri" value="${param.subjectUri}"/>
|
|
||||||
</c:url>
|
|
||||||
|
|
||||||
<%
|
|
||||||
String subjectUri = request.getParameter("subjectUri");
|
|
||||||
String predicateUri = request.getParameter("predicateUri");
|
|
||||||
String objectUri = request.getParameter("objectUri");
|
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
if( wdf == null ) {
|
|
||||||
throw new Error("could not get a WebappDaoFactory");
|
|
||||||
}
|
|
||||||
ObjectProperty prop = wdf.getObjectPropertyDao().getObjectPropertyByURI(predicateUri);
|
|
||||||
if( prop == null ) {
|
|
||||||
throw new Error("In propDelete.jsp, could not find property " + predicateUri);
|
|
||||||
}
|
|
||||||
request.setAttribute("propertyName",prop.getDomainPublic().toLowerCase());
|
|
||||||
|
|
||||||
//do the delete
|
|
||||||
if( request.getParameter("y") != null ) {
|
|
||||||
|
|
||||||
String editorUri = EditN3Utils.getEditorUri(request);
|
|
||||||
wdf = wdf.getUserAwareDaoFactory(editorUri);
|
|
||||||
|
|
||||||
if (prop.getStubObjectRelation()) {
|
|
||||||
Individual object = (Individual)request.getAttribute("object");
|
|
||||||
if (object==null) {
|
|
||||||
object = getUnfilteredDaoFactory().getIndividualDao().getIndividualByURI(objectUri);
|
|
||||||
}
|
|
||||||
if( object != null ) {
|
|
||||||
log.warn("Deleting individual "+object.getName()+" since property has been set to force range object deletion");
|
|
||||||
wdf.getIndividualDao().deleteIndividual(object);
|
|
||||||
} else {
|
|
||||||
throw new Error("Could not find object as request attribute or in model: '" + objectUri + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement(subjectUri,predicateUri,objectUri); %>
|
|
||||||
<c:redirect url="${redirectUrl}${'#'}${localName}"/>
|
|
||||||
<% }
|
|
||||||
|
|
||||||
Individual subject = wdf.getIndividualDao().getIndividualByURI(subjectUri);
|
|
||||||
if( subject == null ) throw new Error("could not find subject " + subjectUri);
|
|
||||||
request.setAttribute("subjectName",subject.getName());
|
|
||||||
|
|
||||||
// Get the statement data to be displayed
|
|
||||||
String templateName = request.getParameter("templateName");
|
|
||||||
Map params = request.getParameterMap();
|
|
||||||
Map<String, String> statement = new HashMap<String, String>();
|
|
||||||
for (Object key : params.keySet()) {
|
|
||||||
String keyString = (String) key; //key.toString()
|
|
||||||
if (keyString.startsWith("statement_")) {
|
|
||||||
keyString = keyString.replaceFirst("statement_", "");
|
|
||||||
String value = ( (String[]) params.get(key))[0];
|
|
||||||
statement.put(keyString, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the statement data through the template to create the display string
|
|
||||||
String statementDisplay = null;
|
|
||||||
if (! statement.isEmpty()) {
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
|
||||||
map.put("statement", statement);
|
|
||||||
|
|
||||||
/* Some propStatements (propStatement-educationalTraining.ftl) make reference to the individual,
|
|
||||||
* but instead of adding it to the data model we'll test in the template for non-existence. If
|
|
||||||
* this becomes more common, add it here instead. We don't want to generate the property
|
|
||||||
* list for the individual, though, so should modify IndividualTemplateModel to make that
|
|
||||||
* conditional, or perhaps use a different template model that contains only the limited
|
|
||||||
* information needed in the propStatement templates.
|
|
||||||
*/
|
|
||||||
//map.put("individual", new IndividualTemplateModel(subject, vreq));
|
|
||||||
|
|
||||||
//map.putAll(FreemarkerHttpServlet.getDirectives());
|
|
||||||
//map.putAll(FreemarkerHttpServlet.getMethods());
|
|
||||||
ServletContext context = getServletContext();
|
|
||||||
FreemarkerConfiguration fmConfig = FreemarkerConfigurationLoader.getConfig(vreq, context);
|
|
||||||
fmConfig.resetRequestSpecificSharedVariables();
|
|
||||||
TemplateProcessingHelper helper = new TemplateProcessingHelper(fmConfig, vreq, context);
|
|
||||||
statementDisplay = helper.processTemplateToString(templateName, map);
|
|
||||||
}
|
|
||||||
request.setAttribute("statementDisplay", statementDisplay);
|
|
||||||
%>
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}"/>
|
|
||||||
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
|
|
||||||
<form action="editRequestDispatch.jsp" method="get">
|
|
||||||
<label for="submit"><h2>Are you sure you want to delete the following entry from <em>${propertyName}</em>?</h2></label>
|
|
||||||
<div class="toBeDeleted objProp">${statementDisplay}</div>
|
|
||||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<input type="hidden" name="objectUri" value="${param.objectUri}"/>
|
|
||||||
<input type="hidden" name="y" value="1"/>
|
|
||||||
<input type="hidden" name="cmd" value="delete"/>
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="Delete" cancel="true" /></p>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
|
@ -1,189 +0,0 @@
|
||||||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
|
||||||
|
|
||||||
<%@ page import="java.util.ArrayList"%>
|
|
||||||
<%@ page import="java.util.Arrays"%>
|
|
||||||
|
|
||||||
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
|
||||||
<%@ 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.configuration.EditConfiguration"%>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash"%>
|
|
||||||
<%@ 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.beans.DataPropertyStatement" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
|
||||||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils" %>
|
|
||||||
|
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
|
||||||
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
||||||
|
|
||||||
<%
|
|
||||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.rdfLabelForm.jsp");
|
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
|
|
||||||
|
|
||||||
String subjectUri = vreq.getParameter("subjectUri");
|
|
||||||
String predicateUri = vreq.getParameter("predicateUri");
|
|
||||||
|
|
||||||
log.debug("Starting rdfsLabelForm.jsp");
|
|
||||||
|
|
||||||
DataPropertyStatement dps = (DataPropertyStatement)vreq.getAttribute("dataprop");
|
|
||||||
|
|
||||||
String datapropKeyStr = vreq.getParameter("datapropKey");
|
|
||||||
|
|
||||||
Individual subject = (Individual)vreq.getAttribute("subject");
|
|
||||||
if( subject == null ) {
|
|
||||||
throw new Error("In rdfsLabelForm.jsp, could not find subject " + subjectUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
|
||||||
|
|
||||||
// Get datatype and language for the data property statement
|
|
||||||
String rangeDatatypeUri = null,
|
|
||||||
rangeLang = null;
|
|
||||||
|
|
||||||
if (dps != null) {
|
|
||||||
|
|
||||||
rangeDatatypeUri = dps.getDatatypeURI();
|
|
||||||
if (rangeDatatypeUri == null) {
|
|
||||||
log.debug("no range datatype uri set on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
|
||||||
} else {
|
|
||||||
log.debug("range datatype uri of [" + rangeDatatypeUri + "] on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
|
||||||
}
|
|
||||||
|
|
||||||
rangeLang = dps.getLanguage();
|
|
||||||
if( rangeLang == null ) {
|
|
||||||
log.debug("no language attribute on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
|
||||||
rangeLang = "";
|
|
||||||
} else {
|
|
||||||
log.debug("language attribute of ["+rangeLang+"] on rdfs:label statement for property " + predicateUri + "in rdfsLabelForm.jsp");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log.debug("No incoming rdfs:label statement for property "+predicateUri+"; adding a new statement");
|
|
||||||
rangeDatatypeUri = XSD.xstring.getURI();
|
|
||||||
}
|
|
||||||
|
|
||||||
String rangeDatatypeUriJson = rangeDatatypeUri == null ? "" : MiscWebUtils.escape(rangeDatatypeUri);
|
|
||||||
|
|
||||||
vreq.setAttribute("rangeDatatypeUriJson", rangeDatatypeUriJson);
|
|
||||||
vreq.setAttribute("rangeLangJson", rangeLang);
|
|
||||||
|
|
||||||
// Create list of validators
|
|
||||||
ArrayList<String> validatorList = new ArrayList<String>();
|
|
||||||
if (predicateUri.equals(VitroVocabulary.LABEL) || predicateUri.equals(VitroVocabulary.RDF_TYPE)) {
|
|
||||||
validatorList.add("\"nonempty\"");
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(rangeDatatypeUriJson)) {
|
|
||||||
validatorList.add("\"datatype:" + rangeDatatypeUriJson + "\"");
|
|
||||||
}
|
|
||||||
vreq.setAttribute("validators", StringUtils.join(validatorList, ","));
|
|
||||||
|
|
||||||
%>
|
|
||||||
|
|
||||||
<c:set var="predicate" value="<%=predicateUri%>" />
|
|
||||||
|
|
||||||
<%-- 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) --%>
|
|
||||||
<v:jsonset var="dataAssertion" >
|
|
||||||
?subject <${predicate}> ?label .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="editjson" scope="request">
|
|
||||||
{
|
|
||||||
"formUrl" : "${formUrl}",
|
|
||||||
"editKey" : "${editKey}",
|
|
||||||
"datapropKey" : "<%= datapropKeyStr == null ? "" : datapropKeyStr %>",
|
|
||||||
"urlPatternToReturnTo" : "/entity",
|
|
||||||
|
|
||||||
"subject" : ["subject", "${subjectUriJson}" ],
|
|
||||||
"predicate" : ["predicate", "${predicateUriJson}" ],
|
|
||||||
"object" : ["label", "", "DATAPROPHASH" ],
|
|
||||||
|
|
||||||
"n3required" : [ "${dataAssertion}" ],
|
|
||||||
"n3optional" : [ ],
|
|
||||||
"newResources" : { },
|
|
||||||
"urisInScope" : { },
|
|
||||||
"literalsInScope": { },
|
|
||||||
"urisOnForm" : [ ],
|
|
||||||
"literalsOnForm" : [ "label" ],
|
|
||||||
"filesOnForm" : [ ],
|
|
||||||
"sparqlForLiterals" : { },
|
|
||||||
"sparqlForUris" : { },
|
|
||||||
"sparqlForExistingLiterals" : { },
|
|
||||||
"sparqlForExistingUris" : { },
|
|
||||||
"fields" : {
|
|
||||||
"label" : {
|
|
||||||
"newResource" : "false",
|
|
||||||
"validators" : [ ${validators} ],
|
|
||||||
"optionsType" : "UNDEFINED",
|
|
||||||
"literalOptions" : [ ],
|
|
||||||
"predicateUri" : "",
|
|
||||||
"objectClassUri" : "",
|
|
||||||
"rangeDatatypeUri" : "${rangeDatatypeUriJson}",
|
|
||||||
"rangeLang" : "${rangeLangJson}",
|
|
||||||
"assertions" : [ "${dataAssertion}" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</c:set>
|
|
||||||
|
|
||||||
<%
|
|
||||||
if( log.isDebugEnabled()) log.debug(request.getAttribute("editjson"));
|
|
||||||
|
|
||||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
||||||
if (editConfig == null) {
|
|
||||||
log.debug("No editConfig in session. Making new editConfig.");
|
|
||||||
log.debug(vreq.getAttribute("editjson"));
|
|
||||||
editConfig = new EditConfiguration((String)vreq.getAttribute("editjson"));
|
|
||||||
EditConfiguration.putConfigInSession(editConfig, session);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( datapropKeyStr != null && datapropKeyStr.trim().length() > 0 ) {
|
|
||||||
editConfig.prepareForDataPropUpdate(model,dps);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure form
|
|
||||||
String actionText = dps == null ? "Add new " : "Edit ";
|
|
||||||
String submitLabel = actionText + "label";
|
|
||||||
String title = actionText + "<em>label</em> for " + subject.getName();
|
|
||||||
|
|
||||||
%>
|
|
||||||
|
|
||||||
<jsp:include page="${preForm}">
|
|
||||||
<jsp:param name="useTinyMCE" value="false"/>
|
|
||||||
</jsp:include>
|
|
||||||
|
|
||||||
<h1>JSP form, must be removed for the 1.4!</h1>
|
|
||||||
|
|
||||||
<h2><%= title %></h2>
|
|
||||||
<form action="<c:url value="/edit/processDatapropRdfForm.jsp"/>" >
|
|
||||||
<v:input type="text" id="label" size="30" />
|
|
||||||
<input type="hidden" name="vitroNsProp" value="true" />
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="<%= submitLabel %>" cancel="true"/></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<c:if test="${ (!empty param.datapropKey) && (empty param.deleteProhibited) }">
|
|
||||||
<form class="deleteForm" action="editDatapropStmtRequestDispatch.jsp" method="post">
|
|
||||||
<label for="delete"><h3>Delete this entry?</h3></label>
|
|
||||||
<input type="hidden" name="subjectUri" value="${param.subjectUri}"/>
|
|
||||||
<input type="hidden" name="predicateUri" value="${param.predicateUri}"/>
|
|
||||||
<input type="hidden" name="datapropKey" value="${param.datapropKey}"/>
|
|
||||||
<input type="hidden" name="cmd" value="delete"/>
|
|
||||||
<input type="hidden" name="vitroNsProp" value="true" />
|
|
||||||
<v:input type="submit" id="delete" value="Delete" cancel="" />
|
|
||||||
</form>
|
|
||||||
</c:if>
|
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue