Adding editing of existing grant NIHVIVO-629

This commit is contained in:
bdc34 2010-07-14 22:50:16 +00:00
parent d32dc24ba1
commit c7933369bf

View file

@ -58,6 +58,9 @@ This is intended to create a set of statements like:
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
<c:set var="label" value="${rdfs}label" />
<%-- grantLabel is required if we are doing an update --%>
<c:set var="labelRequired" ><%= request.getAttribute("objectUri")== null?"":"\"nonempty\"," %></c:set>
<% // set role type based on predicate
String subjectName = ((Individual) request.getAttribute("subject")).getName();
if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %>
@ -98,16 +101,39 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
?role ?inverseRolePredicate ?person.
</v:jsonset>
<v:jsonset var="n3ForNewGrant">
<v:jsonset var="n3ForGrantType">
@prefix core: <${vivoCore}> .
@prefix rdf: <${rdf}> .
@prefix rdfs: <${rdfs}> .
?grant rdf:type core:Grant .
@prefix rdf: <${rdf}> .
?grant rdf:type core:Grant .
</v:jsonset>
<v:jsonset var="n3ForGrantLabel">
@prefix rdfs: <${rdfs}> .
?grant rdfs:label ?grantLabel .
</v:jsonset>
<v:jsonset var="grantLabelQuery">
PREFIX core: <${vivoCore}>
PREFIX rdfs: <${rdfs}>
SELECT ?existingGrantLabel WHERE {
?role core:roleIn ?existingGrant .
?existingGrant rdfs:label ?existingGrantLabel . }
</v:jsonset>
<v:jsonset var="startYearQuery">
PREFIX core: <${vivoCore}>
SELECT ?existingStartYear WHERE { ?role core:startYear ?existingStartYear .}
</v:jsonset>
<v:jsonset var="endYearQuery">
PREFIX core: <${vivoCore}>
SELECT ?existingStartYear WHERE { ?role core:endYear ?existingStartYear .}
</v:jsonset>
<v:jsonset var="grantQuery">
PREFIX core: <${vivoCore}>
SELECT ?existingGrant WHERE { ?role core:roleIn ?existingGrant . }
</v:jsonset>
<v:jsonset var="grantTypeUriJson">${vivoOnt}#Grant</v:jsonset>
<c:set var="editjson" scope="request">
@ -122,7 +148,7 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
"n3required" : [ "${n3ForGrantRole}", "${startYearAssertion}" ],
"n3optional" : [ "${n3ForNewGrant}", "${n3ForInverse}", "${endYearAssertion}" ],
"n3optional" : [ "${n3ForGrantType}", "${n3ForGrantLabel}", "${n3ForInverse}", "${endYearAssertion}" ],
"newResources" : { "role" : "${defaultNamespace}",
"grant" : "${defaultNamespace}" },
@ -133,10 +159,10 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
"urisOnForm" : [ "grant" ],
"literalsOnForm" : [ "grantLabel", "startYear", "endYear" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { },
"sparqlForExistingUris" : { },
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { "grantLabel":"${grantLabelQuery}" , "startYear":"${startYearQuery}", "endYear":"${endYearQuery}" },
"sparqlForExistingUris" : { "grant":"${grantQuery}" },
"fields" : {
"grant" : {
"newResource" : "false",
@ -151,14 +177,14 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
},
"grantLabel" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"validators" : [ ${labelRequired} "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "${personClassUriJson}",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${n3ForExistingPub}"]
"assertions" : ["${n3ForGrantLabel}"]
},
"startYear" : {
"newResource" : "false",
@ -193,13 +219,16 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig,session);
}
//validator for addGrantRoleToPerson.jsp?
//editConfig.addValidator(new AddGrantRoleToPersonValidator());
editConfig.addValidator(new StartYearBeforeEndYear("startYear","endYear") );
Model model = (Model) application.getAttribute("jenaOntModel");
editConfig.prepareForNonUpdate(model);
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) {
editConfig.prepareForObjPropUpdate(model);
} else {
editConfig.prepareForNonUpdate(model);
}
//this will return the browser to the new grant entity after an edit.
editConfig.setEntityToReturnTo("?grant");
@ -251,7 +280,7 @@ if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvest
<%-- Must be all one line for JavaScript. --%>
<c:set var="sparqlForAcFilter">
PREFIX core: <${vivoCore}> SELECT ?grantUri WHERE {<${subjectUri}> core:hasPrincipalInvestigatorRole ?grantRole . ?grantRole core:roleIn ?grantUri .}
PREFIX core: <${vivoCore}> SELECT ?grantUri WHERE {<${subjectUri}> <${predicateUri}> ?grantRole . ?grantRole core:roleIn ?grantUri .}
</c:set>
<script type="text/javascript">