NIHVIVO-798 Add start and end year to grant form
This commit is contained in:
parent
4db980657c
commit
af49aedefc
5 changed files with 105 additions and 20 deletions
|
@ -39,6 +39,8 @@ This is intended to create a set of statements like:
|
|||
String intDatatypeUri = XSD.xint.toString();
|
||||
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
||||
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
||||
vreq.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
||||
|
||||
String predicateUri = (String)request.getAttribute("predicateUri");
|
||||
ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri );
|
||||
if( op != null && op.getURIInverse() != null ){
|
||||
|
@ -69,7 +71,17 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
<c:set var="submitButtonLabel">Investigator</c:set>
|
||||
<c:set var="formHeading">Create a new investigator entry for <%= subjectName %></c:set>
|
||||
<% } %>
|
||||
|
||||
|
||||
<c:set var="startYearUri" value="${vivoCore}startYear" />
|
||||
<v:jsonset var="startYearAssertion" >
|
||||
?role <${startYearUri}> ?startYear .
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="endYearUri" value="${vivoCore}endYear" />
|
||||
<v:jsonset var="endYearAssertion" >
|
||||
?role <${endYearUri}> ?endYear .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="n3ForGrantRole">
|
||||
@prefix core: <${vivoCore}> .
|
||||
@prefix rdf: <${rdf}> .
|
||||
|
@ -106,9 +118,9 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
"predicate" : ["rolePredicate", "${predicateUriJson}" ],
|
||||
"object" : ["role", "${objectUriJson}", "URI" ],
|
||||
|
||||
"n3required" : [ "${n3ForGrantRole}" ],
|
||||
"n3required" : [ "${n3ForGrantRole}", "${startYearAssertion}" ],
|
||||
|
||||
"n3optional" : [ "${n3ForNewGrant}" , "${n3ForInverse}" ],
|
||||
"n3optional" : [ "${n3ForNewGrant}", "${n3ForInverse}", "${endYearAssertion}" ],
|
||||
|
||||
"newResources" : { "role" : "${defaultNamespace}",
|
||||
"grant" : "${defaultNamespace}" },
|
||||
|
@ -117,7 +129,7 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
"inverseRolePredicate" : "${inversePredicate}" },
|
||||
"literalsInScope": { },
|
||||
"urisOnForm" : [ "grant" ],
|
||||
"literalsOnForm" : [ "grantLabel" ],
|
||||
"literalsOnForm" : [ "grantLabel", "startYear", "endYear" ],
|
||||
"filesOnForm" : [ ],
|
||||
"sparqlForLiterals" : { },
|
||||
"sparqlForUris" : { },
|
||||
|
@ -145,6 +157,28 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${n3ForExistingPub}"]
|
||||
},
|
||||
"startYear" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "datatype:${gYearDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${gYearDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${startYearAssertion}"]
|
||||
},
|
||||
"endYear" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "datatype:${gYearDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${gYearDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${endYearAssertion}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +218,7 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
%>
|
||||
|
||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
|
||||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
|
@ -198,7 +233,10 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
|
|||
<%-- bdc34: for some odd reason id and name should not be grant in this input element. --%>
|
||||
<input type="hidden" id="grant" name="grant" class="acReceiver" value="" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
|
||||
<v:input type="text" label="Start Year ${requiredHint} ${yearHint}" id="startYear" size="7"/>
|
||||
<v:input type="text" label="End Year ${yearHint}" id="endYear" size="7"/>
|
||||
|
||||
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonLabel}" cancel="true" /></p>
|
||||
|
||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<%@ 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.utils.TitleCase" %>
|
||||
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.StartDateBeforeEndDate"%>
|
||||
|
||||
<%@ page import="org.apache.commons.logging.Log" %>
|
||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||
|
@ -83,6 +83,8 @@
|
|||
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
|
||||
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
|
||||
|
||||
vreq.setAttribute("gYearMonthDatatypeUriJson", MiscWebUtils.escape(XSD.gYearMonth.toString()));
|
||||
|
||||
vreq.setAttribute("roleActivityTitleCase", TitleCase.toTitleCase(vreq.getParameter("roleActivityTypeLabel")));
|
||||
ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri );
|
||||
if( op != null && op.getURIInverse() != null ){
|
||||
|
@ -97,6 +99,23 @@
|
|||
<c:set var="label" value="${rdfs}label" />
|
||||
<c:set var="defaultNamespace" value=""/> <%--blank triggers default URI generation behavior --%>
|
||||
|
||||
<c:set var="startYearMonthUri" value="${vivoCore}startYearMonth" />
|
||||
<v:jsonset var="startYearMonthExisting" >
|
||||
SELECT ?existingStartYearMonth WHERE {
|
||||
?role <${startYearMonthUri}> ?existingStartYearMonth }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="startYearMonthAssertion" >
|
||||
?role <${startYearMonthUri}> ?startYearMonth .
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="endYearMonthUri" value="${vivoCore}endYearMonth" />
|
||||
<v:jsonset var="endYearMonthExisting">
|
||||
SELECT ?existingEndYearMonth WHERE {
|
||||
?role <${endYearMonthUri}> ?existingEndYearMonth }
|
||||
</v:jsonset>
|
||||
<v:jsonset var="endYearMonthAssertion" >
|
||||
?role <${endYearMonthUri}> ?endYearMonth .
|
||||
</v:jsonset>
|
||||
|
||||
<v:jsonset var="n3ForNewRole">
|
||||
@prefix core: <${vivoCore}> .
|
||||
|
@ -129,8 +148,8 @@
|
|||
"predicate" : ["rolePredicate", "${predicateUriJson}" ],
|
||||
"object" : ["role", "${objectUriJson}", "URI" ],
|
||||
|
||||
"n3required" : [ "${n3ForNewRole}" ],
|
||||
"n3optional" : [ "${n3ForNewActivity}", "${n3ForInverse}" ],
|
||||
"n3required" : [ "${n3ForNewRole}", "${startYearMonthAssertion}" ],
|
||||
"n3optional" : [ "${n3ForNewActivity}", "${n3ForInverse}", "${endYearMonthAssertion}" ],
|
||||
|
||||
"newResources" : { "role" : "${defaultNamespace}",
|
||||
"roleActivity" : "${defaultNamespace}" },
|
||||
|
@ -138,7 +157,7 @@
|
|||
"urisInScope" : { "inverseRolePredicate" : "${inversePredicate}" },
|
||||
"literalsInScope": { },
|
||||
"urisOnForm" : [ "roleActivity", "roleActivityType" ],
|
||||
"literalsOnForm" : [ "title" ],
|
||||
"literalsOnForm" : [ "title", "startYearMonth", "endYearMonth" ],
|
||||
"filesOnForm" : [ ],
|
||||
"sparqlForLiterals" : { },
|
||||
"sparqlForUris" : { },
|
||||
|
@ -177,6 +196,28 @@
|
|||
"rangeDatatypeUri" : "",
|
||||
"rangeLang" : "",
|
||||
"assertions" : [ ]
|
||||
},
|
||||
"startYearMonth" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "datatype:${gYearMonthDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${gYearMonthDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${startYearMonthAssertion}"]
|
||||
},
|
||||
"endYearMonth" : {
|
||||
"newResource" : "false",
|
||||
"validators" : [ "datatype:${gYearMonthDatatypeUriJson}" ],
|
||||
"optionsType" : "UNDEFINED",
|
||||
"literalOptions" : [ ],
|
||||
"predicateUri" : "",
|
||||
"objectClassUri" : "",
|
||||
"rangeDatatypeUri" : "${gYearMonthDatatypeUriJson}",
|
||||
"rangeLang" : "",
|
||||
"assertions" : ["${endYearMonthAssertion}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +230,7 @@
|
|||
EditConfiguration.putConfigInSession(editConfig,session);
|
||||
}
|
||||
|
||||
//editConfig.addValidator(new PersonHasPublicationValidator());
|
||||
editConfig.addValidator(new StartDateBeforeEndDate("startYearMonth","endYearMonth") );
|
||||
|
||||
//this will return the browser to the new activity entity after an edit.
|
||||
editConfig.setEntityToReturnTo("?roleActivity");
|
||||
|
@ -213,6 +254,7 @@
|
|||
%>
|
||||
|
||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||
<c:set var="yearMonthHint" value="<span class='hint'>(YYYY-MM)</span>" />
|
||||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
|
@ -231,6 +273,9 @@
|
|||
<p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
|
||||
<input type="hidden" id="roleActivityURI" name="roleActivity" class="acReceiver" value="" /> <!-- Field value populated by JavaScript -->
|
||||
</div>
|
||||
|
||||
<v:input type="text" label="Start Year and Month ${yearMonthHint} ${requiredHint}" id="startYearMonth" size="7"/>
|
||||
<v:input type="text" label="End Year and Month ${yearMonthHint}" id="endYearMonth" size="7"/>
|
||||
</div>
|
||||
|
||||
<p class="submit"><v:input type="submit" id="submit" value="${roleActivityTitleCase}" cancel="true" /></p>
|
||||
|
|
|
@ -7,4 +7,15 @@
|
|||
.acSelectionInfo {
|
||||
background-color: #d9d9d9;
|
||||
padding: .5em 1em;
|
||||
}
|
||||
|
||||
|
||||
/* jQuery UI autocomplete */
|
||||
ul.ui-autocomplete {
|
||||
font-size: .95em;
|
||||
}
|
||||
|
||||
li.ui-menu-item a.ui-corner-all {
|
||||
text-align: left;
|
||||
padding-left: .25em;
|
||||
}
|
|
@ -104,13 +104,3 @@ option {
|
|||
width: 30%;
|
||||
}
|
||||
|
||||
|
||||
/* jQuery UI autocomplete */
|
||||
ul.ui-autocomplete {
|
||||
font-size: .95em;
|
||||
}
|
||||
|
||||
li.ui-menu-item a.ui-corner-all {
|
||||
text-align: left;
|
||||
padding-left: .25em;
|
||||
}
|
|
@ -23,3 +23,4 @@
|
|||
.verifyMatch {
|
||||
margin-left: .5em;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue