NIHVIVO-193 Preliminary code cleanup before making functional modifications.

This commit is contained in:
rjy7 2010-03-26 20:19:17 +00:00
parent 7bae4b44b3
commit 4a9a81fc15

View file

@ -2,13 +2,14 @@
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%> <%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
<%@ page import="com.hp.hpl.jena.rdf.model.Model"%> <%@ 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.beans.Individual"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
<%@ page <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
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.dao.WebappDaoFactory"%>
<%@ page <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> <%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
@ -25,66 +26,76 @@
flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
} }
vreq.setAttribute("flagURI",flagURI); vreq.setAttribute("flagURI",flagURI);
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
%> %>
<%-- RY *** SET VARIABLES for uris & namespaces --%> <c:set var="vivo" value="http://vivoweb.org/ontology/core#" />
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
<c:set var="rdfs" value="<% VitroVocabulary.RDFS %>" />
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing" <%-- Then 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. 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 Each of these must then be referenced in the sparqlForExistingLiterals section of the JSON block below
and in the literalsOnForm --%> and in the literalsOnForm --%>
<c:set var="titlePred" value="${vivo}titleOrRole" />
<v:jsonset var="titleExisting" > <v:jsonset var="titleExisting" >
SELECT ?titleExisting WHERE { SELECT ?titleExisting WHERE {
?positionUri <http://vivoweb.org/ontology/core#titleOrRole> ?titleExisting } ?positionUri <${titlePred}> ?titleExisting }
</v:jsonset> </v:jsonset>
<%-- Pair the "existing" query with the skeleton of what will be asserted for a new statement involving this field. <%-- 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. 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) --%> NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
<v:jsonset var="titleAssertion" > <v:jsonset var="titleAssertion" >
?positionUri <http://vivoweb.org/ontology/core#titleOrRole> ?title . ?positionUri <${titlePred}> ?title .
?positionUri <http://www.w3.org/2000/01/rdf-schema#label> ?title. ?positionUri <${rdf}label> ?title.
</v:jsonset> </v:jsonset>
<c:set var="involvedOrgNamePred" value="${vivo}involvedOrganizationName" />
<v:jsonset var="organizationNameExisting" > <v:jsonset var="organizationNameExisting" >
SELECT ?existingOrgName WHERE { SELECT ?existingOrgName WHERE {
?positionUri <http://vivoweb.org/ontology/core#involvedOrganizationName> ?existingOrgName } ?positionUri <${involvedOrgNamePred}> ?existingOrgName }
</v:jsonset> </v:jsonset>
<v:jsonset var="organizationNameAssertion" > <v:jsonset var="organizationNameAssertion" >
?positionUri <http://vivoweb.org/ontology/core#involvedOrganizationName> ?organizationName . ?positionUri <${involvedOrgNamePred}> ?organizationName .
</v:jsonset> </v:jsonset>
<c:set var="startYearPred" value="${vivo}startYear" />
<v:jsonset var="startYearExisting" > <v:jsonset var="startYearExisting" >
SELECT ?startYearExisting WHERE { SELECT ?startYearExisting WHERE {
?positionUri <http://vivoweb.org/ontology/core#startYear> ?startYearExisting } ?positionUri <${startYearPred}> ?startYearExisting }
</v:jsonset> </v:jsonset>
<v:jsonset var="startYearAssertion" > <v:jsonset var="startYearAssertion" >
?positionUri <http://vivoweb.org/ontology/core#startYear> ?startYear . ?positionUri <${startYearPred}> ?startYear .
</v:jsonset> </v:jsonset>
<c:set var="endYearPred" value="${vivo}endYear" />
<v:jsonset var="endYearExisting" > <v:jsonset var="endYearExisting" >
SELECT ?endYearExisting WHERE { SELECT ?endYearExisting WHERE {
?positionUri <http://vivoweb.org/ontology/core#endYear> ?endYearExisting } ?positionUri <${endYearPred}> ?endYearExisting }
</v:jsonset> </v:jsonset>
<v:jsonset var="endYearAssertion" > <v:jsonset var="endYearAssertion" >
?positionUri <http://vivoweb.org/ontology/core#endYear> ?endYear . ?positionUri <${endYearPred}> ?endYear .
</v:jsonset> </v:jsonset>
<%-- Note there is really no difference in how things are set up for an object property except <%-- Note there is really no difference in how things are set up for an object property except
below in the n3ForEdit section, in whether the ..Existing variable goes in SparqlForExistingLiterals below in the n3ForEdit section, in whether the ..Existing variable goes in SparqlForExistingLiterals
or in the SparqlForExistingUris, as well as perhaps in how the options are prepared --%> or in the SparqlForExistingUris, as well as perhaps in how the options are prepared --%>
<c:set var="positionInOrgPred" value="${vivo}positionInOrganization" />
<v:jsonset var="organizationUriExisting" > <v:jsonset var="organizationUriExisting" >
SELECT ?existingOrgUri WHERE { SELECT ?existingOrgUri WHERE {
?positionUri <http://vivoweb.org/ontology/core#positionInOrganization> ?existingOrgUri } ?positionUri <${positionInOrgPred}> ?existingOrgUri }
</v:jsonset> </v:jsonset>
<v:jsonset var="organizationUriAssertion" > <v:jsonset var="organizationUriAssertion" >
?positionUri <http://vivoweb.org/ontology/core#positionInOrganization> ?organizationUri . ?positionUri <${positionInOrgPred}> ?organizationUri .
?organizationUri <http://vivoweb.org/ontology/core#organizationForPosition> ?positionUri . ?organizationUri <${vivo}organizationForPosition> ?positionUri .
</v:jsonset> </v:jsonset>
<v:jsonset var="n3ForStmtToPerson" > <v:jsonset var="n3ForStmtToPerson" >
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix rdf: <${rdf}>.
@prefix core: <http://vivoweb.org/ontology/core#>. @prefix core: <${vivo}>.
?person core:personInPosition ?positionUri . ?person core:personInPosition ?positionUri .
?positionUri core:positionForPerson ?person . ?positionUri core:positionForPerson ?person .
@ -157,29 +168,29 @@
"literalOptions" : [ ], "literalOptions" : [ ],
"predicateUri" : "", "predicateUri" : "",
"objectClassUri" : "", "objectClassUri" : "",
"rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#string", "rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "", "rangeLang" : "",
"assertions" : [ "${organizationNameAssertion}" ] "assertions" : [ "${organizationNameAssertion}" ]
}, },
"startYear" : { "startYear" : {
"newResource" : "false", "newResource" : "false",
"validators" : [ "nonempty", "datatype:http://www.w3.org/2001/XMLSchema#gYear" ], "validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ],
"optionsType" : "UNDEFINED", "optionsType" : "UNDEFINED",
"literalOptions" : [ ], "literalOptions" : [ ],
"predicateUri" : "", "predicateUri" : "",
"objectClassUri" : "", "objectClassUri" : "",
"rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#gYear", "rangeDatatypeUri" : "${gYearDatatypeUriJson}",
"rangeLang" : "", "rangeLang" : "",
"assertions" : ["${startYearAssertion}"] "assertions" : ["${startYearAssertion}"]
}, },
"endYear" : { "endYear" : {
"newResource" : "false", "newResource" : "false",
"validators" : [ "datatype:http://www.w3.org/2001/XMLSchema#gYear" ], "validators" : [ "datatype:${gYearDatatypeUriJson}" ],
"optionsType" : "UNDEFINED", "optionsType" : "UNDEFINED",
"literalOptions" : [ ], "literalOptions" : [ ],
"predicateUri" : "", "predicateUri" : "",
"objectClassUri" : "", "objectClassUri" : "",
"rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#gYear", "rangeDatatypeUri" : "${gYearDatatypeUriJson}",
"rangeLang" : "", "rangeLang" : "",
"assertions" : ["${endYearAssertion}"] "assertions" : ["${endYearAssertion}"]
} }
@ -204,14 +215,14 @@
editConfig.prepareForNonUpdate(model); editConfig.prepareForNonUpdate(model);
} }
/* prepare the <title> and text for the submit button */ /* prepare the page title and text for the submit button */
Individual subject = (Individual) request.getAttribute("subject"); String subjectName = ((Individual) request.getAttribute("subject")).getName();
String submitLabel = ""; String submitLabel = "";
if (objectUri != null) { if (objectUri != null) {
request.setAttribute("title","Edit position history entry for "+ subject.getName()); request.setAttribute("title","Edit position entry for "+ subjectName);
submitLabel = "Save changes"; submitLabel = "Save changes";
} else { } else {
request.setAttribute("title","Create a new position history entry for " + subject.getName()); request.setAttribute("title","Create a new position entry for " + subjectName);
submitLabel = "Create new position history entry"; submitLabel = "Create new position history entry";
} }
%> %>