2011-01-19 17:35:22 +00:00
|
|
|
<%-- $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"%>
|
2011-05-12 16:02:37 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration"%>
|
2011-01-19 17:35:22 +00:00
|
|
|
<%@ 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"%>
|
2011-05-12 16:02:37 +00:00
|
|
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
|
2011-01-19 17:35:22 +00:00
|
|
|
|
|
|
|
<%@ page import="org.apache.commons.logging.Log" %>
|
|
|
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
2011-05-12 16:02:37 +00:00
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
|
2011-01-19 17:35:22 +00:00
|
|
|
|
|
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
|
|
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
|
|
|
|
2011-01-21 20:18:05 +00:00
|
|
|
<%!
|
2011-01-19 17:35:22 +00:00
|
|
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.dateTimeValueForm");
|
|
|
|
%>
|
|
|
|
<%
|
|
|
|
VitroRequest vreq = new VitroRequest(request);
|
2011-01-21 20:18:05 +00:00
|
|
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
|
|
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
|
2011-01-19 17:35:22 +00:00
|
|
|
%>
|
|
|
|
|
2011-01-19 17:40:33 +00:00
|
|
|
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
2011-01-19 17:35:22 +00:00
|
|
|
<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 --%>
|
2011-01-21 20:18:05 +00:00
|
|
|
<v:jsonset var="n3ForValue">
|
|
|
|
?subject <${toDateTimeValue}> ?valueNode .
|
|
|
|
?valueNode <${type}> <${valueType}> .
|
2011-02-21 16:09:40 +00:00
|
|
|
?valueNode <${dateTimeValue}> ?dateTimeField-value .
|
|
|
|
?valueNode <${dateTimePrecision}> ?dateTimeField-precision .
|
2011-01-19 17:35:22 +00:00
|
|
|
</v:jsonset>
|
|
|
|
|
|
|
|
<%-- Queries for editing an existing role --%>
|
2011-01-21 20:18:05 +00:00
|
|
|
<v:jsonset var="existingNodeQuery" >
|
2011-01-19 17:35:22 +00:00
|
|
|
SELECT ?existingNode WHERE {
|
|
|
|
?subject <${toDateTimeValue}> ?existingNode .
|
|
|
|
?existingNode <${type}> <${valueType}> . }
|
|
|
|
</v:jsonset>
|
2011-01-21 20:18:05 +00:00
|
|
|
|
|
|
|
<v:jsonset var="existingDateTimeValueQuery" >
|
|
|
|
SELECT ?existingDateTimeValue WHERE {
|
|
|
|
?subject <${toDateTimeValue}> ?existingValueNode .
|
|
|
|
?existingValueNode <${type}> <${valueType}> .
|
2011-01-19 17:35:22 +00:00
|
|
|
?existingValueNode <${dateTimeValue}> ?existingDateTimeValue . }
|
|
|
|
</v:jsonset>
|
|
|
|
|
2011-01-21 20:18:05 +00:00
|
|
|
<v:jsonset var="existingPrecisionQuery" >
|
|
|
|
SELECT ?existingPrecision WHERE {
|
|
|
|
?subject <${toDateTimeValue}> ?existingValueNode .
|
|
|
|
?existingValueNode <${type}> <${valueType}> .
|
2011-01-19 17:35:22 +00:00
|
|
|
?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" />
|
2011-01-21 20:18:05 +00:00
|
|
|
<c:set var="submitButtonText" value="Edit Date/Time Value" />
|
2011-01-19 17:35:22 +00:00
|
|
|
<c:set var="disabledVal" value="disabled" />
|
|
|
|
<%
|
|
|
|
} else { // adding new entry
|
|
|
|
%>
|
|
|
|
<c:set var="editMode" value="add" />
|
|
|
|
<c:set var="titleVerb" value="Create" />
|
2011-01-21 20:18:05 +00:00
|
|
|
<c:set var="submitButtonText" value="Create Date/Time Value" />
|
2011-01-19 17:35:22 +00:00
|
|
|
<c:set var="disabledVal" value="" />
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<c:set var="editjson" scope="request">
|
|
|
|
{
|
|
|
|
"formUrl" : "${formUrl}",
|
|
|
|
"editKey" : "${editKey}",
|
|
|
|
"urlPatternToReturnTo" : "/individual",
|
2011-01-21 20:18:05 +00:00
|
|
|
|
2011-01-19 17:35:22 +00:00
|
|
|
"subject" : ["subject", "${subjectUriJson}" ],
|
|
|
|
"predicate" : ["toDateTimeValue", "${predicateUriJson}" ],
|
|
|
|
"object" : ["valueNode", "${objectUriJson}", "URI" ],
|
2011-01-21 20:18:05 +00:00
|
|
|
|
|
|
|
"n3required" : [ ],
|
|
|
|
|
|
|
|
"n3optional" : [ "${n3ForValue}" ],
|
|
|
|
|
2011-01-19 17:35:22 +00:00
|
|
|
"newResources" : { "valueNode" : "${defaultNamespace}" },
|
2011-01-21 20:18:05 +00:00
|
|
|
|
2011-01-19 17:35:22 +00:00
|
|
|
"urisInScope" : { },
|
|
|
|
"literalsInScope": { },
|
|
|
|
"urisOnForm" : [ ],
|
2011-01-21 20:18:05 +00:00
|
|
|
"literalsOnForm" : [ ],
|
2011-01-19 17:35:22 +00:00
|
|
|
"filesOnForm" : [ ],
|
|
|
|
"sparqlForLiterals" : { },
|
|
|
|
"sparqlForUris" : { },
|
|
|
|
"sparqlForExistingLiterals" : {
|
2011-02-21 16:09:40 +00:00
|
|
|
"dateTimeField-value" : "${existingDateTimeValueQuery}",
|
2011-01-19 17:35:22 +00:00
|
|
|
},
|
|
|
|
"sparqlForExistingUris" : {
|
2011-01-21 20:18:05 +00:00
|
|
|
"valueNode" : "${existingNodeQuery}",
|
2011-02-21 16:09:40 +00:00
|
|
|
"dateTimeField-precision": "${existingPrecisionQuery}"
|
2011-01-19 17:35:22 +00:00
|
|
|
},
|
|
|
|
"fields" : {
|
|
|
|
"dateTimeField" : {
|
|
|
|
"newResource" : "false",
|
|
|
|
"validators" : [ ],
|
|
|
|
"optionsType" : "UNDEFINED",
|
|
|
|
"literalOptions" : [ ],
|
|
|
|
"predicateUri" : "",
|
|
|
|
"objectClassUri" : "",
|
|
|
|
"rangeDatatypeUri" : "",
|
2011-01-21 20:18:05 +00:00
|
|
|
"rangeLang" : "",
|
2011-01-19 17:35:22 +00:00
|
|
|
"assertions" : ["${n3ForValue}"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</c:set>
|
|
|
|
|
|
|
|
<%
|
|
|
|
log.debug(request.getAttribute("editjson"));
|
|
|
|
|
|
|
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
|
|
|
if (editConfig == null) {
|
2011-01-21 20:18:05 +00:00
|
|
|
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
|
2011-01-19 17:35:22 +00:00
|
|
|
EditConfiguration.putConfigInSession(editConfig,session);
|
|
|
|
|
|
|
|
//setup date time edit elements
|
|
|
|
Field dateTimeField = editConfig.getField("dateTimeField");
|
|
|
|
// arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel])
|
2011-01-21 20:18:05 +00:00
|
|
|
dateTimeField.setEditElement(new DateTimeWithPrecision(dateTimeField, VitroVocabulary.Precision.SECOND.uri(), VitroVocabulary.Precision.NONE.uri()));
|
2011-01-19 17:35:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Model model = (Model) application.getAttribute("jenaOntModel");
|
|
|
|
|
|
|
|
if (objectUri != null) { // editing existing
|
|
|
|
editConfig.prepareForObjPropUpdate(model);
|
|
|
|
} else { // adding new
|
|
|
|
editConfig.prepareForNonUpdate(model);
|
2011-01-21 20:18:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
2011-02-04 21:23:25 +00:00
|
|
|
JavaScript.CUSTOM_FORM_UTILS.path()
|
2011-01-21 20:18:05 +00:00
|
|
|
));
|
|
|
|
request.setAttribute("customJs", customJs);
|
|
|
|
|
|
|
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
2011-02-04 21:23:25 +00:00
|
|
|
Css.CUSTOM_FORM.path()
|
2011-01-21 20:18:05 +00:00
|
|
|
));
|
|
|
|
request.setAttribute("customCss", customCss);
|
2011-01-19 17:35:22 +00:00
|
|
|
|
|
|
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
|
|
|
%>
|
|
|
|
|
|
|
|
<jsp:include page="${preForm}" />
|
|
|
|
|
2011-01-21 20:18:05 +00:00
|
|
|
<h2>${titleVerb} date time value for <%= subjectName %></h2>
|
2011-01-19 17:35:22 +00:00
|
|
|
|
|
|
|
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
|
|
|
|
2011-01-21 20:18:05 +00:00
|
|
|
<v:input id="dateTimeField" />
|
2011-01-19 17:35:22 +00:00
|
|
|
|
2011-01-21 20:18:05 +00:00
|
|
|
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p>
|
2011-01-19 17:35:22 +00:00
|
|
|
</form>
|
|
|
|
|
2011-01-21 20:18:05 +00:00
|
|
|
<jsp:include page="${postForm}"/>
|