256 lines
10 KiB
Text
256 lines
10 KiB
Text
<%-- $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.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.edit.n3editing.StartYearBeforeEndYear"%>
|
|
<%@ 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.Field"%>
|
|
|
|
<%@ 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
|
|
%>
|
|
|
|
|
|
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.DateTimeIntervalValidation"%><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 Position" />
|
|
<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="Position" />
|
|
<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.YEAR.uri(), VitroVocabulary.Precision.SECOND.uri()));
|
|
Field endField = editConfig.getField("endField");
|
|
endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.SECOND.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);
|
|
}
|
|
|
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
|
%>
|
|
|
|
<jsp:include page="${preForm}" />
|
|
|
|
<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}"/>
|